Commit e564f49bcf63bd7ee6e07966190d12d4cc584e7a

Authored by wangfan
1 parent 352c5b42

v2 book sendsms

... ... @@ -15,7 +15,8 @@
"pages/reservr/index",
"pages/me/setting",
"pages/me/list",
"pages/book/b_addnew"
"pages/book/b_addnew",
"pages/book/b_sms"
],
"window": {
"navigationStyle": "custom",
... ...
... ... @@ -2,7 +2,7 @@ var util = require('../../../utils/util.js')
var uri=require('../../../utils/uri.js');
Component({
properties:{
phoneNumber:String
bookInfo:Object
},
data:{
list:[
... ... @@ -34,17 +34,23 @@ Component({
},
callcustom:function(e){
var idx=e.currentTarget.dataset.idx;
if(idx==2){
var that=this;
wx.makePhoneCall({
phoneNumber: this.data.phoneNumber, //仅为示例,并非真实的电话号码
complete:function(){
that.close();
}
})
}
if(idx==0){
this.triggerEvent("share");
switch (idx){
case 0:
this.triggerEvent("share");
break;
case 1:
wx.navigateTo({
url:'/pages/book/b_sms?id='+this.data.bookInfo.id
});
break;
case 2:
wx.makePhoneCall({
phoneNumber: this.data.bookInfo.phone, //仅为示例,并非真实的电话号码
complete:()=>{
this.close();
}
})
break;
}
}
}
... ...
... ... @@ -6,13 +6,6 @@ Page({
onLoad:function (opt) {
util.setBarTitle('预定详情');
console.log(opt)
opt.name=opt.name.length>3 ? opt.name.slice(0,3)+'...' : opt.name
opt.rdateStr=util.unixtoTime(opt.rdate,"MM月DD日 HH:II")
this.setData({
sellerid:util.cache('sellerid'),
phoneNumber:opt.phone,
bookInfo:opt
})
this.getDetail(opt.id);
wx.showShareMenu({
withShareTicket: true,
... ... @@ -26,10 +19,10 @@ Page({
this.notice=this.selectComponent('#notice');
},
noticeCall:function(){
this.notice.show();
this.selectComponent('#notice').show();
},
onShareAppMessage: function () {
this.notice.close();
this.selectComponent('#notice').close();
var obj=this.data.bookInfo;
var path='/pages/customer/index?id='+this.data.bookInfo.id;
let nickname="";
... ... @@ -52,11 +45,10 @@ Page({
};
},
getcall:function(){
var that=this;
wx.makePhoneCall({
phoneNumber: this.data.phoneNumber, //仅为示例,并非真实的电话号码
complete:function(){
this.notice.close();
complete:()=>{
this.selectComponent('#notice').close();
}
})
},
... ... @@ -98,10 +90,12 @@ Page({
},
detailData:null,
getDetail(id){
App.Reserve.Detail({rid:id,openid:'1'}).then(res=>{
App.Reserve.Detail({rid:id,openid:''}).then(res=>{
res.data.rdateStr=util.unixtoTime(res.data.rdate,"MM月DD日 HH:II")
this.detailData=res.data;
this.setData({
tables:res.data.tables,
bookInfo:res.data,
})
})
}
... ...
... ... @@ -60,5 +60,5 @@
<!--通知预订人-->
<block wx:if="{{bookInfo.code}}">
<view class="notice-button white-font font34r flex-cc" bindtap="noticeCall">通知预订人</view>
<noticeCall id="notice" phoneNumber="{{phoneNumber}}"></noticeCall>
<noticeCall id="notice" bookInfo="{{bookInfo}}"></noticeCall>
</block>
... ...
// 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
... ...
{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle":"black",
"usingComponents": {
"nav":"/components/nav/nav"
}
}
\ No newline at end of file
... ...
<!--pages/book/b_sms.wxml-->
<nav>发送短信</nav>
<view class="page">
<view class="tip">已自动生成通知短信,可修改或直接发送</view>
<textarea class="tpl" auto-height value="{{tplMsg}}" maxlength="-1">
</textarea>
<button class="sms-but send" bindtap="sendsms" hidden="{{hideSendsms}}">直接发送</button>
<button class="sms-but copy" plain bindtap="copysms">复制短信</button>
</view>
... ...
/* pages/book/b_sms.wxss */
.page{
width: 90%;
margin: 60rpx 5% 0;
font-size: 30rpx;
}
.tip{
margin-bottom: 34rpx;
}
.tpl{
border: solid 2rpx #999999;
border-radius: 10rpx;
width: 90%;
padding: 5%;
margin-bottom: 200rpx;
}
.sms-but,.sms-but[plain]{
margin-bottom: 18rpx;
border: solid 2rpx #199095;
font-size: 34rpx;
height: 84rpx;
line-height: 84rpx;
}
.sms-but.send{
background-color: #199095;
color:#fff;
}
.sms-but.copy{
color:#199095;
}
\ No newline at end of file
... ...
... ... @@ -30,7 +30,7 @@
"list": []
},
"miniprogram": {
"current": 14,
"current": 16,
"list": [
{
"id": 0,
... ... @@ -150,6 +150,18 @@
"pathName": "pages/book/b_addnew",
"query": "seller_id=1&seller_openid=o9pcQ0cbjRKnRWczcOJaaSRGP1lE&manager_id=500",
"scene": "1001"
},
{
"id": -1,
"name": "预定本详情",
"pathName": "pages/book/b_detail",
"query": "id=25"
},
{
"id": -1,
"name": "预定本-发短信",
"pathName": "pages/book/b_sms",
"query": "id=25"
}
]
}
... ...
... ... @@ -50,7 +50,7 @@ function rpc(host='',act,data={},fouce=false,header={},silence=true,cachetime=0,
}
if(!silence){
wx.showLoading({
title: '数据加载中',
title: '处理中',
mask:true
})
}
... ...
... ... @@ -41,4 +41,9 @@ export default {
//设置客户经理
'App.Reserve.SetReserveCusman':null,
//发送短信
'App.SendSMS.Message':{
silence:false,
},
}
\ No newline at end of file
... ...