sadjv3_user/my/address/address.vue

271 lines
6.5 KiB
Vue

<template>
<view class="content">
<!-- #ifndef MP-WEIXIN -->
<view class="address-list" v-for="(item,index) in list" :key='index'>
<view @tap='goBackByAddress(item.addressId)' class="flex align-center">
<view class="address-list-img">
<image src="../../static/bbn.png" mode=""></image>
</view>
<view style="margin-left: 20rpx;flex: 1;">
<view style="color: #333333;font-size: 31rpx;font-weight: bold;">
{{item.name}}
<text class="margin-left-sm" style="font-weight: normal;color: #999;">{{item.phone}}</text>
</view>
<view class="" style="color: #999;margin-top: 8rpx;font-size: 26rpx;">
{{item.province}}{{item.city}}{{item.district}} {{item.detailsAddress}}
</view>
</view>
</view>
<view style="margin-top: 30rpx;height: 1rpx;background-color: #f7f7f7;margin-bottom: 10upx;"></view>
<view style="display: flex;padding: 0 5upx 0 0;font-size: 26upx;">
<radio-group name="openWay" style="text-align: left;width: 70%;">
<label class="tui-radio">
<radio :checked="item.isDefault == 1 ? true : false" color="#019c88" :disabled='item.isDefault == 1 ? false : true'
style="transform:scale(0.6);" />
<text style="font-size: 26upx;margin-left: 8upx;">默认地址</text>
</label>
</radio-group>
<view style="display: flex;margin-left: 80upx;margin-top: 10rpx;width: 40%;text-align: right;">
<view class="delete-view" @tap='deleteAddressList(item.addressId)'>删除</view>
<view class="delete-view delete-btn" @tap='goAddress(item.addressId)'>编辑</view>
</view>
</view>
</view>
<view style="position: fixed;bottom: 0rpx;left: 0;right: 0;background: #FFFFFF;height: 110rpx;line-height: 110rpx;z-index: 999;">
<button class="shouhuo" @tap="goAddress('')">
新增收货地址
</button>
</view>
<empty v-if="list.length == 0" :noneData="noneData"></empty>
<!-- #endif -->
<!-- 悬浮上拉 -->
<!-- <view class="scroll_top" @tap="topScrollTap" v-bind:class="[scrollTop ? 'active' : '', '']"
style="bottom: 56px;"><text class="iconfont icon-shangla"></text></view> -->
</view>
</template>
<script>
import empty from '@/components/empty.vue'
export default {
components: {
empty,
},
data() {
return {
openWay: 0,
list: [],
// loadingType: 0,
type: 1,
scrollTop: true,
page: 1,
limit: 5,
address: '',
isfa: '',
noneData:'地址'
}
},
onShow() {
let userId = this.$queue.getData('userId');
if (userId) {
this.getAddressList();
}
},
onLoad(e) {
this.isfa = e.id
let userId = this.$queue.getData('userId');
if (userId) {
this.getAddressList();
}
},
methods: {
goBackByAddress(addressId) {
// console.log("addressId",addressId)
this.$queue.setData('EditAddress', addressId);
if (this.isfa == 0) {
console.log('1111111')
}else if (this.isfa ==1 ) {
this.updateaddress()
}else if (this.isfa == 2) {
uni.reLaunch({
url:'/my/order/payModify'
})
} else if (this.isfa == 3) {
this.updateaddress()
}
},
updateaddress() {
let addressId = this.$queue.getData('EditAddress')
let data = {
ordersId: this.isfa.order,
addressId: addressId
}
this.$Request.post('/app/orders/updateOrdersAddress', data).then(res => {
console.log(res)
if (res.code == 0) {
uni.showToast({
title: '修改成功',
icon: 'none'
})
uni.navigateBack();
}
})
},
deleteAddressList(id) {
console.log(id)
var id = id
let data = {
addressId: id,
}
uni.showModal({
title: '温馨提示',
content: '您确定要删除此地址信息吗?',
showCancel: true,
cancelText: '取消',
confirmText: '确认',
success: res => {
if (res.confirm) {
this.$Request.postT('/app/address/deleteAddress', data).then(res => {
console.log(res)
if (res.code == 0) {
this.$queue.showToast("删除成功!");
this.getAddressList();
} else {
this.$queue.showToast(res.msg);
}
});
}
}
});
},
getAddressList() {
uni.showLoading({
title: '加载中...'
});
let userId = this.$queue.getData('userId');
let data = {
userId: userId,
page: this.page,
limit: this.limit
}
this.$Request.getT('/app/address/selectAddressListById', data).then(res => {
uni.hideLoading();
uni.stopPullDownRefresh();
if (res.code == 0) {
if (this.page == 1) this.list = []
this.list = [...this.list, ...res.data.list]; //追加新数据
console.log("数据",this.list)
}
});
},
goAddress(id) {
uni.navigateTo({
url: '/my/address/Endaddress?id=' + id
});
},
tabSlect(item) {
this.tabIndex = item.id;
},
selectWay(id) {
this.openWay = id;
},
},
onReachBottom: function() {
this.page = this.page + 1;
this.getAddressList();
},
onPullDownRefresh: function() {
this.page = 1;
this.getAddressList();
}
}
</script>
<style lang="less" scoped>
.delete-btn{
margin-left: 10px;
}
.delete-view{
width: 85rpx;
text-align: center;
background: #FFFFFF;
border-radius: 18rpx;
border: 1px solid #4D4D4D;
font-weight: 400;
font-size: 23rpx;
color: #4D4D4D;
}
.address-list-img{
width: 91rpx;
height: 91rpx;
}
.address-list-img image{
width: 100%;
height: 100%;
border-radius: 50%;
}
.address-list{
width: 95%;
height: 246rpx;
background: #FFFFFF;
border-radius: 24rpx;
margin: 20px auto 0px auto;
height: max-content;
padding: 30upx;
display: flex;
flex-direction: column;
}
.content{
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
background-color: #f7f7f7;
}
// @import '../../../static/less/index.less';
// @import '../../../static/css/index.css';
.shouhuo{
margin: 16rpx 30upx;
position: fixed;
bottom: -7upx;
width: 92%;
height: 92rpx;
background: linear-gradient(90deg, #019C88, #28BA92, #35C495);
border-radius: 46rpx;
line-height: 92rpx;
font-weight: 400;
font-size: 36rpx;
color: #FFFFFF;
}
page {
background: #f7f7f7;
}
.tui-line-cell {
width: 100%;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 2upx solid #f2f2f2;
padding: 0 0 16upx 0;
}
.tui-title {
line-height: 32rpx;
min-width: 120rpx;
flex-shrink: 0;
}
.tui-input {
font-size: 32rpx;
color: #333;
padding-left: 20rpx;
flex: 1;
}
</style>