Commit 51ace0e9 authored by Morson's avatar Morson

feat(parts):修改地址逻辑调整

parent db22cdc3
...@@ -4,6 +4,7 @@ let partsApiFun = function (vm) { ...@@ -4,6 +4,7 @@ let partsApiFun = function (vm) {
const coverage = '/wxh-worker-rest/rest/coverage/' const coverage = '/wxh-worker-rest/rest/coverage/'
const parts = '/wxh-worker-rest/rest/parts/' const parts = '/wxh-worker-rest/rest/parts/'
const base = '/wxh-worker-rest/rest/base/' const base = '/wxh-worker-rest/rest/base/'
const formType = {'content-type': 'application/x-www-form-urlencoded'}
/** /**
* 配件申请单-查询网点地址信息 * 配件申请单-查询网点地址信息
...@@ -12,7 +13,7 @@ let partsApiFun = function (vm) { ...@@ -12,7 +13,7 @@ let partsApiFun = function (vm) {
/** /**
* 配件申请单-修改网点地址信息 * 配件申请单-修改网点地址信息
*/ */
let updateAddress = async (params = {}) => await vm.$u.post(coverage + vm.vuex_token + '/updateSiteAddress', params); let updateAddress = async (params = {}) => await vm.$u.post(coverage + vm.vuex_token + '/updateSiteAddress', params, formType);
/** /**
* 配件过滤-品类列表 * 配件过滤-品类列表
*/ */
......
...@@ -30,7 +30,7 @@ export default { ...@@ -30,7 +30,7 @@ export default {
info: { info: {
type: Object, type: Object,
default() { default() {
return {name: '', mobile: '', address: ''}; return {name: '', mobile: '', address: '', region: []};
} }
}, },
isDefault: { isDefault: {
...@@ -73,8 +73,13 @@ export default { ...@@ -73,8 +73,13 @@ export default {
let address = this.info && this.info.address; let address = this.info && this.info.address;
if (this.$u.test.isEmpty(address)) { if (this.$u.test.isEmpty(address)) {
return '--'; return '--';
} else { }
let region = this.info && this.info.region;
let regionStr = region.join('');
if(this.$u.test.contains(address, regionStr)) {
return address; return address;
} else {
return regionStr + address;
} }
} }
}, },
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<view class="list-view"> <view class="list-view">
<view v-for="(group, ind) in items" :key="ind" class="group-view"> <view v-for="(group, ind) in items" :key="ind" class="group-view">
<u-cell-group :border="false"> <u-cell-group :border="false">
<view v-for="(item, index) in group" :key="index.pathName"> <view v-for="(item, index) in group" :key="index">
<u-cell-item :value="item.value" :border-bottom="false" @click="handleClick(item.pathName)"> <u-cell-item :value="item.value" :border-bottom="false" @click="handleClick(item.pathName)">
<image slot="icon" :src="qnFile(item.icon)" :style="item.imageStyle"></image> <image slot="icon" :src="qnFile(item.icon)" :style="item.imageStyle"></image>
<view slot="title" class="item-title">{{item.title}}</view> <view slot="title" class="item-title">{{item.title}}</view>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
</view> </view>
<view class="item"> <view class="item">
<view class="left">电话号码</view> <view class="left">电话号码</view>
<input :disabled="mobileStatus" v-model="mobile" type="text" placeholder-class="line" placeholder="请填写收货人手机号" /> <input :disabled="mobileStatus" v-model="mobile" type="text" @blur="verifyMobile" placeholder-class="line" placeholder="请填写收货人手机号" />
</view> </view>
<view class="item"> <view class="item">
...@@ -120,13 +120,19 @@ export default { ...@@ -120,13 +120,19 @@ export default {
if(e.mobile) { if(e.mobile) {
this.mobile = decodeURIComponent(e.mobile); this.mobile = decodeURIComponent(e.mobile);
} }
if(e.address) {
this.address = decodeURIComponent(e.address);
}
if(e.region) { if(e.region) {
let regionStr = decodeURIComponent(e.region); let regionStr = decodeURIComponent(e.region);
this.region = regionStr.split('-') this.region = regionStr.split('-')
} }
if(e.address) {
let address = decodeURIComponent(e.address);
let region = this.region.join('')
if(this.$u.test.contains(address, region)) {
this.address = address.replace(region, '')
} else {
this.address = address
}
}
} }
}, },
onShow() { onShow() {
...@@ -138,33 +144,43 @@ export default { ...@@ -138,33 +144,43 @@ export default {
this.nameStatus = false; this.nameStatus = false;
this.mobileStatus = false; this.mobileStatus = false;
} else if (this.siteType == 'edit') { } else if (this.siteType == 'edit') {
let address = ''; if (this.$u.test.isEmpty(this.name)
if (this.$u.test.isEmpty(this.siteInfo)) { || this.$u.test.isEmpty(this.mobile)) {
const callback = (vm, res) => { const callback = (vm, res) => {
this.settled = res.record; this.settled = res.record;
if (this.loading) {
this.name = this.settled.id_card_name; this.name = this.settled.id_card_name;
this.mobile = this.settled.mobile; this.mobile = this.settled.mobile;
this.address = this.settled.address;
this.geocoding();
}
this.loading = this.$u.test.isEmpty(this.settled);
}; };
if (this.vuex_settled && this.vuex_settled.record) { if (this.vuex_settled && this.vuex_settled.record) {
callback(this, this.vuex_settled); callback(this, this.vuex_settled);
} else { } else {
getApp().getBaseInfo(this, callback); getApp().getBaseInfo(this, callback);
} }
} else {
if (this.loading) {
this.loading = false;
this.name = this.siteInfo.name;
this.mobile = this.siteInfo.mobile;
this.address = this.siteInfo.address;
this.geocoding();
} }
if (this.$u.test.isEmpty(this.region)
|| this.$u.test.isEmpty(this.address)) {
}
}
},
loadMineAddress() {
this.$u.api.getSiteAddress().then((res) => {
if(res.code == 200 && res.data) {
this.region = [
res.data.provinceName,
res.data.cityName,
res.data.districtName
]
let address = res.data.address
const regionStr = this.region.join('')
if(this.$u.test.contains(address, regionStr)) {
this.address = address.replace(regionStr, '')
} else {
this.address = address
} }
} }
})
}, },
showRegionPicker() { showRegionPicker() {
this.showPicker = true; this.showPicker = true;
...@@ -234,23 +250,54 @@ export default { ...@@ -234,23 +250,54 @@ export default {
}); });
}, },
verifyMobile() {
if(this.$u.test.isEmpty(this.mobile)) {
this.$u.toast('电话号码不能为空')
return false
} else if(!this.$u.test.mobile(this.mobile)) {
this.$u.toast('电话号码格式错误')
return false
}
return true
},
validateForm() {
if(this.$u.test.isEmpty(this.name)) {
this.$u.toast('收货人姓名不能为空')
return false
}
if(!this.verifyMobile()) {
return false
}
if(this.$u.test.isEmpty(this.region)) {
this.$u.toast('所在地区不能为空')
return false
}
if(this.$u.test.isEmpty(this.address)) {
this.$u.toast('详细地址不能为空')
return false
}
return true
},
async submitForm() { async submitForm() {
if(!this.validateForm()) {
return false
}
if (this.siteType === 'add') { if (this.siteType === 'add') {
} else if (this.siteType === 'select') { } else if (this.siteType === 'select') {
this.commitSite() this.commitSite()
} else if (this.siteType === 'edit') { } else if (this.siteType === 'edit') {
if (this.$u.test.isEmpty(this.siteInfo)) { if (this.$u.test.isEmpty(this.siteInfo)) {
let params = { let params = {
type: this.type, updateFlag: true,
provinceName: this.region[0],
cityName: this.region[1],
districtName: this.region[2],
address: this.region.join("") + this.address address: this.region.join("") + this.address
}; };
let res = await this.$u.api.syncAddress(params); let res = await this.$u.api.updateAddress(params);
const callback = (vm, res) => { if (res && res.code == 200) {
this.$u.route({ type: 'back' }); this.$u.route({ type: 'back' });
this.show = false this.show = false
};
if (res && res.code == 200) {
getApp().getBaseInfo(this, callback);
} }
} else { } else {
...@@ -258,6 +305,9 @@ export default { ...@@ -258,6 +305,9 @@ export default {
} }
}, },
commitSite() { commitSite() {
if(!this.validateForm()) {
return false
}
// 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。 // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
var pages = getCurrentPages(); var pages = getCurrentPages();
var prevPage = pages[pages.length - 2]; //上一个页面 var prevPage = pages[pages.length - 2]; //上一个页面
......
...@@ -28,13 +28,17 @@ export default { ...@@ -28,13 +28,17 @@ export default {
return this.vuex_settled && this.vuex_settled.record || null return this.vuex_settled && this.vuex_settled.record || null
}, },
hasAdderss() { hasAdderss() {
return this.settled && this.settled.address && this.settled.id_card_name return this.settled && this.address && this.settled.id_card_name
},
settledName() {
return this.settled.id_card_name || this.settled.nickname || this.settled.name
}, },
addressInfo() { addressInfo() {
return { return {
name: this.settled.id_card_name || this.settled.nickname || this.settled.name, name: this.settledName,
mobile: this.settled.mobile, mobile: this.settled.mobile,
address: this.settled.address address: this.address,
region: this.region || [],
} }
} }
}, },
...@@ -45,13 +49,12 @@ export default { ...@@ -45,13 +49,12 @@ export default {
if(!this.vuex_token) { if(!this.vuex_token) {
this.$u.route({url: 'pages/login/index'}) this.$u.route({url: 'pages/login/index'})
} else if(!this.settled) { } else if(!this.settled) {
this.getData(); app.getBaseInfo(this);
} }
this.getData();
}, },
methods: { methods: {
getData() { getData() {
let self = this
app.getBaseInfo(self);
this.getMineSite() this.getMineSite()
}, },
getMineSite() { getMineSite() {
...@@ -67,11 +70,17 @@ export default { ...@@ -67,11 +70,17 @@ export default {
}) })
}, },
toAddSite(title){ toAddSite(title){
const info = this.addressInfo
const region = this.region.join('-')
this.$u.route({ this.$u.route({
url: 'pages/mine/address/addSite', url: 'pages/mine/address/addSite',
// params: { params: {
// title: title type: 'edit',
// } name: info.name,
mobile: info.mobile,
region: region,
address: info.address
}
}) })
} }
} }
......
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
<view class="title" v-if="isEmptyParts">配件信息</view> <view class="title" v-if="isEmptyParts">配件信息</view>
<view class="u-flex u-row-between title" v-else> <view class="u-flex u-row-between title" v-else>
<view>选择配件</view> <view>选择配件</view>
<u-icon name="arrow-right" size="24" color="#2272FF" @click="$u.throttle(addParts, 500)" <u-icon name="arrow-right" size="24" color="#2272FF"
label="添加配件" label-pos="left" label-color="#2272FF" label-size="26"/> @click="$u.throttle(addParts, 500)" label="添加配件"
label-pos="left" label-color="#2272FF" label-size="26"/>
</view> </view>
<view class="body"> <view class="body">
<view v-if="isEmptyParts" class="u-flex-col u-col-center list"> <view v-if="isEmptyParts" class="u-flex-col u-col-center list">
...@@ -36,8 +37,7 @@ ...@@ -36,8 +37,7 @@
:bold="false" font-size="26" height="76" :bold="false" font-size="26" height="76"
active-color="#FFFFFF" inactive-color="#333333" active-color="#FFFFFF" inactive-color="#333333"
bg-color="#FFFFFF" button-color="#2272FF" bg-color="#FFFFFF" button-color="#2272FF"
@change="typeChange" @change="typeChange" />
></u-subsection>
</view> </view>
<view class="body"> <view class="body">
<w-address :info="addressInfo" @editSite="editSite" /> <w-address :info="addressInfo" @editSite="editSite" />
...@@ -45,7 +45,9 @@ ...@@ -45,7 +45,9 @@
</view> </view>
</view> </view>
<view class="bottom"> <view class="bottom">
<u-button shape="circle" :disabled="isEmptyParts" :hair-line="false" :custom-style="customStyle" hover-class="none" @click="submitParts">提交</u-button> <u-button shape="circle" :disabled="isEmptyParts"
:hair-line="false" :custom-style="customStyle"
hover-class="none" @click="submitParts">提交</u-button>
</view> </view>
</view> </view>
</template> </template>
...@@ -132,24 +134,19 @@ export default { ...@@ -132,24 +134,19 @@ export default {
}, },
initCustomer() { initCustomer() {
if(this.$u.test.isEmpty(this.order)) { if(this.$u.test.isEmpty(this.order)) {
this.customer = {} this.customer = {name: '', mobile: '', address: '', region: []}
} else { } else {
// this.mine.name = this.order.maintainWorkerName this.mine.name = this.order.maintainWorkerName
// this.mine.mobile = this.order.maintainWorkerPhone this.mine.mobile = this.order.maintainWorkerPhone
this.mine.name = '王先生'
this.mine.mobile = '13045861456'
const region = [
this.order.contactProvinceText,
this.order.contactCityText,
this.order.contactCommunityText,
]
let address = region.join("") + (this.order.contactStreetText || '') + this.order.contactAddress
this.customer = { this.customer = {
name: this.order.contactName, name: this.order.contactName,
mobile: this.order.contactPhone, mobile: this.order.contactPhone,
address: address, address: this.order.contactAddress,
region: region, region: [
this.order.contactProvinceText,
this.order.contactCityText,
this.order.contactCommunityText,
],
} }
} }
}, },
...@@ -160,21 +157,15 @@ export default { ...@@ -160,21 +157,15 @@ export default {
this.curType = index this.curType = index
}, },
editSite() { editSite() {
let region = this.addressInfo.region.join('') this.$u.route({
let address = this.addressInfo.address url: "pages/mine/address/addSite",
if(this.$u.test.contains(address, region)) { params: {
address = address.replace(region, '')
}
let params = {
type: 'select', type: 'select',
name: this.addressInfo.name, name: this.addressInfo.name,
mobile: this.addressInfo.mobile, mobile: this.addressInfo.mobile,
address: address, address: this.addressInfo.address,
region: this.addressInfo.region.join('-'), region: this.addressInfo.region.join('-'),
}; }
this.$u.route({
url: "pages/mine/address/addSite",
params: params
}) })
}, },
updateSite(site) { updateSite(site) {
......
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 to comment