|
|
|
|
const jsapi = require("./utils/openApi.js");
|
|
|
|
|
const utils = require("./utils/utils");
|
|
|
|
|
const msg = require("./utils/msg");
|
|
|
|
|
const wcache = require("./utils/wcache");
|
|
|
|
|
const animation = require("./utils/animation");
|
|
|
|
|
const loginApi = require("./utils/loginApi");
|
|
|
|
|
const mqtt = require("./utils/mqtt.js");
|
|
|
|
|
const util = require("./utils/util.js")
|
|
|
|
|
App({
|
|
|
|
|
|
|
|
|
|
// 引用js
|
|
|
|
|
jsapi: jsapi,
|
|
|
|
|
utils: utils,
|
|
|
|
|
msg: msg,
|
|
|
|
|
wc: wcache,
|
|
|
|
|
ani: animation,
|
|
|
|
|
loginApi: loginApi,
|
|
|
|
|
|
|
|
|
|
name: "v2点餐-base",
|
|
|
|
|
version: "1.1.0", // 系统版本
|
|
|
|
|
sourceSign: "smProgram",
|
|
|
|
|
|
|
|
|
|
openId: wx.getStorageSync("openId"),
|
|
|
|
|
loginKey: wx.getStorageSync('loginKey'),
|
|
|
|
|
client: null, // mqtt
|
|
|
|
|
topic: [],
|
|
|
|
|
page: null,
|
|
|
|
|
appTop1: null,
|
|
|
|
|
appTop2: null,
|
|
|
|
|
appTop3: null,
|
|
|
|
|
baseTopic: "program/cy2/order", // 接单订阅主题
|
|
|
|
|
baseTopic2: "wxdc/sell", // 售罄订阅主题
|
|
|
|
|
baseTopic3:"wxxcx/sell", //小程序门店规格商品售罄主题
|
|
|
|
|
baseTopic4:"wxxcx/delivery",
|
|
|
|
|
isBuoDuo: false, //是否博多版本
|
|
|
|
|
|
|
|
|
|
onLaunch: function() {
|
|
|
|
|
|
|
|
|
|
const updateManager = wx.getUpdateManager()
|
|
|
|
|
updateManager.onCheckForUpdate(function (res) {
|
|
|
|
|
// 请求完新版本信息的回调
|
|
|
|
|
console.log(res.hasUpdate)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
updateManager.onUpdateReady(function () {
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '更新提示',
|
|
|
|
|
content: '新版本已经准备好,是否重启应用?',
|
|
|
|
|
success: function (res) {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
|
|
|
updateManager.applyUpdate()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
updateManager.onUpdateFailed(function () {
|
|
|
|
|
// 新的版本下载失败
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '更新提示',
|
|
|
|
|
content: '新版本下载失败',
|
|
|
|
|
showCancel: false
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onShow: function() {
|
|
|
|
|
var that = this;
|
|
|
|
|
wx.getSystemInfo({
|
|
|
|
|
success: function(res) {
|
|
|
|
|
if (res.errMsg == "getSystemInfo:ok") {
|
|
|
|
|
that.systemInfo.windowHeight = res.windowHeight;
|
|
|
|
|
that.systemInfo.windowWidth = res.windowWidth;
|
|
|
|
|
that.percent = res.windowWidth / 750;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 小程序配置
|
|
|
|
|
*/
|
|
|
|
|
// if (!wx.getStorageSync("cyApi")) {
|
|
|
|
|
if (true) { // 判断是否需要更新接口数据
|
|
|
|
|
this.getWidByAppid();
|
|
|
|
|
} else {
|
|
|
|
|
this.checkSession(); // 检测session
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getWidByAppid: function() {
|
|
|
|
|
var that = this;
|
|
|
|
|
const accountInfo = wx.getAccountInfoSync();
|
|
|
|
|
that.globalData.appid = accountInfo.miniProgram.appId
|
|
|
|
|
wx.request({
|
|
|
|
|
url: that.globalData.serverUrlExtend,
|
|
|
|
|
method: "POST",
|
|
|
|
|
header: {
|
|
|
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
|
|
|
},
|
|
|
|
|
data: {
|
|
|
|
|
"type": "programbaseinfobyappid",
|
|
|
|
|
"appId": accountInfo.miniProgram.appId
|
|
|
|
|
},
|
|
|
|
|
success: res => {
|
|
|
|
|
var data = res.data;
|
|
|
|
|
console.log(data);
|
|
|
|
|
if (data.status == 1) {
|
|
|
|
|
that.cy_openApiExtend(data.data.tenantId, data.data.wid);
|
|
|
|
|
that.globalData.tenantId = data.data.tenantId;
|
|
|
|
|
that.globalData.wid = data.data.wid;
|
|
|
|
|
} else {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: data.message,
|
|
|
|
|
icon: "none",
|
|
|
|
|
})
|
|
|
|
|
that.cy_userInfoReadyCallback(true);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fail: res => {
|
|
|
|
|
that.cy_userInfoReadyCallback(true);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
onShare: {
|
|
|
|
|
title: "",
|
|
|
|
|
desc: "最具人气的点餐小程序",
|
|
|
|
|
path: "pages/tabbar/launch",
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
orderTicket: {
|
|
|
|
|
busMode: 1
|
|
|
|
|
}, // 订单信息
|
|
|
|
|
systemInfo: { // 系统信息
|
|
|
|
|
windowWidth: 0,
|
|
|
|
|
windowHeight: 0,
|
|
|
|
|
},
|
|
|
|
|
temData: {
|
|
|
|
|
orderPointProduct: '',
|
|
|
|
|
orderPointNum: 1,
|
|
|
|
|
orderAddress: '',
|
|
|
|
|
totalMoney: 0,
|
|
|
|
|
orderNo: '',
|
|
|
|
|
type: 1,
|
|
|
|
|
invitationFriendPrizeType: 0,
|
|
|
|
|
invitationFriendPrizeCouponPacketNo: 0,
|
|
|
|
|
invitationFriendDescription: "",
|
|
|
|
|
invitationFriendStartDate: "",
|
|
|
|
|
invitationFriendEndDate: "",
|
|
|
|
|
invitationFriendId: "",
|
|
|
|
|
invitationFriendPrizePointValue: 0,
|
|
|
|
|
invitationFriendTotalAwardCount: 0,
|
|
|
|
|
shareStatus: true,
|
|
|
|
|
fromMemberId: '',
|
|
|
|
|
activityId: '',
|
|
|
|
|
openId: ''
|
|
|
|
|
},
|
|
|
|
|
mqttParam: {
|
|
|
|
|
wsServer: 'wss://iotv2.ffcygl.com',
|
|
|
|
|
wsServerPort: 80,
|
|
|
|
|
client: null,
|
|
|
|
|
interval: null
|
|
|
|
|
},
|
|
|
|
|
globalData: {
|
|
|
|
|
npAmount:0,
|
|
|
|
|
appid: "",
|
|
|
|
|
tenantId: "",
|
|
|
|
|
wid: "",
|
|
|
|
|
|
|
|
|
|
groupNo: '0000',
|
|
|
|
|
sourceSign: 'smWeixin',
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 会员信息
|
|
|
|
|
*/
|
|
|
|
|
userId: wx.getStorageSync("userId"),
|
|
|
|
|
user: wx.getStorageSync("user"),
|
|
|
|
|
workerNo: wx.getStorageSync("workerNo"),
|
|
|
|
|
posNo: wx.getStorageSync("posNo"),
|
|
|
|
|
shopNo: wx.getStorageSync("shopNo"),
|
|
|
|
|
cardNo: wx.getStorageSync("cardNo"),
|
|
|
|
|
memberId: wx.getStorageSync("memberId"),
|
|
|
|
|
cardInfo: wx.getStorageSync("cardInfo"),
|
|
|
|
|
|
|
|
|
|
phone: wx.getStorageSync("phone"),
|
|
|
|
|
programId: wx.getStorageSync("id"),
|
|
|
|
|
appid: wx.getStorageSync("appid"),
|
|
|
|
|
secret: wx.getStorageSync("secret"),
|
|
|
|
|
appKey: wx.getStorageSync("appKey"),
|
|
|
|
|
appSecret: wx.getStorageSync("appSecret"),
|
|
|
|
|
memberWid: wx.getStorageSync("memberWid"),
|
|
|
|
|
memberAppKey: wx.getStorageSync("memberAppKey"),
|
|
|
|
|
memberAppSecret: wx.getStorageSync("memberAppSecret"),
|
|
|
|
|
memberExtendUrl: wx.getStorageSync("memberExtendUrl"),
|
|
|
|
|
memberUrl: wx.getStorageSync("memberUrl"),
|
|
|
|
|
|
|
|
|
|
// 生产地址
|
|
|
|
|
serverUrl: "https://fv2.ffcygl.com/openApi/api",
|
|
|
|
|
serverUrlExtend: "https://fv2.ffcygl.com/openApi/open/api/extend",
|
|
|
|
|
|
|
|
|
|
memberServerUrl: "https://mv2.ffcygl.com/openApi/open/api",
|
|
|
|
|
memberServerUrlExtend: "https://mv2.ffcygl.com/openApi/api/extend",
|
|
|
|
|
|
|
|
|
|
height: wx.getSystemInfoSync()['statusBarHeight'],
|
|
|
|
|
oldCode: "",
|
|
|
|
|
baseImgUri:"http://imgv1.jwsaas.com/",
|
|
|
|
|
memberPayEnabled:0,
|
|
|
|
|
version:"1.1.68",
|
|
|
|
|
color:"#ffc639",
|
|
|
|
|
userIsFee:0,
|
|
|
|
|
globalNumber:0,
|
|
|
|
|
txMapKey:"",
|
|
|
|
|
isLoadSuccess:false
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 小程序配置
|
|
|
|
|
*/
|
|
|
|
|
cy_openApiExtend: function(tenantId, wid) {
|
|
|
|
|
var that = this;
|
|
|
|
|
wx.request({
|
|
|
|
|
url: that.globalData.serverUrlExtend,
|
|
|
|
|
method: "POST",
|
|
|
|
|
header: {
|
|
|
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
|
|
|
},
|
|
|
|
|
data: {
|
|
|
|
|
"type": "programinfobywid",
|
|
|
|
|
"tenantId": tenantId,
|
|
|
|
|
"wid": wid
|
|
|
|
|
},
|
|
|
|
|
success: res => {
|
|
|
|
|
var data = res.data;
|
|
|
|
|
if (data.status == 1) {
|
|
|
|
|
var cardApi = data.data.cardApi;
|
|
|
|
|
var cyApi = data.data.cyApi;
|
|
|
|
|
var wxBoday = data.data.wxBoday;
|
|
|
|
|
if (data.data.description == "") {
|
|
|
|
|
data.data.description = "Hi,美好一天!";
|
|
|
|
|
}
|
|
|
|
|
wx.setStorageSync("description", data.data.description);
|
|
|
|
|
wx.setStorageSync("cyApi", cyApi); //
|
|
|
|
|
wx.setStorageSync("appKey", cyApi.appKey);
|
|
|
|
|
wx.setStorageSync("appSecret", cyApi.appSecret);
|
|
|
|
|
wx.setStorageSync("serverUrl", cyApi.url);
|
|
|
|
|
wx.setStorageSync("id", data.data.id);
|
|
|
|
|
wx.setStorageSync("appid", wxBoday.appId);
|
|
|
|
|
wx.setStorageSync("secret", wxBoday.appSecret);
|
|
|
|
|
wx.setStorageSync("workerNo", cardApi.workerNo);
|
|
|
|
|
wx.setStorageSync("posNo", cardApi.posNo);
|
|
|
|
|
wx.setStorageSync("shopNo", cardApi.shopNo);
|
|
|
|
|
wx.setStorageSync("memberAppKey", cardApi.appKey);
|
|
|
|
|
wx.setStorageSync("memberAppSecret", cardApi.appSecret);
|
|
|
|
|
wx.setStorageSync("memberExtendUrl", cardApi.extendUrl);
|
|
|
|
|
wx.setStorageSync("memberUrl", cardApi.url);
|
|
|
|
|
wx.setStorageSync("pictureInfos", data.data.pictureInfos);
|
|
|
|
|
wx.setStorageSync("memberWid", wxBoday.mWid);
|
|
|
|
|
|
|
|
|
|
that.globalData.programId = data.data.id;
|
|
|
|
|
that.globalData.appKey = cyApi.appKey;
|
|
|
|
|
that.globalData.appSecret = cyApi.appSecret;
|
|
|
|
|
that.globalData.serverUrl = cyApi.url;
|
|
|
|
|
that.globalData.appid = wxBoday.appId;
|
|
|
|
|
that.globalData.secret = wxBoday.appSecret;
|
|
|
|
|
that.globalData.txMapKey=wxBoday.txMapKey;
|
|
|
|
|
that.globalData.isLoadSuccess=true;
|
|
|
|
|
that.globalData.posNo = cardApi.posNo;
|
|
|
|
|
that.globalData.shopNo = cardApi.shopNo;
|
|
|
|
|
that.globalData.memberAppKey = cardApi.appKey
|
|
|
|
|
that.globalData.memberAppSecret = cardApi.appSecret
|
|
|
|
|
that.globalData.memberExtendUrl = cardApi.extendUrl;
|
|
|
|
|
that.globalData.memberUrl = cardApi.url;
|
|
|
|
|
if( data.data.color && data.data.color !='' ){
|
|
|
|
|
that.globalData.color= data.data.color
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
that.globalData.memberWid = wxBoday.mWid;
|
|
|
|
|
that.checkSession();
|
|
|
|
|
} else {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: data.message,
|
|
|
|
|
icon: "none",
|
|
|
|
|
})
|
|
|
|
|
that.cy_userInfoReadyCallback(true);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fail: res => {
|
|
|
|
|
that.cy_userInfoReadyCallback(true);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 检查session
|
|
|
|
|
*/
|
|
|
|
|
checkSession: function() {
|
|
|
|
|
var that = this;
|
|
|
|
|
wx.checkSession({
|
|
|
|
|
success: function(res) {
|
|
|
|
|
if (!that.loginKey || that.loginKey == "") {
|
|
|
|
|
that.login();
|
|
|
|
|
} else {
|
|
|
|
|
wx.setStorageSync("loginKey", that.loginKey)
|
|
|
|
|
wx.setStorageSync("openId", that.openId)
|
|
|
|
|
that.cy_userInfoReadyCallback(true);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fail: function(res) { // session time out, need relogin
|
|
|
|
|
console.log("检测session", res);
|
|
|
|
|
that.login();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* wx.login 获取code
|
|
|
|
|
*/
|
|
|
|
|
login: function() {
|
|
|
|
|
var that = this;
|
|
|
|
|
wx.login({
|
|
|
|
|
success: function(res) {
|
|
|
|
|
if (res.code) {
|
|
|
|
|
wx.request({
|
|
|
|
|
url: that.globalData.serverUrlExtend,
|
|
|
|
|
method: "POST",
|
|
|
|
|
header: {
|
|
|
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
|
|
|
},
|
|
|
|
|
data: {
|
|
|
|
|
"type": "wxdcjscode2session",
|
|
|
|
|
"code": res.code,
|
|
|
|
|
"appid": that.globalData.appid,
|
|
|
|
|
"secret": that.globalData.secret
|
|
|
|
|
},
|
|
|
|
|
success: function(res) {
|
|
|
|
|
console.log(that.globalData.secret);
|
|
|
|
|
console.log("wxdcjscode2session", res);
|
|
|
|
|
if (res.data.status == 1) {
|
|
|
|
|
var data = res.data.data;
|
|
|
|
|
that.openId = data.openId;
|
|
|
|
|
that.loginKey = data.loginKey;
|
|
|
|
|
wx.setStorageSync("openId", that.openId);
|
|
|
|
|
wx.setStorageSync("loginKey", that.loginKey);
|
|
|
|
|
|
|
|
|
|
that.cy_userInfoReadyCallback(true);
|
|
|
|
|
} else {
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
|
|
that.cy_userInfoReadyCallback(true);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fail: function(res) {
|
|
|
|
|
|
|
|
|
|
that.cy_userInfoReadyCallback(true);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 回调函数
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
cy_userInfoReadyCallback(res) {
|
|
|
|
|
var that = this;
|
|
|
|
|
var timer = setInterval(function() {
|
|
|
|
|
if (that.userInfoReadyCallback) {
|
|
|
|
|
that.userInfoReadyCallback(res);
|
|
|
|
|
clearInterval(timer);
|
|
|
|
|
}
|
|
|
|
|
}, 500);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询卡信息
|
|
|
|
|
*/
|
|
|
|
|
cy_selectCardInfo: function() {
|
|
|
|
|
var that = this;
|
|
|
|
|
var params = {
|
|
|
|
|
"method": "card.info",
|
|
|
|
|
"cardNo": that.cardNo,
|
|
|
|
|
"shopNo": that.shopNo,
|
|
|
|
|
"posNo": that.posNo,
|
|
|
|
|
}
|
|
|
|
|
var ignores = [];
|
|
|
|
|
console.log(that.globalData.serverMemberUrl)
|
|
|
|
|
that.jsapi.memberApi(that.globalData.appMemberKey, that.globalData.appMemberSecret, that.globalData.serverMemberUrl).ajax(params, ignores,
|
|
|
|
|
function(json) {
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
var result = json.data;
|
|
|
|
|
if (result.status == 1) {
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
that.cardInfo = result.data;
|
|
|
|
|
app.globalData.npAmount= result.data;
|
|
|
|
|
if (that.cardInfo.mobile != "") {
|
|
|
|
|
that.isIphone = true;
|
|
|
|
|
that.iphone = that.cardInfo.mobile;
|
|
|
|
|
wx.setStorageSync("iphone", that.iphone);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// wx.showModal({
|
|
|
|
|
// title: '提示',
|
|
|
|
|
// content: result.errMessage,
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
function(err) {
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
wx.showLoading({
|
|
|
|
|
title: '网络异常,请检查网络连接',
|
|
|
|
|
icon: "none"
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 会员卡开户
|
|
|
|
|
*/
|
|
|
|
|
cy_openCardInfo: function() {
|
|
|
|
|
var that = this;
|
|
|
|
|
var params = {
|
|
|
|
|
"method": "small.weixin.open.card.wid",
|
|
|
|
|
"wid": that.memberWid,
|
|
|
|
|
"openId": that.openId,
|
|
|
|
|
"mobile": that.iphone,
|
|
|
|
|
"nickName": that.globalData.userInfo.nickname,
|
|
|
|
|
"gender": that.globalData.userInfo.sex,
|
|
|
|
|
"avatarUrl": that.globalData.userInfo.headimgurl,
|
|
|
|
|
}
|
|
|
|
|
var ignores = ["openId", "nickName", "gender", "avatarUrl", "mobile"];
|
|
|
|
|
that.jsapi.memberApi(that.globalData.appMemberKey, that.globalData.appMemberSecret, that.globalData.serverMemberUrl).ajax(params, ignores,
|
|
|
|
|
function(json) {
|
|
|
|
|
console.log(json);
|
|
|
|
|
var result = json.data;
|
|
|
|
|
if (result.status == 1) {
|
|
|
|
|
var data = result.data;
|
|
|
|
|
that.memberId = data.memberId;
|
|
|
|
|
that.cardNo = data.cardNo
|
|
|
|
|
|
|
|
|
|
if (data.giftCouponFlag == 1) {
|
|
|
|
|
var couponPacketNo = data.couponPacketNo;
|
|
|
|
|
that.cy_elecCouponPacketReceive(couponPacketNo);
|
|
|
|
|
} else {
|
|
|
|
|
that.cy_selectCardInfo();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
that.cy_selectCardInfo();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
function(err) {
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '网络连接失败',
|
|
|
|
|
icon: "none",
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 赠送礼包
|
|
|
|
|
*/
|
|
|
|
|
cy_elecCouponPacketReceive: function(couponPacketNo) {
|
|
|
|
|
var that = this;
|
|
|
|
|
var date = new Date();
|
|
|
|
|
var params = {
|
|
|
|
|
"shopNo": that.shopNo,
|
|
|
|
|
"posNo": that.posNo,
|
|
|
|
|
"workerNo": that.workerNo,
|
|
|
|
|
"sourceSign": that.sourceSign,
|
|
|
|
|
"method": "elec.coupon.packet.receive",
|
|
|
|
|
"memberId": that.memberId,
|
|
|
|
|
"outerStr": "37",
|
|
|
|
|
"couponPacketNo": couponPacketNo,
|
|
|
|
|
"ticketNo": that.utils.getFormatTime(date, 2),
|
|
|
|
|
}
|
|
|
|
|
// 忽略签名参数
|
|
|
|
|
var ignores = [];
|
|
|
|
|
that.jsapi.api(that.globalData.appMemberKey, that.globalData.appMemberSecret, that.globalData.serverMemberUrl).ajax(params, ignores,
|
|
|
|
|
function(json) {
|
|
|
|
|
var result = json.data;
|
|
|
|
|
if (result.status == 1) {
|
|
|
|
|
that.cy_selectCardInfo();
|
|
|
|
|
} else {
|
|
|
|
|
that.cy_selectCardInfo();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
function(error) {
|
|
|
|
|
wx.hideLoading();
|
|
|
|
|
app.msg.showMsg("提示", "网络中断,会员信息获取失败");
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//mqtt
|
|
|
|
|
getCouponConsumeCode: function(code) {
|
|
|
|
|
var tenantId = this.globalData.tenantId;
|
|
|
|
|
return tenantId + ":" + code + ':couponconsume';
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
startReconnect: function() {
|
|
|
|
|
// 重连机制
|
|
|
|
|
var that = this;
|
|
|
|
|
interval = setInterval(function() {
|
|
|
|
|
var client = that.mqttParam.client;
|
|
|
|
|
if (client != null) {
|
|
|
|
|
// 10s检测
|
|
|
|
|
mqttApi.api.connect();
|
|
|
|
|
}
|
|
|
|
|
}, 10000);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getPayCode: function() {
|
|
|
|
|
var tenantId = this.globalData.tenantId;
|
|
|
|
|
var memberId = wx.getStorageSync("cardInfo").memberId;
|
|
|
|
|
return tenantId + ':' + memberId + ':pay';
|
|
|
|
|
},
|
|
|
|
|
globalFunction: {
|
|
|
|
|
/*---------扫码会调函数------*/
|
|
|
|
|
scanPayCodeCallBack: function(msg) {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/callback/paySuccess?msg=' + msg,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
/*---------优惠券核销会调函数------*/
|
|
|
|
|
consumeCouponCallBack: function(msg) {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/pages/callback/couponSuccess?msg=' + msg,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
showMsg:function(mes,icon){
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title:mes ,
|
|
|
|
|
icon:icon
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
callBack: function() {
|
|
|
|
|
var url = "http://192.168.0.124:8008";
|
|
|
|
|
var data = {
|
|
|
|
|
content: "hello"
|
|
|
|
|
}
|
|
|
|
|
console.log("--------------", JSON.stringify(data));
|
|
|
|
|
wx.request({
|
|
|
|
|
url: url,
|
|
|
|
|
data: {
|
|
|
|
|
data
|
|
|
|
|
},
|
|
|
|
|
method: "POST",
|
|
|
|
|
|
|
|
|
|
success(res) {
|
|
|
|
|
console.log("====================", res);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
});
|