Commit 72eccfed authored by Damon's avatar Damon

refactor: 收货地址-交互

parent c4649082
......@@ -95,7 +95,7 @@ export default {
},
partsChange(val, index) {
this.$set(this.lists[index], 'quantity', val)
this.valueChange(this.lists)
this.valueChange(JSON.stringify(this.lists))
},
minusValue(val, index) {
if (val === 0) {
......
<template>
<view class="item" @click="$u.throttle(editSite, 500)">
<view class="userinfo u-flex">
<view class="item">
<view class="userinfo u-flex" @click="$u.throttle(selectSite, 500)">
<view class="name">{{ formatName }}</view>
<view class="mobile">{{ formatMobile }}</view>
</view>
<view class="siteinfo u-flex u-row-between u-col-top">
<view class="txt">{{ formatAddress }}</view>
<u-icon custom-prefix="wxh" name="pen" size="32"></u-icon>
<view class="txt" @click="$u.throttle(selectSite, 500)">{{ formatAddress }}</view>
<u-icon custom-prefix="wxh" name="pen" size="32" @click="$u.throttle(editSite, 500)"></u-icon>
</view>
<view class="default" v-show="isDefault">
<u-icon name="checkmark-circle" color="#2272FF" size="32"></u-icon>
<text class="txt">默认地址</text>
<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>
<text class="txt">默认地址</text>
</view>
<view @click="$u.throttle(remove, 500)">
<text class="txt">删除</text>
</view>
</view>
</view>
</template>
......@@ -84,9 +89,18 @@ export default {
}
},
methods: {
selectSite() {
this.$emit('select-site', this.info)
},
editSite() {
this.$emit('edit-site', this.info)
},
setDefault() {
this.$emit('set-default', this.info)
},
remove() {
this.$emit('remove', this.info)
}
}
};
</script>
......
<template>
<view class="address-wrap">
<view class="u-flex address-wrap">
<w-navbar title="收货地址"></w-navbar>
<view class="body" v-if="hasAdderss">
<w-address @editSite="toAddSite" :info="info" :is-default="true" />
<view class="lists">
<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>
</template>
......@@ -21,6 +29,7 @@ export default {
address: '',
region: [],
},
type: ''
};
},
computed: {
......@@ -37,9 +46,17 @@ export default {
address: this.address,
region: this.region || [],
}
},
submitBtn() {
return {
color: '#FFFFFF',
backgroundColor: '#2272FF'
}
}
},
onLoad() {
onLoad(options) {
if (options) this.type = options.type
getApp().trackPage('我的收获地址页')
},
onShow() {
......@@ -69,16 +86,57 @@ export default {
}
})
},
toAddSite(title){
const region = this.info.region.join('-')
toAddSite() {
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({
url: 'pages/mine/address/addSite',
params: {
type: 'edit',
region: region,
name: this.info.name,
mobile: this.info.mobile,
address: this.info.address,
name: val.name,
mobile: val.mobile,
address: val.address,
}
})
}
......@@ -89,6 +147,13 @@ export default {
<style lang="scss" scoped>
.address-wrap {
background-color: #F4F5F7;
flex-direction:column;
height: 100vh;
.lists {
width: 100%;
flex: 1;
overflow-y:auto;
}
}
.body {
padding: 30rpx;
......@@ -96,4 +161,24 @@ export default {
border-radius: 12rpx;
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>
......@@ -35,9 +35,12 @@
</view>
</view>
<view class="card address">
<view class="title">收件信息</view>
<view class="u-flex u-row-between">
<view class="title">收件信息</view>
<view class="more" @click="toAddress">更多地址></view>
</view>
<view class="body">
<w-address :info="addressInfo" @editSite="editSite" />
<w-address :info="addressInfo" @editSite="editSite" @selectSite="editSite" />
</view>
</view>
</view>
......@@ -140,6 +143,14 @@ export default {
}
})
},
toAddress() {
this.$u.route({
url: "pages/mine/address/index",
params: {
type: 'parts'
}
})
},
updateSite(site) {
this.addressInfo = site
},
......@@ -296,6 +307,10 @@ export default {
font-weight: bold;
color: #333333;
}
.more {
color: #2272FF;
font-size: 28rpx;
}
.body {
.list {
.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