emis-app/pages/address/list.vue
2024-04-25 17:57:00 +08:00

212 lines
5.0 KiB
Vue

<template>
<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">
<view class="pgb-header">
<view class="com-jianju">
<!-- 关键字搜索框 -->
<tpx-search placeholder="请输入姓名/电话/地址关键字" v-model:value="searchParam.keyword"></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)" 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>
</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: {
keyword: '',
addressType: tabList[0].val
},
queryOption: {
tab: tabList[0].val, // 当前tab
type: '', // 'choose' 选择操作
},
resData: {
list: []
},
showLoadMore: false,
loadedAll: false
}
},
onShareAppMessage() {
return {
// title: '',
// path: 'TODO'
}
},
onLoad(queryOption) {
this.queryOption = queryOption
this.searchParam.addressType = queryOption.tab || tabList[0].val
this.initData();
},
unmounted() {
},
methods: {
getAddressDetail,
initData(){
},
getListFun: apiService.getCustomerUserAddressList,
handleItemClick(item){
switch(this.queryOption.type) {
case 'choose':
uni.$emit(pageEventNames.chooseAddress, {
queryOption: this.queryOption,
data: item
})
this.goBack()
break
;
}
},
handleEditItem(item={}) {
this.goto(`address/edit?id=${item.id}`)
},
async handleDelItem(item) {
await this.confirmModal('确认要删除吗?')
},
handleDefaultSwitch(item) {
},
}
}
</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;
}
.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>