|
|
|
@ -31,6 +31,9 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { |
|
|
|
getArea |
|
|
|
} from '@/utils/global.js' |
|
|
|
import { |
|
|
|
mapState |
|
|
|
} from 'vuex'; |
|
|
|
@ -40,9 +43,9 @@ |
|
|
|
userInfo: '', |
|
|
|
show: false, |
|
|
|
delShow: false, |
|
|
|
addressObj: {}, |
|
|
|
type:'', |
|
|
|
popleType:'', |
|
|
|
addressObj: {}, |
|
|
|
type: '', |
|
|
|
popleType: '', |
|
|
|
formData: { |
|
|
|
consigneeMobile: '', |
|
|
|
consigneeName: '', |
|
|
|
@ -64,10 +67,9 @@ |
|
|
|
rules: { |
|
|
|
consigneeName: { |
|
|
|
rules: [{ |
|
|
|
required: true, |
|
|
|
errorMessage: '请输入姓名', |
|
|
|
} |
|
|
|
] |
|
|
|
required: true, |
|
|
|
errorMessage: '请输入姓名', |
|
|
|
}] |
|
|
|
}, |
|
|
|
consigneeMobile: { |
|
|
|
rules: [{ |
|
|
|
@ -101,9 +103,9 @@ |
|
|
|
// 需要在onReady中设置规则 |
|
|
|
this.$refs.form.setRules(this.rules) |
|
|
|
}, |
|
|
|
onLoad(option) { |
|
|
|
this.popleType = option.popleType |
|
|
|
this.type=option.type |
|
|
|
onLoad(option) { |
|
|
|
this.popleType = option.popleType |
|
|
|
this.type = option.type |
|
|
|
let data = JSON.parse(option.data) |
|
|
|
if (option.type = "edit") { |
|
|
|
this.formData.address1 = data.province + data.city + data.area |
|
|
|
@ -121,185 +123,211 @@ |
|
|
|
this.delShow = true; |
|
|
|
}, |
|
|
|
delItemModal() { |
|
|
|
this.delShow = false; |
|
|
|
if(this.popleType=="khName"){ |
|
|
|
this.tui.request("/app/customer/delById", "post", { |
|
|
|
id: this.formData.id, |
|
|
|
}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: "删除成功", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
uni.navigateBack() |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: "删除失败", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
this.tui.request("/app/supplier/delByIds", "post", { |
|
|
|
ids: this.formData.id, |
|
|
|
}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: "删除成功", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
uni.navigateBack() |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: "删除失败", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
this.delShow = false; |
|
|
|
if (this.popleType == "khName") { |
|
|
|
this.tui.request("/app/customer/delById", "post", { |
|
|
|
id: this.formData.id, |
|
|
|
}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: "删除成功", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
uni.navigateBack() |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: "删除失败", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
this.tui.request("/app/supplier/delByIds", "post", { |
|
|
|
ids: this.formData.id, |
|
|
|
}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: "删除成功", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
uni.navigateBack() |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: "删除失败", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
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 |
|
|
|
handleOpenSetting() { |
|
|
|
wx.openSetting({ |
|
|
|
success: (res) => { |
|
|
|
console.log('定位 openSetting', res) |
|
|
|
if (res.authSetting["scope.userLocation"]) { |
|
|
|
this.openPicker() |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
//选中省市区 |
|
|
|
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, |
|
|
|
} |
|
|
|
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() { |
|
|
|
submit() { |
|
|
|
let that = this; |
|
|
|
this.$refs.form.validate().then(res => { |
|
|
|
if(this.popleType == 'khName'){ |
|
|
|
if(that.type=='edit'){ |
|
|
|
that.tui.request("/app/customer/edit", "post", { |
|
|
|
name:this.formData.consigneeName, |
|
|
|
phone:this.formData.consigneeMobile, |
|
|
|
address:this.formData.address, |
|
|
|
province:this.addressObj.province, |
|
|
|
city:this.addressObj.city, |
|
|
|
area:this.addressObj.area, |
|
|
|
id:this.formData.id, |
|
|
|
userName:this.formData.consigneeMobile |
|
|
|
}, false,true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: "添加成功", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
let pages = getCurrentPages(); |
|
|
|
let prevPage = pages[pages.length - 2]; |
|
|
|
prevPage.$vm.popleType = 'khName' |
|
|
|
uni.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}) |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: "添加失败", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
that.tui.request("/app/customer/save", "post", { |
|
|
|
name:this.formData.consigneeName, |
|
|
|
phone:this.formData.consigneeMobile, |
|
|
|
address:this.formData.address, |
|
|
|
province:this.addressObj.province, |
|
|
|
city:this.addressObj.city, |
|
|
|
area:this.addressObj.area, |
|
|
|
userName:this.formData.consigneeMobile |
|
|
|
}, false,true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: "添加成功", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
let pages = getCurrentPages(); |
|
|
|
let prevPage = pages[pages.length - 2]; |
|
|
|
prevPage.$vm.popleType = 'khName' |
|
|
|
uni.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}) |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: "添加失败", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
}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) { |
|
|
|
uni.showToast({ |
|
|
|
title: "修改成功", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
uni.navigateBack() |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: "修改失败", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
that.tui.request("/app/supplier/save", "post", Object.assign(that.addressObj, res), false, |
|
|
|
true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: "添加成功", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
let pages = |
|
|
|
getCurrentPages(); |
|
|
|
let prevPage = pages[pages.length - 2]; |
|
|
|
prevPage.$vm.popleType = 'gysName' |
|
|
|
uni.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}) |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: "添加失败", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
this.$refs.form.validate().then(res => { |
|
|
|
if (this.popleType == 'khName') { |
|
|
|
if (that.type == 'edit') { |
|
|
|
that.tui.request("/app/customer/edit", "post", { |
|
|
|
name: this.formData.consigneeName, |
|
|
|
phone: this.formData.consigneeMobile, |
|
|
|
address: this.formData.address, |
|
|
|
province: this.formData.province, |
|
|
|
city: this.formData.city, |
|
|
|
area: this.formData.area, |
|
|
|
id: this.formData.id, |
|
|
|
userName: this.formData.consigneeMobile |
|
|
|
}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: "添加成功", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
let pages = getCurrentPages(); |
|
|
|
let prevPage = pages[pages.length - 2]; |
|
|
|
prevPage.$vm.popleType = 'khName' |
|
|
|
uni.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}) |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: "添加失败", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
that.tui.request("/app/customer/save", "post", { |
|
|
|
name: this.formData.consigneeName, |
|
|
|
phone: this.formData.consigneeMobile, |
|
|
|
address: this.formData.address, |
|
|
|
province: this.formData.province, |
|
|
|
city: this.formData.city, |
|
|
|
area: this.formData.area, |
|
|
|
userName: this.formData.consigneeMobile |
|
|
|
}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: "添加成功", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
let pages = getCurrentPages(); |
|
|
|
let prevPage = pages[pages.length - 2]; |
|
|
|
prevPage.$vm.popleType = 'khName' |
|
|
|
uni.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}) |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: "添加失败", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
if (that.type == 'edit') { |
|
|
|
that.tui.request("/app/supplier/edit", "post", this.formData, false, |
|
|
|
true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: "修改成功", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
uni.navigateBack() |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: "修改失败", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
that.tui.request("/app/supplier/save", "post", this.formData, false, |
|
|
|
true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
uni.showToast({ |
|
|
|
title: "添加成功", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
let pages = |
|
|
|
getCurrentPages(); |
|
|
|
let prevPage = pages[pages.length - 2]; |
|
|
|
prevPage.$vm.popleType = 'gysName' |
|
|
|
uni.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}) |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: "添加失败", |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
}) |
|
|
|
}).catch(err => {}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="scss"> |
|
|
|
.cc_area_view{ |
|
|
|
z-index: 997 !important; |
|
|
|
<style lang="scss"> |
|
|
|
.cc_area_view { |
|
|
|
z-index: 997 !important; |
|
|
|
} |
|
|
|
|
|
|
|
.formBox { |
|
|
|
margin: 20rpx; |
|
|
|
padding: 20rpx; |
|
|
|
@ -323,13 +351,13 @@ |
|
|
|
padding: 0 20rpx; |
|
|
|
|
|
|
|
.tui-btn-mr { |
|
|
|
width:130rpx; |
|
|
|
height: 60rpx; |
|
|
|
background: #088FEB; |
|
|
|
color: #fff; |
|
|
|
border-radius: 10px; |
|
|
|
line-height: 60rpx; |
|
|
|
text-align: center; |
|
|
|
width: 130rpx; |
|
|
|
height: 60rpx; |
|
|
|
background: #088FEB; |
|
|
|
color: #fff; |
|
|
|
border-radius: 10px; |
|
|
|
line-height: 60rpx; |
|
|
|
text-align: center; |
|
|
|
margin-right: 30rpx; |
|
|
|
} |
|
|
|
} |
|
|
|
|