Skip to content

Commit adddc62

Browse files
committed
add comment
1 parent 681a1e1 commit adddc62

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

src/page/forget/forget.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,26 @@
4747
alertTip,
4848
},
4949
methods: {
50+
//判断输入的手机号码是否正确
5051
inputPhone(){
5152
if(/^1\d{10}$/gi.test(this.phoneNumber)){
5253
this.rightPhoneNumber = true;
5354
}else{
5455
this.rightPhoneNumber = false;
5556
}
5657
},
58+
//获取手机验证
5759
async getVerifyCode(){
5860
if (this.rightPhoneNumber) {
61+
//30秒倒计时后可以重新获取验证码
5962
this.computedTime = 30;
6063
this.timer = setInterval(() => {
6164
this.computedTime --;
6265
if (this.computedTime == 0) {
6366
clearInterval(this.timer)
6467
}
6568
}, 1000)
69+
//验证手机号码是否注册
6670
let res = await checkExsis(this.phoneNumber, this.accountType);
6771
if (res.message) {
6872
this.showAlert = true;
@@ -73,6 +77,7 @@
7377
this.alertText = '您输入的手机号尚未绑定';
7478
return
7579
}
80+
//已注册的手机号方可获取验证码
7681
let getCode = await mobileCode(this.phoneNumber);
7782
if (getCode.message) {
7883
this.showAlert = true;
@@ -82,6 +87,7 @@
8287
this.validate_token = getCode.validate_token;
8388
}
8489
},
90+
//重设密码,进行一写判断
8591
async resetButton(){
8692
if (!this.rightPhoneNumber) {
8793
this.showAlert = true;
@@ -104,6 +110,7 @@
104110
this.alertText = '请输验证码';
105111
return
106112
}
113+
//发送重新设置密码的信息
107114
let res = await sendMobile(this.phoneNumber, this.mobileCode, this.accountType, this.newPassWord);
108115
if (res.message) {
109116
this.showAlert = true;
@@ -114,6 +121,7 @@
114121
this.alertText = '密码修改成功';
115122
}
116123
},
124+
//关闭提示框
117125
closeTip(){
118126
this.showAlert = false;
119127
}

src/page/login/login.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,36 +80,44 @@
8080
alertTip,
8181
},
8282
methods: {
83+
//登陆成功后保存用户信息
8384
...mapMutations([
8485
'RECORD_USERINFO',
8586
]),
87+
//改变登陆方式,默认手机登陆
8688
changeLoginWay(){
8789
this.loginWay = !this.loginWay;
8890
},
91+
//用户名登陆时是否显示输入的密码
8992
changePassWordType(){
9093
this.showPassword = !this.showPassword;
9194
},
95+
//输入手机号码时判断,输入正确的手机号码后方可点击获取短信验证码
9296
inputPhone(){
9397
if(/^1\d{10}$/gi.test(this.phoneNumber)){
9498
this.rightPhoneNumber = true;
9599
}else{
96100
this.rightPhoneNumber = false;
97101
}
98102
},
103+
//获取验证码图片
99104
async getCaptchaCode(){
100105
let res = await getcaptchas();
101106
102107
this.captchaCodeImg = 'https://mainsite-restapi.ele.me/v1/captchas/' + res.code;
103108
},
109+
//获取手机验证码
104110
async getVerifyCode(){
105111
if (this.rightPhoneNumber) {
106112
this.computedTime = 30;
113+
//30秒倒计时,30秒后可以重新获取验证码
107114
this.timer = setInterval(() => {
108115
this.computedTime --;
109116
if (this.computedTime == 0) {
110117
clearInterval(this.timer)
111118
}
112119
}, 1000)
120+
//利用后台接口判断当前手机是否已注册
113121
let exsis = await checkExsis(this.phoneNumber, 'mobile');
114122
if (exsis.message) {
115123
this.showAlert = true;
@@ -120,6 +128,7 @@
120128
this.alertText = '您输入的手机号尚未绑定';
121129
return
122130
}
131+
//返回的数据带message,说明登陆失败
123132
let res = await mobileCode(this.phoneNumber);
124133
if (res.message) {
125134
this.showAlert = true;
@@ -129,7 +138,9 @@
129138
this.validate_token = res.validate_token;
130139
}
131140
},
141+
//登陆
132142
async mobileLogin(){
143+
//手机登陆时进行简单的判断
133144
if (this.loginWay) {
134145
if (!this.rightPhoneNumber) {
135146
this.showAlert = true;
@@ -142,6 +153,7 @@
142153
}
143154
this.userInfo = await sendLogin(this.mobileCode, this.phoneNumber, this.validate_token);
144155
}else{
156+
//用户名登陆时进行简单的判断
145157
if (!this.userAccount) {
146158
this.showAlert = true;
147159
this.alertText = '请输入手机号/邮箱/用户名';
@@ -158,16 +170,19 @@
158170
159171
this.userInfo = await accountLogin(this.userAccount, this.passWord, this.codeNumber);
160172
}
173+
//如果返回的信息没有user_id说明登陆失败,弹出提示
161174
if (!this.userInfo.user_id) {
162175
this.showAlert = true;
163176
this.alertText = this.userInfo.message;
164177
if (!this.loginWay) this.getCaptchaCode();
165178
}else{
179+
//登陆成功保存用户信息,返回上一路游
166180
this.RECORD_USERINFO(this.userInfo);
167181
this.$router.go(-1);
168182
169183
}
170184
},
185+
//关闭弹出框
171186
closeTip(){
172187
this.showAlert = false;
173188
}

src/store/index.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ const state = {
1212
cartList: {}, // 加入购物车的商品列表
1313
shopDetail: null, //商家详情信息
1414
userInfo: null, //用户信息
15-
shopid: null,
16-
remarkText: null,
17-
inputText: '',
18-
invoice: false,
19-
searchAddress: null,
20-
geohash: null,
21-
choosedAddress: null,
22-
addressIndex: null,
23-
needValidation: null,
24-
cartId: null,
25-
sig: null,
26-
orderParam: null,
27-
orderMessage: null,
28-
orderDetail: null,
29-
login: true,
15+
shopid: null, // 商铺id
16+
remarkText: null,//可选择的下单备注
17+
inputText: '',//手动输入下单备注
18+
invoice: false,//是否需要开发票,默认否
19+
searchAddress: null,//添加地址时选择的地址,通过vuex传递给上一级页面
20+
geohash: null,//在msite页面中存入geohash,这个全局的变量在任何地方都有可能会被用到
21+
choosedAddress: null,//下单页面确认选择的收货地址
22+
addressIndex: null,//收获地址的索引值
23+
needValidation: null,//下单时需要输入验证码的返回值
24+
cartId: null,//订单的id
25+
sig: null,//订单的sig
26+
orderParam: null,//传递给后台的订单参数
27+
orderMessage: null,//下单成功,保存订单返回信息
28+
orderDetail: null,//进入订单详情页前保存该订单信息
29+
login: true,//登陆的状态,默认登陆
3030
}
3131

3232
export default new Vuex.Store({

0 commit comments

Comments
 (0)