|
|
|
// pack-invitation/pages/detail_owner_invitation12.js
|
|
|
|
var mta = require('mta-wechat-analysis')
|
|
|
|
import util from '../../utils/util';
|
|
|
|
import App from '../../utils/api';
|
|
|
|
import TP from '../../utils/tpls';
|
|
|
|
import RS from '../../utils/reserveStatus'
|
|
|
|
var plugin = requirePlugin("WechatSI");
|
|
|
|
import canvas from "../../pages/customer/canvas"
|
|
|
|
Page({
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
show_white: false,
|
|
|
|
options: {
|
|
|
|
tplid: ''
|
|
|
|
},
|
|
|
|
tableNum: 0,
|
|
|
|
detail: {},
|
|
|
|
staffinfo: {},
|
|
|
|
chef: {},
|
|
|
|
marketing: {},
|
|
|
|
home: {},
|
|
|
|
reserve: {},
|
|
|
|
signboard: {},
|
|
|
|
store: {},
|
|
|
|
recharge_data: {},
|
|
|
|
coupon_dataList: [],
|
|
|
|
seller: {},
|
|
|
|
priceInfo: '',
|
|
|
|
scoreInfo: '',
|
|
|
|
certificate: '',
|
|
|
|
dataStr: Date.now() * 1 / 1000,
|
|
|
|
swich_phone: '0', //是否显示前台电话
|
|
|
|
is_comments: '0',
|
|
|
|
is_user_comments: false, //是否评价过 true有评价 false没评价
|
|
|
|
tableinfo: [], //桌子列表
|
|
|
|
StyleType: '', //邀请函模板
|
|
|
|
showMoreTip: true, //显示滑动查看更多
|
|
|
|
hasValueOrder: false, //商家是否开通提前点餐功能
|
|
|
|
hasValueCertificate: false, //商家是否开通优惠券功能
|
|
|
|
hasValueRecharge: false, //商家是否开通充值功能
|
|
|
|
hasValueBroadcast: false, //商家是否能播报,只有极速版不能播报
|
|
|
|
_attentionAnim: {},
|
|
|
|
isPlay: '1', //语音播报 1运行 2暂停
|
|
|
|
paymentStatus: '', //定金支付状态 1支付 0未支付
|
|
|
|
reserveData: {}, //自定义图文数据
|
|
|
|
toastBool: false, //支付定金提示框
|
|
|
|
toastText: '', //支付定金提示文字
|
|
|
|
paymentId: '', //定金id
|
|
|
|
wxml: null,
|
|
|
|
imgSrc: '', //canvas图片地址
|
|
|
|
colors: '', //导航栏颜色
|
|
|
|
couponData: '', //评价赠送优惠券数据
|
|
|
|
timeList: [], //餐段时间
|
|
|
|
temp_ddate: '', //展示的到店时间
|
|
|
|
lite_style: '', //小程序转发卡片样式
|
|
|
|
isMoreBtn: '', //再次预订按钮
|
|
|
|
isPaymenBtn: '', //支付定金按钮
|
|
|
|
isShareItem: '', //转发客人按钮
|
|
|
|
isVoice: '', //播报按钮
|
|
|
|
openOrder: '', //点餐
|
|
|
|
isComments: '', //券和充值
|
|
|
|
bookType: '', //用餐类型 1婚宴模板1 2商务宴模板1
|
|
|
|
urlsArr: [], //包间预览图片、餐厅logo、餐厅首图列表
|
|
|
|
roomimage: [], //包间信息列表
|
|
|
|
activeTitle: '1', //选择的标题 1优惠券 2充值 3评价
|
|
|
|
titleList: [], //优惠券、充值、评价标题数组
|
|
|
|
modalType: '', //弹框
|
|
|
|
modalTitle: '', //弹框标题
|
|
|
|
},
|
|
|
|
tablestr: '', //桌位id拼接
|
|
|
|
screenHeight: '',
|
|
|
|
attentionAnim: {},
|
|
|
|
audioCtx: '', //播报
|
|
|
|
timers: null, // 动画定时器
|
|
|
|
n: 0,
|
|
|
|
modal: '',
|
|
|
|
publicModal: '',
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad(options) {
|
|
|
|
this.id = options.id
|
|
|
|
let param = {
|
|
|
|
options: options,
|
|
|
|
hasOwner: options.hasSellerShare == 1, //是否为发起人
|
|
|
|
}
|
|
|
|
param.tpls = [TP.tpls(options.tplid)]
|
|
|
|
let bookType = options.bookType;
|
|
|
|
console.log('param', param);
|
|
|
|
console.log('options', options);
|
|
|
|
this.setData({
|
|
|
|
...param,
|
|
|
|
bookType
|
|
|
|
})
|
|
|
|
mta.Page.init({
|
|
|
|
"appID": "500667280",
|
|
|
|
"eventID": "500667287",
|
|
|
|
"statPullDownFresh": true,
|
|
|
|
"statShareApp": true,
|
|
|
|
"statReachBottom": true,
|
|
|
|
"lauchOpts": options, //渠道分析
|
|
|
|
});
|
|
|
|
const systemInfo = wx.getSystemInfoSync();
|
|
|
|
this.screenHeight = systemInfo.windowHeight; // 获取屏幕高度
|
|
|
|
this.modal = this.selectComponent("#payModal"); //通过给组件所起的id调用组件
|
|
|
|
this.publicModal = this.selectComponent("#publicModal"); //通过给组件所起的id调用组件
|
|
|
|
wx.onUserCaptureScreen((res) => {
|
|
|
|
this.modal.showModal()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
//预览图片
|
|
|
|
previewImage(e) {
|
|
|
|
const item = e.target.dataset;
|
|
|
|
wx.previewImage({
|
|
|
|
current: item.url,
|
|
|
|
urls: item.imgs,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 打开截屏弹框
|
|
|
|
showModal() {
|
|
|
|
this.modal.showModal()
|
|
|
|
},
|
|
|
|
// 关闭截屏弹框
|
|
|
|
closeModal() {
|
|
|
|
this.modal.closeModal()
|
|
|
|
},
|
|
|
|
// 公共弹框
|
|
|
|
publicShowModal(e) {
|
|
|
|
const modalType = e.currentTarget.dataset['type'];
|
|
|
|
const modalTitle = e.currentTarget.dataset['title'];
|
|
|
|
this.setData({
|
|
|
|
modalType,
|
|
|
|
modalTitle,
|
|
|
|
})
|
|
|
|
this.publicModal.showModal()
|
|
|
|
},
|
|
|
|
// 关闭截屏弹框
|
|
|
|
closepublicModal() {
|
|
|
|
this.publicModal.closeModal()
|
|
|
|
},
|
|
|
|
// 页面滚动事件
|
|
|
|
onPageScroll: function (event) {
|
|
|
|
if (event.scrollTop > 150) { //当页面滚动到某个位置时(这里设置为50),将导航栏背景颜色设置为白色
|
|
|
|
this.setData({
|
|
|
|
show_white: true
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
show_white: false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
const scrollTop = event.scrollTop * 1 + this.screenHeight - 80; // 获取滚动的距离
|
|
|
|
if (scrollTop < this.screenHeight) {
|
|
|
|
this.setData({
|
|
|
|
showMoreTip: true
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
showMoreTip: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 点击了解更多会员优惠政策
|
|
|
|
gotoFavourableList() {
|
|
|
|
let url = util.http_build_query({
|
|
|
|
sellerName: this.data.seller.name,
|
|
|
|
sellerid: this.data.seller.sid,
|
|
|
|
oid: this.data.detail.id,
|
|
|
|
types: '1'
|
|
|
|
}, '/pack-cookbook/pages/favourableList')
|
|
|
|
wx.navigateTo({
|
|
|
|
url
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 去评价
|
|
|
|
evaluateFun() {
|
|
|
|
let url = util.http_build_query({
|
|
|
|
sellerName: this.data.seller.name,
|
|
|
|
sellerid: this.data.seller.sid,
|
|
|
|
oid: this.data.detail.id,
|
|
|
|
types: '1',
|
|
|
|
previousPage: '1',
|
|
|
|
}, '/pages/pinglun/createOpinion')
|
|
|
|
wx.navigateTo({
|
|
|
|
url
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
return this.sharesetting();
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 监听用户点击分享到朋友圈按钮的操作
|
|
|
|
*/
|
|
|
|
onShareTimeline() {
|
|
|
|
return this.sharesetting();
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
this.setData({
|
|
|
|
titleList: []
|
|
|
|
})
|
|
|
|
this.getDetail()
|
|
|
|
this.getText()
|
|
|
|
this.getPaymentStatus()
|
|
|
|
},
|
|
|
|
// 复制微信号
|
|
|
|
copyWeChat() {
|
|
|
|
if (this.data.staffinfo.wechat) {
|
|
|
|
wx.setClipboardData({
|
|
|
|
data: this.data.staffinfo.wechat,
|
|
|
|
success(res) {
|
|
|
|
wx.getClipboardData({
|
|
|
|
success(res) {
|
|
|
|
console.log(res.data)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
console.log('无微信号')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 拨打电话
|
|
|
|
call(e) {
|
|
|
|
const phone = e.currentTarget.dataset['phone'];
|
|
|
|
wx.reportMonitor('1012', 1)
|
|
|
|
wx.makePhoneCall({
|
|
|
|
phoneNumber: phone
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 跳转到商家入驻页
|
|
|
|
gotoJoinSeller() {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: util.http_build_query({
|
|
|
|
laiyuan: '邀请函'
|
|
|
|
}, '/pages/customer/joinSeller')
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 导航
|
|
|
|
looklocation: function () {
|
|
|
|
wx.reportMonitor('1015', 1)
|
|
|
|
wx.openLocation({
|
|
|
|
latitude: Number(this.data.seller.lat),
|
|
|
|
longitude: Number(this.data.seller.long),
|
|
|
|
scale: 17,
|
|
|
|
address: this.data.seller.addr,
|
|
|
|
success: function (res) {
|
|
|
|
console.log(res)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 获取包间图片列表
|
|
|
|
getroomimage(sellerid, uid) {
|
|
|
|
App.Tables.GetTablesPhoto({
|
|
|
|
sellerid,
|
|
|
|
tableids: this.tablestr
|
|
|
|
}).then((json) => {
|
|
|
|
if (json.ret == 200) {
|
|
|
|
this.setData({
|
|
|
|
roomimage: json.data
|
|
|
|
})
|
|
|
|
var urlsArr = [];
|
|
|
|
json.data.forEach((v, i) => {
|
|
|
|
urlsArr.push(v.url);
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
urlsArr
|
|
|
|
})
|
|
|
|
this.getstaffinfo(uid, sellerid);
|
|
|
|
console.log('包间图片地址urlsArr', urlsArr)
|
|
|
|
console.log('包间信息roomimage', json.data)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 预览图片
|
|
|
|
lookImgs(e) {
|
|
|
|
const url = e.currentTarget.dataset['url'];
|
|
|
|
const imgs = e.currentTarget.dataset['imgs'];
|
|
|
|
let urls = imgs ? imgs : [url]
|
|
|
|
wx.previewImage({
|
|
|
|
current: url,
|
|
|
|
urls,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 获取店铺详情
|
|
|
|
getDetail() {
|
|
|
|
App.Reserve.Detail({
|
|
|
|
openid: getApp().openid,
|
|
|
|
rid: this.data.options.id
|
|
|
|
}).then(res => {
|
|
|
|
let tablesText = '', //桌子信息
|
|
|
|
deskStr = '',
|
|
|
|
tableNum = 0;
|
|
|
|
let tableinfo = util.determine(res.data.tableinfo);
|
|
|
|
console.log('tableinfo', tableinfo);
|
|
|
|
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 tabaleids = [];
|
|
|
|
res.data.tables.forEach(t => {
|
|
|
|
tabaleids.push(t.id);
|
|
|
|
})
|
|
|
|
this.tablestr = tabaleids.toString();
|
|
|
|
let reserev = RS.reserve(res.data)
|
|
|
|
let dateSmart = util.unixtoTime(reserev.ddate, 'YYYY-MM-DD 星期WW');
|
|
|
|
let yearMonthDay = util.unixtoTime(reserev.ddate, 'YYYY年MM月DD日')
|
|
|
|
let yearMonth = util.unixtoTime(reserev.ddate, 'MM月DD日')
|
|
|
|
let dateStr = util.unixtoTime(reserev.ddate, 'HH点')
|
|
|
|
let dateStrDivide = util.unixtoTime(reserev.ddate, 'II分')
|
|
|
|
console.log('dateSmart', dateSmart);
|
|
|
|
let detail = this.formatDatail(reserev, dateSmart)
|
|
|
|
this.setData({
|
|
|
|
detail,
|
|
|
|
tableNum,
|
|
|
|
tableinfo,
|
|
|
|
is_user_comments: res.data.is_user_comments,
|
|
|
|
temp_ddate: this.data.temp_ddate ? this.data.temp_ddate : reserev.temp_ddate ? util.unixtoTime(reserev.temp_ddate, 'HH:II') : util.unixtoTime(reserev.ddate, 'HH:II'),
|
|
|
|
openOrder: (detail && detail.status != '4' && this.data.options.isOrder != '1' && detail.seller && detail.seller.is_open_order == 1) ? '1' : '0',
|
|
|
|
seller: {
|
|
|
|
daily: reserev.seller.daily,
|
|
|
|
name: reserev.seller.sellername,
|
|
|
|
sid: reserev.sid,
|
|
|
|
date: dateSmart,
|
|
|
|
tablesText,
|
|
|
|
addr: reserev.seller.real_address || reserev.seller.map_address,
|
|
|
|
image: reserev.image_url,
|
|
|
|
hasOwner: true,
|
|
|
|
type: reserev.type,
|
|
|
|
is_set_ddate: reserev.is_set_ddate,
|
|
|
|
hasUpTime: reserev.type == 1 && reserev.hasRunning && reserev.status != 2,
|
|
|
|
tel: reserev.seller.seller_tel.split(','),
|
|
|
|
soltName: reserev.soltName,
|
|
|
|
dateTime: util.unixtoTime(reserev.ddate, 'HH:II'),
|
|
|
|
time: util.unixtoTime(reserev.ddate, '星期WW HH:II'),
|
|
|
|
lat: reserev.seller.lat,
|
|
|
|
long: reserev.seller.long,
|
|
|
|
yearMonthDay,
|
|
|
|
yearMonth,
|
|
|
|
dateStr,
|
|
|
|
deskStr,
|
|
|
|
dateStrDivide: dateStrDivide == '00分' ? '' : dateStrDivide,
|
|
|
|
seller_tel: reserev.seller.seller_tel,
|
|
|
|
phone: reserev.phone,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
console.log('reserev信息', reserev);
|
|
|
|
console.log('seller信息', this.data.seller);
|
|
|
|
console.log('detail信息', this.data.detail);
|
|
|
|
setTimeout(() => {
|
|
|
|
this.getroomimage(reserev.sid, res.data.uid)
|
|
|
|
this.getSellerVersionFun(reserev.sid);
|
|
|
|
}, 0);
|
|
|
|
}).catch(res => {
|
|
|
|
console.log(res, '详情请求失败');
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 获取商家版本,不是超能版或者没有开通对应模块,不显示
|
|
|
|
getSellerVersionFun(sellerid) {
|
|
|
|
App.SellerVersion.GetSellerVersion({
|
|
|
|
sellerid
|
|
|
|
}).then((res) => {
|
|
|
|
let data = res.data;
|
|
|
|
console.log('版本列表', data);
|
|
|
|
if (data && data.length > 0) {
|
|
|
|
data.sort((a, b) => b.cdate * 1 - a.cdate * 1);
|
|
|
|
// 获取店铺当前版本 (cdate最大最后一个充入的 && 当前时间有效 && 当前版本)
|
|
|
|
let obj = data.find(item => item.vtype == 1 || item.vtype == 2 || item.vtype == 4);
|
|
|
|
console.log('当前版本', {
|
|
|
|
...obj
|
|
|
|
});
|
|
|
|
// 提前点餐功能:超能版 || 有提前点餐模块
|
|
|
|
const hasValueOrder = obj.vtype == '1' || data.some(item => item.vid == '6');
|
|
|
|
// 优惠券功能:超能版 || 高级版 || 有优惠券模块
|
|
|
|
const hasValueCertificate = obj.vtype == '1' || obj.vtype == '4' || data.some(item => item.vid == '8');
|
|
|
|
// 充值功能:超能版 || 有充值模块
|
|
|
|
const hasValueRecharge = obj.vtype == '1' || data.some(item => item.vid == '9');
|
|
|
|
// 播报功能:超能版 || 标准版 || 标准版首年 || 高级版
|
|
|
|
const hasValueBroadcast = obj.vtype == '1' || obj.vid == '4' || obj.vid == '13' || obj.vtype == '4';
|
|
|
|
this.setData({
|
|
|
|
hasValueOrder,
|
|
|
|
hasValueCertificate,
|
|
|
|
hasValueRecharge,
|
|
|
|
hasValueBroadcast,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 通过预订ID查收定金详情
|
|
|
|
getPaymentStatus() {
|
|
|
|
App.Reserve.GetReserveDepositByRid({
|
|
|
|
rid: this.data.options.id
|
|
|
|
}).then(res => {
|
|
|
|
if (res.ret == 200 && res.data && res.data.length > 0) {
|
|
|
|
let data = res.data[0];
|
|
|
|
let paymentStatus = data.trade_state == 'SUCCESS' ? '1' : '0';
|
|
|
|
let options = this.data.options
|
|
|
|
this.setData({
|
|
|
|
paymentId: data.id,
|
|
|
|
paymentStatus,
|
|
|
|
isPaymenBtn: options.isOrder != '1' && data.id && paymentStatus == '0' && options.hasSellerShare == '1' && options.isDeposit == '1',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 获取自定义图文内容
|
|
|
|
getText() {
|
|
|
|
App.Reserve.GetReserveImgText({
|
|
|
|
rid: this.data.options.id
|
|
|
|
}).then(res => {
|
|
|
|
if (res.ret == 200 && res.data) {
|
|
|
|
let data = res.data;
|
|
|
|
let content = util.determine(data.content)
|
|
|
|
console.log('自定义图文内容content', content);
|
|
|
|
this.setData({
|
|
|
|
reserveData: {
|
|
|
|
title: data.title || '',
|
|
|
|
content,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 点击支付定金
|
|
|
|
paymentFun() {
|
|
|
|
let that = this;
|
|
|
|
App.PayOnline.CombineTransactionsByDeposit({
|
|
|
|
id: this.data.paymentId,
|
|
|
|
openid: getApp().openid,
|
|
|
|
}).then(res => {
|
|
|
|
if (res.ret == 200) {
|
|
|
|
wx.requestPayment({
|
|
|
|
timeStamp: res.data.timeStamp + '',
|
|
|
|
nonceStr: res.data.nonceStr,
|
|
|
|
package: res.data.package,
|
|
|
|
signType: res.data.signType,
|
|
|
|
paySign: res.data.paySign,
|
|
|
|
success(ress) {
|
|
|
|
console.log('微信支付结果', ress);
|
|
|
|
if (ress.errMsg == 'requestPayment:ok') {
|
|
|
|
console.log('支付成功', ress);
|
|
|
|
that.setData({
|
|
|
|
paymentStatus: '1',
|
|
|
|
toastBool: true,
|
|
|
|
toastText: '支付成功'
|
|
|
|
})
|
|
|
|
that.hideToast();
|
|
|
|
return
|
|
|
|
}
|
|
|
|
console.log('支付失败1', ress);
|
|
|
|
that.setData({
|
|
|
|
toastBool: true,
|
|
|
|
toastText: '支付失败,请重新支付'
|
|
|
|
})
|
|
|
|
that.hideToast();
|
|
|
|
},
|
|
|
|
fail(ress) {
|
|
|
|
console.log('支付失败2', ress);
|
|
|
|
that.setData({
|
|
|
|
toastBool: true,
|
|
|
|
toastText: '支付失败,请重新支付'
|
|
|
|
})
|
|
|
|
that.hideToast();
|
|
|
|
},
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
wx.showToast({
|
|
|
|
title: res.msg,
|
|
|
|
icon: 'none',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 关闭支付失败或者成功弹框
|
|
|
|
hideToast() {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.setData({
|
|
|
|
toastBool: false
|
|
|
|
})
|
|
|
|
}, 1500)
|
|
|
|
},
|
|
|
|
// 客户经理获取基本信息
|
|
|
|
getstaffinfo(uid, sid) {
|
|
|
|
App.Activity.GetCustomerActivityBaseinfo({
|
|
|
|
sellerid: this.data.detail.seller.id,
|
|
|
|
uid
|
|
|
|
}).then((json) => {
|
|
|
|
if (json.ret == 200) {
|
|
|
|
console.log('经理信息staffinfo', json.data)
|
|
|
|
this.setData({
|
|
|
|
staffinfo: json.data
|
|
|
|
})
|
|
|
|
this.getSellerTemplateConfFun(sid);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 提前点餐
|
|
|
|
cookbook() {
|
|
|
|
if (this.data.detail.order && this.data.detail.order.cookbooklist.length > 0) {
|
|
|
|
let data = {
|
|
|
|
rid: this.id,
|
|
|
|
oid: this.data.detail.order.id,
|
|
|
|
sellerName: this.data.seller.name,
|
|
|
|
sid: this.data.seller.sid,
|
|
|
|
identity: '1',
|
|
|
|
hasSuccess: '1',
|
|
|
|
}
|
|
|
|
this.closepublicModal()
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `/pack-cookbook/pages/success_new?hasSuccess=${data.hasSuccess}&identity=${data.identity}&oid=${data.oid}&rid=${data.rid}&sellerName=${data.sellerName}&sid=${data.sid}`,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
App.Advance.CreateOrder({
|
|
|
|
rid: this.id,
|
|
|
|
openid: getApp().openid,
|
|
|
|
}).then(res => {
|
|
|
|
if (res.ret != 200) {
|
|
|
|
return util.toast(res.msg, 'none')
|
|
|
|
}
|
|
|
|
wx.navigateTo({
|
|
|
|
url: util.http_build_query({
|
|
|
|
rid: this.id,
|
|
|
|
oid: res.data.id,
|
|
|
|
sid: res.data.sellerid,
|
|
|
|
sellerName: this.data.seller.name,
|
|
|
|
identity: '1',
|
|
|
|
}, '/pack-cookbook/pages/index_new')
|
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 生成海报
|
|
|
|
painterBtn(img, sellerName, date, time) {
|
|
|
|
img = img.replace(/^http:/, "https:");
|
|
|
|
this.setData({
|
|
|
|
wxml: canvas({
|
|
|
|
imgUrl: img || 'https://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png',
|
|
|
|
sellerName,
|
|
|
|
date,
|
|
|
|
time,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
onImgOK(e) {
|
|
|
|
this.setData({
|
|
|
|
imgSrc: e.detail.path
|
|
|
|
})
|
|
|
|
console.log('海报生成成功', this.data.imgSrc);
|
|
|
|
},
|
|
|
|
// 分享
|
|
|
|
sharesetting() {
|
|
|
|
wx.reportMonitor('1017', 1)
|
|
|
|
this.closeModal()
|
|
|
|
if (this.data.options.isOrder == '1' && this.data.detail.status != '4') {
|
|
|
|
return {
|
|
|
|
title: '推荐' + this.data.seller.name + ',点击可查看详情并导航到店',
|
|
|
|
path: util.http_build_query({
|
|
|
|
id: this.data.detail.seller.id
|
|
|
|
}, '/pages/reserve/shopHome'),
|
|
|
|
imageUrl: this.data.detail.seller.seller_image || 'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png',
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
let parmdata = {
|
|
|
|
id: this.id,
|
|
|
|
fromid: getApp().openid,
|
|
|
|
hasInvitation: 1,
|
|
|
|
tplid: this.data.options.tplid
|
|
|
|
}
|
|
|
|
if (this.data.options.uid) {
|
|
|
|
parmdata.uid = this.data.options.uid;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
title: '我已订好' + this.data.seller.name + ',点击可查看详情并导航到店',
|
|
|
|
path: util.http_build_query(parmdata, '/pages/customer/detail_owner_invitation_new'),
|
|
|
|
imageUrl: this.data.imgSrc || 'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 修改detail数据
|
|
|
|
formatDatail(details, dateSmart) {
|
|
|
|
details.rdateStr = dateSmart;
|
|
|
|
details.tableFirst = details.tables[0].name;
|
|
|
|
if (details.tables.length > 1) {
|
|
|
|
details.tableSubInfo = '等' + (details.tables.length) + '个' +
|
|
|
|
(details.tables[0].tid == 2 ? '包间' : '');
|
|
|
|
}
|
|
|
|
details.rname = details.rname.trim()
|
|
|
|
if (details.rname && details.sex != 3) {
|
|
|
|
details.rnameStr = details.rname + (details.sex == 1 ? '先生' : details.sex == 2 ? '女士' : details.sex == 4 ? '贵宾' : '')
|
|
|
|
} else if (!details.rname && details.sex == 4) {
|
|
|
|
details.rnameStr = '贵宾'
|
|
|
|
} else {
|
|
|
|
details.rnameStr = details.rname
|
|
|
|
}
|
|
|
|
details.eatStr = '邀请您共进晚餐';
|
|
|
|
let hi = util.unixtoTime(details.ddate, 'HHII');
|
|
|
|
if (hi < '10:00') {
|
|
|
|
details.eatStr = '邀请您共进早餐';
|
|
|
|
} else if (hi < '15:00') {
|
|
|
|
details.eatStr = '邀请您共进午餐';
|
|
|
|
}
|
|
|
|
return details;
|
|
|
|
},
|
|
|
|
// 获取商家设置营销信息
|
|
|
|
getSellerTemplateConfFun(sid) {
|
|
|
|
App.Seller.GetSellerTemplateConf({
|
|
|
|
sid
|
|
|
|
}).then(res => {
|
|
|
|
let data = res.data
|
|
|
|
let couponList = []
|
|
|
|
let StyleType, 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);
|
|
|
|
signboard = util.determine(data.signboard);
|
|
|
|
store = util.determine(data.store);
|
|
|
|
home = util.determine(data.home);
|
|
|
|
StyleType = data.type;
|
|
|
|
swich_phone = reserve && reserve.swich_phone ? reserve.swich_phone : '';
|
|
|
|
if (store) store.content = (store.is_introduce_all == '1' && store.content) ? util.determine(store.content) : '';
|
|
|
|
if (chef) chef.content = (chef.is_introduce_all == '1' && chef.content) ? util.determine(chef.content) : '';
|
|
|
|
if (signboard) signboard.content = (signboard.is_introduce_all == '1' && signboard.content) ? util.determine(signboard.content) : '';
|
|
|
|
if (reserve) reserve.content = (reserve.is_introduce_all == '1' && reserve.content) ? util.determine(reserve.content) : '';
|
|
|
|
if (home) home.image = (home && home.image && (!home.id_first_image || home.id_first_image != '0')) ? home.image : '';
|
|
|
|
if (marketing) {
|
|
|
|
marketing.logo = (marketing.logo && (!marketing.is_logo || marketing.is_logo != '0')) ? marketing.logo : '';
|
|
|
|
is_comments = marketing.is_comments ? marketing.is_comments : '';
|
|
|
|
coupon = marketing.coupon_data ? util.determine(marketing.coupon_data) : '';
|
|
|
|
let info = marketing.coupon_data_comments ? util.determine(marketing.coupon_data_comments) : '';
|
|
|
|
let couponDataId = info && info.length > 0 ? info[0].id : {}
|
|
|
|
// 根据券ID获取评价赠送的券详情
|
|
|
|
if (couponDataId) this.getEvaluateFun(couponDataId)
|
|
|
|
}
|
|
|
|
// 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
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 根据券ID获取券详情
|
|
|
|
this.getActivityByIdFun(couponList, couponList.length)
|
|
|
|
// 根据充值ID获取充值详情
|
|
|
|
if (marketing && marketing.is_recharge && marketing.is_recharge == '1' && marketing.recharge_data) {
|
|
|
|
this.getRechargeDetail(marketing.recharge_data.id)
|
|
|
|
}
|
|
|
|
if (store && store.images && store.images.length > 0) store.images = util.determine(store.images);
|
|
|
|
if (reserve && reserve.park_info_images && reserve.park_info_images.length > 0) reserve.park_info_images = util.determine(reserve.park_info_images);
|
|
|
|
if (signboard && signboard.images && signboard.images.length > 0) signboard.images = util.determine(signboard.images);
|
|
|
|
if (reserve) reserve = this.processInfo(reserve, '1')
|
|
|
|
if (store) store = this.processInfo(store, '2')
|
|
|
|
if (signboard) signboard = this.processInfo(signboard, '3')
|
|
|
|
if (chef) chef = this.processInfo(chef, '4')
|
|
|
|
let solt = this.data.detail.ddate_solt;
|
|
|
|
let lunchDis = this.data.seller.daily;
|
|
|
|
let timeList = []
|
|
|
|
var morningStr = lunchDis.morning.split("-");
|
|
|
|
var morningArr = lunchDis.morning ? this.computeHour(morningStr[0], morningStr[1], 30) : [];
|
|
|
|
var noonStr = lunchDis.noon.split("-");
|
|
|
|
var noonArr = lunchDis.noon ? this.computeHour(noonStr[0], noonStr[1], 30) : [];
|
|
|
|
var nightStr = lunchDis.night.split("-");
|
|
|
|
var nightArr = lunchDis.night ? this.computeHour(nightStr[0], nightStr[1], 30) : [];
|
|
|
|
timeList = solt == '1' ? morningArr : solt == '2' ? noonArr : solt == '3' ? nightArr : []
|
|
|
|
let bookType = this.data.bookType;
|
|
|
|
let urlsArr = this.data.urlsArr
|
|
|
|
marketing.wecomle = (reserve && reserve.swich_welcome == '1' && marketing && marketing.wecomle) ? marketing.wecomle : ''
|
|
|
|
if (bookType == '1' && home && home.image) urlsArr.push(home.image)
|
|
|
|
if (bookType == '1' && marketing && marketing.logo) urlsArr.push(marketing.logo)
|
|
|
|
let obj = {
|
|
|
|
chef,
|
|
|
|
marketing,
|
|
|
|
home,
|
|
|
|
reserve,
|
|
|
|
signboard,
|
|
|
|
store,
|
|
|
|
swich_phone,
|
|
|
|
StyleType,
|
|
|
|
lite_style: data.lite_style,
|
|
|
|
timeList,
|
|
|
|
is_comments,
|
|
|
|
isMoreBtn: marketing && marketing.is_online_book == '1' && this.data.options.onlineReserve == '1',
|
|
|
|
isShareItem: this.data.options.isOrder != '1' && marketing && marketing.is_transpond == '1',
|
|
|
|
isComments: is_comments == '1' && marketing && marketing.is_comments_coupon == '1',
|
|
|
|
colors: bookType == '1' ? '#17220C' : bookType == '2' ? '#B9A99A' : '',
|
|
|
|
urlsArr
|
|
|
|
}
|
|
|
|
console.log('获取数据GetSellerTemplateConf--------------------', {
|
|
|
|
...obj
|
|
|
|
});
|
|
|
|
this.setData({
|
|
|
|
...obj
|
|
|
|
})
|
|
|
|
// 开启语音播报
|
|
|
|
if (reserve && reserve.swich_voice == '1') {
|
|
|
|
this.setData({
|
|
|
|
isPlay: '1',
|
|
|
|
isVoice: '1',
|
|
|
|
})
|
|
|
|
this.textToSpeechFun(reserve.voice_info)
|
|
|
|
}
|
|
|
|
// 获取转发客人卡片设置
|
|
|
|
let detailInfo = this.data.detail;
|
|
|
|
if (data.lite_style == '0') {
|
|
|
|
this.setData({
|
|
|
|
imgSrc: detailInfo.seller.seller_image
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
let d = detailInfo.ddate_solt;
|
|
|
|
let time1 = util.unixtoTime(detailInfo.ddate, '周WW') + ' ' + (d == '1' ? '早上' : d == '2' ? '中午' : d == '3' ? '晚上' : '');
|
|
|
|
let time2;
|
|
|
|
if (this.data.temp_ddate) {
|
|
|
|
time2 = util.unixtoTime(detailInfo.ddate, '周WW') + this.data.temp_ddate
|
|
|
|
} else {
|
|
|
|
time2 = util.unixtoTime(detailInfo.ddate, '周WW HH:II')
|
|
|
|
}
|
|
|
|
let time3 = util.unixtoTime(detailInfo.ddate, '周WW') + ' ' + (d == '1' ? '早餐' : d == '2' ? '午餐' : d == '3' ? '晚餐' : '');
|
|
|
|
let time = data.lite_style == '1' ? time1 : data.lite_style == '2' ? time2 : data.lite_style == '3' ? time3 : '';
|
|
|
|
this.painterBtn(
|
|
|
|
detailInfo.seller.seller_image,
|
|
|
|
detailInfo.seller.sellername,
|
|
|
|
util.unixtoTime(detailInfo.ddate, 'MM月DD日'),
|
|
|
|
time
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}).catch(res => {
|
|
|
|
console.log('GetSellerTemplateConf请求失败');
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 点击商家有礼
|
|
|
|
gotoSellerGift() {
|
|
|
|
let url = util.http_build_query({
|
|
|
|
id: this.data.detail.id,
|
|
|
|
}, '/pages/reserve/sellerGift')
|
|
|
|
wx.navigateTo({
|
|
|
|
url
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 再次预订
|
|
|
|
secondbook() {
|
|
|
|
wx.reportMonitor('1013', 1)
|
|
|
|
wx.redirectTo({
|
|
|
|
url: '/pages/reserve/shopHome?id=' + this.data.detail.seller.id
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 文字转语音的方法
|
|
|
|
textToSpeechFun(voice_info) {
|
|
|
|
console.log('voice_info', voice_info);
|
|
|
|
let that = this;
|
|
|
|
let data = this.data;
|
|
|
|
data.detail.rname = data.detail.rname.trim()
|
|
|
|
let str = data.detail.sex == 1 ? '先生' : data.detail.sex == 2 ? '女士' : data.detail.sex == 4 ? '贵宾' : '';
|
|
|
|
let charArray = data.seller.deskStr.split('');
|
|
|
|
let modifiedArray = charArray.map(char => char + ' ');
|
|
|
|
let resultString = modifiedArray.join('').slice(0, -1);
|
|
|
|
const replacements = {
|
|
|
|
"{年月日}": data.seller.yearMonthDay,
|
|
|
|
"{月日}": data.seller.yearMonth,
|
|
|
|
"{餐段}": data.seller.soltName,
|
|
|
|
"{就餐时间}": data.seller.dateStr + data.seller.dateStrDivide,
|
|
|
|
"{包间名}": resultString,
|
|
|
|
"{区域名+包间名}": data.seller.tablesText,
|
|
|
|
"{经理名字}": data.staffinfo.name,
|
|
|
|
"{客人姓名}": data.detail.rname ? (data.detail.rname + str) : str == '贵宾' ? '贵宾' : '',
|
|
|
|
"{预订日期}": data.seller.yearMonthDay,
|
|
|
|
"{桌位}": resultString,
|
|
|
|
};
|
|
|
|
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 = '赠送' + recharge_list.price + '元余额';
|
|
|
|
if (recharge_list.is_score == '1') scoreInfo = '赠送' + recharge_list.score + '积分';
|
|
|
|
if (recharge_list.is_coupons == '1' && recharge_list.coupons_names.length > 0) certificate = recharge_list.coupons_names.join('、');
|
|
|
|
let recharge_data = (this.data.dataStr < detail.etime * 1 && detail.is_open == '1') ? detail : ''
|
|
|
|
console.log('邀请函--------------充值', recharge_data);
|
|
|
|
let entry = this.data.titleList
|
|
|
|
if (this.data.hasValueRecharge && this.data.marketing.is_recharge == '1' && recharge_data) {
|
|
|
|
entry.push({
|
|
|
|
id: 2,
|
|
|
|
title: '会员充值优惠'
|
|
|
|
})
|
|
|
|
if (entry.length > 0) {
|
|
|
|
entry.sort((a, b) => a.id - b.id);
|
|
|
|
}
|
|
|
|
recharge_data.timeStr = util.unixtoTime(recharge_data.stime, 'YYYY-MM-DD') + ' - ' + util.unixtoTime(recharge_data.etime, 'YYYY-MM-DD')
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
titleList: entry,
|
|
|
|
activeTitle: entry.length > 0 ? entry[0].id : '',
|
|
|
|
recharge_data,
|
|
|
|
scoreInfo,
|
|
|
|
priceInfo,
|
|
|
|
certificate
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 选择标题
|
|
|
|
checkTitleFun(e) {
|
|
|
|
console.log('e.currentTargete.currentTarget', e.currentTarget);
|
|
|
|
let activeTitle = e.currentTarget.dataset['type'];
|
|
|
|
this.setData({
|
|
|
|
activeTitle
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 获取评价赠送的券最新详情
|
|
|
|
getEvaluateFun(id) {
|
|
|
|
App.Activity.GetActivityById({
|
|
|
|
id
|
|
|
|
}).then(res => {
|
|
|
|
if (res.data.length > 0) {
|
|
|
|
let couponData = res.data[0]
|
|
|
|
couponData.use = couponData.use ? util.determine(couponData.use) : '';
|
|
|
|
couponData.exp_date = couponData.exp_date ? util.determine(couponData.exp_date) : '';
|
|
|
|
if ((couponData.use && (!couponData.use.is_cash || couponData.use.is_cash == '1'))) {
|
|
|
|
let cash = couponData.use.cash * 1;
|
|
|
|
let price = couponData.price * 1;
|
|
|
|
couponData.discount = cash != 0 ? ((price / cash) * 10).toFixed(1) : '';
|
|
|
|
}
|
|
|
|
// showCoupon 代表赠送的券没过有效期 && 是开启状态
|
|
|
|
couponData.showCoupon = (this.data.dataStr < (couponData.etime * 1) && couponData.is_open == '1') ? '1' : '0';
|
|
|
|
console.log('邀请函--------------------评价赠送的优惠券', couponData);
|
|
|
|
let entry = this.data.titleList
|
|
|
|
if (!this.data.is_user_comments && this.data.isComments == '1' && couponData.showCoupon == '1') {
|
|
|
|
entry.push({
|
|
|
|
id: 3,
|
|
|
|
title: '意见反馈有礼'
|
|
|
|
})
|
|
|
|
if (entry.length > 0) {
|
|
|
|
entry.sort((a, b) => a.id - b.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
couponData: res.data[0],
|
|
|
|
titleList: entry,
|
|
|
|
activeTitle: entry.length > 0 ? entry[0].id : '',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 根据券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) : '';
|
|
|
|
}
|
|
|
|
detail.stimeStr = util.unixtoTime(detail.stime, 'YYYY-MM-DD HH:II')
|
|
|
|
detail.etimeStr = util.unixtoTime(detail.etime, 'YYYY-MM-DD HH:II')
|
|
|
|
coupon_dataList.push(detail);
|
|
|
|
if (length === coupon_dataList.length) {
|
|
|
|
coupon_dataList = coupon_dataList.filter(item => {
|
|
|
|
return this.data.dataStr < (item.etime * 1) && item.is_open == '1'
|
|
|
|
})
|
|
|
|
let entry = this.data.titleList
|
|
|
|
if (this.data.hasValueCertificate && this.data.marketing.is_coupon == '1' && coupon_dataList.length > 0) {
|
|
|
|
entry.push({
|
|
|
|
id: 1,
|
|
|
|
title: '专属优惠券'
|
|
|
|
})
|
|
|
|
if (entry.length > 0) {
|
|
|
|
entry.sort((a, b) => a.id - b.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log('邀请函--------------------优惠券', coupon_dataList);
|
|
|
|
this.setData({
|
|
|
|
coupon_dataList,
|
|
|
|
titleList: entry,
|
|
|
|
activeTitle: entry.length > 0 ? entry[0].id : '',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide() {
|
|
|
|
clearInterval(this.timers)
|
|
|
|
if (this.audioCtx) {
|
|
|
|
this.audioCtx.destroy(); // 释放音频资源
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload() {
|
|
|
|
clearInterval(this.timers)
|
|
|
|
if (this.audioCtx) {
|
|
|
|
this.audioCtx.destroy(); // 释放音频资源
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 设置虚拟到店时间
|
|
|
|
bindPickerChange: function (e) {
|
|
|
|
let index = e.detail.value
|
|
|
|
let temp_ddate = this.data.timeList[index]
|
|
|
|
this.setData({
|
|
|
|
temp_ddate
|
|
|
|
})
|
|
|
|
let detailInfo = this.data.detail;
|
|
|
|
const reserveDate = new Date(detailInfo.ddate * 1000);
|
|
|
|
let reserveTime =
|
|
|
|
reserveDate.getFullYear() +
|
|
|
|
"-" +
|
|
|
|
(reserveDate.getMonth() + 1) +
|
|
|
|
"-" +
|
|
|
|
reserveDate.getDate();
|
|
|
|
let times = this.getNewDate(reserveTime + " " + temp_ddate).getTime() / 1000
|
|
|
|
App.Reserve.SetReserveTempDdate({
|
|
|
|
rid: this.id,
|
|
|
|
temp_ddate: times,
|
|
|
|
}).then(res => {
|
|
|
|
if (res.ret == 200) {
|
|
|
|
if (this.data.lite_style == '2') {
|
|
|
|
let time = (util.unixtoTime(detailInfo.ddate, '周WW') + temp_ddate) || (util.unixtoTime(detailInfo.ddate, '周WW') + this.data.timeList[index])
|
|
|
|
this.painterBtn(
|
|
|
|
detailInfo.seller.seller_image,
|
|
|
|
detailInfo.seller.sellername,
|
|
|
|
util.unixtoTime(detailInfo.ddate, 'MM月DD日'),
|
|
|
|
time
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// ios 部分机型不兼容new Date() 转换字符串
|
|
|
|
getNewDate(data) {
|
|
|
|
if (typeof data === 'string') {
|
|
|
|
let arr = data.split(/[- : \/]/)
|
|
|
|
if (arr[1] !== undefined || arr[1] !== null) {
|
|
|
|
arr[1] = arr[1] - 1
|
|
|
|
}
|
|
|
|
return new Date(...arr)
|
|
|
|
}
|
|
|
|
return new Date(data || new Date())
|
|
|
|
},
|
|
|
|
//根据起始时间(获取时间时间段)
|
|
|
|
computeHour(time1, time2, interval) {
|
|
|
|
//time1 开始时间 time2结束时间 interval间隔时长
|
|
|
|
function getTimeList(time1, time2, interval) {
|
|
|
|
var timeList = [];
|
|
|
|
time1 = time1.split(":");
|
|
|
|
time2 = time2.split(":");
|
|
|
|
time1 = new Date(0, 0, 0, time1[0], time1[1], 0);
|
|
|
|
time2 = new Date(0, 0, 0, time2[0], time2[1], 0);
|
|
|
|
interval = interval * 60 * 1000;
|
|
|
|
while (time1 <= time2) {
|
|
|
|
timeList.push(time1.format("hh:mm"));
|
|
|
|
time1 = new Date(time1.getTime() + interval);
|
|
|
|
}
|
|
|
|
return timeList;
|
|
|
|
}
|
|
|
|
Date.prototype.format = function (format) {
|
|
|
|
var date = {
|
|
|
|
"M+": this.getMonth() + 1,
|
|
|
|
"d+": this.getDate(),
|
|
|
|
"h+": this.getHours(),
|
|
|
|
"m+": this.getMinutes(),
|
|
|
|
"s+": this.getSeconds(),
|
|
|
|
"q+": Math.floor((this.getMonth() + 3) / 3),
|
|
|
|
S: this.getMilliseconds(),
|
|
|
|
};
|
|
|
|
if (/(y+)/.test(format))
|
|
|
|
format = format.replace(
|
|
|
|
RegExp.$1,
|
|
|
|
(this.getFullYear() + "").substr(4 - RegExp.$1.length)
|
|
|
|
);
|
|
|
|
for (var k in date)
|
|
|
|
if (new RegExp("(" + k + ")").test(format))
|
|
|
|
format = format.replace(
|
|
|
|
RegExp.$1,
|
|
|
|
RegExp.$1.length == 1 ?
|
|
|
|
date[k] :
|
|
|
|
("00" + date[k]).substr(("" + date[k]).length)
|
|
|
|
);
|
|
|
|
return format;
|
|
|
|
};
|
|
|
|
return getTimeList(time1, time2, interval);
|
|
|
|
},
|
|
|
|
// 模块文字、轮播图数据重组(停车、餐厅介绍、菜品、主厨)
|
|
|
|
processInfo(intel, type) {
|
|
|
|
let imgs = [];
|
|
|
|
intel.textInfo = '';
|
|
|
|
intel.imgsInfo = [];
|
|
|
|
intel.videoImgsInfo = [];
|
|
|
|
if (type == '1') {
|
|
|
|
if (intel.swich_park == '1' && (intel.park_info || intel.park_info_images)) {
|
|
|
|
intel.textInfo = intel.park_info;
|
|
|
|
imgs = intel.park_info_images
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (type == '2') {
|
|
|
|
imgs = intel.images && intel.images.length > 0 && (!intel.is_images || intel.is_images !== '0') ? intel.images : [];
|
|
|
|
intel.textInfo = (intel.introduce && (!intel.is_introduce || intel.is_introduce !== '0')) ? intel.introduce : '';
|
|
|
|
}
|
|
|
|
if (type == '3') {
|
|
|
|
imgs = intel.images || []
|
|
|
|
intel.textInfo = '';
|
|
|
|
}
|
|
|
|
if (type == '4') {
|
|
|
|
imgs = ((!intel.is_images || intel.is_images != '0') && intel.image) ? intel.image : []
|
|
|
|
intel.textInfo = (intel.introduce && (!intel.is_introduce || intel.is_introduce != '0')) ? intel.introduce : '';
|
|
|
|
}
|
|
|
|
intel.imgsInfo = imgs;
|
|
|
|
intel.videoImgsInfo = imgs.map(url => ({
|
|
|
|
type: "1",
|
|
|
|
content: url,
|
|
|
|
}));
|
|
|
|
if (intel.content && intel.content.length > 0 && intel.is_introduce_all == '1') {
|
|
|
|
intel.textInfo = intel.content.filter(item => item.type === "2").map(item => item.content).join('\n');
|
|
|
|
intel.imgsInfo = intel.content.filter(item => item.type === "1" && item.content).map(item => item.content);
|
|
|
|
intel.videoImgsInfo = intel.content.filter(item => ((item.type === "1" || item.type === "3") && item.content));
|
|
|
|
}
|
|
|
|
return intel
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
},
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|