address api

This commit is contained in:
ghusermoon 2020-06-23 17:21:01 +08:00
parent fe995ced2d
commit 8c993da2cd
12 changed files with 390 additions and 55 deletions

View File

@ -78,10 +78,75 @@ export default {
pid: pid pid: pid
}); });
}, },
getArea() {
return vm.$u.post('Area/getAreaTree')
},
// 用户收货地址列表 // 用户收货地址列表
getAddressList() { getAddressList() {
return vm.$u.post('MemberAddress/addressList'); return vm.$u.post('MemberAddress/addressList');
}, },
// 添加收货地址
addressAdd({
area_id,
city_id,
is_default,
area_info,
address,
true_name,
mobile_phone,
// longitude,
// latitude,
}) {
return vm.$u.post('memberAddress/addressAdd', {
area_id: area_id,
city_id: city_id,
is_default: is_default,
area_info: area_info,
address: address,
true_name: true_name,
mobile_phone: mobile_phone,
// longitude: longitude,
// latitude: latitude,
});
},
// 修改收货地址
addressEdit({
address_id,
area_id,
city_id,
is_default,
area_info,
address,
true_name,
mobile_phone,
// longitude,
// latitude,
}) {
return vm.$u.post('memberAddress/addressEdit', {
address_id: address_id,
area_id: area_id,
city_id: city_id,
is_default: is_default,
area_info: area_info,
address: address,
true_name: true_name,
mobile_phone: mobile_phone,
// longitude: longitude,
// latitude: latitude,
});
},
// 删除地址
deleteAddress({ address_id }) {
return vm.$u.post('memberAddress/addressDel', {
address_id: address_id
});
},
// 设默认地址
setDefaultAddress({ address_id }) {
return vm.$u.post('memberAddress/addressSetDefault', {
address_id: address_id
});
},
// 美甲 // 美甲
getManicureList({ page }) { getManicureList({ page }) {
return vm.$u.post('MemberManicure/getManicureList', { return vm.$u.post('MemberManicure/getManicureList', {
@ -95,6 +160,10 @@ export default {
time: time time: time
}); });
}, },
// 会员服务-积分列表
getPointslogList() {
return vm.$u.post('member/pointslogList');
},
} }
} }
} }

View File

@ -2,16 +2,20 @@
<view class="address-active"> <view class="address-active">
<view class="user-info"> <view class="user-info">
<view> <view>
<input type="text" placeholder="收货人" /> <input type="text" placeholder="收货人" v-model="name" />
</view> </view>
<view> <view>
<input type="text" placeholder="手机号" /> <input type="text" placeholder="手机号" maxlength="11" v-model="phone" />
</view> </view>
<view class="area" @click="show=true"> <view class="area" @click="show=true">
<input type="text" placeholder="省市区" disabled /> <input type="text" placeholder="省市区" v-model="address" disabled />
<view>
<image src="/static/image/mine/24.png"></image>
<text>定位</text>
</view>
</view> </view>
<view> <view>
<input type="text" placeholder="详细地址" /> <input type="text" placeholder="详细地址" v-model="area" />
</view> </view>
<view class="set-default"> <view class="set-default">
<view>设为默认地址</view> <view>设为默认地址</view>
@ -20,34 +24,158 @@
</view> </view>
</view> </view>
</view> </view>
<view class="edit-btn">保存地址</view> <view class="edit-btn" @click="confirmBtn">保存地址</view>
<!-- <u-picker mode="region" v-model="show" @confirm="setArea"></u-picker> --> <u-select v-model="show"
<u-select v-model="show" mode="mutil-column-auto" :list="areaList" @confirm="setArea"></u-select> mode="mutil-column-auto"
:list="areaList"
value-name="area_id"
label-name="area_name"
child-name="_child"
@confirm="setArea">
</u-select>
<u-toast ref="uToast" />
</view> </view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
checked: false,
show: false, show: false,
areaList: [] areaList: [],
checked: false, //
name: '',
phone: '',
address: '', //
area: '', //
area_id: '', // id
city_id: '', // id
} }
}, },
props: {
info: Object
},
mounted() { mounted() {
this.getAreaList(0); this.getAreaData();
},
created() {
// console.log(this.info);
this.initAddressInfo();
}, },
methods: { methods: {
setArea(e) { //
console.log(e); initAddressInfo() {
if(JSON.stringify(this.info) != '{}') {
[this.name, this.phone, this.address, this.area, this.area_id, this.city_id] = [
this.info.address_realname,
this.info.address_mob_phone,
this.info.area_info,
this.info.address_detail,
this.info.area_id,
this.info.city_id
]
this.checked = this.info.address_is_default == '0' ? false : true;
}
}, },
getAreaList(pid) { // 
this.$u.api.getAreaList({ confirmBtn() {
pid: pid JSON.stringify(this.info) != '{}' ? this.editAddress() : this.addAddress();
},
//
validateValue() {
if(this.$u.test.isEmpty(this.name)) {
this.showToast('姓名不能为空', 'warning');
return false;
}
if(this.$u.test.isEmpty(this.phone)) {
this.showToast('手机号不能为空', 'warning');
return false;
}
if(!this.$u.test.mobile(this.phone)) {
this.showToast('手机号错误', 'warning');
return false;
}
if(this.$u.test.isEmpty(this.address)) {
this.showToast('地址不能为空', 'warning');
return false;
}
if(this.$u.test.isEmpty(this.area)) {
this.showToast('详细地址不能为空', 'warning');
return false;
}
return true;
},
addAddress() {
if(!this.validateValue()) return false;
this.$u.api.addressAdd({
area_id: this.area_id,
city_id: this.city_id,
is_default: this.checked ? 1 : 0,
area_info: this.address,
address: this.area,
true_name: this.name,
mobile_phone: this.phone,
// longitude,
// latitude,
}).then((res)=>{ }).then((res)=>{
if (res.errCode == 0) {} if (res.errCode == 0) {
this.$refs.uToast.show({
title: res.message,
type: 'success',
url: '/pageE/more/Address'
})
} else {
this.showToast(res.message, 'warning');
}
}) })
} },
editAddress() {
if(!this.validateValue()) return false;
this.$u.api.addressEdit({
address_id: this.info.address_id,
area_id: this.area_id,
city_id: this.city_id,
is_default: this.checked ? 1 : 0,
area_info: this.address,
address: this.area,
true_name: this.name,
mobile_phone: this.phone,
// longitude,
// latitude,
}).then((res)=>{
if (res.errCode == 0) {
this.$refs.uToast.show({
title: res.message,
type: 'success',
url: '/pageE/more/Address'
})
} else {
this.showToast(res.message, 'warning');
}
})
},
getAreaData() {
this.$u.api.getArea().then((res)=>{
if (res.errCode == 0) {
this.areaList = res.data;
}
})
},
setArea(area) {
// console.log(area);
this.area_id = area[0].value;
this.city_id = area[1].value;
let temp = '';
area.forEach(e => {
temp += e.label;
});
this.address = temp;
},
showToast(message, type) {
this.$refs.uToast.show({
title: message,
type: type,
})
},
}, },
} }
</script> </script>
@ -71,6 +199,29 @@ export default {
font-size: 30rpx; font-size: 30rpx;
color: rgba(51,51,51,1); color: rgba(51,51,51,1);
} }
.area {
padding: 0 30rpx;
display: flex;
> input {
padding: 30rpx 0;
flex: 1;
}
> view {
margin-left: 30rpx;
width: 50rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 22rpx;
color: rgba(255,120,15,1);
> image {
width: 26rpx;
height: 32rpx;
margin-bottom: 10rpx;
}
}
}
} }
.edit-btn { .edit-btn {
margin: 122rpx auto 0; margin: 122rpx auto 0;

View File

@ -3,7 +3,7 @@
<view class="item-top"> <view class="item-top">
<view class="user-info"> <view class="user-info">
<view class="user-name">{{ item.address_realname }}</view> <view class="user-name">{{ item.address_realname }}</view>
<view class="user-pnone">{{ item.address_tel_phone }}</view> <view class="user-pnone">{{ item.address_mob_phone | phoneFormat }}</view>
</view> </view>
<view class="user-address u-line-2">{{ $u.trim(item.area_info + item.address_detail, 'all') }}</view> <view class="user-address u-line-2">{{ $u.trim(item.area_info + item.address_detail, 'all') }}</view>
</view> </view>
@ -13,6 +13,7 @@
:name="item.address_id" :name="item.address_id"
shape="circle" shape="circle"
label-size="22" label-size="22"
:disabled="false"
> >
<view :class="[item.address_is_default == '0' ? 'radio-others' : 'radio-default']"> <view :class="[item.address_is_default == '0' ? 'radio-others' : 'radio-default']">
{{ item.address_is_default == '0' ? '设为默认' : '已设为默认' }} {{ item.address_is_default == '0' ? '设为默认' : '已设为默认' }}
@ -24,11 +25,12 @@
<image src="@/pageE/static/mine/24.png"></image> <image src="@/pageE/static/mine/24.png"></image>
<view>编辑</view> <view>编辑</view>
</view> </view>
<view> <view @click="deleteAddress">
<image src="@/pageE/static/mine/25.png"></image> <image src="@/pageE/static/mine/25.png"></image>
<view>删除</view> <view>删除</view>
</view> </view>
</view> </view>
<u-toast ref="uToast" />
</view> </view>
</view> </view>
</template> </template>
@ -42,13 +44,40 @@ export default {
}, },
props: ['item', 'current'], props: ['item', 'current'],
mounted() { mounted() {
console.log(this.item); // console.log(this.item);
},
filters: {
phoneFormat(value) {
return value.replace(/^(\d{3})\d*(\d{4})$/, '$1****$2');
}
}, },
methods: { methods: {
editAddress() { editAddress() {
uni.navigateTo({ this.$u.route({
url: '/pageE/more/EditAddress' url: '/pageE/more/EditAddress',
}); params: {
item: JSON.stringify(this.item)
}
})
},
deleteAddress() {
// console.log(this.item.address_id);
this.$u.api.deleteAddress({
address_id: this.item.address_id
}).then((res)=>{
if(res.errCode == 0) {
this.showToast(res.message, 'success');
this.$emit('getAddressList');
} else {
this.showToast(res.message, 'warning');
}
})
},
showToast(message, type) {
this.$refs.uToast.show({
title: message,
type: type,
})
}, },
}, },
} }

