addressChange.vue
4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<template>
<view class="container">
<!-- <u-navbar title="地址切换" autoBack :safeAreaInsetTop="true" placeholder fixed></u-navbar> -->
<Navbar title="地址切换" canBack></Navbar>
<view class="cardCss" v-for="(item,index) in adsList" :key="index">
<view class="margin-sm" @click="choiceAds(item)">
<u-icon name="checkmark-circle-fill" :color="item.fSfmrdz === 'y'?'#F04332':'#999DB0'"
size="20"></u-icon>
</view>
<view class="flex flex-direction">
<view class="flex align-center margin-bottom-sm">
<view class="text-xl">
{{item.fLxr || ""}}
</view>
<view class="text-lg margin-left-xs text-gray">
{{item.fLxrdh || ""}}
</view>
</view>
<view class="text-gray">
<!-- 湖北省武汉市洪山区青菱街道青菱寺 西路白沙洲农副产品大市场内 -->
<!-- {{item.fXxdz || ""}}-->
{{item.fLxrsf || ""}} {{item.fLxrs || ""}} {{item.fLxrq || ""}} {{item.fLxrjd || ""}} {{item.fLxrxxdz || ""}}
</view>
</view>
</view>
<u-empty mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png" v-if="!adsList.length">
<view class="" @click="goToAdsPage">
<u-button size="small" type="primary" :style="{marginTop:10+'px'}" text=" 去添加地址"></u-button>
</view>
</u-empty>
<u-loadmore :status="status" marginTop="20" height="10" marginBottom="10" v-else />
</view>
</template>
<script>
import {
mapGetters
} from 'vuex'
export default {
components: {},
data() {
return {
formData: {
current: 1,
size: 10
},
status: "loadmore",
total: null,
adsList: [],
qpid: ""
}
},
onPullDownRefresh() {
this.adsList = []
//调用获取数据方法
this.getAdsList()
setTimeout(() => {
//结束下拉刷新
uni.stopPullDownRefresh();
}, 500);
},
onReachBottom() {
let allTotal = this.formData.current * this.formData.size
if (allTotal < this.total) {
//当前条数小于总条数 则增加请求页数
this.formData.current++;
this.status = 'loading';
setTimeout(() => {
this.getAdsList()
}, 500)
} else {
this.status = 'nomore'
// console.log('已加载全部数据')
}
},
computed: {
...mapGetters({
adsId: 'adsId'
})
},
onLoad(data) {
if (data.qpid) {
this.qpid = data.qpid
}
},
onShow() {
this.getAdsList()
},
methods: {
// 查询地址列表
async getAdsList() {
const result = await this.$api.memberApi.getwHydzList(this.formData);
let {
code,
value
} = result;
if (code === 200) {
let allTotal = this.formData.current * this.formData.size
this.total = value.total
const newlist = value.records;
if (this.formData.current === 1) {
this.adsList = newlist;
} else {
this.adsList.push(...newlist)
}
if (this.adsList.length < allTotal) {
this.status = 'nomore'
}
this.adsList.map(item => {
if (item.id === this.adsId) {
item.fSfmrdz = 'y'
}else{
item.fSfmrdz = 'n'
}
})
}
console.log('地址列表', JSON.parse(JSON.stringify(this.adsList)));
},
// 点击勾选默认地址
async choiceAds(item) {
this.adsList.map(item => {
item.fSfmrdz = 'n'
})
item.fSfmrdz = 'y';
let data = {
adsId: item.id,
adsName: item.fLxrs,
adsJd: item.fJd,
adsWd: item.fWd
};
uni.$u.toast('切换地址成功');
this.$store.dispatch('GetDefaultAds', data);
console.log(this.$store);
},
// 跳转到地址管理页
goToAdsPage() {
if (this.qpid) {
uni.navigateTo({
url: "/pages/mine/appList/addressManagement/addAddress?qpid=" + this.qpid
})
} else {
uni.navigateTo({
url: "/pages/mine/appList/addressManagement/addAddress"
})
}
}
}
}
</script>
<style scoped lang="scss">
.container {
padding-bottom: 10px;
}
.cardCss {
display: flex;
align-items: center;
background: #fff;
border-radius: 15px;
height: 100px;
margin: 10px;
padding-right: 10px;
}
</style>