|
|
|
// pages/book/b_sms.js
|
|
|
|
var util = require('../../utils/util.js')
|
|
|
|
import App from '../../utils/api';
|
|
|
|
const {regeneratorRuntime} = global
|
|
|
|
const tpls=[
|
|
|
|
'尊敬的贵宾,您好!${seller_name}恭候您的光临!\n${date}为您预定在${region_room_name}\n人数:${reserve_pnum}\n地址:${seller_addr}\n电话:${seller_phone}\n客户经理${cusman} 电话${cusman_phone},期待您的光临!'
|
|
|
|
];
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
tplsIndex:0,
|
|
|
|
data: {
|
|
|
|
bookInfo:{},
|
|
|
|
tplMsg:''
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
this.getDetail(options.id);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
bookInfo:null,
|
|
|
|
getDetail(id){
|
|
|
|
App.Reserve.Detail({rid:id,openid:''}).then(res=>{
|
|
|
|
res.data.rdateStr=util.unixtoTime(res.data.rdate,"MM月DD日 HH:II")
|
|
|
|
this.bookInfo=res.data;
|
|
|
|
this.setData({
|
|
|
|
bookInfo:res.data,
|
|
|
|
tplMsg:this.getTplMsg()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
smsData:{},
|
|
|
|
getTplMsg(){
|
|
|
|
let region_room_name=this.bookInfo.tables[0].rname+' '+this.bookInfo.tables[0].name;
|
|
|
|
if(this.bookInfo.tables.length>1){
|
|
|
|
region_room_name+='等'+this.bookInfo.tables.length+'桌'
|
|
|
|
}
|
|
|
|
let smsData={
|
|
|
|
seller_name:this.bookInfo.seller.sellername.substr(0,20),
|
|
|
|
date:this.bookInfo.rdateStr,
|
|
|
|
region_room_name:region_room_name.substr(0,20),
|
|
|
|
reserve_pnum:this.bookInfo.pnum_str+'人',
|
|
|
|
seller_addr:this.bookInfo.seller.map_address.substr(0,20),
|
|
|
|
seller_phone:this.bookInfo.seller.phone.substr(0,20),
|
|
|
|
cusman:(this.bookInfo.cusman||this.bookInfo.seller.sellername).substr(0,20),
|
|
|
|
cusman_phone:(this.bookInfo.cusman_phone||this.bookInfo.seller.phone).substr(0,20),
|
|
|
|
code:this.bookInfo.code,
|
|
|
|
}
|
|
|
|
let tpl=tpls[this.tplsIndex];
|
|
|
|
this.smsData=smsData;
|
|
|
|
tpl=tpl.replace(/\${([^}]+)}/ig,function($0,$1){
|
|
|
|
console.log($0,$1);
|
|
|
|
return smsData[$1];
|
|
|
|
})
|
|
|
|
return tpl
|
|
|
|
},
|
|
|
|
sendsms(){
|
|
|
|
App.SendSMS.Message({
|
|
|
|
phone:15877556369,/*this.bookInfo.phone,*/
|
|
|
|
sign_name:'订个座儿',
|
|
|
|
template_code:'SMS_145597605',
|
|
|
|
template_param:JSON.stringify([this.smsData])
|
|
|
|
}).then(()=>{
|
|
|
|
util.toast('短信已发送');
|
|
|
|
this.setData({
|
|
|
|
hideSendsms:true,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
copysms(){
|
|
|
|
wx.setClipboardData({
|
|
|
|
data:this.data.tplMsg
|
|
|
|
})
|
|
|
|
},
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|