oil-station/gasStation-uni/pagesHome/Address/Address.vue

260 lines
5.1 KiB
Vue
Raw Normal View History

2024-08-16 18:26:19 +08:00
<template>
<view class="content">
<view class="container">
<view class="my-header">
<view class="my-icons" @click="goback"> <uni-icons type="left" size="16"></uni-icons> </view>
<view class="my-text">收货地址</view>
<view class="my-icons"></view>
</view>
<!-- 顶部区域 -->
2024-09-25 10:39:17 +08:00
<view class="box-xianze" v-for="(item,index) in dataList" :key="index">
2024-09-25 16:56:41 +08:00
<view class="" @click="choose(item)">
2024-08-16 18:26:19 +08:00
<view style="display: flex;align-items: center;margin-bottom: 5px;">
2024-09-25 10:39:17 +08:00
<view class="">{{item.name || '--'}}</view>
<view style="margin: 0 10px;" v-if="item.sex==0"> 先生</view>
<view style="margin: 0 10px;" v-if="item.sex==1"> 女士</view>
<view class=""> {{item.mobile || '--'}}</view>
2024-08-16 18:26:19 +08:00
</view>
</view>
2024-09-24 15:50:38 +08:00
<view class="box-xia">
2024-09-25 11:17:30 +08:00
<view class="box-left" @click="chooseDefault(item)">
<view class="acvf" v-if="item.checked == false"></view>
<view class="acv" v-else><u-icon name="checkbox-mark" color="#fff" size="14"></u-icon></view>
<view style="font-size: 14px; color: #999; ">默认信息</view>
2024-09-24 15:50:38 +08:00
</view>
<view class="box-right">
<view style="display: flex;" @click="goedit(item)">
<u-icon name="edit-pen-fill" size="12"></u-icon>
<view style="margin-left: 5px;">编辑</view>
</view>
2024-09-25 10:39:17 +08:00
<view style="display: flex;" @click="delInfo(item)">
2024-09-24 15:50:38 +08:00
<u-icon name="trash" size="12"></u-icon>
<view style="margin-left: 5px;">删除</view>
</view>
2024-09-25 10:39:17 +08:00
2024-09-24 15:50:38 +08:00
</view>
2024-08-16 18:26:19 +08:00
</view>
</view>
<view class="bottom-anniu" @click="goedit()">
2024-09-24 15:50:38 +08:00
<view class="">新增预留信息</view>
2024-08-16 18:26:19 +08:00
</view>
</view>
</view>
</template>
<script>
import config from '@/config'
import request from '../../utils/request'
export default {
data() {
return {
title: '',
dataList: '',
2024-09-25 11:17:30 +08:00
checkboxValue1: [],
checked: true,
2024-08-16 18:26:19 +08:00
}
},
onShow() {
this.getList();
},
components: {
},
methods: {
2024-09-25 11:17:30 +08:00
chooseDefault(data) {
console.log(data);
if (data.checked == false) {
2024-09-25 10:39:17 +08:00
data.ifDefault = 1
2024-09-25 11:17:30 +08:00
} else {
2024-09-25 10:39:17 +08:00
data.ifDefault = 2
}
request({
url: '/business/userManager/mtUserExpressAddress',
method: 'put',
2024-09-25 11:17:30 +08:00
data: data
2024-09-25 10:39:17 +08:00
}).then((res) => {
if (res.code == 200) {
this.getList()
2024-09-25 11:17:30 +08:00
console.log(res, 81);
2024-09-25 10:39:17 +08:00
}
})
},
2024-08-16 18:26:19 +08:00
getList() {
request({
2024-09-25 10:39:17 +08:00
url: '/business/userManager/mtUserExpressAddress/getList',
2024-08-16 18:26:19 +08:00
method: 'get',
}).then((res) => {
if (res.code == 200) {
this.dataList = res.data
2024-09-25 10:39:17 +08:00
this.dataList.forEach(item => {
item.checked = false
if (item.ifDefault == 1) {
item.checked = true
}
})
2024-09-25 11:17:30 +08:00
console.log(res, this.dataList, 98);
2024-09-25 10:39:17 +08:00
this.$forceUpdate()
2024-08-16 18:26:19 +08:00
}
})
},
goedit(data) {
if (data != null) {
console.log(data)
//传值
uni.$on('unAddressInfo', function() {
uni.$emit('addressInfo', data)
})
}
uni.navigateTo({
url: '/pagesHome/editress/editress'
})
},
2024-09-25 10:39:17 +08:00
// 删除
2024-09-25 11:17:30 +08:00
delInfo(data) {
2024-09-25 10:39:17 +08:00
request({
url: '/business/userManager/mtUserExpressAddress',
method: 'delete',
2024-09-25 11:17:30 +08:00
params: {
id: data.id
}
2024-09-25 10:39:17 +08:00
}).then((res) => {
if (res.code == 200) {
this.getList()
}
})
},
2024-08-16 18:26:19 +08:00
choose(data) {
//传值
uni.$on('unChooseAddr', function() {
uni.$emit('chooseAddr', data)
})
uni.navigateBack()
},
goback() {
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
.content {
background: #f4f5f6;
}
.container {
width: 100%;
height: 100vh;
box-sizing: border-box;
padding-top: 88px;
}
.my-header {
width: 100%;
height: 88px;
background: #ffffff;
display: flex;
align-items: center;
justify-content: space-between;
color: #000;
box-sizing: border-box;
padding: 0px 15px;
padding-top: 40px;
.my-icons {
width: 20px;
}
position: fixed;
top: 0px;
}
.bottom-anniu {
width: 90%;
2024-09-24 15:50:38 +08:00
height: 40px;
2024-08-16 18:26:19 +08:00
display: flex;
align-items: center;
2024-09-24 15:50:38 +08:00
background: #FF9655;
2024-08-16 18:26:19 +08:00
color: white;
justify-content: center;
position: fixed;
2024-09-24 15:50:38 +08:00
bottom: 40px;
2024-08-16 18:26:19 +08:00
left: 50%;
transform: translateX(-50%);
2024-09-24 15:50:38 +08:00
border-radius: 50px;
2024-08-16 18:26:19 +08:00
}
.box-xianze {
width: 95%;
background-color: #ffffff;
margin: 10px auto;
padding: 10px;
box-sizing: border-box;
}
2024-09-25 11:17:30 +08:00
.box-left {
display: flex;
align-items: center;
}
2024-08-16 18:26:19 +08:00
.box-right {
2024-09-24 15:50:38 +08:00
width: 30%;
2024-08-16 18:26:19 +08:00
display: flex;
align-items: center;
2024-09-24 15:50:38 +08:00
justify-content: space-between;
font-size: 14px;
color: #333333;
2024-08-16 18:26:19 +08:00
}
.tapl {
width: 40px;
height: 20px;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
color: #1678ff;
border: 1px solid #1678ff;
font-size: 14px;
}
2024-09-24 15:50:38 +08:00
.box-xia {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
2024-09-25 11:17:30 +08:00
.acvf {
border-radius: 50%;
border: 1px solid #eee;
height: 16px;
width: 16px;
display: flex;
align-items: center;
justify-content: center;
margin-right: 10px;
}
.acv {
border-radius: 50%;
border: 1px solid #1678ff;
height: 16px;
width: 16px;
background: #1678ff;
color: #fff;
margin-right: 10px;
display: flex;
align-items: center;
justify-content: center;
}
2024-08-16 18:26:19 +08:00
</style>