s_detail.js
4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
var util = require('../../utils/util.js')
var uri = require('../../utils/uri.js')
Page({
data:{
reminder:''
},
onLoad:function(opt){
var seller_tel=opt.type=='phone' && opt.info!='' ? opt.info.split('/') : null;
var seller_tel1='',seller_tel2='';
if(opt.type=='phone' && opt.info!=''){
if(seller_tel && seller_tel.length>1){
seller_tel1=seller_tel[0];
seller_tel2=seller_tel[1]
}else{
seller_tel1=seller_tel[0];
}
}
this.setData({
opt:opt,
sellerid:util.cache('sellerid'),
// optdaily:opt.type=='daily_time' && opt.info!='' ? opt.info.split('-') : null,
seller_tel1:opt.type=='phone' ? seller_tel1 : null,
seller_tel2:opt.type=='phone' ? seller_tel2 : null,
})
// console.log(opt)
},
onShow:function () {
var that=this;
util.postSuccessFun=function(json,uri_code){
switch (uri_code) {
case uri.CGI__USER_SETSELLERBYID__CODE:
console.log(json)
if(json.ret==200){
wx.navigateBack()
}else{
that.setData({
reminder:json.msg.split(':')[1]
})
}
break;
}
}
},
inputphone:function(e){
// var RegExp = /^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/;
// if(util.strtrim(e.detail.value)!=''){
// if(!RegExp.test(util.strtrim(e.detail.value))){
// this.setData({
// reminder:'电话格式不正确或位数不正确'
// })
// }else{
// this.setData({
// reminder:''
// })
// }
// }
if(e.detail.value==''){
this.setData({
reminder:'请输入电话号码'
})
}else{
this.setData({
reminder:''
})
}
},
inputtime:function(e){
// var reg = /^(20|21|22|23|[0-1]\d):[0-5]\d$/;
// var regExp = new RegExp(reg);
if(e.detail.value!='' && util.strtrim(e.detail.value)!=''){
this.setData({
reminder:''
})
}else{
this.setData({
reminder:'请输入营业时间'
})
}
},
formSubmit:function(e){
var formdata={};
if(this.data.opt.type=='daily_time'){
console.log(e)
if(this.data.reminder==''){
formdata=e.detail.value;
formdata.id=this.data.sellerid;
util.post(uri.CGI__USER_SETSELLERBYID,formdata,uri.CGI__USER_SETSELLERBYID__CODE);
}
}else{
if(this.data.opt.type=='phone'){
if(this.data.reminder==''){
if(e.detail.value['seller_tel1']!='' || e.detail.value['seller_tel2']!=''){
var sellertel=[];
for(var key in e.detail.value){
if(e.detail.value[key]!=''){
sellertel.push(e.detail.value[key])
}
}
formdata.seller_tel=sellertel.toString();
formdata.id=this.data.sellerid;
util.post(uri.CGI__USER_SETSELLERBYID,formdata,uri.CGI__USER_SETSELLERBYID__CODE);
}else{
this.setData({
reminder:'请输入电话号码'
})
}
}
}else{
var type=this.data.opt.type;
console.log(type)
if(e.detail.value[type]!='' && util.strtrim(e.detail.value[type])!=''){
formdata[type]=util.strtrim(e.detail.value[type]);
formdata.id=this.data.sellerid;
console.log(formdata)
util.post(uri.CGI__USER_SETSELLERBYID,formdata,uri.CGI__USER_SETSELLERBYID__CODE);
}else{
this.setData({
reminder:'店铺'+this.data.opt.typeinfo+'不能为空'
})
}
}
}
},
netchange:function () {
this.onShow();
}
})