This commit is contained in:
zmr900709 2020-06-22 23:20:05 +08:00
commit 744bc925d3
7 changed files with 197 additions and 148 deletions

View File

@ -72,6 +72,16 @@ export default {
labelList({}) { labelList({}) {
return vm.$u.post('StartUp/labelList', {}); return vm.$u.post('StartUp/labelList', {});
}, },
} // 获取地区列表
getAreaList({ pid }) {
return vm.$u.post('Area/areaList', {
pid: pid
});
},
// 用户收货地址列表
getAddressList() {
return vm.$u.post('MemberAddress/addressList');
}
}
} }
} }

View File

@ -25,7 +25,7 @@ const install = (Vue, vm) => {
const token = uni.getStorageSync('token'); const token = uni.getStorageSync('token');
// console.log(token); // console.log(token);
// config.header.token = token; // config.header.token = token;
config.header.Authorization = token; config.header.Authorization = 'Bearer' + " " + token;
// config.header.Token = 'xxxxxx'; // config.header.Token = 'xxxxxx';
// 可以对某个url进行特别处理此url参数为this.$u.get(url)中的url值 // 可以对某个url进行特别处理此url参数为this.$u.get(url)中的url值

View File

@ -7,8 +7,8 @@
<view> <view>
<input type="text" placeholder="手机号" /> <input type="text" placeholder="手机号" />
</view> </view>
<view class="area"> <view class="area" @click="show=true">
<input type="text" placeholder="省市区" /> <input type="text" placeholder="省市区" disabled />
</view> </view>
<view> <view>
<input type="text" placeholder="详细地址" /> <input type="text" placeholder="详细地址" />
@ -21,16 +21,34 @@
</view> </view>
</view> </view>
<view class="edit-btn">保存地址</view> <view class="edit-btn">保存地址</view>
<!-- <u-picker mode="region" v-model="show" @confirm="setArea"></u-picker> -->
<u-select v-model="show" mode="mutil-column-auto" :list="areaList" @confirm="setArea"></u-select>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
checked: false checked: false,
show: false,
areaList: []
}
},
mounted() {
this.getAreaList(0);
},
methods: {
setArea(e) {
console.log(e);
},
getAreaList(pid) {
this.$u.api.getAreaList({
pid: pid
}).then((res)=>{
if (res.errCode == 0) {}
})
} }
}, },
onLoad() {}
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -1,40 +1,35 @@
<template> <template>
<view class="address"> <view class="items">
<u-radio-group v-model="current" @change="changeDefault" size="29" active-color="#FF780F"> <view class="item-top">
<view v-for="(item, index) in addressList" :key="index" class="address-item"> <view class="user-info">
<view class="item-top"> <view class="user-name">{{ item.address_realname }}</view>
<view class="user-info"> <view class="user-pnone">{{ item.address_tel_phone }}</view>
<view class="user-name">王先生</view> </view>
<view class="user-pnone">174****7492</view> <view class="user-address u-line-2">{{ $u.trim(item.area_info + item.address_detail, 'all') }}</view>
</view>
<view class="item-bottom">
<view class="item-default">
<u-radio
:name="item.address_id"
shape="circle"
label-size="22"
>
<view :class="[item.address_is_default == '0' ? 'radio-others' : 'radio-default']">
{{ item.address_is_default == '0' ? '设为默认' : '已设为默认' }}
</view> </view>
<view class="user-address">山东省临沂市兰山区金雀山街道巴啦啦小区三号楼101室</view> </u-radio>
</view>
<view class="address-operate">
<view @click="editAddress">
<image src="@/pageE/static/mine/24.png"></image>
<view>编辑</view>
</view> </view>
<view class="item-bottom"> <view>
<view class="item-default"> <image src="@/pageE/static/mine/25.png"></image>
<u-radio <view>删除</view>
:name="item"
shape="circle"
label-size="22"
>
<view :class="[item == current ? 'radio-default' : 'radio-others']">
{{ item == current ? '已设为默认' : '设为默认' }}
</view>
</u-radio>
</view>
<view class="address-operate">
<view @click="editAddress">
<image src="@/pageE/static/mine/24.png"></image>
<view>编辑</view>
</view>
<view>
<image src="@/pageE/static/mine/25.png"></image>
<view>删除</view>
</view>
</view>
</view> </view>
</view> </view>
</u-radio-group> </view>
<view class="address-btn" @click="addAddress">添加地址</view>
</view> </view>
</template> </template>
<script> <script>
@ -42,14 +37,12 @@ export default {
name: 'address-item', name: 'address-item',
data() { data() {
return { return {
current: 0
} }
}, },
props: { props: ['item', 'current'],
addressList: Array mounted() {
}, console.log(this.item);
onLoad() {
console.log(22)
}, },
methods: { methods: {
editAddress() { editAddress() {
@ -57,116 +50,89 @@ export default {
url: '/pageE/more/EditAddress' url: '/pageE/more/EditAddress'
}); });
}, },
addAddress() {
uni.navigateTo({
url: '/pageE/more/AddAddress'
});
},
changeDefault(event) {
console.log(event)
// this.current = event
}
}, },
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.address { .items {
padding: 1rpx 0 40rpx; padding: 1rpx 0 0;
.u-radio-group { .item-top {
display: block; position: relative;
.address-item { padding-bottom: 30rpx;
background-color: #ffffff; &::after {
margin-bottom: 20rpx; content: "";
padding: 30rpx; position: absolute;
.item-top { width: 690rpx;
position: relative; height: 2rpx;
padding-bottom: 30rpx; background: rgba(241,241,241,1);
&::after { bottom: 0;
content: ""; left: 50%;
position: absolute; transform: translate(-50%,0);
width: 690rpx; }
height: 2rpx; .user-info {
background: rgba(241,241,241,1); display: flex;
bottom: 0; align-items: center;
left: 50%; margin-bottom: 30rpx;
transform: translate(-50%,0); .user-name {
} font-size: 32rpx;
.user-info { font-weight: 500;
display: flex; color: rgba(51,51,51,1);
align-items: center; margin-right: 13rpx;
margin-bottom: 30rpx;
.user-name {
font-size: 32rpx;
font-weight: 500;
color: rgba(51,51,51,1);
margin-right: 13rpx;
}
.user-pnone {
font-size: 28rpx;
color: rgba(51,51,51,1);
}
}
.user-address {
font-size: 26rpx;
color: rgba(51,51,51,1);
}
} }
.item-bottom { .user-pnone {
padding-top: 30rpx; font-size: 28rpx;
color: rgba(51,51,51,1);
}
}
.user-address {
font-size: 26rpx;
color: rgba(51,51,51,1);
line-height: 32rpx;
}
}
.item-bottom {
padding-top: 30rpx;
display: flex;
align-items: center;
justify-content: space-between;
.item-default {
display: flex;
align-items: center;
font-size: 22rpx;
.radio-default {
color: rgba(255,119,15,1);
}
.radio-others {
color:rgba(153,153,153,1);
}
}
.address-operate {
display: flex;
font-size: 24rpx;
color: rgba(152,152,152,1);
> view {
display: flex; display: flex;
align-items: center; &:not(:last-child) {
justify-content: space-between; margin-right: 30rpx;
.item-default { }
display: flex; > image {
align-items: center; margin-right: 15rpx;
font-size: 22rpx; flex-shrink: 0;
.radio-default { }
color: rgba(255,119,15,1); &:first-child {
} > image {
.radio-others { width: 23rpx;
color:rgba(153,153,153,1); height: 23rpx;
} }
} }
.address-operate { &:nth-child(2) {
display: flex; > image {
font-size: 24rpx; width: 17rpx;
color: rgba(152,152,152,1); height: 21rpx;
> view {
display: flex;
&:not(:last-child) {
margin-right: 30rpx;
}
> image {
margin-right: 15rpx;
flex-shrink: 0;
}
&:first-child {
> image {
width: 23rpx;
height: 23rpx;
}
}
&:nth-child(2) {
> image {
width: 17rpx;
height: 21rpx;
}
}
} }
} }
} }
} }
} }
.address-btn {
margin: 322rpx auto 0;
width: 690rpx;
height: 98rpx;
background: rgba(255,119,15,1);
border-radius: 49rpx;
font-size: 36rpx;
color: rgba(255,255,255,1);
line-height: 98rpx;
text-align: center;
}
} }
</style> </style>

