Commit f9ce10cc by LJM

js

parent 9e753bb0
<template> <template>
<view class="page-userAddress"> <view class="page-userAddress">
<navElement title="发票管理"></navElement> <template v-if="from">
<navElement title="选择发票"></navElement>
</template>
<template v-else>
<navElement title="发票管理"></navElement>
</template>
<view class="tip row verCenter"> <view class="tip row verCenter">
<text class="iconfont icon-ts"></text> <text class="iconfont icon-ts"></text>
<text class="t1">已创建</text> <text class="t1">已创建</text>
...@@ -22,17 +27,25 @@ ...@@ -22,17 +27,25 @@
</view> </view>
<view class="p3">{{ item.consignee_province_val }}{{ item.consignee_city_val }}{{ item.consignee_district_val }}{{ item.consignee_address }}</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"> <view class="operate row bothSide verCenter">
<template v-if="item.is_default == 1"> <template v-if="from">
<view class="row verCenter default-curr"> <view class="row verCenter" @click="chooseTax(item.tax_id)">
<view class="default"></view> <view class="default"></view>
<text class="default-text">默认发票</text> <text class="default-text">选择</text>
</view> </view>
</template> </template>
<template v-else> <template v-else>
<view class="row verCenter" @click="setdefault(item.tax_id)"> <template v-if="item.is_default == 1">
<view class="default"></view> <view class="row verCenter default-curr">
<text class="default-text">设为默认</text> <view class="default"></view>
</view> <text class="default-text">默认发票</text>
</view>
</template>
<template v-else>
<view class="row verCenter" @click="setdefault(item.tax_id)">
<view class="default"></view>
<text class="default-text">设为默认</text>
</view>
</template>
</template> </template>
<view class="row verCenter"> <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"> <navigator class="edit row verCenter" :url="'/user/invoiceEdit?tax_id=' + item.tax_id + '&inv_type=' + item.inv_type" hover-class="none">
...@@ -52,10 +65,18 @@ ...@@ -52,10 +65,18 @@
<text class="tt">暂无发票信息</text> <text class="tt">暂无发票信息</text>
</view> </view>
<view class="btn row verCenter"> <view class="btn row verCenter">
<navigator class="btn1 row rowCenter verCenter" url="/user/invoiceAdd" hover-class="none"> <template v-if="from">
<text class="iconfont icon-tj"></text> <navigator class="btn1 row rowCenter verCenter" :url="'/user/invoiceAdd?from=' + from" hover-class="none">
<text class="text">添加新发票</text> <text class="iconfont icon-tj"></text>
</navigator> <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>
</view> </view>
</template> </template>
...@@ -70,14 +91,29 @@ export default { ...@@ -70,14 +91,29 @@ export default {
}, },
data() { data() {
return { return {
from: '',
list: [] list: []
}; };
}, },
onLoad(options) {
this.from = options.from || '';
},
onShow() { onShow() {
this.getData(); this.getData();
}, },
methods: { methods: {
/** /**
* 选择发票
* @param {Object} tax_id
*/
chooseTax(tax_id) {
if (this.from) {
uni.navigateTo({
url: this.from + '?tax_id=' + tax_id
});
}
},
/**
* 删除发票 * 删除发票
*/ */
deleteInvoice(tax_id) { deleteInvoice(tax_id) {
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<view class="p2">{{ item.province_val }}{{ item.city_val }}{{ item.district_val }}{{ item.detail_address }}</view> <view class="p2">{{ item.province_val }}{{ item.city_val }}{{ item.district_val }}{{ item.detail_address }}</view>
<view class="operate row bothSide verCenter"> <view class="operate row bothSide verCenter">
<template v-if="from"> <template v-if="from">
<view class="row verCenter"> <view class="row verCenter" @click="chooseAddress(item.address_id)">
<view class="default"></view> <view class="default"></view>
<text class="default-text">选择</text> <text class="default-text">选择</text>
</view> </view>
...@@ -60,10 +60,18 @@ ...@@ -60,10 +60,18 @@
<text class="tt">暂无收货地址</text> <text class="tt">暂无收货地址</text>
</view> </view>
<view class="btn row verCenter"> <view class="btn row verCenter">
<navigator class="btn1 row rowCenter verCenter" url="/user/userAddressAdd" hover-class="none"> <template v-if="from">
<text class="iconfont icon-tj"></text> <navigator class="btn1 row rowCenter verCenter" :url="'/user/userAddressAdd?from=' + from" hover-class="none">
<text class="text">新增地址</text> <text class="iconfont icon-tj"></text>
</navigator> <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>
</view> </view>
</template> </template>
...@@ -101,6 +109,16 @@ export default { ...@@ -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 * @param {Object} address_id
*/ */
......
...@@ -49,6 +49,7 @@ export default { ...@@ -49,6 +49,7 @@ export default {
index: 0, index: 0,
array: ['0086', '00886', '00853', '00852'], array: ['0086', '00886', '00853', '00852'],
selectText: '请选择省市区', selectText: '请选择省市区',
from: '',
formParams: { formParams: {
address_type: 0, address_type: 0,
consignee: '', consignee: '',
...@@ -62,6 +63,9 @@ export default { ...@@ -62,6 +63,9 @@ export default {
} }
}; };
}, },
onLoad(options) {
this.from = options.from || '';
},
onShow() { onShow() {
this.getProvince(); this.getProvince();
}, },
...@@ -175,6 +179,34 @@ export default { ...@@ -175,6 +179,34 @@ export default {
* 保存地址 * 保存地址
*/ */
create() { 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 => { this.request(Api_Url + '/address/create', 'POST', this.formParams, true, true).then(res => {
if (res.err_code === 0) { if (res.err_code === 0) {
uni.showToast({ uni.showToast({
...@@ -182,9 +214,15 @@ export default { ...@@ -182,9 +214,15 @@ export default {
icon: 'success' icon: 'success'
}); });
setTimeout(() => { setTimeout(() => {
uni.navigateBack({ if (this.from) {
delta: 1 uni.navigateTo({
}); url: this.from + '?address_id=' + res.data
});
} else {
uni.navigateBack({
delta: 1
});
}
}, 2000); }, 2000);
} else { } else {
uni.showToast({ uni.showToast({
......
...@@ -209,6 +209,34 @@ export default { ...@@ -209,6 +209,34 @@ export default {
* 更新 * 更新
*/ */
update() { 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 => { this.request(Api_Url + '/address/update', 'POST', this.formParams, true, true).then(res => {
if (res.err_code === 0) { if (res.err_code === 0) {
uni.showToast({ 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