6
package-lock.json generated
View File

@ -5,9 +5,9 @@
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"uview-ui": { "uview-ui": {
"version": "1.2.9", "version": "1.3.68",
"resolved": "https://registry.npm.taobao.org/uview-ui/download/uview-ui-1.2.9.tgz", "resolved": "https://registry.npmjs.org/uview-ui/-/uview-ui-1.3.68.tgz",
"integrity": "sha1-PwC6ziaB/LXyMacGRkMfPrZfF2c=" "integrity": "sha512-fwszoohFC1HLvIqwwnXPRytT52qGy0viGEzyJtVwemNBAu5z6Ddjwe9ORqsrlQQo7PSvHdyCNHWrSLGzoyKKoQ=="
} }
} }
} }

View File

@ -13,6 +13,6 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"uview-ui": "^1.2.9" "uview-ui": "^1.3.68"
} }
} }

View File

@ -43,13 +43,13 @@
</swiper-item> </swiper-item>
<swiper-item class="swiper-item"> <swiper-item class="swiper-item">
<scroll-view scroll-y class="details"> <scroll-view scroll-y class="details">
<view v-for="(item, index) in 16" :key="index" class="details-item"> <view v-for="(item, index) in pointslogList" :key="index" class="details-item">
<view class="item-left"> <view class="item-left">
<view class="item-title">积分商城兑换礼品</view> <view class="item-title">{{ item.pl_desc }}</view>
<view class="item-date">2020-03-11</view> <view class="item-date">{{ item.pl_addtime }}</view>
</view> </view>
<view class="item-right" :class="[index&1 ? 'negative' : 'positive']"> <view class="item-right" :class="[item.pl_addtime < 0 ? 'negative' : 'positive']">
{{ index&1 ? '-' + 10.00 : '+' + 10.00 }} {{ item.pl_addtime > 0 ? item.pl_addtime : '+' + 10.00 }}
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
@ -70,9 +70,13 @@ export default {
}], }],
current: 0, current: 0,
swiperCurrent: 0, swiperCurrent: 0,
nodes: '<h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1>' nodes: '<h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1><h1>2</h1>',
pointslogList: []
} }
}, },
onShow() {
this.getPointslogList();
},
methods: { methods: {
tabsChange(index) { tabsChange(index) {
this.swiperCurrent = index; this.swiperCurrent = index;
@ -81,6 +85,13 @@ export default {
let current = e.detail.current; let current = e.detail.current;
this.swiperCurrent = current; this.swiperCurrent = current;
this.current = current; this.current = current;
},
getPointslogList() {
this.$u.api.getPointslogList().then((res)=>{
if (res.errCode == 0) {
this.pointslogList = res.data;
}
})
} }
}, },
} }

