Commit f9ce10cc by LJM

js

parent 9e753bb0
<template>
<view class="page-userAddress">
<template v-if="from">
<navElement title="选择发票"></navElement>
</template>
<template v-else>
<navElement title="发票管理"></navElement>
</template>
<view class="tip row verCenter">
<text class="iconfont icon-ts"></text>
<text class="t1">已创建</text>
......@@ -22,6 +27,13 @@
</view>
<view class="p3">{{ item.consignee_province_val }}{{ item.consignee_city_val }}{{ item.consignee_district_val }}{{ item.consignee_address }}</view>
<view class="operate row bothSide verCenter">
<template v-if="from">
<view class="row verCenter" @click="chooseTax(item.tax_id)">
<view class="default"></view>
<text class="default-text">选择</text>
</view>
</template>
<template v-else>
<template v-if="item.is_default == 1">
<view class="row verCenter default-curr">
<view class="default"></view>
......@@ -34,6 +46,7 @@
<text class="default-text">设为默认</text>
</view>
</template>
</template>
<view class="row verCenter">
<navigator class="edit row verCenter" :url="'/user/invoiceEdit?tax_id=' + item.tax_id + '&inv_type=' + item.inv_type" hover-class="none">
<text class="iconfont icon-bjt"></text>
......@@ -52,10 +65,18 @@
<text class="tt">暂无发票信息</text>
</view>
<view class="btn row verCenter">
<template v-if="from">
<navigator class="btn1 row rowCenter verCenter" :url="'/user/invoiceAdd?from=' + from" hover-class="none">
<text class="iconfont icon-tj"></text>
<text class="text">添加新发票</text>
</navigator>
</template>
<template v-else>
<navigator class="btn1 row rowCenter verCenter" url="/user/invoiceAdd" hover-class="none">
<text class="iconfont icon-tj"></text>
<text class="text">添加新发票</text>
</navigator>
</template>
</view>
</view>
</template>
......@@ -70,14 +91,29 @@ export default {
},
data() {
return {
from: '',
list: []
};
},
onLoad(options) {
this.from = options.from || '';
},
onShow() {
this.getData();
},
methods: {
/**
* 选择发票
* @param {Object} tax_id
*/
chooseTax(tax_id) {
if (this.from) {
uni.navigateTo({
url: this.from + '?tax_id=' + tax_id
});
}
},
/**
* 删除发票
*/
deleteInvoice(tax_id) {
......
......@@ -23,7 +23,7 @@
<view class="p2">{{ item.province_val }}{{ item.city_val }}{{ item.district_val }}{{ item.detail_address }}</view>
<view class="operate row bothSide verCenter">
<template v-if="from">
<view class="row verCenter">
<view class="row verCenter" @click="chooseAddress(item.address_id)">
<view class="default"></view>
<text class="default-text">选择</text>
</view>
......@@ -60,10 +60,18 @@
<text class="tt">暂无收货地址</text>
</view>
<view class="btn row verCenter">
<template v-if="from">
<navigator class="btn1 row rowCenter verCenter" :url="'/user/userAddressAdd?from=' + from" hover-class="none">
<text class="iconfont icon-tj"></text>
<text class="text">新增地址</text>
</navigator>
</template>
<template v-else>
<navigator class="btn1 row rowCenter verCenter" url="/user/userAddressAdd" hover-class="none">
<text class="iconfont icon-tj"></text>
<text class="text">新增地址</text>
</navigator>
</template>
</view>
</view>
</template>
......@@ -101,6 +109,16 @@ export default {
});
},
/**
* 选择地址
*/
chooseAddress(address_id) {
if (this.from) {
uni.navigateTo({
url: this.from + '?address_id=' + address_id
});
}
},
/**
* 删除地址
* @param {Object} address_id
*/
......
......@@ -49,6 +49,7 @@ export default {
index: 0,
array: ['0086', '00886', '00853', '00852'],
selectText: '请选择省市区',
from: '',
formParams: {
address_type: 0,
consignee: '',
......@@ -62,6 +63,9 @@ export default {
}
};
},
onLoad(options) {
this.from = options.from || '';
},
onShow() {
this.getProvince();
},
......@@ -175,6 +179,34 @@ export default {
* 保存地址
*/
create() {
if (!this.formParams.consignee) {
uni.showToast({
title: '请输入收货人',
icon: 'none'
});
return false;
}
if (!this.formParams.mobile) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return false;
}
if (!this.formParams.province) {
uni.showToast({
title: '请选择省市区',
icon: 'none'
});
return false;
}
if (!this.formParams.detail_address) {
uni.showToast({
title: '请输入详细街道地址',
icon: 'none'
});
return false;
}
this.request(Api_Url + '/address/create', 'POST', this.formParams, true, true).then(res => {
if (res.err_code === 0) {
uni.showToast({
......@@ -182,9 +214,15 @@ export default {
icon: 'success'
});
setTimeout(() => {
if (this.from) {
uni.navigateTo({
url: this.from + '?address_id=' + res.data
});
} else {
uni.navigateBack({
delta: 1
});
}
}, 2000);
} else {
uni.showToast({
......
......@@ -209,6 +209,34 @@ export default {
* 更新
*/
update() {
if (!this.formParams.consignee) {
uni.showToast({
title: '请输入收货人',
icon: 'none'
});
return false;
}
if (!this.formParams.mobile) {
uni.showToast({
title: '请输入手机号',
icon: 'none'
});
return false;
}
if (!this.formParams.province) {
uni.showToast({
title: '请选择省市区',
icon: 'none'
});
return false;
}
if (!this.formParams.detail_address) {
uni.showToast({
title: '请输入详细街道地址',
icon: 'none'
});
return false;
}
this.request(Api_Url + '/address/update', 'POST', this.formParams, true, true).then(res => {
if (res.err_code === 0) {
uni.showToast({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment