You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

456 lines
11 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

const app = getApp();
const card = require('../../utils/card.js');
const mqttMessage = require('../../utils/mqttMessage.js')
const log = require('../../utils/log.js');
const myaudio = wx.createInnerAudioContext();
Page({
/**
* 页面的初始数据
*/
data: {
hidden: true,
isiPhone: true,
indicatorDots: true,
autoplay: true,
interval: 3000,
circular: true,
list: [{
linkUrl: '../../images/1.jpg'
},{
linkUrl: '../../images/2.jpg'
},{
linkUrl: '../../images/3.jpg'
}],
video: "http://pos.juweiyun.cn/weChatAppdi.mp4",
videoHidden: true,
autoplay: true
},
confirm: function () {
console.error(" confirm ")
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
pageOption: options
});
if (wx.getStorageSync("ads")) {
this.setData({
list: wx.getStorageSync("ads"),
tenantId: app.globalData.tenantId,
color: app.globalData.color
});
}
if (wx.getStorageSync("pictureInfos")) {
var pictureInfos = wx.getStorageSync("pictureInfos");
//设置背景图片
if (pictureInfos.forHereOrderUrl) this.setData({
forHereOrderUrl: pictureInfos.forHereOrderUrl
})
else this.setData({
forHereOrderUrl: "/images/icon-bg-food.png"
})
if (pictureInfos.takeOutOrderUrl) this.setData({
takeOutOrderUrl: pictureInfos.takeOutOrderUrl
})
else this.setData({
takeOutOrderUrl: "/images/icon-bg-out.png"
})
if (pictureInfos.integralMallUrl) this.setData({
integralMallUrl: pictureInfos.integralMallUrl
})
else this.setData({
integralMallUrl: "/images/icon-bg-coupon.png"
})
if (pictureInfos.userCenterUrl) this.setData({
userCenterUrl: pictureInfos.userCenterUrl
})
else this.setData({
userCenterUrl: "/images/icon-bg-mine.png"
})
if (pictureInfos.rechargeUrl) this.setData({
rechargeUrl: pictureInfos.rechargeUrl
})
else this.setData({
rechargeUrl: "/images/index_menu_rechange.png"
})
if (pictureInfos.couponUrl) this.setData({
couponUrl: pictureInfos.couponUrl
})
else this.setData({
couponUrl: "/images/index_menu_coupon.png"
})
if (pictureInfos.payCodeUrl) this.setData({
payCodeUrl: pictureInfos.payCodeUrl
})
else this.setData({
payCodeUrl: "/images/index_menu_memberCode.png"
})
//设置字体
if (pictureInfos.rechargeFuncName) this.setData({
rechargeFuncName: pictureInfos.rechargeFuncName
})
else this.setData({
rechargeFuncName: "充值"
})
if (pictureInfos.couponFuncName) this.setData({
couponFuncName: pictureInfos.couponFuncName
})
else this.setData({
couponFuncName: "优惠券"
})
if (pictureInfos.payCodeFuncName) this.setData({
payCodeFuncName: pictureInfos.payCodeFuncName
})
else this.setData({
payCodeFuncName: "支付码"
})
//设置连接
if (pictureInfos.forHereOrderPath) this.setData({
forHereOrderPath: pictureInfos.forHereOrderPath
})
else this.setData({
forHereOrderPath: "../store/store?title=门店自提&busMode=1"
})
if (pictureInfos.takeOutOrderPath) this.setData({
takeOutOrderPath: pictureInfos.takeOutOrderPath
})
else this.setData({
takeOutOrderPath: "../store/store?title=外卖门店&busMode=3"
})
if (pictureInfos.integralMallPath) this.setData({
integralMallPath: pictureInfos.integralMallPath
})
else this.setData({
integralMallPath: "../couponCenter/index"
})
if (pictureInfos.userCenterPath) this.setData({
userCenterPath: pictureInfos.userCenterPath
})
else this.setData({
userCenterPath: "mine"
})
if (pictureInfos.rechargePath) this.setData({
rechargePath: pictureInfos.rechargePath
})
else this.setData({
rechargePath: "/pages/mine/memberBalance"
})
if (pictureInfos.couponPath) this.setData({
couponPath: pictureInfos.couponPath
})
else this.setData({
couponPath: "/pages/coupon/couponCenterNew"
})
if (pictureInfos.payCodePath) this.setData({
payCodePath: pictureInfos.payCodePath
})
else this.setData({
payCodePath: "/pages/mine/paymentCode"
})
} else {
this.setData({
forHereOrderUrl: "/images/icon-bg-food.png"
})
this.setData({
takeOutOrderUrl: "/images/icon-bg-out.png"
})
this.setData({
integralMallUrl: "/images/icon-bg-coupon.png"
})
this.setData({
userCenterUrl: "/images/icon-bg-mine.png"
})
this.setData({
rechargeUrl: "/images/index_menu_rechange.png"
})
this.setData({
couponUrl: "/images/index_menu_coupon.png"
})
this.setData({
payCodeUrl: "/images/index_menu_memberCode.png"
})
this.setData({
rechargeFuncName: "充值"
})
this.setData({
couponFuncName: "优惠券"
})
this.setData({
payCodeFuncName: "支付码"
})
this.setData({
forHereOrderPath: "../store/store?title=门店自提&busMode=1"
})
this.setData({
takeOutOrderPath: "../store/store?title=外卖门店&busMode=3"
})
this.setData({
integralMallPath: "../couponCenter/index"
})
this.setData({
userCenterPath: "mine"
})
this.setData({
rechargePath: "/pages/mine/memberBalance"
})
this.setData({
couponPath: "/pages/coupon/couponCenterNew"
})
this.setData({
payCodePath: "/pages/mine/paymentCode"
})
}
this.setData({
description: wx.getStorageSync("description"),
})
this.cy_programAdvpictureDownloadList();
if (options.scanner) {
var url = "";
var type = wx.getStorageSync('type'); // 堂食扫码
log.info('type from storage: ' + type);
console.log("-----------------------", type);
if(type != 'e1' && type != 'e2' && type != 'e3' && type != 'e4') {
app.orderTicket.busMode = 0; //堂食
wx.setStorageSync('mode', 0);
log.info('busMode的值' + wx.getStorageSync('mode'));
url = "../list/shopList";
}
if(type === "e1") {
app.orderTicket.busMode = 1; //自提
wx.setStorageSync('mode', 1);
url = "../list/shopList";
}
if(type === "e3") { // 外卖扫码
app.orderTicket.busMode = 3;
url = "../list/shopList";
}
if(type === "e4"){ // 扫码充值
url = this.data.rechargePath;
}
wx.redirectTo({
url: url,
})
}
},
/**
* 下载广告图片
*/
cy_programAdvpictureDownloadList: function () {
var that = this;
var params = {
method: "program.advpicture.download.list",
programId: app.globalData.programId,
orderType: "asc",
}
var ignores = ["orderType"];
app.jsapi.api(app.globalData.appKey, app.globalData.appSecret, app.globalData.serverUrl).ajax(params, ignores,
function (json) {
console.log(json);
var data = json.data;
if (data.status == 1) {
wx.setStorageSync("ads", data.list);
if (data.list.length != 0) {
that.setData({
list: data.list
})
}
}
},
function (err) {
wx.showToast({
title: "网络连接失败,请检查",
icon: "none"
})
});
},
/**
* 自提
*/
cy_getTangAndPack() {
myaudio.play();
// var url = "../store/store?title=堂食门店&busMode=0";
app.globalData.busMode = 1;
wx.setStorageSync("mode", 1);
wx.navigateTo({
url: this.data.forHereOrderPath,
})
},
/**
* 外卖
*/
cy_getTakeOut() {
myaudio.play();
// var url = "../store/store?title=外卖门店&busMode=3";
app.globalData.busMode = 3;
wx.navigateTo({
url: this.data.takeOutOrderPath,
})
},
/**
* 领券中心
*/
cy_getCoupon() {
myaudio.play();
if (app.globalData.cardNo.length == 0) {
wx.showModal({
title: '提示',
content: '您还不是会员去注册',
success: function (res) {
if (res.confirm) {
wx.navigateTo({
url: 'mine',
})
}
}
})
return;
}
wx.navigateTo({
url: this.data.integralMallPath,
})
},
/**
* 个人中心
*/
cy_getMine() {
myaudio.play();
var url = "mine";
wx.navigateTo({
url: this.data.userCenterPath,
})
},
/**
* 授权获取手机
*/
cy_getPhoneNumber: function (e) {
var that = this;
if (e.detail.errMsg == 'getPhoneNumber:ok') {
var iv = e.detail.iv;
var encryptedData = e.detail.encryptedData;
card.wx_getPhoneNumber(iv, encryptedData, function (json) {
var result = json.data;
if (result.status == '1') {
var data = result.data.data;
var purePhoneNumber = data.purePhoneNumber; //没有区号的手机号
app.iphone = purePhoneNumber;
wx.showLoading({
title: '处理中...',
})
app.cy_openCardInfo(); // 会员开户
var timer = setInterval(function () {
if (app.cardNo) {
clearInterval(timer);
var newCardNo = app.cardNo.replace(/\s/g, '').replace(/(.{4})/g, "$1 ");
that.setData({
isiPhone: true,
cardNo: newCardNo,
})
}
}, 800);
} else {
wx.showModal({
title: '提示',
content: '获取手机号失败',
showCancel: false,
})
}
}, function (err) {
wx.showToast({
title: '授权失败,请重新尝试',
icon: "none",
})
});
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
return app.onShare;
},
onShow: function () {
this.onLoad(this.data.pageOption);
myaudio.src = "http://pos.juweiyun.cn/weChatAppdi.mp4";
this.setData({
color: app.globalData.color
})
var that = this;
setTimeout(() => {
that.setData({
color: app.globalData.color
})
}, 1500);
},
menuClick: function (e) {
myaudio.play();
if (app.globalData.cardNo.length == 0) {
wx.showModal({
title: '提示',
content: '您还不是会员去注册',
success: function (res) {
if (res.confirm) {
wx.navigateTo({
url: 'mine',
})
}
}
})
return;
}
var urls = e.currentTarget.dataset.url;
wx.navigateTo({
url: urls,
})
},
aaaaaa: function name(e) {
wx.requestSubscribeMessage({
tmplIds: [ 'C3kyx0tO-XlI9odtP_1gz9HG2W0oHIMqBgJMROpmE3g'],
success: function (params) {
console.error(" success ", params)
},
fail: function (params) {
console.error(" error ", params)
}
})
}
})