View File

@ -17,7 +17,6 @@ export default {
onLoad() { onLoad() {
}, },
methods: { methods: {
}, },
} }
</script> </script>

View File

@ -2,10 +2,11 @@
<view class="address"> <view class="address">
<u-radio-group v-model="current" @change="changeDefault" size="29" active-color="#FF780F"> <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"> <view v-for="(item, index) in addressList" :key="index" class="address-item">
<AddressItem :item="item" :current='current'></AddressItem> <AddressItem :item="item" :current='current' @getAddressList="getAddressList"></AddressItem>
</view> </view>
</u-radio-group> </u-radio-group>
<view class="address-btn" @click="addAddress">添加地址</view> <view class="address-btn" @click="addAddress">添加地址</view>
<u-toast ref="uToast" />
</view> </view>
</template> </template>
<script> <script>
@ -13,7 +14,7 @@ import AddressItem from '@/components/mine/address-block/address-item'
export default { export default {
data() { data() {
return { return {
current: 0, current: -1,
addressList: [] addressList: []
} }
}, },
@ -31,7 +32,7 @@ export default {
let defaultAddress = this.addressList.filter(item => { let defaultAddress = this.addressList.filter(item => {
return item.address_is_default == '1'; return item.address_is_default == '1';
}) })
this.current = defaultAddress[0].address_id; if(defaultAddress[0]) this.current = defaultAddress[0].address_id;
} }
}) })
}, },
@ -40,9 +41,21 @@ export default {
url: '/pageE/more/AddAddress' url: '/pageE/more/AddAddress'
}); });
}, },
changeDefault(event) { //
console.log(event) changeDefault(id) {
// this.current = event // console.log(id)
this.$u.api.setDefaultAddress({
address_id: id
}).then((res)=>{
if(res.errCode == 0) {
this.getAddressList();
} else {
this.$refs.uToast.show({
title: res.message,
type: 'warning',
})
}
})
}, },
}, },
} }
@ -62,7 +75,7 @@ export default {
} }
} }
.address-btn { .address-btn {
margin: 322rpx auto 0; margin: 260rpx auto 0;
width: 690rpx; width: 690rpx;
height: 98rpx; height: 98rpx;
background: rgba(255,119,15,1); background: rgba(255,119,15,1);

View File

@ -1,6 +1,6 @@
<template> <template>
<view class="edit-address"> <view class="edit-address">
<AddressActive></AddressActive> <AddressActive :info="address"></AddressActive>
<u-popup v-model="popupShow" mode="center" border-radius="10"> <u-popup v-model="popupShow" mode="center" border-radius="10">
<view class="popup-tips">确定要删除该地址吗</view> <view class="popup-tips">确定要删除该地址吗</view>
<view class="popup-btn"> <view class="popup-btn">
@ -8,6 +8,7 @@
<view class="determine" @click="delAddress">确定</view> <view class="determine" @click="delAddress">确定</view>
</view> </view>
</u-popup> </u-popup>
<u-toast ref="uToast" />
</view> </view>
</template> </template>
<script> <script>
@ -15,20 +16,44 @@ import AddressActive from '@/components/mine/address-active/index'
export default { export default {
data() { data() {
return { return {
address: {},
popupShow: false popupShow: false
} }
}, },
components: { components: {
AddressActive AddressActive
}, },
onLoad() {}, onLoad(option) {
// console.log(JSON.parse(option.item));
this.address = JSON.parse(option.item);
},
onNavigationBarButtonTap() { onNavigationBarButtonTap() {
this.popupShow = true this.popupShow = true
}, },
methods: { methods: {
delAddress() { delAddress() {
this.popupShow = false this.deleteAddress().then(() => {
} this.popupShow = false
})
},
async deleteAddress() {
this.$u.api.deleteAddress({
address_id: this.address.address_id
}).then((res)=>{
if(res.errCode == 0) {
this.$refs.uToast.show({
title: res.message,
type: 'success',
url: '/pageE/more/Address'
})
} else {
this.$refs.uToast.show({
title: res.message,
type: 'warning'
})
}
})
},
}, },
} }
</script> </script>

View File

@ -10,10 +10,10 @@
<view v-for="(item, index) in orderList" :key="index" class="order-item"> <view v-for="(item, index) in orderList" :key="index" class="order-item">
<view class="order-title"> <view class="order-title">
<view class="order-text">订单</view> <view class="order-text">订单</view>
<view class="order-status">已预约</view> <view class="order-status">{{ item.status }}</view>
</view> </view>
<view class="order-name">美甲人姓名xxx</view> <view class="order-name">美甲人姓名{{ item.manicure_name }}</view>
<view class="order-date">时间2020-04-12</view> <view class="order-date">时间{{ item.manicure_time | dateFormat }}</view>
</view> </view>
<u-loadmore :status="loadStatus" bgColor="#ECECEC" margin-bottom="20"></u-loadmore> <u-loadmore :status="loadStatus" bgColor="#ECECEC" margin-bottom="20"></u-loadmore>
</view> </view>
@ -39,20 +39,33 @@ export default {
current: 0, current: 0,
swiperCurrent: 0, swiperCurrent: 0,
page: 1, page: 1,
orderList: 5, orderList: [],
loadStatus: 'loadmore', loadStatus: 'loadmore',
} }
}, },
onShow() { onShow() {
this.current = 0; this.current = 0;
this.swiperCurrent = 0; this.swiperCurrent = 0;
this.getManicureList();
},
filters: {
dateFormat(value) {
let date = new Date(value * 1000);
let year, month, day;
year = date.getFullYear();
month = date.getMonth() + 1;
day = date.getDate();
return year + "-" + month + "-" + day;
}
}, },
methods: { methods: {
getManicureList() { getManicureList() {
this.$u.api.getManicureList({ this.$u.api.getManicureList({
page: this.page page: this.page
}).then((res)=>{ }).then((res)=>{
if (res.errCode == 0) {} if (res.errCode == 0) {
this.orderList = res.data.list;
}
}) })
}, },
reachBottom() { reachBottom() {

View File

@ -11,8 +11,9 @@
<view v-else>{{ time }}</view> <view v-else>{{ time }}</view>
</view> </view>
</view> </view>
<view class="order-btn">确认订单</view> <view class="order-btn" @click="addManicureOrder">确认订单</view>
<u-picker mode="time" v-model="show" :params="params" @confirm="chooseDate"></u-picker> <u-picker mode="time" v-model="show" :params="params" @confirm="chooseDate"></u-picker>
<u-toast ref="uToast" />
</view> </view>
</template> </template>
<script> <script>
@ -33,18 +34,42 @@ export default {
} }
}, },
methods: { methods: {
validateValue() {
if(this.$u.test.isEmpty(this.name)) {
this.showToast('姓名不能为空', 'warning');
return false;
}
if(this.$u.test.isEmpty(this.time)) {
this.showToast('日期不能为空', 'warning');
return false;
}
if(new Date() > new Date(this.time)) {
this.showToast('日期错误', 'warning');
return false;
}
return true;
},
addManicureOrder() { addManicureOrder() {
if(!this.validateValue()) return false;
this.$u.api.addManicure({ this.$u.api.addManicure({
name: this.name, name: this.name,
time: this.time time: new Date(this.time)
}).then((res)=>{ }).then((res)=>{
if (res.errCode == 0) {} let type = res.errCode == 0 ? 'success' : 'error';
this.showToast(res.message, type);
}) })
}, },
chooseDate(e) { chooseDate(e) {
let time = e.year + '年' + e.month + '月' + e.day + '日' + e.hour + '时' + e.minute + '分' // let time = e.year + '' + e.month + '' + e.day + '' + e.hour + '' + e.minute + ''
let time = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute
this.time = time this.time = time
} },
showToast(message, type) {
this.$refs.uToast.show({
title: message,
type: type,
})
},
}, },
}; };
</script> </script>

BIN
static/image/mine/24.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB