From 081c50da0c980cda815ab8a67a9304d9cc091194 Mon Sep 17 00:00:00 2001
From: mullins <476823686@qq.com>
Date: Thu, 18 Jun 2020 17:50:55 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E8=AE=A2=E5=8D=95=E8=BF=94?=
=?UTF-8?q?=E5=9B=9E=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/pages/address/addressList.vue | 60 ++++++++++++++++++++++--------
src/pages/confirmOrder/confirmOrder.vue | 48 ++++++++++++++++++++----
src/pages/myOrder/myOrder.vue | 7 ++--
src/pages/myOrderPaying/myOrderPaying.vue | 55 +++++++++++++++------------
src/static/add_address.png | Bin 0 -> 1779 bytes
src/store/modules/address.js | 17 ++++++++-
src/store/url.js | 1 +
7 files changed, 138 insertions(+), 50 deletions(-)
create mode 100644 src/static/add_address.png
diff --git a/src/pages/address/addressList.vue b/src/pages/address/addressList.vue
index 91a85c2..526a027 100644
--- a/src/pages/address/addressList.vue
+++ b/src/pages/address/addressList.vue
@@ -9,6 +9,7 @@
:key="index"
class="order-user"
@tap="toOrder(item.add_id)"
+ @longpress="delAddress(item.add_id)"
>
@@ -43,7 +44,10 @@
>
暂无收货地址
-
+
@@ -56,7 +60,7 @@ export default {
computed: {
addressList () {
return this.$store.state.address.list
- }
+ },
},
onLoad ({ edit }) {
if (edit) {
@@ -74,26 +78,26 @@ export default {
url: 'addAddress',
fail: (error) => {
console.error('跳转出现错误', error)
- }
+ },
})
},
- toEditAddress (addId) {
+ toEditAddress(addId) {
console.log('addId', addId)
uni.navigateTo({
url: `addAddress?addId=${addId}`,
fail: (error) => {
console.error('跳转出现错误', error)
- }
+ },
})
},
- toOrder (addId) {
+ toOrder(addId) {
if (this.edit) {
- let pages = getCurrentPages();
- let prevPage = pages[pages.length - 2]; //上一个页面
- const addressId=addId
- // console.log(addressId)
- prevPage.onShow(addressId);
- uni.navigateBack();
+ const pages = getCurrentPages()
+ const prevPage = pages[pages.length - 2] // 上一个页面
+ const addressId = addId
+ // console.log(addressId)
+ prevPage.onShow(addressId)
+ uni.navigateBack()
// uni.navigateTo({
// url: `../confirmOrder/confirmOrder?addressId=${addId}`,
// fail: (error) => {
@@ -101,8 +105,34 @@ export default {
// }
// })
}
- }
- }
+ },
+ delAddress(addId) {
+ uni.showModal({
+ title: '提示',
+ content: '是否删除该条地址',
+ success: function (res) {
+ if (res.confirm) {
+ if (this.addressList.length > 1) {
+ store.dispatch('address/delete', {
+ add_id: addId,
+ }).then(() => {
+ store.dispatch('address/list')
+ uni.showToast({
+ title: '删除成功',
+ duration: 1000,
+ })
+ })
+ } else {
+ uni.showToast({
+ title: '请保留至少一条地址信息',
+ duration: 1000,
+ })
+ }
+ }
+ },
+ })
+ },
+ },
}
@@ -126,7 +156,7 @@ export default {
width: 100%;
align-items: center;
padding-left: 126rpx;
- box-sizing: border-box;
+ box-sizing: border-box;
.name {
display: flex;
justify-content: space-between;
diff --git a/src/pages/confirmOrder/confirmOrder.vue b/src/pages/confirmOrder/confirmOrder.vue
index 2ef17d4..3d33064 100644
--- a/src/pages/confirmOrder/confirmOrder.vue
+++ b/src/pages/confirmOrder/confirmOrder.vue
@@ -21,7 +21,7 @@
{{addressInfo.address}}\n{{addressInfo.add_detail}}
- 点击添加地址
+
+ 点击添加地址
@@ -125,7 +129,7 @@
@@ -60,7 +61,7 @@ export default {
onShow() {
store.dispatch('myOrder/getList', {
- way: '',
+ way: '',
})
},
onLoad: function(option) {
diff --git a/src/pages/myOrderPaying/myOrderPaying.vue b/src/pages/myOrderPaying/myOrderPaying.vue
index 4b7ea63..22dc83b 100644
--- a/src/pages/myOrderPaying/myOrderPaying.vue
+++ b/src/pages/myOrderPaying/myOrderPaying.vue
@@ -248,29 +248,38 @@ export default {
this.cancleOrder()
},
cancleOrder() {
- console.log('dddd', this.skuList)
- // const uid = this.uid
- // const openid = this.openid
- // const keyname = this.orderInfo.order_info.keyname
- // // console.log('keyname',this.orderInfo.keyname)
- // uni.showModal({
- // title: '提示',
- // content: '现在取消,订单不可恢复哦,确认取消吗?',
- // success: function(res) {
- // if (res.confirm) {
- // store.dispatch('cancelOrder/cancel', {
- // keyname: keyname,
- // uid: uid,
- // openid: openid,
- // })
- // uni.navigateBack({
- // delta: 1,
- // })
- // } else if (res.cancel) {
- // console.log('用户点击取消')
- // }
- // },
- // })
+ const uid = this.uid
+ const openid = this.openid
+ const keyname = this.orderInfo.order_info.keyname
+ const that = this
+ // console.log('keyname',this.orderInfo.keyname)
+ uni.showModal({
+ title: '提示',
+ content: '现在取消,订单不可恢复哦,确认取消吗?',
+ success: function(res) {
+ if (res.confirm) {
+ store.dispatch('cancelOrder/cancel', {
+ keyname: keyname,
+ uid: uid,
+ openid: openid,
+ }).then(() => {
+ if (that.isPay === '1') {
+ console.log('lalallala-1')
+ uni.switchTab({
+ url: '/pages/index/index',
+ })
+ } else {
+ console.log('lalallala-2')
+ uni.navigateBack({
+ delta: 1,
+ })
+ }
+ })
+ } else if (res.cancel) {
+ console.log('用户点击取消', that.isPay)
+ }
+ },
+ })
},
paylog() {
console.log('pay', this.orderInfo)
diff --git a/src/static/add_address.png b/src/static/add_address.png
new file mode 100644
index 0000000000000000000000000000000000000000..cce536960c1fc062ce462bd6a2b9e80948101410
GIT binary patch
literal 1779
zcmb_cX;2eq7=HK2!BI&dLcux&2r3pS1QD#3BjGRzV>lF#j!pUL(;sc8&+hx}v+wurv)}XX
zH%oODc;jRqjb<8a2{uoY@gIQ+f4@V_isoS_nCY7#}
zM=uMNMT9Vm!UYPACY648Lz-S29VQX3T(w%r=?6Ag!yB*wTop>4CP*%ipfxA2jJ|0Y
zxxuU*+UL<)Es;OG-Q=_W$%g3e#SiW!^_t55o|q>j>Xc~e1&So4Myp4SNI={rL$9Iv
zF2n^|v?#<6&^+15kJCKf$eWp(*k~!L=|Y^RR4I@KHh{Q${A>B-*Z8aVq7twS4vB~m
zE*H=D@hr5_wVz%6=
zoW>SlVK4x3Xet+vc1k1ao4wgoPE-wGwGyBqOQX;#jCyFqMo3+fx0t!dEE)k=dnsx-
z4uInZFwsd-&l@Rfq6+Ev09+WME&!hk{vaVRXTbRw!N;g(a6~#RjKQQZh7%-<&EcAv
zTcCn^9^e>3;3UCf(VG$5g64tbv#g!Gg4i}u3XXHSK%8B8kn18j(KJ1}^^wRsUYlcP
zZfp0Zy@Ttl*>l|H&i7g1>$mV-X>dqr*b-TIOziR%amb!BAu%agm9k!^|6pT=VbkXA
zJ92mC?b@ARR9sTJx2$~M{>np#k5pCH)P8>Q)am+$#xKvDy?Cj)@wpzq{Jj-f{g#
zXIFPm-|aj7ckkUF7#w>1WccZ`kv~Sq#%W&|5Jp>QG&=i>FFx{xlO#cMXkQqffr8+Z
zEGI9vbx;&Xk#6HG&gKdvg$GYGnYnmJKbjt|Z8f(Q&F^!4Oj~1|{WD`Z|H+xj*p#oI
zKngem0>=p!K@co93xUmL)8LwO8JNFH$jvLz{``gWRwC!bOz)_3
z@cIp_o~R11wi+*|;HKl%!xdK4j}sRv^XEW~N40H3`}@axokF$mZ7gU{Q_pkn@aY}I
z8{r&_Gki31&6?IvmY&C7_7++*w_4miinjCYFr*y`IR8*c%U*tBNbSqc1ZDyv=@~^Xxr5>BNC#&u9fOoq)x58@w
zR{o3Gqg!qV#Ss<6k<752FJ~BLU-Yf38PzRav#3mJ
zpDy~SRAlY>Fl@d0(mKmu42zl^l6O9{lX;{zXZMK1XFfSsV2us@TzXTEg$U%FAX9s5
m`X()vU{ss2(R8zo!CCxz?HByjd~3_6_-7+A4+0&j?mq!T)FSi%
literal 0
HcmV?d00001
diff --git a/src/store/modules/address.js b/src/store/modules/address.js
index adb3553..d5cbdab 100644
--- a/src/store/modules/address.js
+++ b/src/store/modules/address.js
@@ -1,7 +1,7 @@
import urlAlias from '../url'
import request from '../request'
-const { editAddress, addressList, getAddress, getDefaultAddress } = urlAlias
+const { editAddress, addressList, getAddress, getDefaultAddress, delAddress } = urlAlias
const state = { list: [], detail: {}, defaultInfo: {} }
@@ -87,6 +87,21 @@ const actions = {
},
}))
},
+ delete(_, param) {
+ return new Promise((resolve) => request({
+ url: delAddress,
+ data: param,
+ success: (res) => {
+ resolve()
+ },
+ fail: () => {
+ uni.showModal({
+ content: '删除地址失败',
+ showCancel: false,
+ })
+ },
+ }))
+ },
}
export default {
diff --git a/src/store/url.js b/src/store/url.js
index bb52b32..5bc0310 100644
--- a/src/store/url.js
+++ b/src/store/url.js
@@ -42,6 +42,7 @@ const urlAlias = {
addressList: '/app/address/get_address_list', // 获取用户地址列表
getAddress: '/app/address/get_address_by_id', // 获取用户某一地址信息
getDefaultAddress: '/app/address/get_default_address', // 获取用户默认地址信息
+ delAddress: '/app/address/del_address', // 删除用户地址
// 用户数据
mylovelist: '/app/user/mylovelist', // 关心的人的数据
--
2.0.0