mirror of
https://gitee.com/java110/WechatOwnerService.git
synced 2026-02-24 05:46:04 +08:00
优化代码
This commit is contained in:
parent
dd7b2cff38
commit
73152b1802
@ -55,3 +55,26 @@ export function getCurOwner() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function getUserAddress(_data){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let moreRooms = [];
|
||||||
|
request({
|
||||||
|
url: url.queryUserAddress,
|
||||||
|
method: "GET",
|
||||||
|
data: _data, //动态数据
|
||||||
|
success: function(res) {
|
||||||
|
let _data = res.data;
|
||||||
|
if (_data.code == 0) {
|
||||||
|
resolve(_data);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
reject(_data.msg);
|
||||||
|
},
|
||||||
|
fail: function(e) {
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@ -96,6 +96,7 @@ export default {
|
|||||||
queryProduct: baseUrl +'app/product/queryProduct',
|
queryProduct: baseUrl +'app/product/queryProduct',
|
||||||
saveStoreCart: baseUrl +'app/storeOrder/saveStoreCart',
|
saveStoreCart: baseUrl +'app/storeOrder/saveStoreCart',
|
||||||
queryStoreCart: baseUrl +'app/storeOrder/queryStoreCart',
|
queryStoreCart: baseUrl +'app/storeOrder/queryStoreCart',
|
||||||
|
queryUserAddress: baseUrl + 'app/userAddress/queryUserAddress',
|
||||||
|
|
||||||
NEED_NOT_LOGIN_PAGE: [
|
NEED_NOT_LOGIN_PAGE: [
|
||||||
'/pages/login/login',
|
'/pages/login/login',
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="page_box">
|
<view class="page_box flex flex-direction justify-between">
|
||||||
<view class="head_box"></view>
|
<view class="head_box"></view>
|
||||||
<view class="content_box">
|
<view class="content_box">
|
||||||
<view class="address-list" v-for="address in addressList" :key="address.id" @tap="useAddress(address)">
|
<view class="address-list" v-for="address in addressList" :key="address.id" @tap="useAddress(address)">
|
||||||
@ -12,134 +12,160 @@
|
|||||||
<button class="cu-btn set-btn" @tap.stop="jump('/pages/user/address/edit', { id: address.id })">编辑</button>
|
<button class="cu-btn set-btn" @tap.stop="jump('/pages/user/address/edit', { id: address.id })">编辑</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="foot_box x-ac">
|
<view class="foot_box flex justify-around">
|
||||||
<button class="cu-btn add-btn" @tap="jump('/pages/user/address/edit', { id: 0, from: from })">添加新的收货地址</button>
|
<button class="cu-btn add-btn" @tap="jump('/pages/user/address/edit', { id: 0, from: from })">添加收货地址</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
import {
|
||||||
components: {},
|
getCurOwner,
|
||||||
data() {
|
getUserAddress
|
||||||
return {
|
} from '../../api/owner/ownerApi.js';
|
||||||
addressList: [],
|
export default {
|
||||||
from: '',
|
components: {},
|
||||||
platform: uni.getStorageSync('platform')
|
data() {
|
||||||
};
|
return {
|
||||||
},
|
addressList: [],
|
||||||
computed: {},
|
from: '',
|
||||||
onLoad() {
|
platform: uni.getStorageSync('platform')
|
||||||
},
|
};
|
||||||
onShow() {
|
|
||||||
this.init();
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
init() {
|
|
||||||
return Promise.all([this.getAddressList()]);
|
|
||||||
},
|
},
|
||||||
useAddress(address) {
|
computed: {},
|
||||||
let pages = getCurrentPages();
|
onLoad() {},
|
||||||
|
onShow() {
|
||||||
// #ifdef MP-WEIXIN || APP-PLUS
|
this.init();
|
||||||
let currPage = pages[pages.length - 1].$vm;
|
|
||||||
let prevPage = pages[pages.length - 2].$vm; //上一个页面
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
// #ifdef H5
|
|
||||||
let currPage = pages[pages.length - 1];
|
|
||||||
let prevPage = pages[pages.length - 2]; //上一个页面
|
|
||||||
// #endif
|
|
||||||
prevPage.address = address;
|
|
||||||
|
|
||||||
uni.navigateBack({
|
|
||||||
delta: 1
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
// 路由跳转
|
methods: {
|
||||||
jump(path, parmas) {
|
init() {
|
||||||
this.$Router.push({
|
return Promise.all([this.getAddressList()]);
|
||||||
path: path,
|
},
|
||||||
query: parmas
|
useAddress(address) {
|
||||||
});
|
let pages = getCurrentPages();
|
||||||
},
|
|
||||||
getAddressList() {
|
// #ifdef MP-WEIXIN || APP-PLUS
|
||||||
this.$api('address.list').then(res => {
|
let currPage = pages[pages.length - 1].$vm;
|
||||||
if (res.code === 1) {
|
let prevPage = pages[pages.length - 2].$vm; //上一个页面
|
||||||
this.addressList = res.data;
|
// #endif
|
||||||
}
|
|
||||||
});
|
// #ifdef H5
|
||||||
|
let currPage = pages[pages.length - 1];
|
||||||
|
let prevPage = pages[pages.length - 2]; //上一个页面
|
||||||
|
// #endif
|
||||||
|
prevPage.address = address;
|
||||||
|
|
||||||
|
uni.navigateBack({
|
||||||
|
delta: 1
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 路由跳转
|
||||||
|
jump(path, parmas) {
|
||||||
|
this.$Router.push({
|
||||||
|
path: path,
|
||||||
|
query: parmas
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getAddressList() {
|
||||||
|
let that = this;
|
||||||
|
getCurOwner()
|
||||||
|
.then((ownerInfo) => {
|
||||||
|
let param = {
|
||||||
|
page: 1,
|
||||||
|
row: 30,
|
||||||
|
userId: ownerInfo.userId
|
||||||
|
}
|
||||||
|
return getUserAddress(param);
|
||||||
|
}).then((data) => {
|
||||||
|
that.addressList = data.data;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.address-list {
|
.page_box {
|
||||||
padding: 40rpx;
|
height: 100%;
|
||||||
position: relative;
|
|
||||||
background: #fff;
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
|
|
||||||
.name,
|
|
||||||
.phone {
|
|
||||||
font-size: 30rpx;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.phone {
|
.content_box {
|
||||||
margin: 0 20rpx;
|
height: 100%;
|
||||||
}
|
-webkit-box-flex: 1;
|
||||||
|
-webkit-flex: 1;
|
||||||
.tag {
|
|
||||||
background: rgba(233, 191, 113, 0.2);
|
|
||||||
border-radius: 6rpx;
|
|
||||||
padding: 0 16rpx;
|
|
||||||
line-height: 38rpx;
|
|
||||||
color: #a8700d;
|
|
||||||
font-size: 22rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.detail {
|
|
||||||
margin-top: 25rpx;
|
|
||||||
width: 543rpx;
|
|
||||||
font-size: 26rpx;
|
|
||||||
font-family: PingFang SC;
|
|
||||||
font-weight: 400;
|
|
||||||
color: rgba(153, 153, 153, 1);
|
|
||||||
line-height: 40rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.set-btn {
|
|
||||||
background: none;
|
|
||||||
position: absolute;
|
|
||||||
font-size: 26rpx;
|
|
||||||
color: #a8700d;
|
|
||||||
top: 40rpx;
|
|
||||||
right: 20rpx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.foot_box {
|
|
||||||
padding: 20rpx;
|
|
||||||
.sync-wxaddress {
|
|
||||||
flex: 1;
|
flex: 1;
|
||||||
height: 80rpx;
|
overflow-y: auto;
|
||||||
background: rgba(255, 255, 255, 1);
|
}
|
||||||
border-radius: 40rpx;
|
|
||||||
.cuIcon-weixin {
|
.address-list {
|
||||||
color: #1ea907;
|
padding: 40rpx;
|
||||||
margin-right: 10rpx;
|
position: relative;
|
||||||
font-size: 40rpx;
|
background: #fff;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
|
||||||
|
.name,
|
||||||
|
.phone {
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.phone {
|
||||||
|
margin: 0 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag {
|
||||||
|
background: rgba(233, 191, 113, 0.2);
|
||||||
|
border-radius: 6rpx;
|
||||||
|
padding: 0 16rpx;
|
||||||
|
line-height: 38rpx;
|
||||||
|
color: #a8700d;
|
||||||
|
font-size: 22rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail {
|
||||||
|
margin-top: 25rpx;
|
||||||
|
width: 543rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
font-family: PingFang SC;
|
||||||
|
font-weight: 400;
|
||||||
|
color: rgba(153, 153, 153, 1);
|
||||||
|
line-height: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.set-btn {
|
||||||
|
background: none;
|
||||||
|
position: absolute;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #a8700d;
|
||||||
|
top: 40rpx;
|
||||||
|
right: 20rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.add-btn {
|
|
||||||
height: 80rpx;
|
.foot_box {
|
||||||
flex: 1;
|
padding: 20rpx;
|
||||||
background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
|
|
||||||
border: 1rpx solid rgba(238, 238, 238, 1);
|
.sync-wxaddress {
|
||||||
border-radius: 40rpx;
|
flex: 1;
|
||||||
color: rgba(#fff, 0.9);
|
height: 80rpx;
|
||||||
|
background: rgba(255, 255, 255, 1);
|
||||||
|
border-radius: 40rpx;
|
||||||
|
|
||||||
|
.cuIcon-weixin {
|
||||||
|
color: #1ea907;
|
||||||
|
margin-right: 10rpx;
|
||||||
|
font-size: 40rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.add-btn {
|
||||||
|
height: 80rpx;
|
||||||
|
flex: 1;
|
||||||
|
background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
|
||||||
|
border: 1rpx solid rgba(238, 238, 238, 1);
|
||||||
|
border-radius: 40rpx;
|
||||||
|
color: rgba(#fff, 0.9);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user