·修改部分页面数据冗余

This commit is contained in:
lemon橪
2021-05-14 17:31:40 +08:00
parent 23804939eb
commit 7f4212755d
42 changed files with 1415 additions and 2987 deletions

View File

@@ -1,32 +1,19 @@
<template>
<view class="address">
<view class="bar"></view>
<empty v-if="empty"></empty>
<u-empty class="empty" v-if="empty" text="暂无收货地址" mode="address"></u-empty>
<view class="list" v-else>
<view class="item c-content" v-for="(item, index) in addressList" :key="index">
<view class="basic">
<text>{{ item.name }}</text>
<text>{{ item.mobile }}</text>
<text class="default" v-show="item.isDefault">默认</text>
<view>
<div class="region">
<span v-if="item.consigneeAddressPath[0]">{{
item.consigneeAddressPath[0]
}}</span>
<span v-if="item.consigneeAddressPath[1]">{{
item.consigneeAddressPath[1]
}}</span>
<span v-if="item.consigneeAddressPath[2]">{{
item.consigneeAddressPath[2]
}}</span>
<span v-if="item.consigneeAddressPath[3]">{{
item.consigneeAddressPath[3]
}}</span>
<span>
{{ item.detail }}
</span>
<span v-if="item.consigneeAddressPath[0]">{{item.consigneeAddressPath[0]}}</span>
<span v-if="item.consigneeAddressPath[1]">{{item.consigneeAddressPath[1]}}</span>
<span v-if="item.consigneeAddressPath[2]">{{item.consigneeAddressPath[2]}}</span>
<span v-if="item.consigneeAddressPath[3]">{{item.consigneeAddressPath[3]}}</span>
<span>{{ item.detail }}</span>
</div>
</view>
</view>
@@ -40,7 +27,7 @@
<view class="alifont icon-bianji-copy"></view>
<text class="mr-40" @click="addAddress(item.id)">编辑</text>
<view class="alifont icon-lajitong"></view>
<text @click="delAddress(item.id)">删除</text>
<text @click="removeAddress(item.id)">删除</text>
</view>
</view>
</view>
@@ -52,22 +39,19 @@
添加新收货人
</button>
<u-action-sheet :list="delList" :tips="tips" v-model="showAction" @click="deleteAddressMessage"></u-action-sheet>
<u-action-sheet :list="removeList" :tips="tips" v-model="showAction" @click="deleteAddressMessage"></u-action-sheet>
</view>
</template>
<script>
import * as API_Trade from "@/api/trade";
import * as API_Address from "@/api/address.js";
import storage from "@/utils/storage.js";
export default {
data() {
return {
activeClass: "activeClass",
addressList: [],
showAction: false,
empty: false,
delList: [
addressList: [], //地址列表
showAction: false, //是否显示下栏框
empty: false, //是否为空
removeList: [
{
text: "确定",
},
@@ -75,9 +59,8 @@ export default {
tips: {
text: "确定要删除该收货人信息吗?",
},
delId: "",
addid: "",
routerVal: "",
removeId: "", //删除的地址id
routerVal: "",
params: {
pageNumber: 1,
pageSize: 1000,
@@ -94,22 +77,33 @@ export default {
onLoad: function (val) {
this.routerVal = val;
},
/**
* 进入页面检测当前账户是否登录
*/
onShow() {
let userInfo = storage.getUserInfo();
if (userInfo && userInfo.id) {
if (this.$options.filters.isLogin("auth")) {
this.getAddressList();
} else {
uni.showModal({
title: "提示",
content: "检测到您的账号还未登录,是否去登录?",
confirmColor: this.$lightColor,
success: function (res) {
if (res.confirm) {
uni.navigateTo({
url: "/pages/passport/login",
});
} else if (res.cancel) {
uni.navigateBack();
}
},
});
}
},
onPullDownRefresh() {
this.getAddressList();
uni.stopPullDownRefresh();
},
methods: {
//获取地址列表
getAddressList() {
uni.showLoading();
API_Address.getAddressList(
this.params.pageNumber,
this.params.pageSize
@@ -120,19 +114,19 @@ export default {
res.data.result.records.forEach((item) => {
item.consigneeAddressPath = item.consigneeAddressPath.split(",");
});
this.addressList = res.data.result.records;
}
uni.hideLoading();
});
},
//删除地址
delAddress(id) {
this.delId = id;
removeAddress(id) {
this.removeId = id;
this.showAction = true;
},
// 删除地址
deleteAddressMessage() {
API_Address.deleteAddress(this.delId).then((res) => {
API_Address.deleteAddress(this.removeId).then((res) => {
if (res.statusCode == 200) {
uni.showToast({
icon: "none",
@@ -150,15 +144,9 @@ export default {
},
//新建。编辑地址
addAddress(id) {
if (id) {
uni.navigateTo({
url: "/pages/mine/address/add?id=" + id,
});
} else {
uni.navigateTo({
url: "/pages/mine/address/add",
});
}
uni.navigateTo({
url: `/pages/mine/address/add${id ? "?id=" + id : ""}`,
});
},
//设为默认地址
setDefault(item) {
@@ -168,7 +156,7 @@ export default {
item.isDefault ? "" : (item.isDefault = !item.isDefault);
API_Address.editAddress(item).then((res) => {
API_Address.editAddress(item).then(() => {
uni.showToast({
title: "设置默认地址成功",
icon: "none",
@@ -176,154 +164,10 @@ export default {
this.getAddressList();
});
},
// 地址id
addId(params) {
API_Trade.setAddressId(params.address_id).then((res) => {});
},
},
};
</script>
<style lang="scss" scoped>
.active {
background: #f19736;
}
.alifont {
display: inline-block;
}
.region {
span {
margin: 0 4rpx !important;
}
}
.address {
.bar {
height: 20rpx;
overflow: hidden;
width: 100%;
background: url("/pages/floor/imgs/line.png") no-repeat;
background-size: 100%;
position: relative;
top: 0;
left: 0;
transform: scale(1, 0.8);
}
.default {
border: 1px solid #ff6262;
color: #ff6262;
font-size: 22rpx;
border-radius: 6rpx;
align-self: center;
padding: 2rpx 20rpx;
}
.list {
.item {
margin-top: 20rpx;
font-size: $font-base;
color: #666;
.basic {
padding: 30rpx;
line-height: 1.5em;
border-bottom: 1px solid $border-color-light;
:nth-child(2) {
margin: 0 20rpx;
}
:nth-child(4) {
color: $font-color-light;
font-size: $font-sm;
margin-top: 10rpx;
text:nth-child(2) {
margin: 0;
}
view {
font-size: 28rpx;
}
}
}
.edit {
display: flex;
justify-content: space-between;
align-items: center;
vertical-align: middle;
height: 80rpx;
font-size: $font-sm;
color: $font-color-light;
padding: 0 30rpx;
.unchecked {
width: 28rpx;
height: 28rpx;
border-radius: 50%;
border: 1px solid #e0e0e0;
display: inline-block;
vertical-align: middle;
margin-right: 8rpx;
position: relative;
top: -2rpx;
left: 0;
}
view:nth-child(1) {
view:nth-child(1) {
font-size: $font-base;
color: $main-color;
margin-right: 8rpx;
vertical-align: middle;
}
}
view:nth-child(2) {
text {
margin-left: 5rpx;
}
.alifont {
font-size: 32rpx;
}
.icon-bianji-copy {
font-size: 28rpx;
position: relative;
top: 2rpx;
left: 0;
}
.icon-lajitong {
position: relative;
top: 4rpx;
}
}
.mr-40 {
margin-right: 40rpx;
}
}
}
}
.btn {
background: $light-color;
position: fixed;
width: 690rpx;
bottom: 60rpx;
height: 80rpx;
left: 30rpx;
font-size: 30rpx;
line-height: 80rpx;
.u-icon {
margin-right: 10rpx;
}
}
}
@import './address.scss';
</style>