Commit 590d94e0b852be2093edf3312f36ffedde1d8f62

Authored by wangfan
1 parent 39ff7288

smsbatch

@@ -17,10 +17,7 @@ @@ -17,10 +17,7 @@
17 </block> 17 </block>
18 <block wx:elif="{{item.status==1}}"> 18 <block wx:elif="{{item.status==1}}">
19 <view> 19 <view>
20 - <userinfo wx:if="{{hasScene==1}}" binduserinfo="sendMsg" data-id="{{item.id}}">  
21 - <view class="opt-but">立即发放</view>  
22 - </userinfo>  
23 - <sendsms wx:else="" item="{{item}}" bindsend="sendoff"> 20 + <sendsms item="{{item}}" bindsend="sendoff">
24 <view class="opt-but">立即发放</view> 21 <view class="opt-but">立即发放</view>
25 </sendsms> 22 </sendsms>
26 </view> 23 </view>
@@ -3,81 +3,88 @@ import util from '../../../utils/util'; @@ -3,81 +3,88 @@ import util from '../../../utils/util';
3 import App from '../../../utils/api'; 3 import App from '../../../utils/api';
4 const {regeneratorRuntime} = global 4 const {regeneratorRuntime} = global
5 Component({ 5 Component({
6 - /**  
7 - * 组件的属性列表  
8 - */  
9 - properties: {  
10 - item:Object,  
11 - }, 6 + /**
  7 + * 组件的属性列表
  8 + */
  9 + properties: {
  10 + item: Object,
  11 + },
12 12
13 - /**  
14 - * 组件的初始数据  
15 - */  
16 - data: {  
17 - showGopay:false, 13 + /**
  14 + * 组件的初始数据
  15 + */
  16 + data: {
  17 + showGopay: false,
  18 + hasScene:1,
  19 + },
  20 + attached(){
  21 + this.setData({
  22 + hasScene:util.cache('enter_params')?0:1,
  23 + })
  24 + console.log('hasScene',this.data.hasScene)
  25 + },
  26 + /**
  27 + * 组件的方法列表
  28 + */
  29 + methods: {
  30 + hideGopay(){
  31 + this.setData({
  32 + showGopay: false,
  33 + })
18 }, 34 },
  35 + goPay(){
  36 + this.hideGopay();
  37 + wx.navigateTo({
  38 + url: '/pages/book/setting/sms_buy?scene=' + encodeURI('seller_id=' + this.data.item.sid)
  39 + })
  40 + },
  41 + async sendMsg(e){
  42 + let sign_name = '一键订';
  43 + let item = this.data.item;
  44 + let ss = await App.Reserve.SmsInfo({seller_id: item.sid}, true);
  45 + let id = item.id;
  46 + let reduce_num = item.send_total;
  47 + let sl = (item.send_msg + sign_name).length
  48 + if (sl > 70) {
  49 + reduce_num = Math.ceil(sl / 67) * reduce_num;
  50 + }
  51 + if (parseInt(reduce_num) > parseInt(ss.data.last_num)) {
  52 + this.setData({
  53 + reduce_num: reduce_num,
  54 + last_num: ss.data.last_num,
  55 + showGopay: true,
  56 + })
  57 + return;
  58 + }
  59 + let note_name = '';
  60 + let enter_params = util.cache('enter_params');
19 61
20 - /**  
21 - * 组件的方法列表  
22 - */  
23 - methods: {  
24 - hideGopay(){  
25 - this.setData({  
26 - showGopay:false,  
27 - })  
28 - },  
29 - goPay(){  
30 - this.hideGopay();  
31 - wx.navigate({  
32 - url:'/pages/book/setting/sms_buy?scene='+encodeURI('seller_id='+this.data.item.sid)  
33 - })  
34 - },  
35 - async sendMsg(e){  
36 - let sign_name='一键订';  
37 - let item=this.data.item;  
38 - let ss=await App.Reserve.SmsInfo({seller_id:item.sid},true);  
39 - let id=item.id;  
40 - let reduce_num=item.send_total;  
41 - let sl=(item.send_msg+sign_name).length  
42 - if(sl>70){  
43 - reduce_num=Math.ceil(sl/67)*reduce_num;  
44 - }  
45 - if(parseInt(reduce_num)>parseInt(ss.data.last_num)){  
46 - this.setData({  
47 - reduce_num:reduce_num,  
48 - last_num:ss.data.last_num,  
49 - showGopay:true,  
50 - })  
51 - return;  
52 - }  
53 - let note_name='';  
54 - let enter_params=util.cache('enter_params');  
55 -  
56 - if(enter_params){  
57 - try {  
58 - let si=App.Reserve.SellerInfo(enter_params);  
59 - note_name=si.data.seller_user.nick_name||si.data.seller_user.nickname  
60 - }catch (e){}  
61 - }  
62 - let param={  
63 - id:id,  
64 - sid:item.sid,  
65 - sender:note_name,  
66 - reduce_num:reduce_num,  
67 - sign_name:sign_name, 62 + if (enter_params) {
  63 + try {
  64 + let si = App.Reserve.SellerInfo(enter_params);
  65 + note_name = si.data.seller_user.nick_name || si.data.seller_user.nickname
  66 + } catch (e) {
68 } 67 }
69 - if(!note_name){  
70 - param.sender=e.detail.nickName 68 + }
  69 + let param = {
  70 + id: id,
  71 + sid: item.sid,
  72 + sender: note_name,
  73 + reduce_num: reduce_num,
  74 + sign_name: sign_name,
  75 + }
  76 + if (!note_name) {
  77 + param.sender = e.detail.nickName
  78 + }
  79 + App.Reserve.SmsBatchSend(param).then(res => {
  80 + if (res.ret != 200) {
  81 + return util.toast(res.msg || '发送失败,请联系客服', 'none');
71 } 82 }
72 - App.Reserve.SmsBatchSend(param).then(res=>{  
73 - if(res.ret!=200){  
74 - return util.toast(res.msg||'发送失败,请联系客服','none');  
75 - }  
76 - this.triggerEvent('send');  
77 - util.toast('已发送');  
78 - }).catch(res=>{  
79 - util.toast('发送失败,请联系客服','none');  
80 - });  
81 - },  
82 - } 83 + this.triggerEvent('send');
  84 + util.toast('已发送');
  85 + }).catch(res => {
  86 + util.toast('发送失败,请联系客服', 'none');
  87 + });
  88 + },
  89 + }
83 }) 90 })
1 { 1 {
2 "component": true, 2 "component": true,
3 - "usingComponents": {} 3 + "usingComponents": {
  4 + "userinfo":"/components/userinfo/userinfo"
  5 + }
4 } 6 }
1 <!--components/book/smsbatch/sendsms.wxml--> 1 <!--components/book/smsbatch/sendsms.wxml-->
2 -<view bindtap="sendMsg"> 2 +<userinfo wx:if="{{hasScene==1}}" binduserinfo="sendMsg" data-id="{{item.id}}">
3 <slot></slot> 3 <slot></slot>
  4 +</userinfo>
  5 +<view wx:else="" bindtap="sendMsg">
  6 + <slot ></slot>
