|
@@ -3,6 +3,7 @@ var util = require('../../utils/util.js') |
|
@@ -3,6 +3,7 @@ var util = require('../../utils/util.js') |
|
3
|
import App from '../../utils/api';
|
3
|
import App from '../../utils/api';
|
|
4
|
import bcm from '../../utils/bookCommon';
|
4
|
import bcm from '../../utils/bookCommon';
|
|
5
|
const {regeneratorRuntime} = global
|
5
|
const {regeneratorRuntime} = global
|
|
|
|
6
|
+import ST from './b_sms_tpls';
|
|
6
|
const tpls = {
|
7
|
const tpls = {
|
|
7
|
SMS_154587043: '${guest},您好!${seller_name}已为您预订${date}的桌位:${region_room_name};地址:${seller_addr},电话:${seller_phone}\n客户经理${cusman},期待您的光临!',
|
8
|
SMS_154587043: '${guest},您好!${seller_name}已为您预订${date}的桌位:${region_room_name};地址:${seller_addr},电话:${seller_phone}\n客户经理${cusman},期待您的光临!',
|
|
8
|
SMS_162733710: '尊敬的贵宾,您好!${reserve_date}的用餐,为您安排在${seller_name_addr_room}房间,${cusman}期待您的光临,预祝就餐愉快!',
|
9
|
SMS_162733710: '尊敬的贵宾,您好!${reserve_date}的用餐,为您安排在${seller_name_addr_room}房间,${cusman}期待您的光临,预祝就餐愉快!',
|
|
@@ -63,112 +64,19 @@ Page({ |
|
@@ -63,112 +64,19 @@ Page({ |
|
63
|
bookInfo: null,
|
64
|
bookInfo: null,
|
|
64
|
async getDetail(id){
|
65
|
async getDetail(id){
|
|
65
|
let res=await App.Reserve.Detail({rid: id, openid: ''});
|
66
|
let res=await App.Reserve.Detail({rid: id, openid: ''});
|
|
66
|
- res.data.rdateStr = util.unixtoTime(res.data.ddate, "MM月DD日 HH:II")
|
|
|
|
67
|
- this.bookInfo = res.data;
|
|
|
|
68
|
- let tplMsg= await this.getTplMsg()
|
67
|
+ this.bookInfo=res.data
|
|
|
|
68
|
+ let tplMsg=await ST.getTplMsg(res.data,this.sc.setting.template_code,this.sc)
|
|
69
|
this.setData({
|
69
|
this.setData({
|
|
70
|
bookInfo: res.data,
|
70
|
bookInfo: res.data,
|
|
71
|
tplMsg: tplMsg
|
71
|
tplMsg: tplMsg
|
|
72
|
})
|
72
|
})
|
|
73
|
},
|
73
|
},
|
|
74
|
- getTableName(tables){
|
|
|
|
75
|
- let bao = [], san = [];
|
|
|
|
76
|
- tables.forEach(t => {
|
|
|
|
77
|
- if (t.tid == 2) {
|
|
|
|
78
|
- bao.push(t.name);
|
|
|
|
79
|
- } else {
|
|
|
|
80
|
- san.push(t.name);
|
|
|
|
81
|
- }
|
|
|
|
82
|
- })
|
|
|
|
83
|
- let str = '';
|
|
|
|
84
|
- if (bao.length > 0) {
|
|
|
|
85
|
- str = '包厢(' + bao.join('、') + ')';
|
|
|
|
86
|
- }
|
|
|
|
87
|
- if (san.length > 0) {
|
|
|
|
88
|
- str += san.join('、');
|
|
|
|
89
|
- }
|
|
|
|
90
|
- str = str.substr(0, 20);
|
|
|
|
91
|
- if (str.indexOf('(') > -1 && str.indexOf(')') < 0) {
|
|
|
|
92
|
- str = str.substr(0, 19) + ')';
|
|
|
|
93
|
- }
|
|
|
|
94
|
- return str;
|
|
|
|
95
|
- },
|
|
|
|
96
|
- getTableNameOne(tables){
|
|
|
|
97
|
- let bao = [];
|
|
|
|
98
|
- tables.forEach(t => {
|
|
|
|
99
|
- bao.push(t.name);
|
|
|
|
100
|
- })
|
|
|
|
101
|
- return bao.join('、');
|
|
|
|
102
|
- },
|
|
|
|
103
|
- getTableNameShort(tables){//短桌位
|
|
|
|
104
|
- let str=tables[0].name;
|
|
|
|
105
|
- if(tables.length>1){
|
|
|
|
106
|
- str+='等'+tables.length+'个';
|
|
|
|
107
|
- }
|
|
|
|
108
|
- return str;
|
|
|
|
109
|
- },
|
|
|
|
110
|
- smsData: {},
|
|
|
|
111
|
- async getTplMsg(){
|
|
|
|
112
|
- let smsData = {}
|
|
|
|
113
|
- let txa=['早上','中午','晚上']
|
|
|
|
114
|
- let tx=await bcm.getTimeSpaceIndexData(this.bookInfo.rdate);
|
|
|
|
115
|
- switch (this.tplsIndex) {
|
|
|
|
116
|
- //尊敬的贵宾,您好!(4月6日)(中午)的用餐,为您安排在(好又多复兴路店)(202)房间,(王丽娜)期待您的光临,预祝就餐愉快!
|
|
|
|
117
|
- case 'SMS_162733710':
|
|
|
|
118
|
- smsData = {
|
|
|
|
119
|
- reserve_date: util.unixtoTime(this.bookInfo.rdate,'MM月DD日')
|
|
|
|
120
|
- .replace(/0(\d)/g,function($0,$1){
|
|
|
|
121
|
- return $1;
|
|
|
|
122
|
- })+' '+txa[tx.timeIndex],
|
|
|
|
123
|
- seller_name_addr_room: this.sc.seller.selleralias+this.getTableNameShort(this.bookInfo.tables).substr(0, 20),
|
|
|
|
124
|
- cusman: (this.bookInfo.cusman || this.bookInfo.seller.sellername).substr(0, 20),
|
|
|
|
125
|
- }
|
|
|
|
126
|
- break;
|
|
|
|
127
|
- case 'SMS_163050401':
|
|
|
|
128
|
- smsData = {
|
|
|
|
129
|
- seller_name: this.bookInfo.seller.sellername.substr(0, 20),
|
|
|
|
130
|
- date: this.bookInfo.rdateStr.replace('日','日'+txa[tx.timeIndex]),
|
|
|
|
131
|
- region_room_name: this.getTableNameOne(this.bookInfo.tables).substr(0, 20),
|
|
|
|
132
|
- seller_addr: (this.bookInfo.seller.real_address || this.bookInfo.seller.map_address).substr(0, 20),
|
|
|
|
133
|
- seller_phone: this.bookInfo.seller.phone.substr(0, 20),
|
|
|
|
134
|
- cusman: (this.bookInfo.cusman||'').substr(0, 20),
|
|
|
|
135
|
- }
|
|
|
|
136
|
- break;
|
|
|
|
137
|
- default:
|
|
|
|
138
|
- let guest = '';
|
|
|
|
139
|
- if (this.bookInfo.sex == 3) {
|
|
|
|
140
|
- guest = '贵宾'
|
|
|
|
141
|
- } else {
|
|
|
|
142
|
- guest = this.bookInfo.rname.substr(0, 1) + (this.bookInfo.sex == 1 ? '先生' : '女士')
|
|
|
|
143
|
- }
|
|
|
|
144
|
- smsData = {
|
|
|
|
145
|
- guest: guest,
|
|
|
|
146
|
- seller_name: this.bookInfo.seller.sellername.substr(0, 20),
|
|
|
|
147
|
- date: this.bookInfo.rdateStr,
|
|
|
|
148
|
- region_room_name: this.getTableName(this.bookInfo.tables),
|
|
|
|
149
|
- reserve_pnum: (this.bookInfo.pnum || this.bookInfo.pnum_str) + '人',
|
|
|
|
150
|
- seller_addr: (this.bookInfo.seller.real_address || this.bookInfo.seller.map_address).substr(0, 20),
|
|
|
|
151
|
- seller_phone: this.bookInfo.seller.phone.substr(0, 20),
|
|
|
|
152
|
- cusman: (this.bookInfo.cusman || this.bookInfo.seller.sellername).substr(0, 20),
|
|
|
|
153
|
- cusman_phone: (this.bookInfo.cusman_phone || this.bookInfo.seller.phone).substr(0, 20),
|
|
|
|
154
|
- code: this.bookInfo.code,
|
|
|
|
155
|
- }
|
|
|
|
156
|
- break;
|
|
|
|
157
|
- }
|
|
|
|
158
|
- let tpl = tpls[this.tplsIndex];
|
|
|
|
159
|
- this.smsData = smsData;
|
|
|
|
160
|
- tpl = tpl.replace(/\${([^}]+)}/ig, function ($0, $1) {
|
|
|
|
161
|
- //console.log($0, $1);
|
|
|
|
162
|
- return smsData[$1];
|
|
|
|
163
|
- })
|
|
|
|
164
|
- return tpl
|
|
|
|
165
|
- },
|
|
|
|
166
|
sendsms(){
|
74
|
sendsms(){
|
|
167
|
App.SendSMS.Message({
|
75
|
App.SendSMS.Message({
|
|
168
|
phone: this.bookInfo.phone,
|
76
|
phone: this.bookInfo.phone,
|
|
169
|
sign_name: '一键订',
|
77
|
sign_name: '一键订',
|
|
170
|
template_code: this.tplsIndex,
|
78
|
template_code: this.tplsIndex,
|
|
171
|
- template_param: JSON.stringify(this.smsData),
|
79
|
+ template_param: JSON.stringify(ST.smsData),
|
|
172
|
rid: this.bookInfo.id,
|
80
|
rid: this.bookInfo.id,
|
|
173
|
len:this.data.tplMsg.length
|
81
|
len:this.data.tplMsg.length
|
|
174
|
}).then((res) => {
|
82
|
}).then((res) => {
|