Commit 72eccfed authored by Damon's avatar Damon

refactor: 收货地址-交互

parent c4649082
...@@ -95,7 +95,7 @@ export default { ...@@ -95,7 +95,7 @@ export default {
}, },
partsChange(val, index) { partsChange(val, index) {
this.$set(this.lists[index], 'quantity', val) this.$set(this.lists[index], 'quantity', val)
this.valueChange(this.lists) this.valueChange(JSON.stringify(this.lists))
}, },
minusValue(val, index) { minusValue(val, index) {
if (val === 0) { if (val === 0) {
......
<template> <template>
<view class="item" @click="$u.throttle(editSite, 500)"> <view class="item">
<view class="userinfo u-flex"> <view class="userinfo u-flex" @click="$u.throttle(selectSite, 500)">
<view class="name">{{ formatName }}</view> <view class="name">{{ formatName }}</view>
<view class="mobile">{{ formatMobile }}</view> <view class="mobile">{{ formatMobile }}</view>
</view> </view>
<view class="siteinfo u-flex u-row-between u-col-top"> <view class="siteinfo u-flex u-row-between u-col-top">
<view class="txt">{{ formatAddress }}</view> <view class="txt" @click="$u.throttle(selectSite, 500)">{{ formatAddress }}</view>
<u-icon custom-prefix="wxh" name="pen" size="32"></u-icon> <u-icon custom-prefix="wxh" name="pen" size="32" @click="$u.throttle(editSite, 500)"></u-icon>
</view> </view>
<view class="default" v-show="isDefault"> <view class="u-flex u-row-between default" v-show="isDefault">
<view @click="$u.throttle(setDefault, 500)">
<u-icon name="checkmark-circle" color="#2272FF" size="32"></u-icon> <u-icon name="checkmark-circle" color="#2272FF" size="32"></u-icon>
<text class="txt">默认地址</text> <text class="txt">默认地址</text>
</view> </view>
<view @click="$u.throttle(remove, 500)">
<text class="txt">删除</text>
</view>
</view>
</view> </view>
</template> </template>
...@@ -84,9 +89,18 @@ export default { ...@@ -84,9 +89,18 @@ export default {
} }
}, },
methods: { methods: {
selectSite() {
this.$emit('select-site', this.info)
},
editSite() { editSite() {
this.$emit('edit-site', this.info) this.$emit('edit-site', this.info)
}, },
setDefault() {
this.$emit('set-default', this.info)
},
remove() {
this.$emit('remove', this.info)
}
} }
}; };
</script> </script>
......
<template> <template>
<view class="address-wrap"> <view class="u-flex address-wrap">
<w-navbar title="收货地址"></w-navbar> <w-navbar title="收货地址"></w-navbar>
<view class="body" v-if="hasAdderss"> <view class="lists">
<w-address @editSite="toAddSite" :info="info" :is-default="true" /> <view class="body">
<w-address @editSite="toEditSite" @selectSite="selectSite" @setDefault="setDefault" @remove="remove" :info="info" :is-default="true" />
</view>
</view>
<view class="addSite" @tap="toAddSite">
<view class="add">
新建收货地址
</view>
</view> </view>
</view> </view>
</template> </template>
...@@ -21,6 +29,7 @@ export default { ...@@ -21,6 +29,7 @@ export default {
address: '', address: '',
region: [], region: [],
}, },
type: ''
}; };
}, },
computed: { computed: {
...@@ -37,9 +46,17 @@ export default { ...@@ -37,9 +46,17 @@ export default {
address: this.address, address: this.address,
region: this.region || [], region: this.region || [],
} }
},
submitBtn() {
return {
color: '#FFFFFF',
backgroundColor: '#2272FF'
}
} }
}, },
onLoad() { onLoad(options) {
if (options) this.type = options.type
getApp().trackPage('我的收获地址页') getApp().trackPage('我的收获地址页')
}, },
onShow() { onShow() {
...@@ -69,16 +86,57 @@ export default { ...@@ -69,16 +86,57 @@ export default {
} }
}) })
}, },
toAddSite(title){ toAddSite() {
const region = this.info.region.join('-') this.$u.route({
url: 'pages/mine/address/addSite',
params: {
type: 'add'
}
})
},
setDefault(val) {
console.log("val", val)
},
remove(val) {
uni.showModal({
title: '温馨提示',
content: '确定要删除该收货地址?',
success: (res) => {
if (res.confirm) {
console.log("delete")
}
}
})
},
selectSite(val) {
if (this.type === 'parts') {
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2]; //上一个页面
let address = val.region.join("") + val.address
let site = {
name: val.name,
mobile: val.mobile,
address: address,
region: val.region
}
prevPage.$vm.updateSite(site)
this.$u.route({
type: 'back'
})
} else {
this.toEditSite(val)
}
},
toEditSite(val){
const region = val.region.join('-')
this.$u.route({ this.$u.route({
url: 'pages/mine/address/addSite', url: 'pages/mine/address/addSite',
params: { params: {
type: 'edit', type: 'edit',
region: region, region: region,
name: this.info.name, name: val.name,
mobile: this.info.mobile, mobile: val.mobile,
address: this.info.address, address: val.address,
} }
}) })
} }
...@@ -89,6 +147,13 @@ export default { ...@@ -89,6 +147,13 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.address-wrap { .address-wrap {
background-color: #F4F5F7; background-color: #F4F5F7;
flex-direction:column;
height: 100vh;
.lists {
width: 100%;
flex: 1;
overflow-y:auto;
}
} }
.body { .body {
padding: 30rpx; padding: 30rpx;
...@@ -96,4 +161,24 @@ export default { ...@@ -96,4 +161,24 @@ export default {
border-radius: 12rpx; border-radius: 12rpx;
background-color: #FFFFFF; background-color: #FFFFFF;
} }
.addSite {
display: flex;
justify-content: space-around;
width: 600rpx;
height: 100rpx;
line-height: 100rpx;
margin: 50rpx 0;
background-color: #2272FF;
border-radius: 60rpx;
font-size: 30rpx;
.add{
display: flex;
align-items: center;
color: #ffffff;
.icon{
margin-right: 10rpx;
}
}
}
</style> </style>
...@@ -35,9 +35,12 @@ ...@@ -35,9 +35,12 @@
</view> </view>
</view> </view>
<view class="card address"> <view class="card address">
<view class="u-flex u-row-between">
<view class="title">收件信息</view> <view class="title">收件信息</view>
<view class="more" @click="toAddress">更多地址></view>
</view>
<view class="body"> <view class="body">
<w-address :info="addressInfo" @editSite="editSite" /> <w-address :info="addressInfo" @editSite="editSite" @selectSite="editSite" />
</view> </view>
</view> </view>
</view> </view>
...@@ -140,6 +143,14 @@ export default { ...@@ -140,6 +143,14 @@ export default {
} }
}) })
}, },
toAddress() {
this.$u.route({
url: "pages/mine/address/index",
params: {
type: 'parts'
}
})
},
updateSite(site) { updateSite(site) {
this.addressInfo = site this.addressInfo = site
}, },
...@@ -296,6 +307,10 @@ export default { ...@@ -296,6 +307,10 @@ export default {
font-weight: bold; font-weight: bold;
color: #333333; color: #333333;
} }
.more {
color: #2272FF;
font-size: 28rpx;
}
.body { .body {
.list { .list {
.sold-out { .sold-out {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment