Skip to content

Commit 4146673

Browse files
committed
add comment
1 parent adddc62 commit 4146673

File tree

8 files changed

+99
-37
lines changed

8 files changed

+99
-37
lines changed

src/page/confirmOrder/children/children/addAddress.vue

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,16 @@
6464
export default {
6565
data(){
6666
return{
67-
name: null,
68-
sex: 1,
69-
phone: null,
70-
address_detail: null,
71-
tag: '',
72-
tag_type: 1,
73-
phone_bk: false,
74-
anntherPhoneNumber: '',
75-
showAlert: false,
76-
alertText: null,
77-
poi_type: 0,
67+
name: null,//姓名
68+
sex: 1, //性别
69+
phone: null,//电话
70+
address_detail: null,//详细地址
71+
tag: '',//标签
72+
tag_type: 1,//标签类别
73+
phone_bk: false,//是否显示备注电话
74+
anntherPhoneNumber: '',//备注电话号码
75+
showAlert: false,//是否显示弹出框
76+
alertText: null,//弹出框信息
7877
}
7978
},
8079
created(){
@@ -93,9 +92,11 @@
9392
...mapMutations([
9493
9594
]),
95+
//选择性别
9696
chooseSex(sex){
9797
this.sex = sex;
9898
},
99+
//发送地址信息,添加地址,做一下简单的验证
99100
async addAddress(){
100101
if (!(this.userInfo && this.userInfo.user_id)) {
101102
this.showAlert = true;
@@ -121,6 +122,7 @@
121122
this.tag_type = 4;
122123
}
123124
let res = await postAddAddress(this.userInfo.user_id, this.searchAddress.name, this.address_detail, this.geohash, this.name, this.phone, this.anntherPhoneNumber, 0, this.sex, this.tag, this.tag_type);
125+
//添加成功返回地址列表页
124126
this.$router.go(-1);
125127
},
126128
}

src/page/confirmOrder/children/children/children/searchAddress.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
export default {
3030
data(){
3131
return{
32-
searchValue: null,
33-
searchData: null,
32+
searchValue: null,//搜索的信息
33+
searchData: null,//搜索返回的地址列表
3434
}
3535
},
3636
components: {
@@ -41,13 +41,16 @@
4141
...mapMutations([
4242
'CHOOSE_SEARCH_ADDRESS'
4343
]),
44+
//搜索附近地址
4445
async searchPlace(){
4546
if (this.searchValue) {
4647
this.searchData = await searchNearby(this.searchValue);
4748
}
4849
},
4950
choooedAddress(item){
51+
//将选择的地址传入vuex
5052
this.CHOOSE_SEARCH_ADDRESS(item);
53+
//返回上一页,添加地址页
5154
this.$router.go(-1);
5255
},
5356

src/page/confirmOrder/children/chooseAddress.vue

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@
6060
export default {
6161
data(){
6262
return{
63-
addressList: [],
64-
deliverable: [],
65-
deliverdisable: [],
66-
id: null,
67-
sig: null,
68-
showAlert: false,
69-
alertText: null,
63+
addressList: [],//地址列表
64+
deliverable: [],//地址列表中符合配送范围的地址
65+
deliverdisable: [],//地址列表中,超出配送范围的值
66+
id: null,//订单id
67+
sig: null,//订单sig
68+
showAlert: false,//控制弹出提示框
69+
alertText: null,//弹出框的文字
7070
}
7171
},
7272
created(){
@@ -83,6 +83,7 @@
8383
...mapState([
8484
'userInfo', 'addressIndex'
8585
]),
86+
//默认选择的地址
8687
defaultIndex: function (){
8788
if (this.addressIndex) {
8889
return this.addressIndex;
@@ -95,28 +96,36 @@
9596
...mapMutations([
9697
'CHOOSE_ADDRESS'
9798
]),
99+
//初始化获取数据
98100
async initData(){
101+
//用户未登陆时弹出提示框
99102
if (!(this.userInfo && this.userInfo.user_id)) {
100103
this.showAlert = true;
101104
this.alertText = '请登陆'
102105
return
103106
}
107+
//获取地址列表
104108
this.addressList = await getAddress(this.id, this.sig);
109+
//将地址列表中在配送范围和不在配送范围的地址分开
105110
this.addressList.forEach(item => {
111+
//满足配送范围
106112
if (item.is_deliverable) {
107113
this.deliverable.push(item);
114+
//不在配送范围
108115
}else{
109116
this.deliverdisable.push(item);
110117
}
111118
112119
})
113120
},
121+
//地址标识的背景颜色
114122
iconColor(name){
115123
switch(name){
116124
case '公司': return '#4cd964';
117125
case '学校': return '#3190e8';
118126
}
119127
},
128+
//选择地址时,将地址的信息,索引传入vuex,然后返回订单页面
120129
chooseAddress(address, index){
121130
this.CHOOSE_ADDRESS({address, index});
122131
this.$router.go(-1);

src/page/confirmOrder/children/invoice.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
...mapMutations([
3030
'CONFIRM_INVOICE'
3131
]),
32+
//是否需要发票
3233
chooseInvoice(){
3334
this.invoice = !this.invoice;
3435
},
36+
//点击确认时将发票信息存入vuex
3537
confrimInvoice(){
3638
this.CONFIRM_INVOICE(this.invoice);
3739
this.$router.go(-1);

src/page/confirmOrder/children/payment.vue

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
data(){
5252
return{
5353
payDetail: false, //付款信息详情
54-
showAlert: false,
55-
alertText: null,
56-
payWay: 1,
57-
countNum: 900,
58-
gotoOrders: false,
54+
showAlert: false,//是否显示提示框
55+
alertText: null, //提示框的文字
56+
payWay: 1, //付款方式,默认为1,支付宝
57+
countNum: 900, //付款倒计时,15分钟
58+
gotoOrders: false, //是否跳转到订单列表页面
5959
}
6060
},
6161
components: {
@@ -64,20 +64,25 @@
6464
},
6565
created(){
6666
this.initData();
67+
//进入此页面说明下单成功,清空购物车中当前餐馆的购物车信息
6768
this.CLEAR_CART(this.shopid);
6869
},
6970
mounted(){
71+
//开始倒计时
7072
this.remainingTime();
7173
},
7274
beforeDestroy(){
75+
//组件卸载前清空定时器
7376
clearInterval(this.timer);
7477
},
7578
props:[],
7679
computed: {
7780
...mapState([
7881
'orderMessage', 'userInfo', 'shopid'
7982
]),
83+
//定时器时间
8084
remaining: function (){
85+
//个位数的时间前面加上0 5:4--05:04
8186
let minute = parseInt(this.countNum/60);
8287
if (minute < 10) {
8388
minute = '0' + minute;
@@ -93,30 +98,36 @@
9398
...mapMutations([
9499
'CONFIRM_INVOICE', 'CLEAR_CART'
95100
]),
101+
//初始化获取订单成功信息,返回的值包括付款方式等
96102
async initData(){
97103
this.payDetail = await payRequest(this.orderMessage.order_id, this.userInfo.user_id);
104+
//如果返回的值有message,则弹出提示框
98105
if (this.payDetail.message) {
99106
this.showAlert = true;
100107
this.alertText = this.payDetail.message;
101108
return
102109
}
103110
},
111+
//计算时间
104112
remainingTime(){
105113
clearInterval(this.timer);
106114
this.timer = setInterval(() => {
107115
this.countNum --;
116+
//倒计时结束时,清空定时器,弹出提示框
108117
if (this.countNum == 0) {
109118
clearInterval(this.timer);
110119
this.showAlert = true;
111120
this.alertText = '支付超时';
112121
}
113122
}, 1000);
114123
},
124+
//点击确认,弹出提示框
115125
confrimPay(){
116126
this.showAlert = true;
117127
this.alertText = '当前环境无法支付,请打开官方APP进行付款';
118128
this.gotoOrders = true;
119129
},
130+
//关闭提示框时跳转订单列表页面
120131
closeTipFun(){
121132
this.showAlert = false;
122133
if (this.gotoOrders) {

src/page/confirmOrder/children/remark.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
export default {
3030
data(){
3131
return{
32-
id: null,
33-
sig: null,
34-
remarkList: null,
35-
showLoading: true,
36-
remarkText: {},
37-
inputText: null,
32+
id: null, //订单id
33+
sig: null, //订单sig
34+
remarkList: null, //备注列表
35+
showLoading: true, //显示加载动画
36+
remarkText: {}, //选择的备注
37+
inputText: null, //输入的备注
3838
}
3939
},
4040
created(){
@@ -54,15 +54,19 @@
5454
...mapMutations([
5555
'CONFIRM_REMARK'
5656
]),
57+
//初始化数据,获取备注列表
5758
async initData(){
5859
this.remarkList = await getRemark(this.id, this.sig);
5960
this.showLoading = false;
6061
},
62+
//将选取的备注存入remarkText数组
6163
chooseRemark(index, remarkIndex, text){
6264
this.remarkText[index] = [remarkIndex, text];
65+
//返回一个新的对象,显示已选中的备注
6366
this.remarkText = Object.assign({}, this.remarkText);
6467
},
6568
confirmRemark(){
69+
//将选择和输入的备注存入vuex ,订单页面从vuex中获取
6670
this.CONFIRM_REMARK({remarkText: this.remarkText, inputText: this.inputText});
6771
this.$router.go(-1);
6872
}

src/page/confirmOrder/children/userValidation.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
return{
3333
validate: null, //验证码
3434
countDown: 30, //倒计时
35-
sig: null,
36-
reCallVerify: null,
37-
showAlert: false,
38-
alertText: null,
39-
showVoiceTip: false,
40-
type: 'sms',
35+
sig: null, //订单sig
36+
reCallVerify: null, //重新获取验证码
37+
showAlert: false, //是否显示提示框
38+
alertText: null, //提示框信息
39+
showVoiceTip: false,//是否发送语音验证
40+
type: 'sms', //发送数据的类型
4141
}
4242
},
4343
components: {
@@ -52,6 +52,7 @@
5252
this.getData();
5353
},
5454
beforeDestroy(){
55+
//卸载前清空定时器
5556
clearInterval(this.timer);
5657
},
5758
props:[],
@@ -64,6 +65,7 @@
6465
...mapMutations([
6566
'CHANGE_ORDER_PARAM', 'ORDER_SUCCESS'
6667
]),
68+
//30秒到记时,倒计时结束后可以重新获取
6769
count(){
6870
this.countDown = 30;
6971
clearInterval(this.timer);
@@ -74,32 +76,40 @@
7476
}
7577
}, 1000);
7678
},
79+
//重新获取验证码
7780
recall(){
7881
this.count();
7982
this.type = 'sms';
8083
this.getData();
8184
},
85+
//获取语音验证
8286
sendVoice(){
8387
this.showVoiceTip = true;
8488
this.type = 'voice';
8589
this.getData();
8690
},
91+
//获取验证码
8792
async getData(){
8893
this.reCallVerify = await rePostVerify(this.cart_id, this.sig, this.type);
94+
//返回的信息有message则弹出提示框
8995
if (this.reCallVerify.message) {
9096
this.showAlert = true;
9197
this.alertText = this.reCallVerify.message;
9298
}
9399
},
100+
//改变订单参数,向后台多传入两个信息
94101
async confrimOrder(){
95102
this.CHANGE_ORDER_PARAM({validation_code: this.validate, validation_token: this.reCallVerify.validate_token})
96103
let orderRes = await validateOrders(this.orderParam);
104+
//返回的信息有message则弹出提示框
97105
if (orderRes.message) {
98106
this.showAlert = true;
99107
this.alertText = orderRes.message;
100108
return
101109
}
110+
//订单成功,保存信息
102111
this.ORDER_SUCCESS(orderRes);
112+
//进入付款页面
103113
this.$router.push('/confirmOrder/payment');
104114
},
105115
}

0 commit comments

Comments
 (0)