You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
high-mini/pages/address/address.vue

296 lines
6.1 KiB

2 years ago
<template>
<view class="user-address backcor9 ">
2 years ago
<scroll-view scroll-y="true" class="address-contain paading10">
2 years ago
<radio-group @change="radioChange">
2 years ago
<view v-for="(item,index) in addressList" @click.stop="chooseAddress(item)" :key="item.id"
class="border-8r paading10 backcolorfff marb10">
<view class="user-msg border-b paddbotm5">
<view class=" mart3 ">
<text class="address-name">{{item.consignee}}</text>
<text class=" margle10 ">{{item.phone}}</text>
</view>
<view class="color999 mart5">
地址:{{item.regionName +" " +item.address}}
</view>
2 years ago
</view>
2 years ago
<view class="user-handle mart10">
<view class="handle-left">
<!-- <radio :checked="item.whetherDefault" style="transform:scale(0.7)" :value="item.id" color="#FF1A34" /> -->
<radio :checked="selectId == item.id" style="transform:scale(0.7)" :value="item.id"
color="#FF1A34" />
<text class=" margle">默认地址</text>
</view>
<view class="handle-right">
<button type="primary" class="marRight10" plain="true" size="mini"
@click.stop="editAddress(item.id)">编辑</button>
<button type="warn" plain="true" size="mini"
@click.stop="deleteAddress(item.id)">删除</button>
</view>
2 years ago
</view>
2 years ago
2 years ago
</view>
</radio-group>
<noMore></noMore>
</scroll-view>
2 years ago
2 years ago
<view class="address-btn fcorfff font16">
<view class="add-btn" @click="addNewAddress">添加新地址</view>
2 years ago
<!-- <view class="add-btn" @click="daoRu">导入系统地址</view> -->
2 years ago
</view>
</view>
</template>
<script>
import noMore from '@/pages/classify/no-more/no-more.vue'
2 years ago
import {
getDeliveryAddressList,
deleteAddress,
updateDeliveryAddress
} from '@/Utils/physicalObject.js'
2 years ago
export default {
2 years ago
components: {
2 years ago
noMore,
2 years ago
2 years ago
},
2 years ago
data() {
return {
addressId: [
111, 222, 333, 444
2 years ago
],
2 years ago
selectId: 0,
addressList: [],
status: 0, //其他页面调过来的状态码。
2 years ago
}
},
2 years ago
onLoad(options) {
if (options.status) { //1:从订单确认页面跳过来的
this.status = options.status;
}
2 years ago
this.initData()
},
2 years ago
methods: {
initData() {
2 years ago
this.selectId = 0;
2 years ago
uni.showLoading({
title: '加载中',
mask:true,
});
getDeliveryAddressList().then(res => {
uni.hideLoading();
2 years ago
if (res.return_code == '000000') {
2 years ago
if (res.return_data.length > 0) {
// console.log(res.return_data)
this.addressList = res.return_data;
this.addressList.map(item => {
if (item.whetherDefault) {
this.selectId = item.id;
}
})
2 years ago
}
2 years ago
} else {
2 years ago
uni.showToast({
title: res.return_msg,
icon: 'none',
duration: 2000
})
}
2 years ago
2 years ago
})
},
2 years ago
2 years ago
// 修改默认地址
2 years ago
radioChange(e) {
console.log(e)
let select = e.detail.value
let content = null;
this.addressList.map(item => {
if (item.id == select) {
2 years ago
content = item;
}
})
2 years ago
let params = {
2 years ago
"id": content.id,
"address": content.address,
"consignee": content.consignee,
"phone": content.phone,
"regionId": content.regionId,
2 years ago
"regionName": content.regionName,
2 years ago
"whetherDefault": true
}
2 years ago
updateDeliveryAddress(params).then(res => {
let title;
if (res.return_code == '000000') {
title = res.return_data;
this.selectId = e.detail.value;
} else {
title = res.return_msg;
}
uni.showToast({
title: title,
icon: 'none',
duration: 2000
})
})
2 years ago
},
2 years ago
editAddress(id) {
2 years ago
uni.navigateTo({
2 years ago
url: "./addNewAddress/addNewAddress?id=" + id
2 years ago
})
},
2 years ago
deleteAddress(id) {
2 years ago
uni
let _this = this;
uni.showModal({
title: '提示',
content: '确定删除该地址吗?',
success: function(res) {
if (res.confirm) {
2 years ago
let params = {
id: id
2 years ago
}
2 years ago
deleteAddress(params).then(res => {
let title;
2 years ago
if (res.return_code == '000000') {
2 years ago
title = res.return_data;
} else {
2 years ago
title = res.return_msg;
}
uni.showToast({
title: title,
icon: 'none',
duration: 2000
2 years ago
})
2 years ago
_this.initData();
2 years ago
2 years ago
})
2 years ago
2 years ago
} else if (res.cancel) {
2 years ago
2 years ago
// console.log('用户点击取消');
}
}
});
2 years ago
2 years ago
},
// 新增地址
2 years ago
addNewAddress() {
2 years ago
uni.navigateTo({
2 years ago
url: "./addNewAddress/addNewAddress"
2 years ago
})
},
// 导入系统地址
2 years ago
daoRu() {
uni.chooseAddress({
2 years ago
success: (res) => {
2 years ago
console.log(res)
2 years ago
var data = {
2 years ago
"name": res.userName || '',
"tel": res.telNumber || '',
"province": res.provinceName || '',
"city": res.cityName || '',
"county": res.countyName || '',
"address": res.detailInfo || ''
2 years ago
};
2 years ago
2 years ago
// 之后再发起一个添加地址的请求
2 years ago
2 years ago
},
fail: (err) => {
2 years ago
2 years ago
}
})
2 years ago
},
chooseAddress(addressItem) {
console.log(addressItem, "addressItem")
if (this.status == 1) {
let pages = getCurrentPages(); // 当前页面
let beforePage = pages[pages.length - 2]; // 上一页
uni.navigateBack({
success: function() {
beforePage.$vm.getRegiFreight(addressItem);
console.log("返回成功!");
}
})
}
2 years ago
}
}
}
</script>
<style lang="scss" scoped>
2 years ago
.border-b {
border-bottom: 1px solid #f6f6f6;
}
.user-address {
height: 100vh;
overflow: hidden;
.address-contain {
height: calc(100vh - 70px);
width: calc(100% - 20px);
}
.user-handle {
display: flex;
align-items: center;
justify-content: space-between;
}
2 years ago
2 years ago
.handle-right {
vertical-align: middle;
}
2 years ago
}
2 years ago
// 底部按钮
.address-btn {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 50px;
line-height: 50px;
box-sizing: border-box;
2 years ago
display: flex;
2 years ago
justify-content: space-around;
2 years ago
align-items: center;
2 years ago
.add-btn {
width: 45%;
height: 40px;
line-height: 40px;
text-align: center;
border-radius: 20px;
&:first-of-type {
background-color: #F6C133;
}
&:last-of-type {
background-color: #3da7e7;
}
2 years ago
}
}
2 years ago
</style>