emis-sapp/pages/address/list.vue
2024-05-31 18:58:28 +08:00

238 lines
5.9 KiB
Vue

<template>
<tpx-layout>
<template v-slot:header> </template>
<template v-slot:body>
<scroll-view :scroll-y="true" @scrolltolower="onScrollBottom()" class="pos-abt-all"
>
<view class="pgb-header">
<view class="com-jianju">
<!-- 关键字搜索框 -->
<tpx-search placeholder="请输入姓名/电话/地址关键字" v-model:value="searchParam.keyword" @change="handleSearchParamChange()" ></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.tabType"
@tabchange="(val)=> { handleSearchParamChange() }" 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 dataList" class="data-list-item">
<view @click="handleItemClick(item)">
<u-row>
<view class="pr-20">
<u-text :text="'李先生'" size="30" :bold="true"></u-text>
</view>
<view>
<u-text :text="'18627068352'" size="28" mode="phone" color="#999"></u-text>
</view>
</u-row>
<u-text :text="'上海市大世界大世界大世界大世界大世界大世界大世界大世界大世界大世界大世界大世界大世界大世界大世界大世界大世界大世界大世界大世界大世界'"
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.morenTODO" @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>
<!-- 加载更多 -->
<u-loadmore icon-size="28" font-size="28" margin-top="30" v-if="showLoadMore || loadedAll"
:status="loadedAll ? 'nomore' : 'loading'" />
<!-- 空数据页 -->
<view v-if="dataList.length == 0" style="padding-top: 100rpx;">
<u-empty text="无数据" :icon="getCdnUrl('kong.png')" textSize="28" width="86" height="97">
</u-empty>
</view>
</view>
</scroll-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 getCdnUrl from "@/common/getCdnUrl"
import { goto, goBack, setClipboardData, confirmModal, showLoading } from "@/common/untool"
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: '',
tabType: tabList[0].val
},
queryOption: {},
dataList: [
{},{},{},{},{},{},{},{}
],
showLoadMore: false,
loadedAll: false
}
},
onShareAppMessage() {
return {
// title: '',
// path: 'TODO'
}
},
onLoad(queryOption) {
this.queryOption = queryOption
this.searchParam.tabType = queryOption.tab || tabList[0].val
this.initData();
},
onUnload() {
},
methods: {
getCdnUrl,
initData(){
// showLoading()
setTimeout(() => {
uni.stopPullDownRefresh();
}, 300);
},
setListData() {
},
onScrollBottom() {
console.log("onScrollBottom");
if (this.loadedAll) {
return;
}
this.showLoadMore = true;
setTimeout(() => {
this.setListData();
}, 300);
},
handleSearchMoreBtn(){
if(!this.showLoadMore) {
// 回显更多条件
Object.keys(this.tmpSearchParam).map(t=> {
this.tmpSearchParam[t] = this.searchParam[t] || ''
})
}
this.showSearchMore = !this.showSearchMore
},
handleSearchParamChange(key, val) {
if(key) {
this.searchParam[key] = val
}
},
handleItemClick(item){
if(this.queryOption.type == "choose") {
goBack()
}
},
handleEditItem(item={}) {
goto(`address/edit?id=${item.id}`)
},
async handleDelItem(item) {
await 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>