提交 | 用户 | age
|
234b22
|
1 |
import MyValidator from "../../utils/myValidator";
|
S |
2 |
let validatorInstance:MyValidator;
|
|
3 |
const app = getApp<IAppOption>();
|
|
4 |
Page({
|
|
5 |
data: {
|
aa6d80
|
6 |
region: [],
|
701f60
|
7 |
checked:false,
|
S |
8 |
telephone:'',
|
|
9 |
actualName:''
|
aa6d80
|
10 |
// customItem: '全部',
|
234b22
|
11 |
},
|
S |
12 |
onLoad() {
|
|
13 |
console.log(app);
|
aa6d80
|
14 |
console.log(wx.$utils);
|
S |
15 |
console.log(wx.$utils.formatTime(new Date()));
|
234b22
|
16 |
},
|
S |
17 |
onReady() {
|
|
18 |
this.initValidator()
|
aa6d80
|
19 |
},
|
S |
20 |
bindRegionChange(e:any) {
|
|
21 |
console.log('picker发送选择改变,携带值为', e.detail.value)
|
|
22 |
this.setData({
|
|
23 |
region: e.detail.value
|
|
24 |
})
|
|
25 |
},
|
|
26 |
onAgreeChange(event:any) {
|
|
27 |
console.log(event);
|
|
28 |
this.setData({
|
|
29 |
checked: event.detail,
|
|
30 |
});
|
234b22
|
31 |
},
|
S |
32 |
checkActualName(e:any){
|
|
33 |
let { value } = e.detail
|
|
34 |
console.log(e);
|
|
35 |
validatorInstance.checkField('actualName',value);
|
|
36 |
},
|
701f60
|
37 |
async getPhoneNumber(e:any){
|
a38dad
|
38 |
console.log('getPhoneNumber', e);
|
701f60
|
39 |
if (e.detail.errMsg == 'getPhoneNumber:ok') {
|
S |
40 |
let [error, result] = await wx.$utils.to(
|
|
41 |
wx.$http.request({
|
|
42 |
url:`/shopping/account.do?m=telRegByAutoReg`,
|
|
43 |
data:{
|
|
44 |
ReferralsCode: '',
|
|
45 |
ReferralsName: '',
|
|
46 |
encryptedData: e.detail.encryptedData,
|
|
47 |
iv: e.detail.iv,
|
|
48 |
}
|
|
49 |
})
|
|
50 |
)
|
|
51 |
if (error){
|
|
52 |
console.log(error);
|
|
53 |
return;
|
|
54 |
}
|
|
55 |
console.log(result);
|
|
56 |
this.setData({
|
|
57 |
telephone:result.Telephone,
|
|
58 |
phoneError:''
|
|
59 |
})
|
a38dad
|
60 |
} else{
|
S |
61 |
console.log('取消授权');
|
|
62 |
wx.showToast({
|
|
63 |
title: '取消授权',
|
|
64 |
icon: 'none',
|
|
65 |
duration: 1000
|
|
66 |
});
|
|
67 |
}
|
aa6d80
|
68 |
},
|
a38dad
|
69 |
// checkPhone(e:any){
|
S |
70 |
// let { value } = e.detail
|
|
71 |
// console.log(value);
|
|
72 |
// validatorInstance.checkField('phone',value);
|
|
73 |
// },
|
aa6d80
|
74 |
onSubmit(){
|
701f60
|
75 |
let {checked,region,telephone} = this.data;
|
aa6d80
|
76 |
let checkRegion = region.length < 1;
|
S |
77 |
console.log(checked,region);
|
|
78 |
if (checkRegion) {
|
701f60
|
79 |
wx.showToast({
|
S |
80 |
title: '请选择地区',
|
|
81 |
icon: 'none',
|
|
82 |
});
|
aa6d80
|
83 |
return;
|
S |
84 |
}
|
|
85 |
let checkAllData = validatorInstance.checkAllData();
|
|
86 |
// let checkArr = [checkRegion,checkChecked,checkAllData];
|
|
87 |
if (!checkAllData){
|
701f60
|
88 |
return;
|
S |
89 |
}
|
|
90 |
if (!telephone) {
|
|
91 |
this.setData({
|
|
92 |
phoneError:'请输入手机号'
|
|
93 |
})
|
|
94 |
return;
|
|
95 |
}
|
|
96 |
if (!checked){
|
|
97 |
console.log('请同意商家条款');
|
|
98 |
wx.showToast({
|
|
99 |
title: '请同意商家条款',
|
|
100 |
icon: 'none',
|
|
101 |
});
|
aa6d80
|
102 |
return;
|
S |
103 |
}
|
|
104 |
console.log('....提交成功');
|
701f60
|
105 |
this.postFormData();
|
S |
106 |
},
|
|
107 |
async postFormData(){
|
|
108 |
let {region,actualName,telephone} = this.data;
|
|
109 |
let [provinceName,cityName,countyName] = region;
|
|
110 |
let data = {
|
|
111 |
countryName:'中国',
|
|
112 |
provinceName,
|
|
113 |
cityName,
|
|
114 |
countyName,
|
|
115 |
actualName,
|
|
116 |
telephone
|
|
117 |
}
|
|
118 |
console.log(data);
|
|
119 |
let [error, result] = await wx.$utils.to(
|
|
120 |
wx.$http.request({
|
|
121 |
url:`/shopping/customerSignup.do?m=saveCustomerSignup`,
|
|
122 |
data,
|
|
123 |
method:'POST'
|
|
124 |
})
|
|
125 |
)
|
|
126 |
if (error){
|
|
127 |
console.log(error);
|
|
128 |
return;
|
|
129 |
}
|
|
130 |
console.log(result);
|
|
131 |
if (result.status=='success'){
|
282d69
|
132 |
await wx.$commonRequest.getUserInfo();
|
701f60
|
133 |
wx.navigateBack();
|
S |
134 |
}
|
234b22
|
135 |
},
|
S |
136 |
initValidator(){
|
|
137 |
// 实例化
|
|
138 |
validatorInstance = new MyValidator({
|
|
139 |
rules: {
|
|
140 |
actualName: {
|
|
141 |
required: true,
|
701f60
|
142 |
minlength: 2
|
a38dad
|
143 |
}
|
234b22
|
144 |
},
|
S |
145 |
messages: {
|
|
146 |
actualName: {
|
|
147 |
required: '请输入用户名',
|
a38dad
|
148 |
}
|
234b22
|
149 |
},
|
S |
150 |
multiCheck:true
|
|
151 |
},this)
|
|
152 |
},
|
|
153 |
})
|
|
154 |
export {}
|