...
|
...
|
@@ -84,21 +84,22 @@ |
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import Layout from "../../../components/layout/layout-app";
|
|
|
import Input from "./components/input";
|
|
|
import FormItem from "./components/form-item";
|
|
|
import Radio from "./components/radio";
|
|
|
import AddressAct from "./components/address-act";
|
|
|
import RadioGroup from "./components/radio-group";
|
|
|
import { Scroll } from "cube-ui";
|
|
|
|
|
|
import { createNamespacedHelpers } from "vuex";
|
|
|
import Layout from '../../../components/layout/layout-app';
|
|
|
import Input from './components/input';
|
|
|
import FormItem from './components/form-item';
|
|
|
import Radio from './components/radio';
|
|
|
import AddressAct from './components/address-act';
|
|
|
import RadioGroup from './components/radio-group';
|
|
|
import { Scroll } from 'cube-ui';
|
|
|
|
|
|
import { createNamespacedHelpers } from 'vuex';
|
|
|
|
|
|
const { mapState, mapMutations, mapActions } = createNamespacedHelpers(
|
|
|
"address/address"
|
|
|
'address/address'
|
|
|
);
|
|
|
|
|
|
export default {
|
|
|
name: "addressEdit",
|
|
|
name: 'addressEdit',
|
|
|
components: {
|
|
|
LayoutApp: Layout,
|
|
|
CInput: Input,
|
...
|
...
|
@@ -115,24 +116,24 @@ export default { |
|
|
},
|
|
|
isShowProvince: false,
|
|
|
isUpdate: false,
|
|
|
updateMobileNum: "",
|
|
|
updateMobileNum: '',
|
|
|
isMobileNumEdit: false,
|
|
|
title: "",
|
|
|
orderCode: "",
|
|
|
title: '',
|
|
|
orderCode: '',
|
|
|
model: {
|
|
|
consignee: "",
|
|
|
address_id: "",
|
|
|
mobile: "",
|
|
|
area_code: "",
|
|
|
area: "",
|
|
|
address: "",
|
|
|
tag_code: "",
|
|
|
consignee: '',
|
|
|
address_id: '',
|
|
|
mobile: '',
|
|
|
area_code: '',
|
|
|
area: '',
|
|
|
address: '',
|
|
|
tag_code: '',
|
|
|
is_default: false
|
|
|
}
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
|
"model.mobile": function(val) {
|
|
|
'model.mobile': function(val) {
|
|
|
if (val === this.updateMobileNum) {
|
|
|
this.isMobileNumEdit = false;
|
|
|
} else {
|
...
|
...
|
@@ -141,10 +142,10 @@ export default { |
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState(["addressTags", "updateAddressInfo"]),
|
|
|
...mapState(['addressTags', 'updateAddressInfo']),
|
|
|
submitClass() {
|
|
|
return [
|
|
|
"sure-btn",
|
|
|
'sure-btn',
|
|
|
{
|
|
|
active: this.inNotEmpty
|
|
|
}
|
...
|
...
|
@@ -162,11 +163,11 @@ export default { |
|
|
methods: {
|
|
|
...mapMutations({}),
|
|
|
...mapActions([
|
|
|
"fetchAddressTags",
|
|
|
"addUserAddress",
|
|
|
"updateUserAddress",
|
|
|
"deleteUserAddress",
|
|
|
"updateReceiptAddressInOrder"
|
|
|
'fetchAddressTags',
|
|
|
'addUserAddress',
|
|
|
'updateUserAddress',
|
|
|
'deleteUserAddress',
|
|
|
'updateReceiptAddressInOrder'
|
|
|
]),
|
|
|
|
|
|
async onSubmit() {
|
...
|
...
|
@@ -196,15 +197,15 @@ export default { |
|
|
|
|
|
if (result && result.code === 200) {
|
|
|
this.$createToast({
|
|
|
type: "txt",
|
|
|
txt: result.message.split(".").join("")
|
|
|
type: 'txt',
|
|
|
txt: result.message.split('.').join('')
|
|
|
}).show();
|
|
|
|
|
|
await this.sleep(1000);
|
|
|
this.$router.go(-1);
|
|
|
} else {
|
|
|
this.$createToast({
|
|
|
type: "error",
|
|
|
type: 'error',
|
|
|
txt: result.message,
|
|
|
mask: true
|
|
|
}).show();
|
...
|
...
|
@@ -212,16 +213,16 @@ export default { |
|
|
},
|
|
|
validator() {
|
|
|
let info = this.model;
|
|
|
let username = info.consignee.replace(/(^\s+)|(\s+$)/g, "");
|
|
|
let username = info.consignee.replace(/(^\s+)|(\s+$)/g, '');
|
|
|
|
|
|
// 简单的表单校验
|
|
|
if (!username) {
|
|
|
this.showToast("收件人不能为空");
|
|
|
this.showToast('收件人不能为空');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (!/^[\u4E00-\u9FA5A-Za-z0-9*]+$/gi.test(username)) {
|
|
|
this.showToast("收货人姓名不支持特殊符号");
|
|
|
this.showToast('收货人姓名不支持特殊符号');
|
|
|
return false;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -233,32 +234,32 @@ export default { |
|
|
}
|
|
|
|
|
|
if (!info.mobile) {
|
|
|
this.showToast("手机号不能为空");
|
|
|
this.showToast('手机号不能为空');
|
|
|
return false;
|
|
|
} else {
|
|
|
if (!reg.test(info.mobile)) {
|
|
|
this.showToast("请输入正确11位手机号码");
|
|
|
this.showToast('请输入正确11位手机号码');
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!info.area_code || !info.area) {
|
|
|
this.showToast("省市区不能为空");
|
|
|
this.showToast('省市区不能为空');
|
|
|
return false;
|
|
|
}
|
|
|
if (!info.address) {
|
|
|
this.showToast("地址不能为空");
|
|
|
this.showToast('地址不能为空');
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
id: info.address_id || "",
|
|
|
id: info.address_id || '',
|
|
|
consignee: username,
|
|
|
mobile: info.mobile,
|
|
|
area_code: info.area_code,
|
|
|
area: info.area,
|
|
|
address: info.address,
|
|
|
is_default: info.is_default ? "Y" : "N",
|
|
|
is_default: info.is_default ? 'Y' : 'N',
|
|
|
tag_code: info.tag_code
|
|
|
};
|
|
|
},
|
...
|
...
|
@@ -266,15 +267,15 @@ export default { |
|
|
const result = await this.deleteUserAddress(this.model.address_id);
|
|
|
if (result && result.code === 200) {
|
|
|
this.$createToast({
|
|
|
type: "txt",
|
|
|
txt: result.message.split(".").join("")
|
|
|
type: 'txt',
|
|
|
txt: result.message.split('.').join('')
|
|
|
}).show();
|
|
|
|
|
|
await this.sleep(1000);
|
|
|
this.$router.go(-1);
|
|
|
} else {
|
|
|
this.$createToast({
|
|
|
type: "error",
|
|
|
type: 'error',
|
|
|
txt: result.message,
|
|
|
mask: true
|
|
|
}).show();
|
...
|
...
|
@@ -300,7 +301,7 @@ export default { |
|
|
},
|
|
|
showToast(tip) {
|
|
|
this.$createToast({
|
|
|
type: "txt",
|
|
|
type: 'txt',
|
|
|
txt: tip
|
|
|
}).show();
|
|
|
},
|
...
|
...
|
@@ -318,7 +319,7 @@ export default { |
|
|
|
|
|
this.isUpdate = addressInfo.isUpdate;
|
|
|
this.orderCode = addressInfo.orderCode;
|
|
|
this.title = addressInfo.isUpdate ? "编辑地址" : "添加地址";
|
|
|
this.title = addressInfo.isUpdate ? '编辑地址' : '添加地址';
|
|
|
|
|
|
// 订单编辑 不查标签
|
|
|
if (!this.orderCode) {
|
...
|
...
|
@@ -334,7 +335,7 @@ export default { |
|
|
this.model.area = addressInfo.area;
|
|
|
this.model.address = addressInfo.address;
|
|
|
this.model.tag_code = addressInfo.tag_code;
|
|
|
this.model.is_default = addressInfo.is_default === "Y" ? true : false;
|
|
|
this.model.is_default = addressInfo.is_default === 'Y' ? true : false;
|
|
|
} else {
|
|
|
this.model = {};
|
|
|
}
|
...
|
...
|
|