229 lines
6.0 KiB
Vue
229 lines
6.0 KiB
Vue
<template>
|
|
<tpx-page>
|
|
<tpx-layout>
|
|
<template v-slot:header> </template>
|
|
<template v-slot:body>
|
|
<view class="pos-abt-all">
|
|
<tpx-scroll-view v-model:resObject="resData" :searchParam="searchParam" :getListFun="getListFun"
|
|
ref="listRef"
|
|
>
|
|
<view class="pgb-header">
|
|
<view class="com-jianju">
|
|
<!-- 关键字搜索框 -->
|
|
<tpx-search placeholder="请输入姓名/电话/地址关键字" v-model:value="searchParam.searchValue"></tpx-search>
|
|
</view>
|
|
|
|
<view class="com-jianju" style="padding-top: 40rpx;">
|
|
<u-row justify="between" align="top">
|
|
<u-col span="12">
|
|
<tpx-tabs :list="tabList" v-model:value="searchParam.addressType"
|
|
v-slot="curTab"
|
|
>
|
|
<text slot>
|
|
<!-- (<text>{{curTab.item.val}}</text>) -->
|
|
</text>
|
|
</tpx-tabs>
|
|
</u-col>
|
|
|
|
</u-row>
|
|
</view>
|
|
</view>
|
|
<view class="pgb-cont">
|
|
<!-- 列表数据 -->
|
|
<view v-for="(item) in resData.list" class="data-list-item">
|
|
<view @click="handleItemClick(item)">
|
|
<u-row>
|
|
<view class="pr-20">
|
|
<u-text :text="item.name" size="30" :bold="true"></u-text>
|
|
</view>
|
|
<view>
|
|
<u-text :text="item.phone" size="28" mode="phone" color="#999"></u-text>
|
|
</view>
|
|
</u-row>
|
|
<u-text :text="getAddressDetail(item)"
|
|
size="24" margin="20rpx 0 0 0" color="#999"
|
|
></u-text>
|
|
</view>
|
|
<u-line color="#DEDEDE" margin="30rpx 0 0 0"></u-line>
|
|
|
|
<u-row custom-style="margin-top:20rpx;" justify="between">
|
|
<u-row>
|
|
<text class="pr-20 clr-sub">默认地址</text>
|
|
<u-switch v-model="item.blDefaultFlag" @change="handleDefaultSwitch(item)" activeValue="1" active-color="#B12D29" size="34"></u-switch>
|
|
</u-row>
|
|
<u-row>
|
|
<u-text @click="handleEditItem(item)" text="编辑" prefixIcon="edit-pen" size="26"></u-text>
|
|
<u-text @click="handleDelItem(item)" text="删除" prefixIcon="trash" size="26" margin="0 0 0 20rpx"></u-text>
|
|
</u-row>
|
|
</u-row>
|
|
</view>
|
|
</view>
|
|
</tpx-scroll-view>
|
|
</view>
|
|
</template>
|
|
|
|
<template v-slot:footer>
|
|
<view class="blcok-white-noradius">
|
|
<u-button @click="handleEditItem()" type="primary" size="large" shape="circle"
|
|
custom-style="height:80rpx;font-size: 30rpx;"
|
|
>
|
|
<u-row>
|
|
<u-icon size="34" color="#fff" name="plus"></u-icon>
|
|
<text class="pl-10">新增地址</text>
|
|
|
|
<u-icon size="34" color="#fff" ></u-icon>
|
|
</u-row>
|
|
</u-button>
|
|
</view>
|
|
</template>
|
|
</tpx-layout>
|
|
</tpx-page>
|
|
</template>
|
|
|
|
<script>
|
|
import * as apiService from "@/common/api"
|
|
import { pageEventNames } from "@/common/enum"
|
|
import { getAddressDetail } from "@/common/util"
|
|
|
|
const tabList = [
|
|
{ title: '寄件地址', val: 1 },
|
|
{ title: '收件地址', val: 2 },
|
|
// { title: '其他', val: 3 }
|
|
]
|
|
export default {
|
|
props: {
|
|
// hasLeftWin: {
|
|
// type: Boolean
|
|
// }
|
|
},
|
|
computed: {
|
|
hasExtSchParam() {
|
|
return Object.values(this.tmpSearchParam).filter(v=> !!v).length > 0
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
tabList ,
|
|
searchParam: {
|
|
searchValue: '',
|
|
addressType: tabList[0].val
|
|
},
|
|
queryOption: {
|
|
tab: tabList[0].val, // 当前tab
|
|
type: '', // 'choose' 选择操作
|
|
},
|
|
resData: { list: [] }
|
|
}
|
|
},
|
|
onShareAppMessage() {
|
|
return {
|
|
// title: '',
|
|
// path: 'TODO'
|
|
}
|
|
},
|
|
onLoad(queryOption) {
|
|
this.queryOption = queryOption
|
|
this.searchParam.addressType = queryOption.tab || tabList[0].val
|
|
this.initData();
|
|
},
|
|
unmounted() {
|
|
uni.$off(pageEventNames.addressSaveSuccess, this.addressSaveSuccessEventBack)
|
|
},
|
|
onShow(){
|
|
this?.$refs?.listRef?.getDataList?.(true) // 重置到第一页数据
|
|
},
|
|
methods: {
|
|
getAddressDetail,
|
|
initData(){
|
|
uni.$on(pageEventNames.addressSaveSuccess, this.addressSaveSuccessEventBack)
|
|
},
|
|
getListFun: apiService.getCustomerUserAddressList,
|
|
|
|
handleItemClick(item){
|
|
switch(this.queryOption.type) {
|
|
case 'choose':
|
|
uni.$emit(pageEventNames.chooseAddress, {
|
|
queryOption: this.queryOption,
|
|
data: item
|
|
})
|
|
this.goBack()
|
|
break
|
|
;
|
|
}
|
|
},
|
|
addressSaveSuccessEventBack({ data }){
|
|
|
|
},
|
|
handleEditItem(item={}) {
|
|
this.goto(`address/edit?id=${item.id || ''}&addressType=${this.searchParam.addressType}`)
|
|
},
|
|
async handleDelItem(item) {
|
|
let bl = await this.confirmModal('确认要删除吗?')
|
|
if(bl) {
|
|
await apiService.deleteAddressById({ id: item.id, _loading: true })
|
|
this.showToast('操作成功')
|
|
this.$refs.listRef.getDataList(true) // 重置到第一页数据
|
|
}
|
|
},
|
|
async handleDefaultSwitch(item) {
|
|
try{
|
|
await apiService.setDefaultAddressById({ id: item.id, defaultFlag: Number(!!item.blDefaultFlag), _loading: true })
|
|
this.showToast('操作成功')
|
|
this.$refs.listRef.getDataList(true) // 重置到第一页数据
|
|
}catch(e){
|
|
// 操作失败,切回按钮状态
|
|
item.blDefaultFlag = !item.blDefaultFlag
|
|
}
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
@import '@/common/uni-nvue.scss';
|
|
page {
|
|
background-color: #F6F6F6;
|
|
height: 100% !important;
|
|
}
|
|
|
|
</style>
|
|
<style scoped lang="scss">
|
|
.pgb-header {
|
|
// padding-top: --status-bar-height;
|
|
padding-top: 30rpx;
|
|
background-color: #FFF;
|
|
position: relative;
|
|
}
|
|
.pgb-cont{
|
|
padding: 30rpx 30rpx 0 30rpx;
|
|
}
|
|
|
|
.data-list-item{
|
|
box-shadow: 0rpx 3rpx 12rpx 0rpx rgba(139,139,139,0.06);
|
|
border-radius: 20rpx;
|
|
padding: 22rpx 30rpx;
|
|
background-color: #fff;
|
|
margin-bottom: 30rpx;
|
|
}
|
|
.search-more-panel{
|
|
overflow: hidden;
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
height: calc(70vh);
|
|
z-index: 200;
|
|
}
|
|
.smp-body{
|
|
padding: 30rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
height: 100%;
|
|
background-color: #FFF;
|
|
border-radius: 0 0 30rpx 30rpx;
|
|
box-sizing: border-box;
|
|
}
|
|
.smp-content{
|
|
flex: 1;
|
|
position: relative;
|
|
}
|
|
</style> |