guhongwei 2 years ago
parent
commit
ec5a2060d2
1 changed files with 42 additions and 6 deletions
  1. 42 6
      pagesMy/address/index.vue

+ 42 - 6
pagesMy/address/index.vue

@@ -148,7 +148,7 @@
 											title: '添加收货地址成功',
 											title: '添加收货地址成功',
 											icon: 'none'
 											icon: 'none'
 										})
 										})
-										that.search()
+										that.clearPage();
 									} else {
 									} else {
 										uni.showToast({
 										uni.showToast({
 											title: arr.errmsg,
 											title: arr.errmsg,
@@ -166,12 +166,26 @@
 			},
 			},
 			// 设置默认
 			// 设置默认
 			toDefa(e) {
 			toDefa(e) {
+				const that = this;
 				uni.showModal({
 				uni.showModal({
 					title: '提示',
 					title: '提示',
 					content: '确定设置该地址为默认地址吗?',
 					content: '确定设置该地址为默认地址吗?',
-					success: function(res) {
+					success: async function(res) {
 						if (res.confirm) {
 						if (res.confirm) {
-							console.log('用户点击确定');
+							const arr = await that.$api(`/address/toDefault/${e._id}`, `POST`);
+							if (arr.errcode == '0') {
+								uni.showToast({
+									title: '添加默认成功',
+									icon: 'none'
+								})
+								that.clearPage();
+								that.search();
+							} else {
+								uni.showToast({
+									title: arr.errmsg,
+									icon: 'none'
+								})
+							}
 						}
 						}
 					}
 					}
 				});
 				});
@@ -184,15 +198,37 @@
 			},
 			},
 			// 删除
 			// 删除
 			toDel(e) {
 			toDel(e) {
+				const that = this;
 				uni.showModal({
 				uni.showModal({
 					title: '提示',
 					title: '提示',
 					content: '确定删除该地址吗?',
 					content: '确定删除该地址吗?',
-					success: function(res) {
+					success: async function(res) {
 						if (res.confirm) {
 						if (res.confirm) {
-							console.log('用户点击确定');
+							const arr = await that.$api(`/address/${e._id}`, 'DELETE');
+							if (arr.errcode == '0') {
+								uni.showToast({
+									title: '删除信息成功',
+									icon: 'none'
+								})
+								that.clearPage();
+								that.search();
+							} else {
+								uni.showToast({
+									title: arr.errmsg,
+									icon: 'none'
+								})
+							}
 						}
 						}
 					}
 					}
 				});
 				});
+			},
+			// 清空列表
+			clearPage() {
+				const that = this;
+				that.$set(that, `list`, [])
+				that.$set(that, `skip`, 0)
+				that.$set(that, `limit`, 5)
+				that.$set(that, `page`, 0)
 			}
 			}
 		}
 		}
 	}
 	}
@@ -220,7 +256,7 @@
 
 
 				.name {
 				.name {
 					font-size: var(--font16Size);
 					font-size: var(--font16Size);
-					margin: 0 0 1vw 0;
+					margin: 0 0 2vw 0;
 
 
 					text {
 					text {
 						padding: 0 2vw 0 0;
 						padding: 0 2vw 0 0;