View File

@ -164,8 +164,8 @@
// token // token
uni.setStorage({ uni.setStorage({
key: 'token', key: 'token',
data: res.data.data.token, data: res.data.token,
}); });
// //
this.$refs.uToast.show({ this.$refs.uToast.show({

View File

@ -14,7 +14,11 @@ export default {
components: { components: {
AddressActive AddressActive
}, },
onLoad() {} onLoad() {
},
methods: {
},
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -1,6 +1,11 @@
<template> <template>
<view class="address"> <view class="address">
<AddressItem :addressList='addressList'></AddressItem> <u-radio-group v-model="current" @change="changeDefault" size="29" active-color="#FF780F">
<view v-for="(item, index) in addressList" :key="index" class="address-item">
<AddressItem :item="item" :current='current'></AddressItem>
</view>
</u-radio-group>
<view class="address-btn" @click="addAddress">添加地址</view>
</view> </view>
</template> </template>
<script> <script>
@ -8,18 +13,64 @@ import AddressItem from '@/components/mine/address-block/address-item'
export default { export default {
data() { data() {
return { return {
addressList: ['0', '1', '2', '3'] current: 0,
addressList: []
} }
}, },
components: { components: {
AddressItem AddressItem
}, },
onLoad() {} onLoad() {
this.getAddressList();
},
methods: {
getAddressList() {
this.$u.api.getAddressList().then((res)=>{
if (res.errCode == 0) {
this.addressList = res.data.addressList;
let defaultAddress = this.addressList.filter(item => {
return item.address_is_default == '1';
})
this.current = defaultAddress[0].address_id;
}
})
},
addAddress() {
uni.navigateTo({
url: '/pageE/more/AddAddress'
});
},
changeDefault(event) {
console.log(event)
// this.current = event
},
},
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.address { .address {
min-height: calc(100vh - var(--window-top)); min-height: calc(100vh - var(--window-top));
background-color: #ECECEC; background-color: #ECECEC;
padding: 1rpx 0 40rpx;
box-sizing: border-box;
.u-radio-group {
display: block;
.address-item {
background-color: #ffffff;
margin-bottom: 20rpx;
padding: 30rpx;
}
}
.address-btn {
margin: 322rpx auto 0;
width: 690rpx;
height: 98rpx;
background: rgba(255,119,15,1);
border-radius: 49rpx;
font-size: 36rpx;
color: rgba(255,255,255,1);
line-height: 98rpx;
text-align: center;
}
} }
</style> </style>