4 </view> 7 </view>
5 <view hidden="{{!showGopay}}" class="mask" bindtap="hideGopay"> 8 <view hidden="{{!showGopay}}" class="mask" bindtap="hideGopay">
6 <view class="flex-vc showGopay" catchtap="none"> 9 <view class="flex-vc showGopay" catchtap="none">
@@ -4,72 +4,77 @@ import App from '../../../utils/api'; @@ -4,72 +4,77 @@ import App from '../../../utils/api';
4 const {regeneratorRuntime} = global 4 const {regeneratorRuntime} = global
5 Page({ 5 Page({
6 6
7 - /**  
8 - * 页面的初始数据  
9 - */  
10 - data: {  
11 -  
12 - },  
13 -  
14 - /**  
15 - * 生命周期函数--监听页面加载  
16 - */  
17 - onLoad: function (options) {  
18 - App.Reserve.SmsBatchInfo({id:options.id}).then(res=>{  
19 - this.setData({  
20 - ...res.data,  
21 - addtimeStr:util.unixtoTime(res.data.addtime,'YYYY-MM-DD HH:II'),  
22 - sendertimeStr:util.unixtoTime(res.data.stime ||'','YYYY-MM-DD HH:II'),  
23 - });  
24 - })  
25 - },  
26 -  
27 - /**  
28 - * 生命周期函数--监听页面初次渲染完成  
29 - */  
30 - onReady: function () {  
31 -  
32 - },  
33 -  
34 - /**  
35 - * 生命周期函数--监听页面显示  
36 - */  
37 - onShow: function () {  
38 -  
39 - },  
40 -  
41 - /**  
42 - * 生命周期函数--监听页面隐藏  
43 - */  
44 - onHide: function () {  
45 -  
46 - },  
47 -  
48 - /**  
49 - * 生命周期函数--监听页面卸载  
50 - */  
51 - onUnload: function () {  
52 -  
53 - },  
54 -  
55 - /**  
56 - * 页面相关事件处理函数--监听用户下拉动作  
57 - */  
58 - onPullDownRefresh: function () {  
59 -  
60 - },  
61 -  
62 - /**  
63 - * 页面上拉触底事件的处理函数  
64 - */  
65 - onReachBottom: function () {  
66 -  
67 - },  
68 -  
69 - /**  
70 - * 用户点击右上角分享  
71 - */  
72 - onShareAppMessage: function () {  
73 -  
74 - } 7 + /**
  8 + * 页面的初始数据
  9 + */
  10 + data: {},
  11 +
  12 + /**
  13 + * 生命周期函数--监听页面加载
  14 + */
  15 + onLoad: function (options) {
  16 + this.getInfo(options.id)
  17 + },
  18 +
  19 + /**
  20 + * 生命周期函数--监听页面初次渲染完成
  21 + */
  22 + onReady: function () {
  23 +
  24 + },
  25 +
  26 + /**
  27 + * 生命周期函数--监听页面显示
  28 + */
  29 + onShow: function () {
  30 +
  31 + },
  32 +
  33 + /**
  34 + * 生命周期函数--监听页面隐藏
  35 + */
  36 + onHide: function () {
  37 +
  38 + },
  39 +
  40 + /**
  41 + * 生命周期函数--监听页面卸载
  42 + */
  43 + onUnload: function () {
  44 +
  45 + },
  46 +
  47 + /**
  48 + * 页面相关事件处理函数--监听用户下拉动作
  49 + */
  50 + onPullDownRefresh: function () {
  51 +
  52 + },
  53 +
  54 + /**
  55 + * 页面上拉触底事件的处理函数
  56 + */
  57 + onReachBottom: function () {
  58 +
  59 + },
  60 +
  61 + /**
  62 + * 用户点击右上角分享
  63 + */
  64 + onShareAppMessage: function () {
  65 +
  66 + },
  67 + getInfo(id,flag=false){
  68 + App.Reserve.SmsBatchInfo({id: id},flag).then(res => {
  69 + this.setData({
  70 + item:res.data,
  71 + ...res.data,
  72 + addtimeStr: util.unixtoTime(res.data.addtime, 'YYYY-MM-DD HH:II'),
  73 + sendertimeStr: util.unixtoTime(res.data.stime || '', 'YYYY-MM-DD HH:II'),
  74 + });
  75 + })
  76 + },
  77 + sendoff(){
  78 + this.getInfo(this.data.id,true)
  79 + },
75 }) 80 })
@@ -6,7 +6,8 @@ @@ -6,7 +6,8 @@
6 "userinfo":"/components/userinfo/userinfo", 6 "userinfo":"/components/userinfo/userinfo",
7 "nav":"/components/nav/nav", 7 "nav":"/components/nav/nav",
8 "formids":"/components/formids/formids", 8 "formids":"/components/formids/formids",
9 - "service":"/components/book/smsbatch/service" 9 + "service":"/components/book/smsbatch/service",
  10 + "sendsms":"/components/book/smsbatch/sendsms"
