|
@@ -3,70 +3,37 @@
|
|
|
<view class="main">
|
|
|
<view class="one">
|
|
|
<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
|
|
|
- <view class="list-scroll-view">
|
|
|
- <radio-group @change="addressChange" v-if="type=='shopping'">
|
|
|
- <label class="radio" v-for="(item, index) in list" :key="index">
|
|
|
+ <radio-group @change="addressChange">
|
|
|
+ <view class="list" v-for="(item,index) in list" :key="index">
|
|
|
+ <label class="radio" v-if="type=='shopping'">
|
|
|
<radio :value="item._id" :checked="index === address" />
|
|
|
- <view class="radio_1">
|
|
|
- <view class="name">
|
|
|
- <text>{{item.name}}</text>
|
|
|
- <text>{{item.phone}}</text>
|
|
|
- </view>
|
|
|
- <view class="address">
|
|
|
- <text>{{item.province}}</text>
|
|
|
- <text>{{item.city}}</text>
|
|
|
- <text>{{item.area}}</text>
|
|
|
- <text>{{item.address}}</text>
|
|
|
- <text>{{item.number}}</text>
|
|
|
- </view>
|
|
|
- <view class="btn">
|
|
|
- <view class="btn_1" v-if="item.is_default==false">
|
|
|
- <button type="default" size="mini" @click="toDefa(item)">设为默认</button>
|
|
|
- </view>
|
|
|
- <view class="btn_1">
|
|
|
- <button type="default" size="mini" @click="toCommon(item)">编辑</button>
|
|
|
- </view>
|
|
|
- <view class="btn_1">
|
|
|
- <button type="default" size="mini" @click="toDel(item)">删除</button>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view class="default" v-if="item.is_default==true">
|
|
|
- <text>默认</text>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
</label>
|
|
|
- </radio-group>
|
|
|
- <view v-else class="list" v-for="(item,index) in list" :key="index">
|
|
|
- <view class="name">
|
|
|
- <text>{{item.name}}</text>
|
|
|
- <text>{{item.phone}}</text>
|
|
|
- </view>
|
|
|
- <view class="address">
|
|
|
- <text>{{item.province}}</text>
|
|
|
- <text>{{item.city}}</text>
|
|
|
- <text>{{item.area}}</text>
|
|
|
- <text>{{item.address}}</text>
|
|
|
- <text>{{item.number}}</text>
|
|
|
- </view>
|
|
|
- <view class="btn">
|
|
|
- <view class="btn_1" v-if="item.is_default==false">
|
|
|
- <button type="default" size="mini" @click="toDefa(item)">设为默认</button>
|
|
|
+ <view class="list_1">
|
|
|
+ <view class="name">
|
|
|
+ <text>{{item.name}}</text>
|
|
|
+ <text>{{item.phone}}</text>
|
|
|
</view>
|
|
|
- <view class="btn_1">
|
|
|
- <button type="default" size="mini" @click="toCommon(item)">编辑</button>
|
|
|
+ <view class="address">
|
|
|
+ <text>{{item.province}}</text>
|
|
|
+ <text>{{item.city}}</text>
|
|
|
+ <text>{{item.area}}</text>
|
|
|
+ <text>{{item.address}}</text>
|
|
|
+ <text>{{item.number}}</text>
|
|
|
</view>
|
|
|
- <view class="btn_1">
|
|
|
- <button type="default" size="mini" @click="toDel(item)">删除</button>
|
|
|
+ <view class="btn">
|
|
|
+ <button class="btn_1" size="mini" @click="toDefa(item)" v-if="item.is_default==false">设为默认</button>
|
|
|
+ <button class="btn_2" size="mini" @click="toCommon(item)">编辑</button>
|
|
|
+ <button class="btn_3" size="mini" @click="toDel(item)">删除</button>
|
|
|
+ </view>
|
|
|
+ <view class="default" v-if="item.is_default==true">
|
|
|
+ <text>默认</text>
|
|
|
</view>
|
|
|
- </view>
|
|
|
- <view class="default" v-if="item.is_default==true">
|
|
|
- <text>默认</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="is_bottom" v-if="is_bottom">
|
|
|
<text>{{config.bottom_title}}</text>
|
|
|
</view>
|
|
|
- </view>
|
|
|
+ </radio-group>
|
|
|
</scroll-view>
|
|
|
</view>
|
|
|
<view class="two">
|
|
@@ -80,7 +47,6 @@
|
|
|
</view>
|
|
|
</mobile-frame>
|
|
|
</template>
|
|
|
-
|
|
|
<script>
|
|
|
export default {
|
|
|
data() {
|
|
@@ -95,22 +61,33 @@
|
|
|
list: [],
|
|
|
total: 0,
|
|
|
skip: 0,
|
|
|
- limit: 5,
|
|
|
+ limit: 6,
|
|
|
page: 0,
|
|
|
// 数据是否触底
|
|
|
is_bottom: false,
|
|
|
scrollTop: 0,
|
|
|
};
|
|
|
},
|
|
|
- onLoad: async function(e) {
|
|
|
+ onLoad: function(e) {
|
|
|
const that = this;
|
|
|
that.$set(that, `type`, e && e.type || '');
|
|
|
that.$set(that, `id`, e && e.id || '');
|
|
|
+ },
|
|
|
+ onShow: async function(e) {
|
|
|
+ const that = this;
|
|
|
that.searchConfig();
|
|
|
that.watchLogin();
|
|
|
},
|
|
|
- onShow: function() {},
|
|
|
- onHide: function() {},
|
|
|
+ onHide: function() {
|
|
|
+ const that = this;
|
|
|
+ that.clearPage()
|
|
|
+ },
|
|
|
+ onPullDownRefresh: function() {
|
|
|
+ const that = this;
|
|
|
+ that.clearPage()
|
|
|
+ that.search();
|
|
|
+ uni.stopPullDownRefresh();
|
|
|
+ },
|
|
|
methods: {
|
|
|
// 查询基本设置
|
|
|
searchConfig() {
|
|
@@ -186,6 +163,7 @@
|
|
|
uni.hideLoading();
|
|
|
} else that.$set(that, `is_bottom`, true)
|
|
|
},
|
|
|
+ // 计算是否触底
|
|
|
toScroll(e) {
|
|
|
const that = this;
|
|
|
let up = that.scrollTop;
|
|
@@ -207,6 +185,32 @@
|
|
|
delta: 1
|
|
|
})
|
|
|
},
|
|
|
+ // 设置默认
|
|
|
+ toDefa(e) {
|
|
|
+ const that = this;
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '确定设置该地址为默认地址吗?',
|
|
|
+ success: async function(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ const arr = await that.$api(`/address/toDefault/${e._id}`, `POST`);
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ uni.showToast({
|
|
|
+ title: '添加默认成功',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ that.clearPage()
|
|
|
+ that.search()
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: arr.errmsg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
// 获取微信地址
|
|
|
toWxaddress() {
|
|
|
const that = this;
|
|
@@ -237,8 +241,7 @@
|
|
|
title: '添加收货地址成功',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
- that.clearPage();
|
|
|
- that.search();
|
|
|
+ that.clearPage()
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
title: arr.errmsg,
|
|
@@ -246,46 +249,20 @@
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
- fail: async function(err) {
|
|
|
- that.clearPage();
|
|
|
- that.search();
|
|
|
+ fail: function() {
|
|
|
+ that.clearPage()
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- // 设置默认
|
|
|
- toDefa(e) {
|
|
|
- const that = this;
|
|
|
- uni.showModal({
|
|
|
- title: '提示',
|
|
|
- content: '确定设置该地址为默认地址吗?',
|
|
|
- success: async function(res) {
|
|
|
- if (res.confirm) {
|
|
|
- const arr = await that.$api(`/address/toDefault/${e._id}`, `POST`);
|
|
|
- if (arr.errcode == '0') {
|
|
|
- uni.showToast({
|
|
|
- title: '添加默认成功',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- that.clearPage();
|
|
|
- that.search();
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: arr.errmsg,
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
// 编辑
|
|
|
toCommon(e) {
|
|
|
const that = this;
|
|
|
+ that.clearPage();
|
|
|
uni.navigateTo({
|
|
|
- url: `/pagesMy/address/add?id=${e&&e.id?e.id:''}`
|
|
|
+ url: `/pagesMy/address/add?id=${e&&e._id||''}`
|
|
|
})
|
|
|
},
|
|
|
// 删除
|
|
@@ -302,8 +279,8 @@
|
|
|
title: '删除信息成功',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
- that.clearPage();
|
|
|
- that.search();
|
|
|
+ that.clearPage()
|
|
|
+ that.search()
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
title: arr.errmsg,
|
|
@@ -323,15 +300,7 @@
|
|
|
that.$set(that, `page`, 0)
|
|
|
}
|
|
|
},
|
|
|
- onPullDownRefresh: async function() {
|
|
|
- const that = this;
|
|
|
- that.$set(that, `list`, [])
|
|
|
- that.$set(that, `skip`, 0)
|
|
|
- that.$set(that, `limit`, 6)
|
|
|
- that.$set(that, `page`, 0)
|
|
|
- await that.search();
|
|
|
- uni.stopPullDownRefresh();
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
</script>
|
|
|
|
|
@@ -341,23 +310,23 @@
|
|
|
flex-direction: column;
|
|
|
width: 100vw;
|
|
|
height: 100vh;
|
|
|
+ background-color: var(--f1Color);
|
|
|
|
|
|
.one {
|
|
|
position: relative;
|
|
|
flex-grow: 1;
|
|
|
- background-color: var(--f5Color);
|
|
|
|
|
|
- .radio {
|
|
|
- position: relative;
|
|
|
+ .list {
|
|
|
display: flex;
|
|
|
background: var(--fffColor);
|
|
|
- padding: 2vw;
|
|
|
- width: 92vw;
|
|
|
margin: 2vw 2vw 0 2vw;
|
|
|
+ padding: 2vw;
|
|
|
border-radius: 5px;
|
|
|
+ position: relative;
|
|
|
+
|
|
|
+ .list_1 {
|
|
|
+ flex-grow: 1;
|
|
|
|
|
|
- .radio_1 {
|
|
|
- width: 80vw;
|
|
|
.name {
|
|
|
font-size: var(--font16Size);
|
|
|
margin: 0 0 2vw 0;
|
|
@@ -377,30 +346,20 @@
|
|
|
}
|
|
|
|
|
|
.btn {
|
|
|
- display: flex;
|
|
|
- flex-direction: row;
|
|
|
- justify-content: space-around;
|
|
|
- border-top: 1px solid var(--font16Size);
|
|
|
- padding: 2vw 0 0 0;
|
|
|
+ text-align: center;
|
|
|
|
|
|
- .btn_1 {
|
|
|
- button {
|
|
|
- width: 100%;
|
|
|
- color: var(--fffColor);
|
|
|
- background-color: var(--f35BColor);
|
|
|
- }
|
|
|
+ button {
|
|
|
+ margin: 0 2vw 2vw 2vw;
|
|
|
+ background-color: var(--f35BColor);
|
|
|
+ color: var(--fffColor);
|
|
|
}
|
|
|
|
|
|
- .btn_1:nth-child(2) {
|
|
|
- button {
|
|
|
- background-color: var(--f0fColor);
|
|
|
- }
|
|
|
+ .btn_2 {
|
|
|
+ background-color: var(--f0fColor);
|
|
|
}
|
|
|
|
|
|
- .btn_1:last-child {
|
|
|
- button {
|
|
|
- background-color: var(--fFB1Color);
|
|
|
- }
|
|
|
+ .btn_3 {
|
|
|
+ background-color: var(--fFB1Color);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -419,81 +378,10 @@
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- .list {
|
|
|
- position: relative;
|
|
|
- background: var(--fffColor);
|
|
|
- padding: 2vw;
|
|
|
- width: 92vw;
|
|
|
- margin: 2vw 2vw 0 2vw;
|
|
|
- border-radius: 5px;
|
|
|
-
|
|
|
- .name {
|
|
|
- font-size: var(--font16Size);
|
|
|
- margin: 0 0 2vw 0;
|
|
|
-
|
|
|
- text {
|
|
|
- padding: 0 2vw 0 0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- .address {
|
|
|
- font-size: var(--font14Size);
|
|
|
- margin: 0 0 1vw 0;
|
|
|
-
|
|
|
- text {
|
|
|
- padding: 0 2vw 0 0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- .btn {
|
|
|
- display: flex;
|
|
|
- flex-direction: row;
|
|
|
- justify-content: space-around;
|
|
|
- border-top: 1px solid var(--font16Size);
|
|
|
- padding: 2vw 0 0 0;
|
|
|
-
|
|
|
- .btn_1 {
|
|
|
- button {
|
|
|
- width: 100%;
|
|
|
- color: var(--fffColor);
|
|
|
- background-color: var(--f35BColor);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- .btn_1:nth-child(2) {
|
|
|
- button {
|
|
|
- background-color: var(--f0fColor);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- .btn_1:last-child {
|
|
|
- button {
|
|
|
- background-color: var(--fFB1Color);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- .default {
|
|
|
- position: absolute;
|
|
|
- top: 0;
|
|
|
- right: 0;
|
|
|
-
|
|
|
- text {
|
|
|
- background: var(--ff0Color);
|
|
|
- color: var(--fffColor);
|
|
|
- font-size: var(--font12Size);
|
|
|
- padding: 1vw;
|
|
|
- border-radius: 5px;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
.two {
|
|
|
display: flex;
|
|
|
- flex-direction: row;
|
|
|
justify-content: space-between;
|
|
|
|
|
|
.two_1 {
|