|
...
|
...
|
@@ -4,6 +4,7 @@ import util from '../../utils/util'; |
|
|
|
import App from '../../utils/api';
|
|
|
|
import TP from '../../utils/tpls';
|
|
|
|
import RS from '../../utils/reserveStatus'
|
|
|
|
var plugin = requirePlugin("WechatSI");
|
|
|
|
Page({
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
...
|
...
|
@@ -26,7 +27,6 @@ Page({ |
|
|
|
store: {},
|
|
|
|
recharge_data: {},
|
|
|
|
coupon_dataList: [],
|
|
|
|
stringifyUse: '',
|
|
|
|
current: 0,
|
|
|
|
seller: {
|
|
|
|
name: '',
|
|
...
|
...
|
@@ -49,8 +49,14 @@ Page({ |
|
|
|
hasValueOrder:false,//商家是否开通提前点餐功能
|
|
|
|
hasValueCertificate:false,//商家是否开通优惠券功能
|
|
|
|
hasValueRecharge:false,//商家是否开通充值功能
|
|
|
|
_attentionAnim: {},
|
|
|
|
isPlay: '1',
|
|
|
|
},
|
|
|
|
screenHeight: '',
|
|
|
|
attentionAnim: {},
|
|
|
|
audioCtx: '', //播报
|
|
|
|
timers: null, // 动画定时器
|
|
|
|
n: 0,
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
...
|
...
|
@@ -175,10 +181,12 @@ Page({ |
|
|
|
rid: this.data.options.id
|
|
|
|
}).then(res => {
|
|
|
|
let tablesText = '', //桌子信息
|
|
|
|
deskStr = '',
|
|
|
|
tableNum = 0;
|
|
|
|
res.data.tables.forEach((t, i) => {
|
|
|
|
tableNum += t.table_pnum * 1
|
|
|
|
tablesText += t.rname + t.name + (i == (res.data.tables.length - 1) ? '' : '、');
|
|
|
|
deskStr += t.name + (i == (res.data.tables.length - 1) ? '' : '、');
|
|
|
|
})
|
|
|
|
let reserev = RS.reserve(res.data)
|
|
|
|
let dateSmart
|
|
...
|
...
|
@@ -192,6 +200,9 @@ Page({ |
|
|
|
} else {
|
|
|
|
dateSmart = util.unixtoTime(reserev.ddate, this.data.tpls[this.data.current].timeStr)
|
|
|
|
}
|
|
|
|
let yearMonthDay = util.unixtoTime(reserev.ddate, 'YYYY年MM月DD日')
|
|
|
|
let yearMonth = util.unixtoTime(reserev.ddate, 'MM月DD日')
|
|
|
|
let dateStr = util.unixtoTime(reserev.ddate, 'HH点II分')
|
|
|
|
this.setData({
|
|
|
|
detail: this.formatDatail(reserev, dateSmart),
|
|
|
|
tableNum,
|
|
...
|
...
|
@@ -212,14 +223,17 @@ Page({ |
|
|
|
lat: reserev.seller.lat,
|
|
|
|
long: reserev.seller.long,
|
|
|
|
seller_tel: reserev.seller.seller_tel,
|
|
|
|
yearMonthDay,
|
|
|
|
yearMonth,
|
|
|
|
dateStr,
|
|
|
|
deskStr,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
console.log('reserev reserev', reserev);
|
|
|
|
console.log('seller seller', this.data.seller);
|
|
|
|
console.log('detail detail', this.data.detail);
|
|
|
|
setTimeout(() => {
|
|
|
|
this.getSellerTemplateConfFun(reserev.sid);
|
|
|
|
this.getstaffinfo(res.data.uid)
|
|
|
|
this.getstaffinfo(res.data.uid, reserev.sid);
|
|
|
|
this.getSellerVersionFun(reserev.sid);
|
|
|
|
}, 0);
|
|
|
|
}).catch(res => {
|
|
...
|
...
|
@@ -244,7 +258,8 @@ Page({ |
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getstaffinfo(uid) {
|
|
|
|
// 客户经理获取基本信息
|
|
|
|
getstaffinfo(uid, sid) {
|
|
|
|
console.log('sellerid', this.data.detail.seller.id);
|
|
|
|
App.Activity.GetCustomerActivityBaseinfo({
|
|
|
|
sellerid: this.data.detail.seller.id,
|
|
...
|
...
|
@@ -255,6 +270,7 @@ Page({ |
|
|
|
this.setData({
|
|
|
|
staffinfo: json.data
|
|
|
|
})
|
|
|
|
this.getSellerTemplateConfFun(sid);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
...
|
...
|
@@ -337,8 +353,8 @@ Page({ |
|
|
|
}).then(res => {
|
|
|
|
let data = res.data
|
|
|
|
console.log('data', data);
|
|
|
|
let coupon_dataList = []
|
|
|
|
let themeColor, StyleType, whiteBj, home, chef, marketing, coupon, reserve, swich_phone, is_comments, signboard, store, priceInfo, certificate, scoreInfo, recharge_list, stringifyUse;
|
|
|
|
let couponList = []
|
|
|
|
let themeColor, StyleType, whiteBj, home, chef, marketing, coupon, reserve, swich_phone, is_comments, signboard, store;
|
|
|
|
chef = util.determine(data.chef);
|
|
|
|
reserve = util.determine(data.reserve);
|
|
|
|
marketing = util.determine(data.marketing);
|
|
...
|
...
|
@@ -352,31 +368,21 @@ Page({ |
|
|
|
is_comments = marketing.is_comments ? marketing.is_comments : '';
|
|
|
|
coupon = marketing.coupon_data ? util.determine(marketing.coupon_data) : '';
|
|
|
|
}
|
|
|
|
// is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示
|
|
|
|
if (coupon && util.getType(coupon) == 'object') {
|
|
|
|
coupon.stringifyUse = JSON.stringify(coupon.use)
|
|
|
|
if (marketing.is_coupon == '1' && coupon && coupon.use && (!coupon.use.is_cash || coupon.use.is_cash == '1')) {
|
|
|
|
let cash = coupon.use.cash * 1;
|
|
|
|
let price = coupon.price * 1;
|
|
|
|
console.log('cash', cash + '---' + 'price', price + '---' + 'discount', ((price / cash) * 10).toFixed(1));
|
|
|
|
coupon.discount = cash != 0 ? ((price / cash) * 10).toFixed(1) : '';
|
|
|
|
}
|
|
|
|
coupon_dataList.push(coupon);
|
|
|
|
}
|
|
|
|
if (coupon && util.getType(coupon) == 'array') {
|
|
|
|
if (coupon.length > 0) {
|
|
|
|
coupon.forEach(item => {
|
|
|
|
item.stringifyUse = item.use?JSON.stringify(item.use):'';
|
|
|
|
if ((item.use && (!item.use.is_cash || item.use.is_cash == '1'))) {
|
|
|
|
let cash = item.use.cash * 1;
|
|
|
|
let price = item.price * 1;
|
|
|
|
console.log('cash', cash + '---' + 'price', price + '---' + 'discount', ((price / cash) * 10).toFixed(1));
|
|
|
|
item.discount = cash != 0 ? ((price / cash) * 10).toFixed(1) : '';
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
coupon_dataList = coupon;
|
|
|
|
}
|
|
|
|
// is_cash 代金券 is_discount折扣券 is_dish菜品券 只有代金券有几折显示
|
|
|
|
if (coupon && util.getType(coupon) == 'object') {
|
|
|
|
couponList.push({
|
|
|
|
id: coupon.id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (coupon && util.getType(coupon) == 'array') {
|
|
|
|
if (coupon.length > 0) {
|
|
|
|
coupon.forEach(item => {
|
|
|
|
couponList.push({
|
|
|
|
id: item.id
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let obj = {
|
|
|
|
chef,
|
|
|
|
reserve,
|
|
...
|
...
|
@@ -384,9 +390,8 @@ Page({ |
|
|
|
signboard,
|
|
|
|
store,
|
|
|
|
home,
|
|
|
|
stringifyUse,
|
|
|
|
coupon,
|
|
|
|
coupon_dataList,
|
|
|
|
couponList,
|
|
|
|
swich_phone,
|
|
|
|
is_comments,
|
|
|
|
StyleType,
|
|
...
|
...
|
@@ -395,24 +400,12 @@ Page({ |
|
|
|
console.log('获取数据', {
|
|
|
|
...obj
|
|
|
|
});
|
|
|
|
if (marketing && marketing.is_recharge == '1' && marketing.recharge_data) {
|
|
|
|
let recharge_data = marketing.recharge_data
|
|
|
|
recharge_list = marketing.recharge_data.recharge_list
|
|
|
|
if (recharge_list.is_price == '1') priceInfo = '会员充值满' + recharge_data.recharge_money + '元赠送' + recharge_list.price + '元余额';
|
|
|
|
if (recharge_list.is_score == '1') scoreInfo = '会员充值满' + recharge_data.recharge_money + '元赠送' + recharge_list.score + '积分';
|
|
|
|
if (recharge_list.is_coupons == '1' && recharge_data.recharge_list.coupons_names.length > 0) certificate = recharge_data.recharge_list.coupons_names.join('、');
|
|
|
|
console.log('scoreInfo', scoreInfo);
|
|
|
|
console.log('priceInfo', priceInfo);
|
|
|
|
this.setData({
|
|
|
|
recharge_data: marketing.recharge_data,
|
|
|
|
certificate
|
|
|
|
})
|
|
|
|
console.log('recharge_data', recharge_data);
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
coupon_dataList,
|
|
|
|
stringifyUse
|
|
|
|
})
|
|
|
|
// 根据券ID获取券详情
|
|
|
|
this.getActivityByIdFun(couponList, couponList.length)
|
|
|
|
// 根据充值ID获取充值详情
|
|
|
|
if (marketing && marketing.is_recharge == '1' && marketing.recharge_data) {
|
|
|
|
this.getRechargeDetail(marketing.recharge_data.id)
|
|
|
|
}
|
|
|
|
if (store && store.images.length > 0) store.images = util.determine(store.images);
|
|
|
|
if (signboard && signboard.images) signboard.images = util.determine(signboard.images);
|
|
|
|
if (marketing && marketing.is_online_book == '1' && marketing.is_transpond == '1') {
|
|
...
|
...
|
@@ -432,14 +425,19 @@ Page({ |
|
|
|
reserve,
|
|
|
|
signboard,
|
|
|
|
store,
|
|
|
|
priceInfo,
|
|
|
|
scoreInfo,
|
|
|
|
swich_phone,
|
|
|
|
is_comments,
|
|
|
|
StyleType,
|
|
|
|
themeColor,
|
|
|
|
whiteBj,
|
|
|
|
})
|
|
|
|
// 开启语音播报
|
|
|
|
if (reserve && reserve.swich_voice == '1') {
|
|
|
|
this.setData({
|
|
|
|
isPlay: '1',
|
|
|
|
})
|
|
|
|
this.textToSpeechFun(reserve.voice_info)
|
|
|
|
}
|
|
|
|
}).catch(res => {
|
|
|
|
console.log('GetSellerTemplateConf请求失败');
|
|
|
|
})
|
|
...
|
...
|
@@ -451,12 +449,160 @@ Page({ |
|
|
|
url: '../reserve/detail?id=' + this.data.detail.seller.id
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 文字转语音的方法
|
|
|
|
textToSpeechFun(voice_info) {
|
|
|
|
console.log('voice_info', voice_info);
|
|
|
|
let that = this;
|
|
|
|
let data = this.data;
|
|
|
|
let str = data.detail.sex == '1' ? '先生' : data.detail.sex == '2' ? '女士' : '';
|
|
|
|
const replacements = {
|
|
|
|
"{年月日}": data.seller.yearMonthDay,
|
|
|
|
"{月日}": data.seller.yearMonth,
|
|
|
|
"{餐段}": data.seller.soltName,
|
|
|
|
"{就餐时间}": data.seller.dateStr,
|
|
|
|
"{包间名}": data.seller.deskStr,
|
|
|
|
"{区域名+包间名}": data.seller.tablesText,
|
|
|
|
"{经理名字}": data.staffinfo.name,
|
|
|
|
"{客人姓名}": data.detail.rname + str,
|
|
|
|
};
|
|
|
|
let newStr = voice_info.replace(/{年月日}|{月日}|{餐段}|{就餐时间}|{包间名}|{区域名\+包间名}|{经理名字}|{客人姓名}/g, function (matched) {
|
|
|
|
return replacements[matched];
|
|
|
|
});
|
|
|
|
console.log('newStr', newStr);
|
|
|
|
plugin.textToSpeech({
|
|
|
|
lang: "zh_CN",
|
|
|
|
tts: true,
|
|
|
|
content: newStr,
|
|
|
|
success: function (res) {
|
|
|
|
that.filename = res.filename
|
|
|
|
that.speech()
|
|
|
|
},
|
|
|
|
fail: function (res) {
|
|
|
|
console.log("fail tts", res)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 开启语音播报
|
|
|
|
speech() {
|
|
|
|
var attentionAnim = wx.createAnimation({
|
|
|
|
duration: 1000,
|
|
|
|
timingFunction: 'linear',
|
|
|
|
})
|
|
|
|
this.attentionAnim = attentionAnim
|
|
|
|
this.setData({
|
|
|
|
_attentionAnim: attentionAnim,
|
|
|
|
attentionAnim: attentionAnim.export()
|
|
|
|
})
|
|
|
|
this.audioCtx = wx.createInnerAudioContext()
|
|
|
|
this.audioCtx.src = this.filename
|
|
|
|
this.audioCtx.loop = true
|
|
|
|
this.audioCtx.play()
|
|
|
|
this.audioCtx.onPlay((e) => {
|
|
|
|
this.setData({
|
|
|
|
isPlay: this.audioCtx.paused ? '2' : '1'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
this.audioCtx.onPause((e) => {
|
|
|
|
this.setData({
|
|
|
|
isPlay: this.audioCtx.paused ? '2' : '1'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
clearInterval(this.timers)
|
|
|
|
this.animation()
|
|
|
|
},
|
|
|
|
// 持续旋转动画
|
|
|
|
animation() {
|
|
|
|
let that = this;
|
|
|
|
var time = setInterval(function () {
|
|
|
|
this.n = this.n + 1;
|
|
|
|
let attentionAnim = that.data._attentionAnim
|
|
|
|
attentionAnim.rotate(180 * (this.n)).step()
|
|
|
|
that.setData({
|
|
|
|
attentionAnim: attentionAnim.export(),
|
|
|
|
})
|
|
|
|
}.bind(this), 1000)
|
|
|
|
this.timers = time;
|
|
|
|
},
|
|
|
|
// 暂停/继续播放
|
|
|
|
stopMusic() {
|
|
|
|
if (this.data.isPlay == '2') { // 2 暂停状态
|
|
|
|
console.log("开始");
|
|
|
|
clearInterval(this.timers)
|
|
|
|
this.animation()
|
|
|
|
this.audioCtx.play() //开始
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this.data.isPlay == '1') { // 1 运行状态
|
|
|
|
console.log('暂停');
|
|
|
|
if (this.n % 2 != 0) {
|
|
|
|
this.n = this.n + 1;
|
|
|
|
let attentionAnim = this.data._attentionAnim;
|
|
|
|
attentionAnim.rotate(180 * this.n).step();
|
|
|
|
this.setData({
|
|
|
|
attentionAnim: attentionAnim.export(),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
clearInterval(this.timers)
|
|
|
|
this.audioCtx.pause() //暂停
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 根据充值ID获取充值详情
|
|
|
|
getRechargeDetail(id) {
|
|
|
|
App.Activity.GetNewRecharge({
|
|
|
|
id
|
|
|
|
}).then(res => {
|
|
|
|
let detail = res.data
|
|
|
|
let exp_date = res.data.exp_date ? JSON.parse(res.data.exp_date) : ''
|
|
|
|
let recharge_list = res.data.recharge_list ? JSON.parse(res.data.recharge_list) : ''
|
|
|
|
let priceInfo, scoreInfo, certificate;
|
|
|
|
detail.recharge_list = recharge_list;
|
|
|
|
detail.exp_date = exp_date;
|
|
|
|
if (recharge_list.is_price == '1') priceInfo = '会员充值满' + detail.recharge_money + '元赠送' + recharge_list.price + '元余额';
|
|
|
|
if (recharge_list.is_score == '1') scoreInfo = '会员充值满' + detail.recharge_money + '元赠送' + recharge_list.score + '积分';
|
|
|
|
if (recharge_list.is_coupons == '1' && recharge_list.coupons_names.length > 0) certificate = recharge_list.coupons_names.join('、');
|
|
|
|
this.setData({
|
|
|
|
recharge_data: detail,
|
|
|
|
scoreInfo,
|
|
|
|
priceInfo,
|
|
|
|
certificate
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 根据券ID获取券详情
|
|
|
|
getActivityByIdFun(ids, length) {
|
|
|
|
let coupon_dataList = [];
|
|
|
|
ids.forEach(i => {
|
|
|
|
App.Activity.GetActivityById({
|
|
|
|
id: i.id
|
|
|
|
}).then(res => {
|
|
|
|
if (res.data.length > 0) {
|
|
|
|
let detail = res.data[0];
|
|
|
|
detail.stringifyUse = detail.use ? JSON.stringify(detail.use) : '';
|
|
|
|
detail.exp_date = detail.exp_date ? util.determine(detail.exp_date) : '';
|
|
|
|
detail.use = detail.use ? util.determine(detail.use) : '';
|
|
|
|
if ((detail.use && (!detail.use.is_cash || detail.use.is_cash == '1'))) {
|
|
|
|
let cash = detail.use.cash * 1;
|
|
|
|
let price = detail.price * 1;
|
|
|
|
detail.discount = cash != 0 ? ((price / cash) * 10).toFixed(1) : '';
|
|
|
|
}
|
|
|
|
coupon_dataList.push(detail);
|
|
|
|
if (length === ids.length) {
|
|
|
|
this.setData({
|
|
|
|
coupon_dataList,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
},
|
|
|
|
onHide() {
|
|
|
|
clearInterval(this.timers)
|
|
|
|
this.audioCtx.pause() //暂停
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
...
|
...
|
|