10 } 11 }
11 12
12 } 13 }
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 <service wx:if="{{status==-1}}"> 43 <service wx:if="{{status==-1}}">
44 <view class="opt-but">联系客服</view> 44 <view class="opt-but">联系客服</view>
45 </service> 45 </service>
46 - <sendsms wx:if="{{status==1}}"> 46 + <sendsms wx:if="{{status==1}}" bindsend="sendoff" item="{{item}}">
47 <view class="opt-but">立即发放</view> 47 <view class="opt-but">立即发放</view>
48 </sendsms> 48 </sendsms>
49 </view> 49 </view>
@@ -23,7 +23,6 @@ Page({ @@ -23,7 +23,6 @@ Page({
23 */ 23 */
24 hasScene:0, 24 hasScene:0,
25 seller_id:'', 25 seller_id:'',
26 - note_name:'',  
27 list:{}, 26 list:{},
28 onLoad: function (options) { 27 onLoad: function (options) {
29 //转化场景值到 options 28 //转化场景值到 options
@@ -44,11 +43,6 @@ Page({ @@ -44,11 +43,6 @@ Page({
44 hasScene:this.hasScene, 43 hasScene:this.hasScene,
45 seller_id:this.seller_id, 44 seller_id:this.seller_id,
46 }) 45 })
47 - if(this.hasScene!=1){  
48 - App.Reserve.SellerInfo(util.cache('enter_params')).then(res=>{  
49 - this.note_name=res.data.seller_user.nickname;  
50 - })  
51 - }  
52 }, 46 },
53 47
54 /** 48 /**
@@ -17,11 +17,12 @@ Page({ @@ -17,11 +17,12 @@ Page({
17 */ 17 */
18 options:{}, 18 options:{},
19 onLoad: function (options) { 19 onLoad: function (options) {
  20 + console.log('options',options);
20 this.options=options 21 this.options=options
21 App.Reserve.SmsInfo({seller_id: options.seller_id}, true).then(res => { 22 App.Reserve.SmsInfo({seller_id: options.seller_id}, true).then(res => {
22 this.setData({ 23 this.setData({
23 - total: options.total,  
24 - last_num:res.data.last_num, 24 + total: parseInt(options.total),
  25 + last_num:parseInt(res.data.last_num),
25 }) 26 })
26 }) 27 })
27 }, 28 },
@@ -75,7 +76,7 @@ Page({ @@ -75,7 +76,7 @@ Page({
75 76
76 }, 77 },
77 goPay(){ 78 goPay(){
78 - wx.navigate({ 79 + wx.navigateTo({
79 url:'/pages/book/setting/sms_buy?scene='+encodeURI('seller_id='+this.options.seller_id) 80 url:'/pages/book/setting/sms_buy?scene='+encodeURI('seller_id='+this.options.seller_id)
80 }) 81 })
81 } 82 }
@@ -148,7 +148,8 @@ Page({ @@ -148,7 +148,8 @@ Page({
148 } 148 }
149 App.Reserve.SmsBatchUpdate(param).then(res=>{ 149 App.Reserve.SmsBatchUpdate(param).then(res=>{
150 this.options.id=res.data.id; 150 this.options.id=res.data.id;
151 - this.options.total=this.data.totalSms*this.reservePhones.length 151 + console.log('this.options.total',this.data.totalSms,this.reservePhonesMap.length)
  152 + this.options.total=this.data.totalSms*this.reservePhonesMap.length
152 wx.redirectTo({ 153 wx.redirectTo({
153 url:util.http_build_query(this.options,'./result'), 154 url:util.http_build_query(this.options,'./result'),
154 }); 155 });
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 "list": [] 30 "list": []
31 }, 31 },
32 "miniprogram": { 32 "miniprogram": {
33 - "current": 30, 33 + "current": 31,
34 "list": [ 34 "list": [
35 { 35 {
36 "id": 0, 36 "id": 0,
@@ -230,10 +230,11 @@ @@ -230,10 +230,11 @@
230 "query": "" 230 "query": ""
231 }, 231 },
232 { 232 {
233 - "id": -1, 233 + "id": 26,
234 "name": "pages/book/smsbatch/index", 234 "name": "pages/book/smsbatch/index",
235 "pathName": "pages/book/smsbatch/index", 235 "pathName": "pages/book/smsbatch/index",
236 - "query": "seller_id=80" 236 + "query": "scene=seller_id%3D80",
  237 + "scene": "1011"
237 }, 238 },
238 { 239 {
239 "id": -1, 240 "id": -1,
@@ -259,6 +260,13 @@ @@ -259,6 +260,13 @@
259 "pathName": "pages/book/smsbatch/result", 260 "pathName": "pages/book/smsbatch/result",
260 "query": "seller_id=&id=6&total=10", 261 "query": "seller_id=&id=6&total=10",
261 "scene": "1001" 262 "scene": "1001"
  263 + },
  264 + {
  265 + "id": 31,
  266 + "name": "pages/book/smsbatch/index(普通)",
  267 + "pathName": "pages/book/smsbatch/index",
  268 + "query": "seller_id=80",
  269 + "scene": "1011"
262 } 270 }
263 ] 271 ]
264 } 272 }