Commit a0e1e3c5944f9786e8a4c2cb5933a8a38f13e05b

Authored by vking
1 parent ac2fcd2e

boost

@@ -26,6 +26,13 @@ Component({ @@ -26,6 +26,13 @@ Component({
26 this.setData({ 26 this.setData({
27 displayType:0, 27 displayType:0,
28 }) 28 })
  29 + util.elog(null,'点击关闭了红包弹窗')
  30 + },
  31 + enter(){
  32 + this.setData({
  33 + displayType:0,
  34 + })
  35 + util.elog(null,'点击红包进入活动主页')
29 }, 36 },
30 hasActivity(e){//有通知就可以参加活动 37 hasActivity(e){//有通知就可以参加活动
31 console.log('hasActivity.enter',e) 38 console.log('hasActivity.enter',e)
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 <view class="money-dw">元</view> 19 <view class="money-dw">元</view>
20 </view> 20 </view>
21 <navigator url="/pack-activity/pages/index?id={{activity.id}}" 21 <navigator url="/pack-activity/pages/index?id={{activity.id}}"
22 - bindtap="close" 22 + bindtap="enter"
23 hover-class="navigator-hover"> 23 hover-class="navigator-hover">
24 <view class="money-button flex-cc">开心收下</view> 24 <view class="money-button flex-cc">开心收下</view>
25 </navigator> 25 </navigator>
1 -var util = require('../../../utils/util.js')  
2 -var uri=require('../../../utils/uri.js')  
3 -var bookOrder=require('../../../utils/bookCommon.js')  
4 -const {regeneratorRuntime} = global  
5 -Page({  
6 - data:{  
7 - grand:[  
8 - {  
9 - sex:1,  
10 - grand_title:'先生',  
11 - isselect:true  
12 - },  
13 - {  
14 - sex:2,  
15 - grand_title:'女士',  
16 - isselect:false  
17 - }  
18 - ],  
19 - name:'',  
20 - sex:1,  
21 - phone:'',  
22 - remark:'',  
23 - buttonhide:true,  
24 - pnum:'6'  
25 - },  
26 - onLoad:function(opt){  
27 - wx.removeStorage({  
28 - key:'tableid',  
29 - })  
30 - wx.removeStorage({  
31 - key:'tabletype',  
32 - })  
33 - util.setBarTitle('录入订座信息');  
34 - var selectmonth=opt.date.split('-')[0][0]=='0' ? opt.date.split('-')[0][1] : opt.date.split('-')[0];  
35 - var selectday=opt.date.split('-')[1][0]=='0' ? opt.date.split('-')[1][1] : opt.date.split('-')[1];  
36 - console.log(opt)  
37 - var stringTime =opt.year+'-'+opt.date+' ' +opt.time+':00';  
38 - console.log(stringTime)  
39 - var time=bookOrder.gettimestamp(stringTime);  
40 - console.log(time)  
41 - this.setData({  
42 - thisyear:opt.year,  
43 - selectdate:selectmonth+'月'+selectday+'日',  
44 - time_dur:opt.time,  
45 - sellerid:util.cache('sellerid'),  
46 - time:time,  
47 - pnum:util.cache('order_pnum') ? util.cache('order_pnum') : this.data.pnum,  
48 - })  
49 - this.getdesklist();  
50 - },  
51 - onShow:function(){  
52 - var that=this;  
53 - if(util.cache('tableid')){  
54 - var tables=util.cache('tableid');  
55 - var templist=this.data.templist;  
56 - var showdesk=[];  
57 - for(var i=0;i<tables.length;i++){  
58 - templist.forEach(function(r,n){  
59 - if(tables[i]==r.id){  
60 - r.isselect=true;  
61 - if(r.tid==2){  
62 - r.name=r.name.length>4 ? r.name.slice(0,3)+'...' : r.name;  
63 - showdesk.unshift(r);  
64 - }else {  
65 - r.name=r.name.length>4 ? r.name.slice(0,3)+'...' : r.name;  
66 - showdesk.push(r);  
67 - }  
68 - }  
69 - })  
70 - }  
71 - this.setData({  
72 - showdesk:showdesk.slice(0,2)  
73 - })  
74 - }  
75 - if(util.cache('tableid') && util.cache('tableid').length>0){  
76 - if(this.data.name!='' && this.data.phone!='' && !this.data.reminder){  
77 - this.setData({  
78 - buttonhide:false  
79 - })  
80 - }  
81 - }  
82 - util.postSuccessFun=function(json,uri_code){  
83 - switch (uri_code) {  
84 - case uri.CGI_USER_SETRESERVEINFO__CODE:  
85 - wx.hideLoading()  
86 - if(json.ret==200){  
87 - wx.reLaunch({  
88 - url:util.http_build_query(json.data,'b_detail')  
89 - })  
90 - }  
91 - break;  
92 - case uri.CGI_USER_GETTABLELIST__CODE:  
93 - console.log('xxxx',json.data);  
94 - var list=json.data;  
95 - var templist=[];  
96 - for(var key in list){  
97 - if(key!='typex' && key!='typey'){  
98 - list[key].list.forEach(function(v,i){  
99 - templist.push(v)  
100 - })  
101 -  
102 - }  
103 - }  
104 - var tempsan=[];  
105 - var tempbao=[];  
106 - var showdesk=[];  
107 - var temp={};  
108 - templist.forEach(function(v,i){  
109 - v.name=v.name.length>4 ? v.name.slice(0,3)+'...' : v.name;  
110 - if(!v.r_status){  
111 - if(v.tid==2){  
112 - tempbao.push(v);  
113 - v.isselect=false;  
114 - showdesk.unshift(v);  
115 - }else{  
116 - tempsan.push(v);  
117 - v.isselect=false;  
118 - showdesk.push(v);  
119 - }  
120 - }  
121 - if(v.tid==2){  
122 - if(!temp.hasOwnProperty("tabletype_2")){  
123 - temp['tabletype_2']=true  
124 - }  
125 -  
126 - }else{  
127 - if(!temp.hasOwnProperty("tabletype_1")){  
128 - temp['tabletype_1']=true  
129 - }  
130 - }  
131 - })  
132 - util.cache('tabletype',temp);  
133 - console.log(showdesk)  
134 - that.setData({  
135 - sancount:list.typex, //typex散台  
136 - baocount:list.typey, //typey包间  
137 - showdesk:showdesk.slice(0,2),  
138 - templist:templist  
139 -  
140 - })  
141 - break;  
142 - }  
143 - }  
144 - },  
145 - changetime:function(){  
146 - wx.navigateBack()  
147 - },  
148 - selectgrand:function(e){  
149 - var sex=e.currentTarget.dataset.sex;  
150 - console.log(sex)  
151 - var grandlist=this.data.grand;  
152 - grandlist.forEach(function(v,i){  
153 - v.isselect=false;  
154 - if(v.sex==sex){  
155 - v.isselect=true;  
156 - }  
157 - })  
158 - this.setData({  
159 - grand:grandlist,  
160 - sex:sex  
161 - })  
162 - },  
163 - condition:function(e){  
164 - var name=this.data.name;  
165 - var phone=e.detail.value;  
166 - var regExp = /^(86)?((13\d{9})|(15[0,1,2,3,5,6,7,8,9]\d{8})|(18[0,5,6,7,8,9]\d{8}))$/  
167 - if(!(regExp.test(phone))){  
168 - this.setData({  
169 - reminder:'手机格式不正确'  
170 - })  
171 - }else{  
172 - this.setData({  
173 - reminder:null  
174 - })  
175 - }  
176 - if(name!='' && !this.data.reminder && phone!='' && util.cache('tableid')){  
177 - this.setData({  
178 - buttonhide:false  
179 - })  
180 - }  
181 - },  
182 - changename:function(e){  
183 - this.setData({  
184 - name:e.detail.value  
185 - })  
186 - },  
187 - changephone:function(e){  
188 - this.setData({  
189 - phone:e.detail.value  
190 - })  
191 - },  
192 - changeremark:function(e){  
193 - this.setData({  
194 - remark:e.detail.value  
195 - })  
196 - },  
197 - ifAll:function(){  
198 - var name=this.data.name;  
199 - var phone=this.data.phone;  
200 - if(name!='' && !this.data.reminder && phone!='' && util.cache('tableid')){  
201 - this.setData({  
202 - buttonhide:false  
203 - })  
204 - }  
205 - },  
206 - formsubmit:async function(){  
207 - wx.showLoading({  
208 - title:'正在预订',  
209 - mask:true  
210 - });  
211 - console.log(this.data.time)  
212 - var formData={  
213 - sid:this.data.sellerid,  
214 - tid:util.cache('tableid').toString(),  
215 - rname:this.data.name, //姓名  
216 - phone:this.data.phone, //手机号  
217 - sex:this.data.sex, //性别  
218 - pnum:this.data.pnum, //人数  
219 - rdate:this.data.time, //时间  
220 - cusdem:this.data.remark //备注  
221 - }  
222 - try{  
223 - let enter_params=util.cache('enter_params');  
224 - let manager_id=enter_params.manager_id;  
225 - if(manager_id){  
226 - let sc=(await App.Reserve.SellerInfo(enter_params)).data  
227 - let managers=sc.manager;  
228 - managers.forEach(man=>{  
229 - if(manager_id==man.id){  
230 - formData.cusman_id=man.id;  
231 - formData.cusman=man.user_name;  
232 - formData.cusman_phone=man.user_phone?man.user_phone:'';  
233 - formData.cusman_account=man.user_wechat?man.user_wechat:'';  
234 - }  
235 - })  
236 - }  
237 -  
238 -  
239 - let man=managers[mansIndex];  
240 - if(man){  
241 - App.Reserve.SetReserveCusman({  
242 - rid:this.data.bookInfo.id,  
243 - cusman_id:man.id,  
244 - cusman:man.user_name,  
245 - cusman_phone:man.user_phone?man.user_phone:'158777556369',  
246 - cusman_account:man.user_wechat?man.user_wechat:'',  
247 - });  
248 - }  
249 - }catch (e){}  
250 - console.log(formData)  
251 - util.post(uri.CGI_USER_SETRESERVEINFO,formData,uri.CGI_USER_SETRESERVEINFO__CODE)  
252 - },  
253 - changepnum:function(e){  
254 - console.log(e)  
255 - this.setData({  
256 - pnum:e.detail  
257 - })  
258 - this.getdesklist();  
259 - },  
260 - selectdesk:function(){  
261 - wx.navigateTo({  
262 - url:'b_desk?pnum='+this.data.pnum+'&year='+this.data.thisyear+'&date='+this.data.selectdate+'&time_dur='+this.data.time_dur  
263 - })  
264 - },  
265 - getdesklist:function(){  
266 - util.post(uri.CGI_USER_GETTABLELIST,{sid:this.data.sellerid,pnum:parseInt(this.data.pnum),rdate:this.data.time},uri.CGI_USER_GETTABLELIST__CODE)  
267 - },  
268 - binddesk:function(e){  
269 - var id=e.currentTarget.dataset.id;  
270 - var tables=util.cache('tableid') ? util.cache('tableid') : [];  
271 - var showdesk=this.data.showdesk;  
272 - showdesk.forEach(function(v,i){  
273 - if(v.id==id){  
274 - if(v.isselect==true){  
275 - var thisindex=tables.indexOf(id);  
276 - tables.splice(thisindex,1)  
277 - }else{  
278 - tables.push(id)  
279 - }  
280 - v.isselect=!v.isselect  
281 - }  
282 - })  
283 - util.cache('tableid',tables);  
284 - this.setData({  
285 - showdesk:showdesk  
286 - })  
287 - var name=this.data.name;  
288 - var phone=this.data.phone;  
289 - if(name!='' && !this.data.reminder && phone!='' && util.cache('tableid')){  
290 - this.setData({  
291 - buttonhide:false  
292 - })  
293 - }  
294 - }  
295 -})  
1 -{  
2 - "backgroundTextStyle":"light",  
3 - "navigationBarBackgroundColor": "#fff",  
4 - "navigationBarTextStyle":"black",  
5 - "usingComponents": {  
6 - "selectPeople":"../../components/book/people/people",  
7 - "step":"../../components/book/step/step",  
8 - "nav":"/components/nav/nav"  
9 - }  
10 -}  
1 -<nav>点餐商户端</nav>  
2 -<step step="1"></step>  
3 -<view class="other-info flex-lr">  
4 - <view class="selected-time flex-vc" bindtap="changetime">  
5 - <view class="font30r black-font">时间</view>  
6 - <view class="actual-time green-font font34r">{{selectdate}} {{time_dur}}</view>  
7 - </view>  
8 - <selectPeople bind:changepnum="changepnum" pnum="{{pnum}}"></selectPeople>  
9 -</view>  
10 -<view class="border-line"></view>  
11 -  
12 -<view class="advice-desk flex-lr">  
13 - <view class="black-font font30r">桌位</view>  
14 - <view>  
15 - <view class="font26r gray-deep-font flex-rr">(包间余{{baocount}}个,散台余{{sancount}}个)</view>  
16 - <view class="advice-desk-detail flex-rr">  
17 - <block wx:for="{{showdesk}}">  
18 - <block wx:if="{{item.tid==2}}">  
19 - <view class="order-desk-info {{item.isselect==true ? 'desk-active' : ''}}" bindtap="binddesk" data-id="{{item.id}}" data-type="{{item.tid}}">  
20 - <view class="flex-vc order-desk-detail">  
21 - <view class="font28r black-font smooth">{{item.name}}</view>  
22 - <view class="font26r black-font" style="margin-top:6rpx;">{{item.table_pnum}}人</view>  
23 - </view>  
24 - <view class="order-desk-type flex-cc white-font font20r">包间</view>  
25 - </view>  
26 - </block>  
27 - <block wx:else>  
28 - <view class="order-desk-info {{item.isselect==true ? 'desk-active' : ''}}" bindtap="binddesk" data-id="{{item.id}}" data-type="{{item.tid}}">  
29 - <view class="flex-vc order-desk-detail" style="height:100%;">  
30 - <view class="font28r black-font smooth">{{item.name}}</view>  
31 - <view class="font26r black-font" style="margin-top:6rpx;">6人</view>  
32 - </view>  
33 - </view>  
34 - </block>  
35 - </block>  
36 - <view class="flex-rr advice-more" bindtap="selectdesk">  
37 - <view style="padding-right:30rpx;" class="gray-deep-font font26r">更多</view>  
38 - <image src="http://nosqn.colorcun.com/custom/lite-yd/image/click.png" class="icon12-22"></image>  
39 - </view>  
40 - </view>  
41 - </view>  
42 -</view>  
43 -<view class="cut"></view>  
44 -  
45 -  
46 -<view class="book-info" style="margin-bottom: 205rpx;">  
47 - <view class="book-info-single flex-lr" style="align-items:flex-start;">  
48 - <input placeholder="请输入预订人姓名(必填)" placeholder-class="gray-font font34r" class="black-font font34r" maxlength="5" style="width:450rpx;" value="{{name}}" bindinput="changename" bindblur="ifAll"/>  
49 - <view class="book-info-grand flex-rr font28r gray-deep-font">  
50 - <block wx:for="{{grand}}">  
51 - <view class="book-grand flex-cc {{index==0 ? 'book-grand-border' : ''}} {{item.isselect==true ? 'book-grand-active white-font' : ''}}" bindtap="selectgrand" data-sex="{{item.sex}}">{{item.grand_title}}</view>  
52 - </block>  
53 - </view>  
54 - </view>  
55 - <view class="book-info-single flex-lr" style="align-items:flex-start;">  
56 - <input placeholder="请输入预订人手机号码(必填)" placeholder-class="gray-font font34r" class="black-font font34r" type="number" maxlength="11" bindblur="condition" bindinput="changephone" value="{{phone}}" style="color:{{reminder ? '#E14553' : '#353535'}};width:{{reminder ? 400 : 680}}rpx;"/>  
57 - <block wx:if="{{reminder}}">  
58 - <view class="flex-rr" style="height:100rpx;">  
59 - <view style="color:#E14553;" class="font28r">{{reminder}}</view>  
60 - <image src="http://nosqn.colorcun.com/custom/lite-yd/image/name-have.png" class="phone-reminder"></image>  
61 - </view>  
62 - </block>  
63 - </view>  
64 - <view class="book-info-single">  
65 - <input placeholder="请输入顾客要求(25字以内,选填)" placeholder-class="gray-font font34r" class="black-font font34r" maxlength="25" value="{{remark}}" bindinput="changeremark"/>  
66 - </view>  
67 -</view>  
68 -<view class="zhanwei">  
69 - <view class="confirm-button white-font flex-vc font34r {{buttonhide==false ? 'confirm-button-active' : ''}}" bindtap="{{buttonhide==false ? 'formsubmit' : ''}}">确定</view>  
70 -</view>  
1 -view{  
2 - line-height:1.2;  
3 -}  
4 -.other-info{  
5 - width:100%;  
6 - height:220rpx;  
7 - padding:20rpx 0;  
8 - box-sizing:border-box;  
9 -}  
10 -.selected-time{  
11 - width:375rpx;  
12 - height:100%;  
13 - border-right:1px solid #efeef3;  
14 - box-sizing:border-box;  
15 -}  
16 -.actual-time{  
17 - margin-top:30rpx;  
18 -}  
19 -.border-line{  
20 - width:680rpx;  
21 - height:1px;  
22 - background:#efeef3;  
23 - margin:0 auto;  
24 -}  
25 -.advice-desk{  
26 - width:680rpx;  
27 - height:auto;  
28 - padding:40rpx 0;  
29 - margin:0 auto;  
30 -}  
31 -.advice-desk-detail{  
32 - margin-top:30rpx;  
33 -}  
34 -.order-desk-info{  
35 - width:120rpx;  
36 - height:120rpx;  
37 - background:#EBF8F8;  
38 - border:1px solid #199095;  
39 - border-radius:10rpx;  
40 - position:relative;  
41 - overflow:hidden;  
42 - margin-right:40rpx;  
43 -}  
44 -.desk-active{  
45 - background:#A9E3E6;  
46 -}  
47 -.order-desk-detail{  
48 - width:100%;  
49 - height:90rpx;  
50 -}  
51 -.order-desk-type{  
52 - width:100%;  
53 - height:30rpx;  
54 - background:#199095;  
55 - position:absolute;  
56 - left:0;  
57 - bottom:0;  
58 -}  
59 -.advice-more{  
60 - padding:20rpx 0;  
61 - padding-left:30rpx;  
62 -}  
63 -.cut{  
64 - width:100%;  
65 - height:4px;  
66 - background:#efeef3;  
67 -}  
68 -  
69 -  
70 -  
71 -.book-info{  
72 - width:680rpx;  
73 - padding-top:20rpx;  
74 - margin:0 auto;  
75 -}  
76 -.book-info-single{  
77 - width:100%;  
78 - height:120rpx;  
79 - padding-top:80rpx;  
80 - border-bottom:1px solid #efeef3;  
81 -}  
82 -.book-info-single>input{  
83 - width:100%;  
84 - height:100rpx;  
85 -}  
86 -.book-info-grand{  
87 - height:50rpx;  
88 - border:1px solid #199095;  
89 - margin-top:20rpx;  
90 -}  
91 -.book-grand{  
92 - width:90rpx;  
93 - height:100%;  
94 - box-sizing:border-box;  
95 -}  
96 -.book-grand-active{  
97 - background:rgba(25,153,149,.8);  
98 -}  
99 -.book-grand-border{  
100 - border-right:1px solid #199095;  
101 -}  
102 -.phone-reminder{  
103 - width:32rpx;  
104 - height:32rpx;  
105 - margin-left:20rpx;  
106 -}  
107 -  
108 -.zhanwei{  
109 - width:100%;  
110 - height:170rpx;  
111 - background:#efeef3;  
112 - position:fixed;  
113 - left:0;  
114 - right:0;  
115 - bottom:0;  
116 - z-index: 99;  
117 -}  
118 -  
119 -  
120 -.confirm-button{  
121 - width:680rpx;  
122 - height:85rpx;  
123 - background:#199095;  
124 - margin:42rpx auto 0;  
125 - border-radius:10rpx;  
126 - opacity:.6;  
127 -}  
128 -.confirm-button-active{  
129 - opacity:1;  
130 -}  
@@ -147,7 +147,7 @@ Page({ @@ -147,7 +147,7 @@ Page({
147 /** 147 /**
148 * 生命周期函数--监听页面显示 148 * 生命周期函数--监听页面显示
149 */ 149 */
150 - onShow: async function () { 150 + onShow: async function (e) {
151 console.log({ 151 console.log({
152 'this.hasGetLocation':this.hasGetLocation, 152 'this.hasGetLocation':this.hasGetLocation,
153 'this.hasOnLoad':this.hasOnLoad, 153 'this.hasOnLoad':this.hasOnLoad,
@@ -199,7 +199,8 @@ Page({ @@ -199,7 +199,8 @@ Page({
199 /** 199 /**
200 * 生命周期函数--监听页面隐藏 200 * 生命周期函数--监听页面隐藏
201 */ 201 */
202 - onHide: function () { 202 + onHide: function (e) {
  203 + util.elog(null,'离开地图页')
203 }, 204 },
204 205
205 /** 206 /**
@@ -386,6 +387,10 @@ Page({ @@ -386,6 +387,10 @@ Page({
386 m.callout.display='ALWAYS'; 387 m.callout.display='ALWAYS';
387 } 388 }
388 hasCurrent=false 389 hasCurrent=false
  390 + if("markertap"==e.type){
  391 + util.elog({id:m.seller.id,sellername:m.seller.sellername},'点击地图区域的店铺标记')
  392 + }
  393 +
389 } 394 }
390 if(m.display!='none' && hasCurrent){ 395 if(m.display!='none' && hasCurrent){
391 current++ 396 current++
@@ -707,6 +712,7 @@ Page({ @@ -707,6 +712,7 @@ Page({
707 wx.navigateTo({ 712 wx.navigateTo({
708 url:'/pages/reserve/detail?id='+util.attr(e,'sid') 713 url:'/pages/reserve/detail?id='+util.attr(e,'sid')
709 }) 714 })
  715 + util.elog({sid:util.attr(e,'sid')},'点击橱窗中的商家,进入店铺详情')
710 }, 716 },
711 IsSetActivity(){ 717 IsSetActivity(){
712 let cmap=this.data.map; 718 let cmap=this.data.map;
@@ -910,8 +916,7 @@ Page({ @@ -910,8 +916,7 @@ Page({
910 }) 916 })
911 }, 917 },
912 boostEvent(e){ 918 boostEvent(e){
913 - console.log('boostEvent',e)  
914 - //wx.aldstat.sendEvent( '强提醒', {...e.detail,time:parseInt(new Date()/1000)}) 919 + util.elog(e.detail,'强提醒')
915 if(e.detail.act=='hide'){ 920 if(e.detail.act=='hide'){
916 this.setData({ 921 this.setData({
917 hasGetPos:true, 922 hasGetPos:true,
@@ -919,4 +924,7 @@ Page({ @@ -919,4 +924,7 @@ Page({
919 this.selectComponent('#getpos').getPos(); 924 this.selectComponent('#getpos').getPos();
920 } 925 }
921 }, 926 },
  927 + elog(e){
  928 + util.elog({attr:util.attr(e),detail:e.detail},util.attr(e,'ename')||'点击')
  929 + }
922 }) 930 })
@@ -16,8 +16,8 @@ @@ -16,8 +16,8 @@
16 subkey="SDEBZ-I74W4-QLGUX-XXYXU-HIR23-3QFBJ" 16 subkey="SDEBZ-I74W4-QLGUX-XXYXU-HIR23-3QFBJ"
17 layer-style="2" 17 layer-style="2"
18 style="width: 100%; height: {{map.height+60}}px;"></map> 18 style="width: 100%; height: {{map.height+60}}px;"></map>
19 - <formids url="/pages/reserve/search" style="position: fixed;">  
20 - <view 19 + <formids url="/pages/reserve/search" style="position: fixed;" >
  20 + <view bindtap="elog" data-ename="点击搜索框"
21 class="flex-ll" 21 class="flex-ll"
22 style="position:fixed;top:{{statusBarHeight}}px;left:0;height: {{titleBarHeight}}px; line-height: {{titleBarHeight}}px;"> 22 style="position:fixed;top:{{statusBarHeight}}px;left:0;height: {{titleBarHeight}}px; line-height: {{titleBarHeight}}px;">
23 <view class="searchList flex-ll" catchtap="listShow"> 23 <view class="searchList flex-ll" catchtap="listShow">
@@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
54 "list": [] 54 "list": []
55 }, 55 },
56 "miniprogram": { 56 "miniprogram": {
57 - "current": 0, 57 + "current": -1,
58 "list": [ 58 "list": [
59 { 59 {
60 "id": 0, 60 "id": 0,
@@ -127,13 +127,6 @@ @@ -127,13 +127,6 @@
127 }, 127 },
128 { 128 {
129 "id": 11, 129 "id": 11,
130 - "name": "录入订座信息 b_info",  
131 - "pathName": "pack-book/pages/book/b_info",  
132 - "query": "year=2018&date=08-23&time=18:30",  
133 - "scene": "1001"  
134 - },  
135 - {  
136 - "id": 11,  
137 "name": "pages/customer/remind", 130 "name": "pages/customer/remind",
138 "pathName": "pages/customer/remind", 131 "pathName": "pages/customer/remind",
139 "query": "id=21&rdate=153745200", 132 "query": "id=21&rdate=153745200",
@@ -197,11 +190,11 @@ @@ -197,11 +190,11 @@
197 "scene": 1001 190 "scene": 1001
198 }, 191 },
199 { 192 {
200 - "id": -1, 193 + "id": 17,
201 "name": "pages/reserve/index 在线订座", 194 "name": "pages/reserve/index 在线订座",
202 "pathName": "pages/reserve/index", 195 "pathName": "pages/reserve/index",
203 - "query": "",  
204 - "scene": "1044", 196 + "query": "a=b&c=d",
  197 + "scene": 1044,
205 "shareInfo": { 198 "shareInfo": {
206 "groupName": "测试模拟群1", 199 "groupName": "测试模拟群1",
207 "shareName": "8DEbIRpK4pa9mH_QY2vU4ZUKYPuI97WoQ4BQoFej-Q8@cr4dev", 200 "shareName": "8DEbIRpK4pa9mH_QY2vU4ZUKYPuI97WoQ4BQoFej-Q8@cr4dev",
1 -var util = require('util.js')  
2 -var uri=require('uri.js')  
3 -module.exports = {  
4 - onShareAppMessage:function() {  
5 - var token=util.cache(uri.CACHE__TOKEN);  
6 - if(!token) {  
7 - wx.navigateTo({  
8 - url:"/pages/login/index"  
9 - });  
10 -  
11 - }else{  
12 - console.log("this.data.share_xcx_url",this.data.share_xcx_url)  
13 - this.sharecallback();  
14 - return {  
15 - title: this.data.share_xcx_name?this.data.share_xcx_name:(this.data.share_xcx_title?this.data.share_xcx_title:'纳极,最懂你的店铺管家'),  
16 - desc: this.data.share_xcx_desc?this.data.share_xcx_desc:'',  
17 - path: this.data.share_xcx_url?this.data.share_xcx_url:'/pages/index/index',  
18 - }  
19 - }  
20 - },  
21 - sharecallback:function(){  
22 - util.post(uri.CGI__ASYN_TOURIST_OPRRATION,{provider_id:this.data.provider_id,type:this.data.sharetype},uri.CGI__ASYN_TOURIST_OPRRATION__CODE);  
23 - },  
24 - onRefresh:function(){  
25 - this.setData({  
26 - refreshpage:true  
27 - })  
28 - var pageinfo=getCurrentPages();  
29 - var pagelength=pageinfo.length;  
30 - var n_pageinfo=pageinfo[pagelength-1];  
31 - var turnpage='/'+n_pageinfo.route;  
32 - if(JSON.stringify(n_pageinfo.options)!='{}'){  
33 - turnpage+='?';  
34 - for(var opt in n_pageinfo.options){  
35 - turnpage+=opt+'='+n_pageinfo.options[opt]+'&';  
36 - }  
37 - }  
38 - wx.redirectTo({  
39 - url: turnpage,  
40 - })  
41 - },  
42 - restartLogin:function(){  
43 - console.log('hahah');  
44 - var pages = getCurrentPages();  
45 - var num = pages.length;  
46 - console.log('hahah');  
47 - wx.openSetting({  
48 - success: (res) => {  
49 - console.log('openSetting',res);  
50 - res.authSetting = {  
51 - "scope.userInfo": true,  
52 - "scope.userLocation": true  
53 - }  
54 - /*wx.redirectTo({  
55 - url:'/pages/index/s_index',  
56 - })*/  
57 - wx.redirectTo({  
58 - url:'../index/s_index',  
59 - })  
60 - },  
61 - fail:(res) => {  
62 - console.log('failsetting');  
63 - wx.redirectTo({  
64 - url:'../me/s_index',  
65 - })  
66 - }  
67 - })  
68 - },  
69 -};  
1 -var uri=require('uri.js') 1 +var uri = require('uri.js')
2 2
3 -function formatTime(date,type,connect) {  
4 - var year = date.getFullYear()  
5 - var month = date.getMonth() + 1  
6 - var day = date.getDate() 3 +function formatTime(date, type, connect) {
  4 + var year = date.getFullYear()
  5 + var month = date.getMonth() + 1
  6 + var day = date.getDate()
7 7
8 - var hour = date.getHours()  
9 - var minute = date.getMinutes()  
10 - var second = date.getSeconds()  
11 - if(type==1){  
12 - if(connect){  
13 - return [year, month, day].map(formatNumber).join(connect)  
14 - }else{  
15 - return [year, month, day].map(formatNumber).join('/')  
16 - }  
17 - }else if(type==2){  
18 - return [month, day].map(formatNumber).join('/')  
19 - }else{  
20 - return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') 8 + var hour = date.getHours()
  9 + var minute = date.getMinutes()
  10 + var second = date.getSeconds()
  11 + if (type == 1) {
  12 + if (connect) {
  13 + return [year, month, day].map(formatNumber).join(connect)
  14 + } else {
  15 + return [year, month, day].map(formatNumber).join('/')
21 } 16 }
  17 + } else if (type == 2) {
  18 + return [month, day].map(formatNumber).join('/')
  19 + } else {
  20 + return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
  21 + }
22 22
23 } 23 }
  24 +
24 function formatNumber(n) { 25 function formatNumber(n) {
25 - n = n.toString()  
26 - return n[1] ? n : '0' + n 26 + n = n.toString()
  27 + return n[1] ? n : '0' + n
27 } 28 }
  29 +
28 //时间戳转为时间 30 //时间戳转为时间
29 -function unixtoTime(ns,format='') {  
30 - var result;  
31 - var time = new Date(ns*1000);  
32 - //result=format || 'YYYY年MM月DD日 HH时II分SS秒 WW';  
33 - result=format || 'YYYY年MM月DD日 HH时II分SS秒';  
34 - //console.log(format);  
35 - result=result.toUpperCase();  
36 - result=result.replace('YYYY',time.getFullYear());  
37 - var m=time.getMonth()+1;  
38 - result=result.replace('MM',m>9?m:"0"+m);  
39 - var d=time.getDate();  
40 - result=result.replace('DD',d>9?d:'0'+d);  
41 - var hh=time.getHours();  
42 - result=result.replace('HH',hh>9?hh:'0'+hh);  
43 - var ii=time.getMinutes();  
44 - result=result.replace('II',ii>9?ii:'0'+ii);  
45 - var ss=time.getSeconds();  
46 - result=result.replace('SS',ss>9?ss:'0'+ss);  
47 - var week;  
48 - switch (time.getDay()) {  
49 - case 0:week="日";break  
50 - case 1:week="一";break  
51 - case 2:week="二";break  
52 - case 3:week="三";break  
53 - case 4:week="四";break  
54 - case 5:week="五";break  
55 - case 6:week="六";break  
56 - }  
57 - result=result.replace('WW',week);  
58 - if(format.indexOf('DAY')>0){  
59 - // 获取当天 0 点的时间戳  
60 - var timeStamp = new Date(new Date().setHours(0, 0, 0, 0)) / 1000; 31 +function unixtoTime(ns, format = '') {
  32 + var result;
  33 + var time = new Date(ns * 1000);
  34 + //result=format || 'YYYY年MM月DD日 HH时II分SS秒 WW';
  35 + result = format || 'YYYY年MM月DD日 HH时II分SS秒';
  36 + //console.log(format);
  37 + result = result.toUpperCase();
  38 + result = result.replace('YYYY', time.getFullYear());
  39 + var m = time.getMonth() + 1;
  40 + result = result.replace('MM', m > 9 ? m : "0" + m);
  41 + var d = time.getDate();
  42 + result = result.replace('DD', d > 9 ? d : '0' + d);
  43 + var hh = time.getHours();
  44 + result = result.replace('HH', hh > 9 ? hh : '0' + hh);
  45 + var ii = time.getMinutes();
  46 + result = result.replace('II', ii > 9 ? ii : '0' + ii);
  47 + var ss = time.getSeconds();
  48 + result = result.replace('SS', ss > 9 ? ss : '0' + ss);
  49 + var week;
  50 + switch (time.getDay()) {
  51 + case 0:
  52 + week = "日";
  53 + break
  54 + case 1:
  55 + week = "一";
  56 + break
  57 + case 2:
  58 + week = "二";
  59 + break
  60 + case 3:
  61 + week = "三";
  62 + break
  63 + case 4:
  64 + week = "四";
  65 + break
  66 + case 5:
  67 + week = "五";
  68 + break
  69 + case 6:
  70 + week = "六";
  71 + break
  72 + }
  73 + result = result.replace('WW', week);
  74 + if (format.indexOf('DAY') > 0) {
  75 + // 获取当天 0 点的时间戳
  76 + var timeStamp = new Date(new Date().setHours(0, 0, 0, 0)) / 1000;
61 77
62 - var day1 = timeStamp+86400//今天结束  
63 - var day2 = day1+86400//明天结束 78 + var day1 = timeStamp + 86400//今天结束
  79 + var day2 = day1 + 86400//明天结束
64 80
65 - //console.log('ns<day.getTime()',timeStamp,ns,day1,day2) 81 + //console.log('ns<day.getTime()',timeStamp,ns,day1,day2)
66 82
67 - if(ns>=timeStamp && ns<day1){  
68 - result=result.replace('DAY','今天');  
69 - }else{  
70 - if(ns>=day1 && ns<day2){  
71 - result=result.replace('DAY','明天');  
72 - }else{  
73 - result=result.replace('DAY','');  
74 - }  
75 - }  
76 - }  
77 - if(format.indexOf('`')>-1){  
78 - result=result.replace(/`(.*)\/(.*)`/ig,function($0,$1,$2){  
79 - return $1||$2;  
80 - }); 83 + if (ns >= timeStamp && ns < day1) {
  84 + result = result.replace('DAY', '今天');
  85 + } else {
  86 + if (ns >= day1 && ns < day2) {
  87 + result = result.replace('DAY', '明天');
  88 + } else {
  89 + result = result.replace('DAY', '');
  90 + }
81 } 91 }
82 - return result; 92 + }
  93 + if (format.indexOf('`') > -1) {
  94 + result = result.replace(/`(.*)\/(.*)`/ig, function ($0, $1, $2) {
  95 + return $1 || $2;
  96 + });
  97 + }
  98 + return result;
83 } 99 }
84 100
85 //时间转为时间戳 101 //时间转为时间戳
86 -function timetouUnix(dasr,connect)  
87 -{  
88 - if(connect){  
89 - var newstr = dasr.replace(/-/g,connect);  
90 - }else{  
91 - var newstr = dasr.replace(/-/g,'/');  
92 - } 102 +function timetouUnix(dasr, connect) {
  103 + if (connect) {
  104 + var newstr = dasr.replace(/-/g, connect);
  105 + } else {
  106 + var newstr = dasr.replace(/-/g, '/');
  107 + }
93 108
94 - var date = new Date(newstr);  
95 - var time_str = date.getTime().toString();  
96 - return time_str.substr(0, 10); 109 + var date = new Date(newstr);
  110 + var time_str = date.getTime().toString();
  111 + return time_str.substr(0, 10);
97 } 112 }
98 113
99 -//支付  
100 -function orderPay(charge){  
101 - var that=this;  
102 - console.log(charge);  
103 - var obj = JSON.parse(charge)  
104 - console.log('obj:',obj);  
105 - wx.requestPayment({  
106 - 'timeStamp': obj.timeStamp,  
107 - 'nonceStr': obj.nonceStr,  
108 - 'package': obj.package,  
109 - 'signType': 'MD5',  
110 - 'paySign': obj.paySign,  
111 - 'success':function(res){  
112 - console.log('success:',res);  
113 - },  
114 - 'fail':function(res){  
115 - console.log('fail:',res); 114 +module.exports = {
  115 + formatTime: formatTime,
  116 + unixtoTime: unixtoTime,
  117 + timetouUnix: timetouUnix,
  118 + cgi: function (act) {
  119 + return uri.HOST__LINE + act //正式
  120 + //return uri.HOST__TEST+act //测试
  121 + },
  122 + wxApiIsUse: function (api) {
  123 + if (wx.canIUse(api)) {
  124 + return true;
  125 + } else {
  126 + this.alert('当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。');
  127 + }
  128 + },
  129 + openXcx: function (data) {
  130 + if (this.wxApiIsUse('navigateToMiniProgram')) {
  131 + wx.navigateToMiniProgram({
  132 + appId: data.appId,
  133 + path: data.path,
  134 + extraData: {
  135 + foo: 'bar'
116 }, 136 },
117 - 'complete':function(res){  
118 - 137 + envVersion: 'trial',
  138 + //envVersion: '',
  139 + success(res) {
  140 + // 打开成功
119 } 141 }
  142 + })
  143 + }
  144 + },
  145 + loading: function (flag) {
  146 + if (flag == 'clear' || flag == "clean") {
  147 + wx.hideNavigationBarLoading();
  148 + return;
  149 + }
  150 + wx.showNavigationBarLoading();
  151 + },
  152 + alert: function (msg, success, cancel, title) {
  153 + wx.showModal({
  154 + title: title ? title : "提示信息",
  155 + content: msg,
  156 + showCancel: typeof cancel == 'undefined' ? false : true,
  157 + success: function (res) {
  158 + if (res.confirm) {
  159 + if (success) success();
  160 + } else {
  161 + if (cancel) cancel();
  162 + }
  163 + }
  164 + });
  165 + },
  166 + toast: function (title, icon = 'success') {
  167 + wx.showToast({
  168 + title: title,
  169 + icon: icon
  170 + })
  171 + },
  172 + showLoading: function (title) {
  173 + wx.showLoading({
  174 + title: '加载中',
120 }) 175 })
121 -}  
122 -module.exports = {  
123 - formatTime: formatTime,  
124 - unixtoTime:unixtoTime,  
125 - timetouUnix:timetouUnix,  
126 - orderPay:orderPay,  
127 - cgi:function(act){  
128 - return uri.HOST__LINE+act //正式  
129 - //return uri.HOST__TEST+act //测试  
130 - },  
131 - wxApiIsUse:function(api){  
132 - if(wx.canIUse(api)){  
133 - return true;  
134 - }else{  
135 - this.alert('当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。');  
136 - }  
137 - },  
138 - openXcx:function(data){  
139 - if(this.wxApiIsUse('navigateToMiniProgram')){  
140 - wx.navigateToMiniProgram({  
141 - appId: data.appId,  
142 - path: data.path,  
143 - extraData: {  
144 - foo: 'bar'  
145 - },  
146 - envVersion: 'trial',  
147 - //envVersion: '',  
148 - success(res) {  
149 - // 打开成功  
150 - }  
151 - })  
152 - }  
153 - },  
154 - loading:function(flag){  
155 - if(flag=='clear' || flag=="clean"){  
156 - wx.hideNavigationBarLoading();  
157 - return;  
158 - }  
159 - wx.showNavigationBarLoading();  
160 - },  
161 - postSuccessFun:function(json,uri_code){  
162 - console.log("APP::postSuccessFun",uri_code,json);  
163 - },  
164 - postFailFun:function(json,uri_code){  
165 - console.log(json,uri_code);  
166 - },  
167 - getToken:function(n_function){  
168 - var token=this.cache(uri.CACHE__TOKEN);  
169 - console.log("token:",token);  
170 - if(!token) {  
171 - this.loginStart(n_function);  
172 - return;  
173 - }  
174 - return token;  
175 - },  
176 - asyn:function(act,data,uri_code,n_function){//静默方式,不带loading  
177 - data=data||{};  
178 - var that=this;  
179 - data.token=that.cache(uri.CACHE__TOKEN);  
180 - wx.request({  
181 - url: that.cgi(act),  
182 - method:'POST',  
183 - data: data,  
184 - header: {  
185 - 'content-type': 'application/x-www-form-urlencoded'  
186 - },  
187 - success: function(res) {  
188 - console.log('request==>',that.http_build_query(data,that.cgi(act))+'\nrequest.success',res.data);  
189 - that.loading('clear');  
190 - if(n_function){  
191 - that.loginStart(n_function);  
192 - }  
193 - /*if(typeof res.data!='string'){  
194 - if(res.data.code!=200&&res.data.code!=1000){  
195 - console.log(res.data.code==-1,res.data.code);  
196 - if(res.data.code==-1) {  
197 - that.loginStart(n_function);  
198 - return;  
199 - }else{  
200 - that.alert(res.data.message);  
201 - return;  
202 - }  
203 - }  
204 - }*/  
205 - that.postSuccessFun(res.data,uri_code);  
206 - },  
207 - fail: function(res) {  
208 - console.log('request==>',that.http_build_query(data,that.cgi(act))+'\nrequest.fail',res);  
209 - that.loading('clear');  
210 - that.toast(res.errMsg);  
211 - that.postFailFun(res.data,uri_code);  
212 - }  
213 - })  
214 - },  
215 - post:function(act,data,uri_code,is_load,n_function,header={'Content-Type': 'application/x-www-form-urlencoded'}){  
216 - console.log('act:',act)  
217 - if(is_load!='0'){  
218 - this.loading();  
219 - }  
220 - this.asyn(act,data,uri_code,n_function,header);  
221 - },  
222 - upload:function(filePath,fileIndex,uri_code,sellerid,type,file){  
223 - var that=this;  
224 - this.loading();  
225 - if(this.wxApiIsUse('uploadFile')){  
226 - wx.uploadFile({  
227 - url: that.cgi('Seller/Index/UploadImages'),  
228 - filePath: filePath,  
229 - name: 'file',  
230 - formData:{  
231 - sellerid:sellerid,  
232 - type:type  
233 - },  
234 - success: function(res){  
235 - that.loading('clear');  
236 - that.postSuccessFun(res.data,uri_code,fileIndex);  
237 - },  
238 - fail: function(res) {  
239 - that.loading('clear');  
240 - that.toast("上传失败,请重试");  
241 - that.postFailFun(res.data,uri_code,fileIndex);  
242 - }  
243 - });  
244 - }  
245 - },  
246 -  
247 - uploading:function(filePath,fileIndex,dir,uri_code,file){  
248 - var that=this;  
249 - this.loading();  
250 -  
251 - console.log(filePath,fileIndex,dir,uri_code);  
252 -  
253 - if(this.wxApiIsUse('uploadFile')){  
254 - wx.uploadFile({  
255 - url: 'https://xt05.colorcun.com/?s=App.Cookbook.UpLoadFile',  
256 - filePath: filePath,  
257 - name: 'file',  
258 - formData:{  
259 - dir:dir  
260 - },  
261 - success: function(res){  
262 - console.log('上传成功')  
263 - console.log(res)  
264 - that.loading('clear');  
265 - that.postSuccessFun(res.data,uri_code,fileIndex);  
266 - },  
267 - fail: function(res) {  
268 -  
269 - that.toast("上传失败,请重试");  
270 - that.postFailFun(res.data,uri_code,fileIndex);  
271 - }  
272 - });  
273 - }  
274 - },  
275 -  
276 - uploadImg:function(filePath,fileIndex,uri_code){  
277 - var that=this;  
278 - if(this.wxApiIsUse('uploadFile')){  
279 - wx.uploadFile({  
280 - url: that.cgi('bargainimage'),  
281 - filePath: filePath,  
282 - name: 'path',  
283 - formData:{  
284 - 'token': that.getToken()  
285 - },  
286 - success: function(res){  
287 - console.log(res);  
288 - res.data=JSON.parse(res.data);  
289 - if(res.data.code!=200){  
290 - if(res.data.code==-1) {  
291 - wx.navigateTo({url:'/pages/login/index'});  
292 - return;  
293 - }else{  
294 - that.alert(res.data.message);  
295 - }  
296 - }  
297 - console.log("res-code-data",uri_code,res.data);  
298 - that.postSuccessFun(res.data,uri_code,fileIndex);  
299 - },  
300 - fail:function(res){  
301 - console.log(res);  
302 - }  
303 - });  
304 - }  
305 - },  
306 - download:function(id,uri_code,width){  
307 - var that=this;  
308 - this.loading();  
309 - if(this.wxApiIsUse('downloadFile')){  
310 - wx.downloadFile({  
311 - url: that.cgi('download'),  
312 - success: function(res) {  
313 - console.log("res-code-data",uri_code,res);  
314 - wx.playVoice({  
315 - filePath: res.tempFilePath  
316 - })  
317 - that.postSuccessFun(id,uri_code,width,res.data);  
318 - }  
319 - });  
320 - }  
321 - },  
322 - alert:function(msg,success,cancel,title){  
323 - wx.showModal({  
324 - title:title?title:"提示信息",  
325 - content:msg,  
326 - showCancel:typeof cancel=='undefined'?false:true,  
327 - success:function(res){  
328 - if(res.confirm){  
329 - if(success) success();  
330 - }else{  
331 - if(cancel) cancel();  
332 - }  
333 - }  
334 - });  
335 - },  
336 - toast:function(title,icon='success'){  
337 - wx.showToast({  
338 - title:title,  
339 - icon:icon  
340 - })  
341 - },  
342 - showLoading:function(title){  
343 - wx.showLoading({  
344 - title: '加载中',  
345 - })  
346 -  
347 - },  
348 - getCommonType:function(key){  
349 - var that=this;  
350 - var common = that.cache(uri.CACHE__COMMON) || {time:0};  
351 - var time=Date.now();  
352 - if(common.time<time-600000){  
353 - wx.request({  
354 - url: that.cgi('commontype'),  
355 - header: {  
356 - 'Content-Type': 'application/json'  
357 - },  
358 - success: function(res) {  
359 - if(res.data.code==200){  
360 - common={data:res.data.data,time:time};  
361 - //wx.setStorageSync(uri.CACHE__COMMON,common);  
362 - that.cache(uri.CACHE__COMMON,common)  
363 - }  
364 - }  
365 - })  
366 - }  
367 - if(!key) return common.data;  
368 - common = that.cache(uri.CACHE__COMMON) || {time:0};  
369 - return common.data[key];  
370 - },  
371 - getCommonTag:function(key,v_id){  
372 - var that=this;  
373 - var tagsdata=this.cache(uri.CACHE__COMMONTAG);  
374 - if(!tagsdata){  
375 -  
376 - wx.request({  
377 - url: that.cgi(uri.CGI__USER_TCOMMONTAG),  
378 - data:{  
379 - 'token': that.getToken()  
380 - },  
381 - header: {  
382 - 'Content-Type': 'application/json'  
383 - },  
384 - success: function(res) {  
385 - if(res.data.code==200){  
386 - that.cache(uri.CACHE__COMMONTAG,res.data.data);  
387 - }  
388 - }  
389 - })  
390 - }  
391 - tagsdata=this.cache(uri.CACHE__COMMONTAG);  
392 - var result;  
393 - if(v_id){  
394 - tagsdata[key].map(function(v){  
395 - if(v.id==v_id){  
396 - result=v.tag_name;  
397 - }  
398 - })  
399 - }else{  
400 - result=tagsdata[key];  
401 - }  
402 - return result;  
403 - },  
404 - cache:function(key,value){  
405 - if(value){  
406 - wx.setStorageSync(key,value);  
407 - }  
408 - return wx.getStorageSync(key);  
409 - },  
410 - remove:function(key){  
411 - if(key){  
412 - wx.removeStorage({key: key})  
413 - }  
414 - },  
415 - image:function(id,width=""){  
416 - var url=this.cgi(uri.CGI__DOWNLOAD+'/id/'+id);  
417 - if(width){  
418 - url+='/width/'+width;  
419 - }  
420 - return url;  
421 - },  
422 -  
423 - avatar:function(id,t='pu'){  
424 - return this.cgi(uri.CGI__AVATAR +'/'+t+'/'+id);  
425 - },  
426 - trim:function(str){  
427 - return str.replace(/^([ ]+)/,"").replace(/([ ]+)$/,"");  
428 - },  
429 - clear:function(str){//去除html标签  
430 - return this.trim(str.replace(/<[^>]+>/ig,""));  
431 - },  
432 - clearHtml:function(html){//去除html中特殊字符  
433 - html=html.replace(/[\n\r\t]+/ig,'');  
434 - html=html.replace(/<html[^>]*>(.*)<body[^>]*>/ig,'');  
435 - html=html.replace(/<div[^>]*>(.*)<article[^>]*>/ig,'');  
436 - html=html.replace(/<\/article[^>]*>(.*)<\/div[^>]*>/ig,'');  
437 - html=html.replace(/<style[^>]*>(.*)<\/style>/ig,'');  
438 - html=html.replace(/<\/body.*/ig,'');  
439 - html=html.replace(/<!--[^>]+>/ig,'');  
440 - html=html.replace(/&quot;/ig,'');  
441 - return html;  
442 - },  
443 - val:function(e,key=''){  
444 - if(key!='') return e.detail.value[key]||'';  
445 - return e.detail.value;  
446 - },  
447 - attr:function(e,key=''){  
448 - if(!key){  
449 - return e.currentTarget.dataset  
450 - }  
451 - return e.currentTarget.dataset[key];  
452 - },  
453 - extend:function(destination, source) {  
454 - for (var property in source) {  
455 - destination[property] = source[property];  
456 - }  
457 - return destination;  
458 - },  
459 - getToken:function(n_function){  
460 - var token=this.cache(uri.CACHE__TOKEN);  
461 - console.log("token:",token);  
462 - if(!token) {  
463 - this.loginStart(n_function);  
464 - return;  
465 - }  
466 - return token;  
467 - },  
468 - loginStart:function(n_function){  
469 - console.log("n_function:",n_function,1111);  
470 - var that=this;  
471 - wx.login({  
472 - success: function(login_res) {  
473 - if (login_res.code) {  
474 - console.log('success');  
475 - console.log('wx.login.res' , login_res);  
476 - that.cache(uri.CACHE__LOGINCODE,login_res.code);  
477 - wx.getUserInfo({  
478 - success: function(res) {  
479 - res.code=login_res.code;  
480 - console.log('wx.getProviderInfo.res' , res);  
481 - var data={  
482 - code:login_res.code,  
483 - encryptData:res.encryptData,  
484 - encryptedData:res.encryptedData,  
485 - iv:res.iv,  
486 - rawData:res.rawData,  
487 - signature:res.signature,  
488 - appid:'wxc359908817c7bdd9',  
489 - secret:'a14a8415a501ade9542968d8a6504820',  
490 - }  
491 - wx.request({  
492 - url: that.cgi(uri.CGI__USER_XCXLOGIN),  
493 - data: data,  
494 - header: {  
495 - 'content-type': 'application/json'  
496 - },  
497 - success: function(res) {  
498 - that.cache('setting','success');  
499 - that.cache(uri.CACHE__LOGINCODE,login_res.code);  
500 - /*if(n_function){  
501 - var pagelength=getCurrentPages().length;  
502 - console.log("pagelength:",pagelength);  
503 - console.log("getCurrentPages:",getCurrentPages());  
504 - if(typeof getCurrentPages()[pagelength-1][n_function]()!='undefined'){  
505 - getCurrentPages()[pagelength-1][n_function]();  
506 - }  
507 - }*/  
508 - return;  
509 - }  
510 - })  
511 - },  
512 - fail:function(){  
513 - that.cache('loginfail','fail');  
514 - if(n_function){  
515 - var pagelength=getCurrentPages().length;  
516 - console.log('hahahah');  
517 - getCurrentPages()[pagelength-1].onShow();  
518 - }  
519 - }  
520 - });  
521 - } else {  
522 - console.log('获取用户登录态失败!' + res.errMsg)  
523 - }  
524 - }  
525 - });  
526 - },  
527 - //重新调起授权  
528 - userInfoHandler:function(etarget){  
529 - if(this.wxApiIsUse('button.open-type.getUserInfo')){  
530 - if(etarget.detail&& etarget.detail.errMsg=='getUserInfo:ok'){  
531 - return true  
532 - //this.dc_loginStart()  
533 - }  
534 - }  
535 - },  
536 -  
537 - getAccess_token: function (a, s, n_tempmessage) {  
538 - var that = this;  
539 - wx.request({  
540 - url: 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' + a + '&secret=' + s, //仅为示例,并非真实的接口地址  
541 - header: {  
542 - 'content-type': 'application/json'  
543 - },  
544 - success: function (res) {  
545 - console.log('access_token!!!!console:', res)  
546 - console.log('access_token:', res.data.access_token)  
547 - that.sendMessage(res.data.access_token, n_tempmessage);  
548 - }  
549 - })  
550 - },  
551 - //模板消息  
552 - sendMessage: function (a_t, dd) {  
553 - var that = this;  
554 - wx.request({  
555 - url: 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=' + a_t, //仅为示例,并非真实的接口地址  
556 - data: dd,  
557 - method: 'POST',  
558 - header: {  
559 - 'content-type': 'application/json'  
560 - },  
561 - success: function (res) {  
562 - console.log('发送模板消息:',res)  
563 - //that.sendMessuc(res);  
564 - }  
565 - })  
566 - },  
567 - //获取当前网络状态  
568 - getNetwork:function(){  
569 - var that=this;  
570 - if(this.wxApiIsUse('getNetworkType')){  
571 - wx.getNetworkType({  
572 - success: function(res) {  
573 - that.getNetworkSuccess(res.networkType);  
574 - },  
575 - fail:function(res){  
576 - that.toast('获取网络状况失败!');  
577 - }  
578 - })  
579 - }  
580 - },  
581 - getNetworkSuccess:function(network){  
582 - return network;  
583 - },  
584 - compare:function(property){  
585 - return function(a,b){  
586 - var value1 = a[property];  
587 - var value2 = b[property];  
588 - return value1 - value2;  
589 - }  
590 - },  
591 - getJsonLength:function(jsonData){  
592 - var jsonLength = 0;  
593 - for(var item in jsonData){  
594 - jsonLength++;  
595 - }  
596 - return jsonLength;  
597 - },  
598 - testPhone:function(phone){  
599 - if(!/^1[3-9][0-9]{9}$/.test(phone)){  
600 - this.alert("请输入正确的电话号码");  
601 - return false;  
602 - }  
603 - },  
604 - //加入卡包  
605 - addInCard:function(sellerid){  
606 - var that = this;  
607 - wx.request({  
608 - url: that.cgi(uri.CGI__USER_GETSIGNOPENCARD),  
609 - method:'GET',  
610 - header: {  
611 - 'content-type': 'application/x-www-form-urlencoded'  
612 - },  
613 - data:{  
614 - sellerid:1,  
615 - },  
616 - success: function(res) {  
617 - console.log(res)  
618 - var cardExtstr = res.data.data.cardExt  
619 - var cardId = res.data.data.cardid  
620 - console.log('cardExtstr:',cardExtstr);  
621 - wx.addCard({  
622 - cardList: [  
623 - {  
624 - cardId: cardId,  
625 - cardExt: cardExtstr,  
626 - }  
627 - ],  
628 - success: function(res) {  
629 - console.log('success:',res)  
630 - that.cache('cardList',res.cardList);  
631 - },  
632 - fail:function(res) {  
633 - console.log('fail:',res)  
634 - },  
635 - })  
636 - }  
637 - })  
638 - },  
639 - //保存图片  
640 - saveImage: function(url){  
641 - var that = this;  
642 - wx.downloadFile({  
643 - url:url,  
644 - success:function(res){  
645 - var path = res.tempFilePath  
646 - wx.saveImageToPhotosAlbum({  
647 - filePath: path,  
648 - success(res) {  
649 -  
650 - },  
651 - //保存图片重新授权  
652 - fail(res) {  
653 - wx.openSetting({  
654 - success: (res) => {  
655 - res.authSetting = {  
656 - "scope.writePhotosAlbum": true  
657 - }  
658 - }  
659 - })  
660 - },  
661 - })  
662 - },  
663 - fail:function(res){  
664 176
665 - }  
666 - })  
667 - },  
668 - //根据source判断会员卡1 或优惠券2  
669 - sourceFrom:function(){  
670 - var source = this.cache('source')  
671 - console.log('source:',source)  
672 - var title = ''  
673 - if(source==1){  
674 - title = '会员卡'  
675 - }else{  
676 - title = '优惠券'  
677 - }  
678 - wx.setNavigationBarTitle({  
679 - title:title  
680 - })  
681 - return source  
682 - },  
683 - //返回会员卡 优惠券的开通进度  
684 - stepSetting:function(stepnum){  
685 - var source = this.cache('source')  
686 - var step = {  
687 - content:['会员卡开通','会员卡设置','发放确认','发放完成'],  
688 - step:[{id:'0'},{id:'1'},{id:'2'},{id:'3'}],  
689 - stepnum:stepnum  
690 - }  
691 - if(step&&source==2){  
692 - step.content[0] = '优惠券开通'  
693 - step.content[1] = '优惠券设置'  
694 - }  
695 - return step  
696 - },  
697 - setBarTitle:function(title){  
698 - wx.setNavigationBarTitle({  
699 - title:title  
700 - })  
701 - },  
702 - //小数规则:小数只能存在一个小数点并且至多保留两位小数 数字首位可以为0 第二位不能为0  
703 - limitDigit:function(value,firsezero){  
704 - if(value.length==1&value=='.'){  
705 - value = '0'+'.'  
706 - }  
707 - if(value=='00'){  
708 - value = '0'  
709 - }  
710 - value = value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的  
711 - value = value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");  
712 - value = value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数  
713 - //firsezero存在 首位不能为0  
714 - if(firsezero){  
715 - if(value.indexOf(".")< 0 && value !=""){//以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额  
716 - value= parseFloat(value);  
717 - }  
718 - }  
719 - return value  
720 - }, 177 + },
  178 + cache: function (key, value) {
  179 + if (value) {
  180 + wx.setStorageSync(key, value);
  181 + }
  182 + return wx.getStorageSync(key);
  183 + },
  184 + remove: function (key) {
  185 + if (key) {
  186 + wx.removeStorage({key: key})
  187 + }
  188 + },
  189 + image: function (id, width = "") {
  190 + var url = this.cgi(uri.CGI__DOWNLOAD + '/id/' + id);
  191 + if (width) {
  192 + url += '/width/' + width;
  193 + }
  194 + return url;
  195 + },
721 196
722 - //  
723 - isEOne : function(arr,value){  
724 - for(var i = 0,vlen = arr.length; i < vlen; i++){  
725 - if(arr[i] == value){  
726 - return i;  
727 - }  
728 - }  
729 - return -1;  
730 - },  
731 - linkTo:function(url,sellerid,code){  
732 - var path='pages/menu/'+url;  
733 - if(code!=''){  
734 - path+='?sellerid='+sellerid+'&code='+code  
735 - }  
736 - if(sellerid!=''){  
737 - path+='?sellerid='+sellerid  
738 - } 197 + avatar: function (id, t = 'pu') {
  198 + return this.cgi(uri.CGI__AVATAR + '/' + t + '/' + id);
  199 + },
  200 + trim: function (str) {
  201 + return str.replace(/^([ ]+)/, "").replace(/([ ]+)$/, "");
  202 + },
  203 + clear: function (str) {//去除html标签
  204 + return this.trim(str.replace(/<[^>]+>/ig, ""));
  205 + },
  206 + val: function (e, key = '') {
  207 + if (key != '') return e.detail.value[key] || '';
  208 + return e.detail.value;
  209 + },
  210 + attr: function (e, key = '') {
  211 + if (!key) {
  212 + return e.currentTarget.dataset
  213 + }
  214 + return e.currentTarget.dataset[key];
  215 + },
  216 + extend: function (destination, source) {
  217 + for (var property in source) {
  218 + destination[property] = source[property];
  219 + }
  220 + return destination;
  221 + },
  222 + compare: function (property) {
  223 + return function (a, b) {
  224 + var value1 = a[property];
  225 + var value2 = b[property];
  226 + return value1 - value2;
  227 + }
  228 + },
  229 + getJsonLength: function (jsonData) {
  230 + var jsonLength = 0;
  231 + for (var item in jsonData) {
  232 + jsonLength++;
  233 + }
  234 + return jsonLength;
  235 + },
  236 + testPhone: function (phone) {
  237 + if (!/^1[3-9][0-9]{9}$/.test(phone)) {
  238 + this.alert("请输入正确的电话号码");
  239 + return false;
  240 + }
  241 + },
  242 + setBarTitle: function (title) {
  243 + wx.setNavigationBarTitle({
  244 + title: title
  245 + })
  246 + },
  247 + //
  248 + isEOne: function (arr, value) {
  249 + for (var i = 0, vlen = arr.length; i < vlen; i++) {
  250 + if (arr[i] == value) {
  251 + return i;
  252 + }
  253 + }
  254 + return -1;
  255 + },
  256 + linkTo: function (url, sellerid, code) {
  257 + var path = 'pages/menu/' + url;
  258 + if (code != '') {
  259 + path += '?sellerid=' + sellerid + '&code=' + code
  260 + }
  261 + if (sellerid != '') {
  262 + path += '?sellerid=' + sellerid
  263 + }
  264 + console.log(path)
  265 + wx.navigateToMiniProgram({
  266 + appId: 'wx52646daaa3f42a4f',
  267 + path: path,
  268 + envVersion: 'release',
  269 + success: function (res) {
739 console.log(path) 270 console.log(path)
740 - wx.navigateToMiniProgram({  
741 - appId: 'wx52646daaa3f42a4f',  
742 - path: path,  
743 - envVersion: 'release',  
744 - success:function(res) {  
745 - console.log(path)  
746 - }  
747 - })  
748 - },  
749 - setting:function(){  
750 - if(wx.canIUse('openSetting')==true){  
751 - wx.openSetting({  
752 - success:function(res){  
753 - console.log(res.authSetting)  
754 - return res.authSetting  
755 - }  
756 - })  
757 - }  
758 - },  
759 - //获取设备信息  
760 - getsystem:function(){  
761 - try {  
762 - var res = wx.getSystemInfoSync()  
763 - return res;  
764 - } catch (e) {  
765 - return false  
766 - }  
767 - },  
768 - http_build_query(obj,url=''){  
769 - let ps=[]  
770 - for(let i in obj){  
771 - if(typeof obj[i]=='undefined' || obj[i]==null || obj[i]===false) continue;  
772 - ps.push(i+'='+obj[i].toString())  
773 - }  
774 - ps=ps.join('&');  
775 - if(!url){  
776 - return ps;  
777 - }  
778 - url+=(url.indexOf('?')>-1?'&':'?')+ps;  
779 - return url; 271 + }
  272 + })
  273 + },
  274 + setting: function () {
  275 + if (wx.canIUse('openSetting') == true) {
  276 + wx.openSetting({
  277 + success: function (res) {
  278 + console.log(res.authSetting)
  279 + return res.authSetting
  280 + }
  281 + })
  282 + }
  283 + },
  284 + //获取设备信息
  285 + getsystem: function () {
  286 + try {
  287 + var res = wx.getSystemInfoSync()
  288 + return res;
  289 + } catch (e) {
  290 + return false
  291 + }
  292 + },
  293 + http_build_query(obj, url = '') {
  294 + let ps = []
  295 + for (let i in obj) {
  296 + if (typeof obj[i] == 'undefined' || obj[i] == null || obj[i] === false) continue;
  297 + ps.push(i + '=' + obj[i].toString())
  298 + }
  299 + ps = ps.join('&');
  300 + if (!url) {
  301 + return ps;
  302 + }
  303 + if(ps){
  304 + url += (url.indexOf('?') > -1 ? '&' : '?') + ps;
780 } 305 }
  306 + return url;
  307 + },
  308 + /**
  309 + * @param edata is object: ename,edata
  310 + */
  311 + elog(edata,ename='EVENT_NAME') {
  312 + let key='EVENT_LOG_CACHE'
  313 + let ps=getCurrentPages();
  314 + console.log(ps)
  315 + let page=ps[ps.length-1]
  316 + edata=edata?edata:{}
  317 + edata.curPage={
  318 + path:page.route,
  319 + options:page.options,
  320 + }
  321 + let eobj={
  322 + ename:ename,
  323 + edata:edata,
  324 + page:this.http_build_query(page.options,page.route),
  325 + time:parseInt(new Date()/1000),
  326 + }
  327 + wx.getStorage({
  328 + key:key,
  329 + success:res=>{
  330 + let data=res.data||[]
  331 + data.push(eobj)
  332 + wx.setStorage({
  333 + key:key,
  334 + data:data,
  335 + })
  336 + },
  337 + fail:res=>{
  338 + let data=[eobj]
  339 + wx.setStorage({
  340 + key:key,
  341 + data:data,
  342 + })
  343 + },
  344 + })
  345 + },
781 } 346 }
782 347
783 348