|
|
|
@ -31,6 +31,9 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { |
|
|
|
getArea |
|
|
|
} from '@/utils/global.js' |
|
|
|
import { |
|
|
|
mapState |
|
|
|
} from 'vuex'; |
|
|
|
@ -66,8 +69,7 @@ |
|
|
|
rules: [{ |
|
|
|
required: true, |
|
|
|
errorMessage: '请输入姓名', |
|
|
|
} |
|
|
|
] |
|
|
|
}] |
|
|
|
}, |
|
|
|
consigneeMobile: { |
|
|
|
rules: [{ |
|
|
|
@ -162,24 +164,53 @@ |
|
|
|
nameBlur() { |
|
|
|
this.formData.username = this.formData.phone; |
|
|
|
}, |
|
|
|
openPicker() { |
|
|
|
this.show = true |
|
|
|
authVerification() { |
|
|
|
uni.getSetting({ |
|
|
|
success: (res) => { |
|
|
|
if (res.authSetting['scope.userLocation']) { |
|
|
|
/* 用户授权成功时走这里 */ |
|
|
|
this.openPicker() |
|
|
|
} else if (res.authSetting['scope.userLocation'] === undefined) { |
|
|
|
/* 用户未授权时走这里 */ |
|
|
|
console.log('没有授权') |
|
|
|
this.handleOpenSetting() |
|
|
|
} else { |
|
|
|
/* 用户拒绝了授权后走这里 */ |
|
|
|
console.log('拒绝了授权 false') |
|
|
|
this.handleOpenSetting() |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
onhideShow() { |
|
|
|
this.show = false |
|
|
|
}) |
|
|
|
}, |
|
|
|
//选中省市区 |
|
|
|
onsetCity(e) { |
|
|
|
let data = e.detail.target.dataset; |
|
|
|
let address = data.province + data.city + data.area; |
|
|
|
this.show = false |
|
|
|
this.formData.address1 = address; |
|
|
|
this.addressObj = { |
|
|
|
province: data.province, |
|
|
|
city: data.city, |
|
|
|
area: data.area, |
|
|
|
handleOpenSetting() { |
|
|
|
wx.openSetting({ |
|
|
|
success: (res) => { |
|
|
|
console.log('定位 openSetting', res) |
|
|
|
if (res.authSetting["scope.userLocation"]) { |
|
|
|
this.openPicker() |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
openPicker() { |
|
|
|
let that = this; |
|
|
|
uni.chooseLocation({ |
|
|
|
success: function(res) { |
|
|
|
if(res.name != ''){ |
|
|
|
let aaa = getArea(res.address) |
|
|
|
that.formData.province = aaa.province |
|
|
|
that.formData.city = aaa.city |
|
|
|
that.formData.area = aaa.country |
|
|
|
that.formData.address = aaa.address + '-' + res.name |
|
|
|
that.formData.address1 = aaa.province + aaa.city + aaa.country |
|
|
|
}else{ |
|
|
|
that.tui.toast("微信地址选择器调用失败,请重新选择!") |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: function(res) { |
|
|
|
console.log(res) |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
// 触发提交表单 |
|
|
|
submit() { |
|
|
|
@ -191,9 +222,9 @@ |
|
|
|
name: this.formData.consigneeName, |
|
|
|
phone: this.formData.consigneeMobile, |
|
|
|
address: this.formData.address, |
|
|
|
province:this.addressObj.province, |
|
|
|
city:this.addressObj.city, |
|
|
|
area:this.addressObj.area, |
|
|
|
province: this.formData.province, |
|
|
|
city: this.formData.city, |
|
|
|
area: this.formData.area, |
|
|
|
id: this.formData.id, |
|
|
|
userName: this.formData.consigneeMobile |
|
|
|
}, false, true).then((res) => { |
|
|
|
@ -220,9 +251,9 @@ |
|
|
|
name: this.formData.consigneeName, |
|
|
|
phone: this.formData.consigneeMobile, |
|
|
|
address: this.formData.address, |
|
|
|
province:this.addressObj.province, |
|
|
|
city:this.addressObj.city, |
|
|
|
area:this.addressObj.area, |
|
|
|
province: this.formData.province, |
|
|
|
city: this.formData.city, |
|
|
|
area: this.formData.area, |
|
|
|
userName: this.formData.consigneeMobile |
|
|
|
}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
@ -247,9 +278,6 @@ |
|
|
|
|
|
|
|
} else { |
|
|
|
if (that.type == 'edit') { |
|
|
|
this.formData.city = this.addressObj.city |
|
|
|
this.formData.area = this.addressObj.area |
|
|
|
this.formData.province = this.addressObj.province |
|
|
|
that.tui.request("/app/supplier/edit", "post", this.formData, false, |
|
|
|
true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
@ -266,7 +294,7 @@ |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
that.tui.request("/app/supplier/save", "post", Object.assign(that.addressObj, res), false, |
|
|
|
that.tui.request("/app/supplier/save", "post", this.formData, false, |
|
|
|
true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
@ -289,8 +317,7 @@ |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
}) |
|
|
|
}).catch(err => {}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -300,6 +327,7 @@ |
|
|
|
.cc_area_view { |
|
|
|
z-index: 997 !important; |
|
|
|
} |
|
|
|
|
|
|
|
.formBox { |
|
|
|
margin: 20rpx; |
|
|
|
padding: 20rpx; |
|
|
|
|