Commit 739a1dfa0d2afc5af0c09769993e7bf3497062fe

Authored by wangfan
1 parent 1f704a06

新增2套短信模板

@@ -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) => {
1 // pages/book/b_sms.js 1 // pages/book/b_sms.js
2 import App from '../../utils/api'; 2 import App from '../../utils/api';
  3 +import util from '../../utils/util';
3 import bcm from '../../utils/bookCommon'; 4 import bcm from '../../utils/bookCommon';
4 const {regeneratorRuntime} = global 5 const {regeneratorRuntime} = global
5 const tpls = { 6 const tpls = {
6 SMS_154587043: '${guest},您好!${seller_name}已为您预订${date}的桌位:${region_room_name};地址:${seller_addr},电话:${seller_phone}\n客户经理${cusman},期待您的光临!', 7 SMS_154587043: '${guest},您好!${seller_name}已为您预订${date}的桌位:${region_room_name};地址:${seller_addr},电话:${seller_phone}\n客户经理${cusman},期待您的光临!',
7 SMS_162733710: '尊敬的贵宾,您好!${reserve_date}的用餐,为您安排在${seller_name_addr_room}房间,${cusman}期待您的光临,预祝就餐愉快!', 8 SMS_162733710: '尊敬的贵宾,您好!${reserve_date}的用餐,为您安排在${seller_name_addr_room}房间,${cusman}期待您的光临,预祝就餐愉快!',
8 SMS_163050401: '尊敬的贵宾,您好!\n ${seller_name}已为您安排${date}的用餐,房间:${region_room_name}; \n地址:${seller_addr}; \n电话:${seller_phone} \n预祝用餐愉快,${cusman}期待您的光临!', 9 SMS_163050401: '尊敬的贵宾,您好!\n ${seller_name}已为您安排${date}的用餐,房间:${region_room_name}; \n地址:${seller_addr}; \n电话:${seller_phone} \n预祝用餐愉快,${cusman}期待您的光临!',
  10 + SMS_164277855:'贵宾您好!${seller_name}为您预留${date}的${region_room_name};\n电话:${seller_phone},预祝用餐愉快!',
  11 + SMS_164268239:'贵宾您好!${seller_name}为您预留${date}的${region_room_name};\n地址:${seller_addr},电话:${seller_phone},预祝用餐愉快!',
9 }; 12 };
10 13
11 module.exports ={ 14 module.exports ={
@@ -32,6 +35,25 @@ module.exports ={ @@ -32,6 +35,25 @@ module.exports ={
32 } 35 }
33 return str; 36 return str;
34 }, 37 },
  38 + getTableNameBSK(tables){
  39 + let bsk={
  40 + 1:'散座',
  41 + 2:'包间',
  42 + 3:'卡台',
  43 + }
  44 + let ts={};
  45 + tables.forEach(t => {
  46 + ts[t.tid]=typeof ts[t.tid]=='undefined'?[]:ts[t.tid];
  47 + ts[t.tid].push(t.name);
  48 + })
  49 + let str = '';
  50 + Object.keys(ts).forEach(tid => {
  51 + str += bsk[tid]+'('+ts[tid].join('、')+')、';
  52 + });
  53 + let mxl=str.length-1;
  54 + str=str.substr(0,mxl>20?20:mxl);
  55 + return str;
  56 + },
35 getTableNameOne(tables){ 57 getTableNameOne(tables){
36 let bao = []; 58 let bao = [];
37 tables.forEach(t => { 59 tables.forEach(t => {
@@ -50,6 +72,9 @@ module.exports ={ @@ -50,6 +72,9 @@ module.exports ={
50 let smsData = {} 72 let smsData = {}
51 let txa=['早上','中午','晚上'] 73 let txa=['早上','中午','晚上']
52 let tx=await bcm.getTimeSpaceIndexData(bookInfo.rdate,sc); 74 let tx=await bcm.getTimeSpaceIndexData(bookInfo.rdate,sc);
  75 + if(!bookInfo.rdateStr){
  76 + bookInfo.rdateStr=util.unixtoTime(bookInfo.ddate, "MM月DD日 HH:II")
  77 + }
53 switch (tplcode) { 78 switch (tplcode) {
54 //尊敬的贵宾,您好!(4月6日)(中午)的用餐,为您安排在(好又多复兴路店)(202)房间,(王丽娜)期待您的光临,预祝就餐愉快! 79 //尊敬的贵宾,您好!(4月6日)(中午)的用餐,为您安排在(好又多复兴路店)(202)房间,(王丽娜)期待您的光临,预祝就餐愉快!
55 case 'SMS_162733710': 80 case 'SMS_162733710':
@@ -72,6 +97,23 @@ module.exports ={ @@ -72,6 +97,23 @@ module.exports ={
72 cusman: (bookInfo.cusman||'').substr(0, 20), 97 cusman: (bookInfo.cusman||'').substr(0, 20),
73 } 98 }
74 break; 99 break;
  100 + case 'SMS_164277855'://短店名+无地址
  101 + smsData = {
  102 + seller_name: sc.seller.selleralias.substr(0, 20),
  103 + date: bookInfo.rdateStr.replace('日','日'+txa[tx.timeIndex]),
  104 + region_room_name: this.getTableNameBSK(bookInfo.tables),
  105 + seller_phone: bookInfo.seller.phone.substr(0, 20),
  106 + }
  107 + break;
  108 + case 'SMS_164268239'://店名+地址
  109 + smsData = {
  110 + seller_name: bookInfo.seller.sellername.substr(0, 20),
  111 + date: bookInfo.rdateStr.replace('日','日'+txa[tx.timeIndex]),
  112 + region_room_name: this.getTableNameBSK(bookInfo.tables),
  113 + seller_addr: (bookInfo.seller.real_address || bookInfo.seller.map_address).substr(0, 20),
  114 + seller_phone: bookInfo.seller.phone.substr(0, 20),
  115 + }
  116 + break;
75 default: 117 default:
76 let guest = ''; 118 let guest = '';
77 if (bookInfo.sex == 3) { 119 if (bookInfo.sex == 3) {