Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
W
wly-APP
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘川
wly-APP
Commits
a87452c2
Commit
a87452c2
authored
Feb 25, 2026
by
chicheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
要货添加企业团购渠道相关逻辑
parent
dbdccfc4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
587 additions
and
77 deletions
+587
-77
launch.json
.hbuilderx/launch.json
+5
-1
login.nvue
pages/login/login.nvue
+20
-13
purchase-main.nvue
pages/purchase-main/purchase-main.nvue
+147
-7
purchase-receive.nvue
pages/purchase-receive/purchase-receive.nvue
+274
-35
select-address.nvue
pages/select-address/select-address.nvue
+135
-19
index.js
store/index.js
+6
-2
No files found.
.hbuilderx/launch.json
View file @
a87452c2
...
...
@@ -20,12 +20,16 @@
"type"
:
"uni-app:app-android"
},
{
"playground"
:
"
custom
"
,
"playground"
:
"
standard
"
,
"type"
:
"uni-app:app-ios"
},
{
"openVueDevtools"
:
false
,
"type"
:
"uni-app:h5"
},
{
"playground"
:
"standard"
,
"type"
:
"uni-app:app-ios_simulator"
}
]
}
pages/login/login.nvue
View file @
a87452c2
...
...
@@ -344,21 +344,28 @@
...res.data.operator
}
});
this.$uStore({
name: 'userBpData',
value: {
...res.data.userBpData
}
});
const isChildCustomer = res.data.userBpData.ROLES.some(user => user.ROLE_ID === 'WLY027');
this.$uStore({
name: 'isChildCustomer',
value: isChildCustomer
});
// 保存客户详细信息,包含客户类型等信息
if (res.data.customerDetails) {
this.$uStore({
name: 'userBpData',
value: {
...res.data.userBpData
}
});
const isChildCustomer = res.data.userBpData.ROLES.some(user => user.ROLE_ID === 'WLY027');
this.$uStore({
name: 'isChildCustomer',
value: isChildCustomer
});
this.$uStore({
name: 'vuex_token',
value: res.data.token
name: 'customerDetails',
value: res.data.customerDetails
});
}
this.$uStore({
name: 'vuex_token',
value: res.data.token
});
uni.switchTab({
url: '/pages/home/home'
});
...
...
pages/purchase-main/purchase-main.nvue
View file @
a87452c2
...
...
@@ -38,9 +38,9 @@
<view class="middle-date-address uni-list picker-year">
<view class="uni-list-cell">
<view class="uni-list-cell-db">
<picker class="picker-block" @change="bindPickerChange($event,'channelType')" :value="
orderItem.channelsType
"
range-key='name' mode="selector" :range="channelTypeArr">
<text class="uni-input">{{orderItem.channelTypeName}}</text>
<picker class="picker-block" @change="bindPickerChange($event,'channelType')" :value="
channelTypeIndex
"
range-key='name' mode="selector" :range="channelTypeArr"
:disabled="isV032NormalApply"
>
<text class="uni-input">{{orderItem.channelTypeName
|| '请选择'
}}</text>
</picker>
</view>
</view>
...
...
@@ -237,7 +237,8 @@
significanceArr : [],
marketPlaceArr : [],
manifestArr : [],
pcjArr: [{value:'0',name: '否'}, {value:'1',name: '是'}]
pcjArr: [{value:'0',name: '否'}, {value:'1',name: '是'}],
channelTypeIndex: 0 // 渠道类型选择器的索引
}
},
props: {
...
...
@@ -269,7 +270,13 @@
'height': `${this.sysinfo.safeArea.top + 44}px`
}
},
...mapState(['sysinfo'])
// 是否为V032客户类型且为普通要货申请
isV032NormalApply() {
// 优先从 store 中获取客户类型
const customerType = this.customerDetails?.info?.zzfld000016
return customerType === 'V032' && this.orderItem.demandType !== 'ZDZG'
},
...mapState(['sysinfo', 'customerDetails'])
},
mounted() {
console.log('监听到事件来自 update');
...
...
@@ -293,6 +300,38 @@
_this.orderItem.city = data.selectTerminal.cityName
_this.orderItem.district = data.selectTerminal.districtName
})
// V032普通要货申请,初始化渠道类型
this.$nextTick(() => {
if (this.isV032NormalApply && this.channelTypeArr && this.channelTypeArr.length > 0) {
// 确保只有H选项并设置默认值
setTimeout(() => {
const hasH = this.channelTypeArr.some(item => item.value === 'H')
if (hasH) {
// 只保留H选项
if (this.channelTypeArr.length > 1) {
this.channelTypeArr = this.channelTypeArr.filter(item => item.value === 'H')
}
// 设置默认值为H
if (!this.orderItem.channelsType || this.orderItem.channelsType !== 'H') {
this.$set(this.orderItem, 'channelsType', 'H')
this.$set(this.orderItem, 'channelTypeName', '行业团购')
}
// 设置选择器索引
const hIndex = this.channelTypeArr.findIndex(item => item.value === 'H')
if (hIndex >= 0) {
this.channelTypeIndex = hIndex
}
} else {
// 如果没有H选项,添加H选项
this.channelTypeArr = [{ value: 'H', name: '行业团购' }]
this.$set(this.orderItem, 'channelsType', 'H')
this.$set(this.orderItem, 'channelTypeName', '行业团购')
this.channelTypeIndex = 0
}
}, 100)
}
})
},
onUnload() {
uni.$off('selectSalePlaceAccountInfo')
...
...
@@ -319,6 +358,63 @@
// 'orderItem.planType':function(res,res1){
// res && this.getChannelType()
// }
// 监听渠道类型数组变化,如果是V032普通要货申请,设置默认值
channelTypeArr: {
handler(newVal) {
if (this.isV032NormalApply && newVal && newVal.length > 0) {
this.$nextTick(() => {
// 确保只有H选项
const hasH = newVal.some(item => item.value === 'H')
if (hasH) {
// 设置默认值为H
if (!this.orderItem.channelsType || this.orderItem.channelsType !== 'H') {
this.$set(this.orderItem, 'channelsType', 'H')
this.$set(this.orderItem, 'channelTypeName', '行业团购')
}
// 设置选择器索引
const hIndex = newVal.findIndex(item => item.value === 'H')
if (hIndex >= 0) {
this.channelTypeIndex = hIndex
}
} else {
// 如果没有H选项,通知父组件添加H选项
this.$emit('updateChannelType', [{ value: 'H', name: '行业团购' }])
this.$set(this.orderItem, 'channelsType', 'H')
this.$set(this.orderItem, 'channelTypeName', '行业团购')
this.channelTypeIndex = 0
}
})
}
},
immediate: true
},
// 监听客户类型和要货类型变化
isV032NormalApply: {
handler(newVal) {
if (newVal && this.channelTypeArr && this.channelTypeArr.length > 0) {
this.$nextTick(() => {
// 确保只有H选项并设置默认值
const hasH = this.channelTypeArr.some(item => item.value === 'H')
if (hasH) {
// 设置默认值为H
this.$set(this.orderItem, 'channelsType', 'H')
this.$set(this.orderItem, 'channelTypeName', '行业团购')
const hIndex = this.channelTypeArr.findIndex(item => item.value === 'H')
if (hIndex >= 0) {
this.channelTypeIndex = hIndex
}
} else {
// 如果没有H选项,通知父组件添加H选项
this.$emit('updateChannelType', [{ value: 'H', name: '行业团购' }])
this.$set(this.orderItem, 'channelsType', 'H')
this.$set(this.orderItem, 'channelTypeName', '行业团购')
this.channelTypeIndex = 0
}
})
}
},
immediate: true
}
},
methods: {
goTerminal() {
...
...
@@ -381,6 +477,11 @@
this.orderItem.planType = this.deliveryPlanArr[index].name
break;
case 'channelType':
// V032普通要货申请不允许修改渠道类型
if (this.isV032NormalApply) {
return
}
this.channelTypeIndex = index
this.orderItem.channelsType = this.channelTypeArr[index].value
this.orderItem.channelTypeName = this.channelTypeArr[index].name
// 渠道类型变化时,如果是终端要货则清空终端信息
...
...
@@ -454,10 +555,49 @@
},
async getChannelType(){
const res = await getChannelType({'salePlan': this.orderItem.planType})
this.channelTypeArr = res.data
this.channelTypeArr = res.data
|| []
if (!this.channelTypeArr.length) {
this.channelTypeArr = [{ value: 'S', name: '社会化渠道' }]
}
}
// V032普通要货申请,确保只有H-行业团购选项,并默认设置
if (this.isV032NormalApply) {
// 检查是否已有H选项
const hasH = this.channelTypeArr.some(item => item.value === 'H')
if (!hasH) {
// 如果没有H选项,添加H-行业团购选项
this.channelTypeArr = [{ value: 'H', name: '行业团购' }]
} else {
// 如果已有H选项,只保留H选项
this.channelTypeArr = this.channelTypeArr.filter(item => item.value === 'H')
}
// 设置默认值为H
this.$set(this.orderItem, 'channelsType', 'H')
this.$set(this.orderItem, 'channelTypeName', '行业团购')
// 设置选择器索引
const hIndex = this.channelTypeArr.findIndex(item => item.value === 'H')
if (hIndex >= 0) {
this.channelTypeIndex = hIndex
}
// 使用 $nextTick 确保数据更新
this.$nextTick(() => {
setTimeout(() => {
if (this.orderItem.channelsType !== 'H') {
this.$set(this.orderItem, 'channelsType', 'H')
this.$set(this.orderItem, 'channelTypeName', '行业团购')
}
}, 100)
})
} else {
// 非V032普通要货申请,初始化选择器索引
if (this.orderItem.channelsType && this.channelTypeArr.length > 0) {
const index = this.channelTypeArr.findIndex(item => item.value === this.orderItem.channelsType)
this.channelTypeIndex = index >= 0 ? index : 0
}
}
},
// 渠道类型变化处理,参考PC端逻辑
onChannelsTypeChange(value) {
...
...
pages/purchase-receive/purchase-receive.nvue
View file @
a87452c2
...
...
@@ -11,7 +11,7 @@
<view class="uni-list-cell">
<view class="uni-list-cell-db">
<picker class="picker-block" @change="bindPickerChange($event,'shunt')" :value="shuntIndex"
range-key='name' mode="selector" :range="shuntArr">
range-key='name' mode="selector" :range="shuntArr"
:disabled="isV032NormalApply"
>
<text class="uni-input">{{orderItem.shuntName || '请选择'}}</text>
</picker>
</view>
...
...
@@ -93,20 +93,20 @@
</view>
<view class="text-block text-block-last">
<text class="middle-date">收货联系人</text>
<input class="middle-date-des" type="text" v-model="orderItem.contacPerson" :disabled="!isTerminalType" placeholder="请输入" />
<input class="middle-date-des" type="text" v-model="orderItem.contacPerson" :disabled="!isTerminalType
&& !isV032NormalApply
" placeholder="请输入" />
<!-- <text class="middle-date-des">{{orderItem.contacPerson}}</text> -->
</view>
</view>
<view class="middle view">
<view class="text-block">
<text class="middle-date">联系人电话</text>
<input class="middle-date-des" type="text" v-model="orderItem.contactNumber" :disabled="!isTerminalType" placeholder="请输入" />
<input class="middle-date-des" type="text" v-model="orderItem.contactNumber" :disabled="!isTerminalType
&& !isV032NormalApply
" placeholder="请输入" />
</view>
<view class="text-address">
<text class="middle-date-add">收货地址</text>
<text class="middle-date-des-add">{{orderItem.receiveAddress}}</text>
</view>
<text class="edit-add" @click="handleAdd" v-if="isTerminalType">修改</text>
<text class="edit-add" @click="handleAdd" v-if="isTerminalType
|| isV032NormalApply
">修改</text>
<view class="text-block text-block-last">
<text class="middle-date">备注</text>
</view>
...
...
@@ -201,15 +201,25 @@
export default {
data() {
return {
terminalAdd: {
REGION: '',
REGION_TEXT: '',
CITY_CODE: '',
CITY_TEXT: '',
STREET_CODE: '',
STREET_TEXT: '',
STREET: ''
},
terminalAdd: {
REGION: '',
REGION_TEXT: '',
CITY_CODE: '',
CITY_TEXT: '',
STREET_CODE: '',
STREET_TEXT: '',
STREET: ''
},
// V032普通要货申请的地址数据
commonAddressData: {
REGION: '',
REGION_TEXT: '',
CITY_CODE: '',
CITY_TEXT: '',
STREET_CODE: '',
STREET_TEXT: '',
STREET: ''
},
isRadio: false,
receiveUnitArr: [],
shuntArr: [],
...
...
@@ -301,6 +311,13 @@
isTerminalType() {
return this.orderItem.demandType == 'ZDZG'
},
// 是否为V032客户类型且为普通要货申请
isV032NormalApply() {
console.log('zzfld000016:',this.customerDetails?.info?.zzfld000016);
// 优先从 store 中获取客户类型,其次从 orderItem 中获取
const customerType = this.customerDetails?.info?.zzfld000016 || this.orderItem.customerType || this.orderItem.zzfld000016
return customerType === 'V032' && !this.isTerminalType
},
imageStyles() {
return {
width: 64,
...
...
@@ -324,7 +341,7 @@
}
}
},
...mapState(['sysinfo', 'userInfo'])
...mapState(['sysinfo', 'userInfo'
, 'customerDetails'
])
},
// onLoad(option) {
// this.orderItem = {
...
...
@@ -383,6 +400,30 @@
_this.orderItem.contacPerson = data.selectReceiveUnitInfo.C_O_NAME
_this.orderItem.receiveAddress = data.selectReceiveUnitInfo.STREET
_this.orderItem.spurtCodeUnitName = data.selectReceiveUnitInfo.PARTNER_NAME
// V032普通要货申请,保存省市区信息(如果收货单位数据中包含)
if (_this.isV032NormalApply && data.selectReceiveUnitInfo) {
const unitData = data.selectReceiveUnitInfo
// 如果收货单位数据中包含省市区信息,保存它们
if (unitData.REGION || unitData.REGION_TEXT) {
_this.orderItem.province = unitData.REGION_TEXT || ''
_this.orderItem.provinceId = unitData.REGION || ''
}
if (unitData.CITY_CODE || unitData.CITY_NAME || unitData.CITY_TEXT) {
_this.orderItem.city = unitData.CITY_TEXT || unitData.CITY_NAME || ''
_this.orderItem.cityId = unitData.CITY_CODE || ''
_this.orderItem.cityCode = unitData.CITY_CODE || ''
}
if (unitData.STREET_CODE || unitData.STREET_TEXT) {
_this.orderItem.district = unitData.STREET_TEXT || ''
_this.orderItem.districtId = unitData.STREET_CODE || ''
_this.orderItem.streetcode = unitData.STREET_CODE || ''
}
if (unitData.REGION) {
_this.orderItem.region = unitData.REGION
}
}
// 更新收货单位索引
if(_this.receiveUnitArr.length > 0){
const receiveIndex = _this.receiveUnitArr.findIndex(item => item.PARTNER === data.selectReceiveUnitInfo.PARTNER)
...
...
@@ -399,6 +440,49 @@
_this.terminalAdd = { ...data.selectTerminalAddress }
_this.orderItem.receiveAddress = _this.terminalAdd.REGION_TEXT + _this.terminalAdd.CITY_TEXT + _this.terminalAdd.STREET_TEXT + _this.terminalAdd.STREET
})
uni.$on('selectCommonAddress', function(data) {
console.log('监听到事件来自 selectCommonAddress ,携带参数 msg 为:', data);
// V032普通要货申请修改收货地址
if (data && data.selectCommonAddress) {
const addrData = data.selectCommonAddress
_this.commonAddressData = { ...addrData }
_this.orderItem.receiveAddress = (addrData.REGION_TEXT || '') + (addrData.CITY_TEXT || '') + (addrData.STREET_TEXT || '') + (addrData.STREET || '')
// 保存省市区名称和编码,用于行业团购时传递到后端
_this.$set(_this.orderItem, 'province', addrData.REGION_TEXT || '')
_this.$set(_this.orderItem, 'city', addrData.CITY_TEXT || '')
_this.$set(_this.orderItem, 'district', addrData.STREET_TEXT || '')
_this.$set(_this.orderItem, 'provinceId', addrData.REGION || '')
_this.$set(_this.orderItem, 'cityId', addrData.CITY_CODE || '')
_this.$set(_this.orderItem, 'districtId', addrData.STREET_CODE || '')
// 同时保存 region、cityCode、streetcode 字段(用于兼容)
_this.$set(_this.orderItem, 'region', addrData.REGION || '')
_this.$set(_this.orderItem, 'cityCode', addrData.CITY_CODE || '')
_this.$set(_this.orderItem, 'streetcode', addrData.STREET_CODE || '')
// 允许修改联系人和手机号
if (addrData.CONTACT_PERSON) {
_this.$set(_this.orderItem, 'contacPerson', addrData.CONTACT_PERSON)
}
if (addrData.CONTACT_NUMBER) {
_this.$set(_this.orderItem, 'contactNumber', addrData.CONTACT_NUMBER)
}
// 调试日志
console.log('保存省市区信息到 orderItem:', {
province: _this.orderItem.province,
city: _this.orderItem.city,
district: _this.orderItem.district,
provinceId: _this.orderItem.provinceId,
cityId: _this.orderItem.cityId,
districtId: _this.orderItem.districtId,
region: _this.orderItem.region,
cityCode: _this.orderItem.cityCode,
streetcode: _this.orderItem.streetcode
})
console.log('commonAddressData:', _this.commonAddressData)
} else {
console.error('selectCommonAddress 事件数据格式错误:', data)
}
})
if(this.sourceType === 'myPurchase'){
this.getFiles(this.orderItem.id)
}
...
...
@@ -412,22 +496,24 @@
}, 300)
})
},
onUnload() {
uni.$off('selectShuntAccountInfo')
uni.$off('selectShuntAdressAccountInfo')
uni.$off('selectReceiveUnitInfo')
uni.$off('selectShuntCode')
uni.$off('selectAllShuntCode')
uni.$off('selectTerminalAddress')
},
beforeDestroy() {
uni.$off('selectShuntAccountInfo')
uni.$off('selectShuntAdressAccountInfo')
uni.$off('selectReceiveUnitInfo')
uni.$off('selectShuntCode')
uni.$off('selectAllShuntCode')
uni.$off('selectTerminalAddress')
},
onUnload() {
uni.$off('selectShuntAccountInfo')
uni.$off('selectShuntAdressAccountInfo')
uni.$off('selectReceiveUnitInfo')
uni.$off('selectShuntCode')
uni.$off('selectAllShuntCode')
uni.$off('selectTerminalAddress')
uni.$off('selectCommonAddress')
},
beforeDestroy() {
uni.$off('selectShuntAccountInfo')
uni.$off('selectShuntAdressAccountInfo')
uni.$off('selectReceiveUnitInfo')
uni.$off('selectShuntCode')
uni.$off('selectAllShuntCode')
uni.$off('selectTerminalAddress')
uni.$off('selectCommonAddress')
},
created() {
// 是否分流:B0099
// 分流渠道:A0054
...
...
@@ -557,9 +643,17 @@
}
},
handleAdd() {
uni.navigateTo({
url: `/pages/select-address/select-address`
})
if (this.isV032NormalApply) {
// V032普通要货申请,跳转到普通地址选择页面(不传ZDZG参数)
uni.navigateTo({
url: `/pages/select-address/select-address?isCommon=true&order=${JSON.stringify(this.orderItem)}`
})
} else {
// 终端直配,跳转到终端地址选择页面
uni.navigateTo({
url: `/pages/select-address/select-address`
})
}
},
handleReceiveUnit() {
// 跳转到收货单位选择页面(复用select-shunt-adress页面,type=2表示普通收货单位)
...
...
@@ -641,6 +735,27 @@
this.orderItem.contacPerson = this.receiveUnitArr[0].C_O_NAME
this.orderItem.receiveAddress = this.receiveUnitArr[0].STREET
this.orderItem.receiveUnitName = this.receiveUnitArr[0].PARTNER_NAME
// V032普通要货申请,保存省市区信息(如果收货单位数据中包含)
if (this.isV032NormalApply && this.receiveUnitArr[0]) {
const unitData = this.receiveUnitArr[0]
if (unitData.REGION || unitData.REGION_TEXT) {
this.orderItem.province = unitData.REGION_TEXT || ''
this.orderItem.provinceId = unitData.REGION || ''
this.orderItem.region = unitData.REGION || ''
}
if (unitData.CITY_CODE || unitData.CITY_NAME || unitData.CITY_TEXT) {
this.orderItem.city = unitData.CITY_TEXT || unitData.CITY_NAME || ''
this.orderItem.cityId = unitData.CITY_CODE || ''
this.orderItem.cityCode = unitData.CITY_CODE || ''
}
if (unitData.STREET_CODE || unitData.STREET_TEXT) {
this.orderItem.district = unitData.STREET_TEXT || ''
this.orderItem.districtId = unitData.STREET_CODE || ''
this.orderItem.streetcode = unitData.STREET_CODE || ''
}
}
// 保存默认值
this.defaultReceiveUnit = {
receiveUnitCode: this.receiveUnitArr[0].PARTNER,
...
...
@@ -722,6 +837,26 @@
this.orderItem.receiveAddress = this.receiveUnitArr[index].STREET
this.orderItem.contacPerson = this.receiveUnitArr[index].C_O_NAME
// V032普通要货申请,保存省市区信息(如果收货单位数据中包含)
if (this.isV032NormalApply && this.receiveUnitArr[index]) {
const unitData = this.receiveUnitArr[index]
if (unitData.REGION || unitData.REGION_TEXT) {
this.orderItem.province = unitData.REGION_TEXT || ''
this.orderItem.provinceId = unitData.REGION || ''
this.orderItem.region = unitData.REGION || ''
}
if (unitData.CITY_CODE || unitData.CITY_NAME || unitData.CITY_TEXT) {
this.orderItem.city = unitData.CITY_TEXT || unitData.CITY_NAME || ''
this.orderItem.cityId = unitData.CITY_CODE || ''
this.orderItem.cityCode = unitData.CITY_CODE || ''
}
if (unitData.STREET_CODE || unitData.STREET_TEXT) {
this.orderItem.district = unitData.STREET_TEXT || ''
this.orderItem.districtId = unitData.STREET_CODE || ''
this.orderItem.streetcode = unitData.STREET_CODE || ''
}
}
}
},
submit() {
...
...
@@ -851,6 +986,42 @@
// obj.district = this.terminalAdd.STREET_TEXT || this.orderItem.district
}else{
obj.demandType = 'none'
// V032普通要货申请且渠道类型为H(行业团购),传递省市区信息
if (this.isV032NormalApply && this.orderItem.channelsType === 'H') {
// 优先使用 orderItem 中的值,如果没有则从 commonAddressData 中获取
obj.province = this.orderItem.province || this.commonAddressData.REGION_TEXT || ''
obj.city = this.orderItem.city || this.commonAddressData.CITY_TEXT || ''
obj.district = this.orderItem.district || this.commonAddressData.STREET_TEXT || ''
obj.provinceId = this.orderItem.provinceId || this.orderItem.region || this.commonAddressData.REGION || ''
obj.cityId = this.orderItem.cityId || this.orderItem.cityCode || this.commonAddressData.CITY_CODE || ''
obj.districtId = this.orderItem.districtId || this.orderItem.streetcode || this.commonAddressData.STREET_CODE || ''
// 调试日志
console.log('preSave - 省市区信息:', {
orderItem: {
province: this.orderItem.province,
city: this.orderItem.city,
district: this.orderItem.district,
provinceId: this.orderItem.provinceId,
cityId: this.orderItem.cityId,
districtId: this.orderItem.districtId
},
commonAddressData: this.commonAddressData,
obj: {
province: obj.province,
city: obj.city,
district: obj.district,
provinceId: obj.provinceId,
cityId: obj.cityId,
districtId: obj.districtId
}
})
// 如果仍然为空,尝试从收货地址字符串中解析(作为最后的后备方案)
if (!obj.province && !obj.city && !obj.district && this.orderItem.receiveAddress) {
console.warn('省市区信息为空,请检查地址选择是否正确')
}
}
}
const params = JSON.parse(JSON.stringify(obj))
params.wantGoodsDetailList = JSON.stringify(params.wantGoodsDetailList)
...
...
@@ -955,7 +1126,43 @@
obj.city = this.terminalAdd.CITY_TEXT || this.orderItem.city
obj.district = this.terminalAdd.STREET_TEXT || this.orderItem.district
}else{
obj.demandType = 'none'
obj.demandType = 'none'
// V032普通要货申请且渠道类型为H(行业团购),传递省市区信息
if (this.isV032NormalApply && this.orderItem.channelsType === 'H') {
// 优先使用 orderItem 中的值,如果没有则从 commonAddressData 中获取
obj.province = this.orderItem.province || this.commonAddressData.REGION_TEXT || ''
obj.city = this.orderItem.city || this.commonAddressData.CITY_TEXT || ''
obj.district = this.orderItem.district || this.commonAddressData.STREET_TEXT || ''
obj.provinceId = this.orderItem.provinceId || this.orderItem.region || this.commonAddressData.REGION || ''
obj.cityId = this.orderItem.cityId || this.orderItem.cityCode || this.commonAddressData.CITY_CODE || ''
obj.districtId = this.orderItem.districtId || this.orderItem.streetcode || this.commonAddressData.STREET_CODE || ''
// 调试日志
console.log('nextStep - 省市区信息:', {
orderItem: {
province: this.orderItem.province,
city: this.orderItem.city,
district: this.orderItem.district,
provinceId: this.orderItem.provinceId,
cityId: this.orderItem.cityId,
districtId: this.orderItem.districtId
},
commonAddressData: this.commonAddressData,
obj: {
province: obj.province,
city: obj.city,
district: obj.district,
provinceId: obj.provinceId,
cityId: obj.cityId,
districtId: obj.districtId
}
})
// 如果仍然为空,尝试从收货地址字符串中解析(作为最后的后备方案)
if (!obj.province && !obj.city && !obj.district && this.orderItem.receiveAddress) {
console.warn('省市区信息为空,请检查地址选择是否正确')
}
}
}
const params = JSON.parse(JSON.stringify(obj))
params.wantGoodsDetailList = JSON.stringify(params.wantGoodsDetailList)
...
...
@@ -976,7 +1183,17 @@
}
if (status == 1 || flagStatus) {
try{
const res = await exceedMonthPlan(JSON.parse(JSON.stringify(obj)))
// exceedMonthPlan 也需要传递省市区信息(如果是行业团购)
const exceedParams = JSON.parse(JSON.stringify(obj))
if (this.isV032NormalApply && exceedParams.channelsType === 'H') {
exceedParams.province = exceedParams.province || this.orderItem.province || this.commonAddressData.REGION_TEXT || ''
exceedParams.city = exceedParams.city || this.orderItem.city || this.commonAddressData.CITY_TEXT || ''
exceedParams.district = exceedParams.district || this.orderItem.district || this.commonAddressData.STREET_TEXT || ''
exceedParams.provinceId = exceedParams.provinceId || this.orderItem.provinceId || this.orderItem.region || this.commonAddressData.REGION || ''
exceedParams.cityId = exceedParams.cityId || this.orderItem.cityId || this.orderItem.cityCode || this.commonAddressData.CITY_CODE || ''
exceedParams.districtId = exceedParams.districtId || this.orderItem.districtId || this.orderItem.streetcode || this.commonAddressData.STREET_CODE || ''
}
const res = await exceedMonthPlan(exceedParams)
this.flag = false
const that = this
if(res.status == 0){
...
...
@@ -1022,6 +1239,28 @@
// 提交
params.wantGoodsDetailList = JSON.stringify(params.wantGoodsDetailList)
}
// V032普通要货申请且渠道类型为H(行业团购),确保传递省市区信息
if (this.isV032NormalApply && params.channelsType === 'H') {
// 优先使用 params 中的值,其次使用 orderItem,最后使用 commonAddressData
params.province = params.province || this.orderItem.province || this.commonAddressData.REGION_TEXT || ''
params.city = params.city || this.orderItem.city || this.commonAddressData.CITY_TEXT || ''
params.district = params.district || this.orderItem.district || this.commonAddressData.STREET_TEXT || ''
params.provinceId = params.provinceId || this.orderItem.provinceId || this.orderItem.region || this.commonAddressData.REGION || ''
params.cityId = params.cityId || this.orderItem.cityId || this.orderItem.cityCode || this.commonAddressData.CITY_CODE || ''
params.districtId = params.districtId || this.orderItem.districtId || this.orderItem.streetcode || this.commonAddressData.STREET_CODE || ''
// 调试日志
console.log('提交省市区信息:', {
province: params.province,
city: params.city,
district: params.district,
provinceId: params.provinceId,
cityId: params.cityId,
districtId: params.districtId
})
}
for(let k in params){
params[k] = params[k] === null ? '' : params[k]
}
...
...
pages/select-address/select-address.nvue
View file @
a87452c2
...
...
@@ -8,9 +8,9 @@
<view class="middle-date-des uni-list picker-year">
<view class="uni-list-cell">
<view class="uni-list-cell-db">
<picker class="picker-block" @change="changeArea($event,'city')" :value="
terminalAdd.REGION
"
<picker class="picker-block" @change="changeArea($event,'city')" :value="
regionIndex
"
range-key='BEZEI' mode="selector" :range="selectDataOptions['regionList']">
<text class="uni-input">{{terminalAdd.REGION_TEXT}}</text>
<text class="uni-input">{{terminalAdd.REGION_TEXT
|| '请选择'
}}</text>
</picker>
</view>
</view>
...
...
@@ -22,9 +22,9 @@
<view class="middle-date-des uni-list picker-year">
<view class="uni-list-cell">
<view class="uni-list-cell-db">
<picker class="picker-block" @change="changeArea($event,'street')" :value="
terminalAdd.CITY_CODE
"
<picker class="picker-block" @change="changeArea($event,'street')" :value="
cityIndex
"
range-key='CITY_NAME' mode="selector" :range="selectDataOptions['cityList']">
<text class="uni-input">{{terminalAdd.CITY_TEXT}}</text>
<text class="uni-input">{{terminalAdd.CITY_TEXT
|| '请选择'
}}</text>
</picker>
</view>
</view>
...
...
@@ -36,9 +36,9 @@
<view class="middle-date-des uni-list picker-year">
<view class="uni-list-cell">
<view class="uni-list-cell-db">
<picker class="picker-block" @change="changeArea($event,'q')" :value="
terminalAdd.STREET_CODE
"
<picker class="picker-block" @change="changeArea($event,'q')" :value="
streetIndex
"
range-key='MC_STREET' mode="selector" :range="selectDataOptions['streetList']">
<text class="uni-input">{{terminalAdd.STREET_TEXT}}</text>
<text class="uni-input">{{terminalAdd.STREET_TEXT
|| '请选择'
}}</text>
</picker>
</view>
</view>
...
...
@@ -74,6 +74,7 @@
export default {
data() {
return {
isCommon: false, // 是否为普通要货申请的地址选择
terminalAdd: {
REGION: '',
REGION_TEXT: '',
...
...
@@ -81,13 +82,18 @@
CITY_TEXT: '',
STREET_CODE: '',
STREET_TEXT: '',
STREET: ''
STREET: '',
CONTACT_PERSON: '', // 联系人
CONTACT_NUMBER: '' // 联系电话
},
selectDataOptions: {
cityList: [],
streetList: [],
regionList: []
},
regionIndex: 0,
cityIndex: 0,
streetIndex: 0
}
},
computed: {
...
...
@@ -109,7 +115,39 @@
},
},
onLoad() {
onLoad(options) {
console.log('select-address onLoad options:', options)
// 检查是否是普通要货申请的地址选择(isCommon=true)
if (options.isCommon === 'true' || options.isCommon === true) {
this.isCommon = true
console.log('设置为普通要货申请地址选择模式')
// 如果有传入的订单数据,初始化地址信息
if (options.order) {
try {
const orderData = JSON.parse(decodeURIComponent(options.order))
console.log('解析订单数据:', orderData)
if (orderData.region || orderData.cityCode || orderData.streetcode) {
// 初始化地址数据
this.terminalAdd.REGION = orderData.region || ''
this.terminalAdd.CITY_CODE = orderData.cityCode || ''
this.terminalAdd.STREET_CODE = orderData.streetcode || ''
// 如果有联系人信息,也初始化
if (orderData.contacPerson) {
this.terminalAdd.CONTACT_PERSON = orderData.contacPerson
}
if (orderData.contactNumber) {
this.terminalAdd.CONTACT_NUMBER = orderData.contactNumber
}
// 加载对应的省市区数据
this.initAddressData()
}
} catch (e) {
console.error('解析订单数据失败:', e)
}
}
} else {
this.isCommon = false
}
},
created() {
this.getAreaArr()
...
...
@@ -117,36 +155,79 @@
methods: {
// 省
async getAreaArr(){
await getArea('','region',"ZDZG").then(res => {
// 普通要货申请不传 ZDZG 参数
const mode = this.isCommon ? '' : 'ZDZG'
await getArea('','region', mode).then(res => {
this.selectDataOptions['regionList'] = res.DATA
})
},
// 初始化地址数据(当有初始地址时)
async initAddressData() {
if (this.terminalAdd.REGION) {
// 加载省数据
await this.getAreaArr()
// 找到对应的省
const regionItem = this.selectDataOptions['regionList'].find(item => item.BLAND === this.terminalAdd.REGION)
if (regionItem) {
this.terminalAdd.REGION_TEXT = regionItem.BEZEI
// 加载市数据
const cityRes = await getArea(this.terminalAdd.REGION, 'city', this.isCommon ? '' : 'ZDZG')
this.selectDataOptions.cityList = cityRes.DATA || []
if (this.terminalAdd.CITY_CODE) {
const cityItem = this.selectDataOptions['cityList'].find(item => item.CITY_CODE === this.terminalAdd.CITY_CODE)
if (cityItem) {
this.terminalAdd.CITY_TEXT = cityItem.CITY_NAME
// 加载区数据
const streetRes = await getArea(this.terminalAdd.CITY_CODE, 'street', this.isCommon ? '' : 'ZDZG')
this.selectDataOptions.streetList = streetRes.DATA || []
if (this.terminalAdd.STREET_CODE) {
const streetItem = this.selectDataOptions['streetList'].find(item => item.STRT_CODE === this.terminalAdd.STREET_CODE)
if (streetItem) {
this.terminalAdd.STREET_TEXT = streetItem.MC_STREET
}
}
}
}
}
}
},
async changeArea(e, type) {
if (e) {
console.log('picker发送选择改变,携带值为', e.detail.value)
const index = e.detail.value || 0
// 普通要货申请不传 ZDZG 参数
const mode = this.isCommon ? '' : 'ZDZG'
if (type === 'city') {
const code = this.selectDataOptions['regionList'][index].BLAND
const { DATA } = await getArea(code, type,"ZDZG")
this.selectDataOptions.cityList = DATA
this.terminalAdd.REGION_TEXT = this.selectDataOptions['regionList'].find(v => v.BLAND === code)?.BEZEI
this.terminalAdd.REGION = code
this.regionIndex = index
const { DATA } = await getArea(code, type, mode)
this.selectDataOptions.cityList = DATA || []
this.terminalAdd.REGION_TEXT = this.selectDataOptions['regionList'].find(v => v.BLAND === code)?.BEZEI || ''
this.terminalAdd.CITY_CODE = ''
this.terminalAdd.STREET_CODE = ''
this.terminalAdd.CITY_TEXT = ''
this.terminalAdd.STREET_TEXT = ''
this.terminalAdd.STREET = ''
this.selectDataOptions.streetList = []
this.cityIndex = 0
this.streetIndex = 0
} else if (type === 'street') {
const code = this.selectDataOptions['cityList'][index].CITY_CODE
const { DATA } = await getArea(code, type)
this.selectDataOptions.streetList = DATA
this.terminalAdd.CITY_CODE = code
this.cityIndex = index
const { DATA } = await getArea(code, type, mode)
this.selectDataOptions.streetList = DATA || []
this.terminalAdd.STREET_CODE = ''
this.terminalAdd.STREET_TEXT = ''
this.terminalAdd.STREET = ''
this.terminalAdd.CITY_TEXT = this.selectDataOptions['cityList'].find(v => v.CITY_CODE === code)?.CITY_NAME
this.terminalAdd.CITY_TEXT = this.selectDataOptions['cityList'].find(v => v.CITY_CODE === code)?.CITY_NAME || ''
this.streetIndex = 0
} else {
const code = this.selectDataOptions['streetList'][index].STRT_CODE
this.terminalAdd.STREET_TEXT = this.selectDataOptions['streetList'].find(v => v.STRT_CODE === code)?.MC_STREET
this.terminalAdd.STREET_CODE = code
this.streetIndex = index
this.terminalAdd.STREET_TEXT = this.selectDataOptions['streetList'].find(v => v.STRT_CODE === code)?.MC_STREET || ''
}
}
},
...
...
@@ -183,9 +264,44 @@
});
return
}
uni.$emit('selectTerminalAddress', {
selectTerminalAddress: this.terminalAdd
})
// 确保所有编码字段都已保存
if (!this.terminalAdd.REGION && this.terminalAdd.REGION_TEXT) {
// 如果只有名称没有编码,尝试从列表中找到编码
const regionItem = this.selectDataOptions['regionList'].find(item => item.BEZEI === this.terminalAdd.REGION_TEXT)
if (regionItem) {
this.terminalAdd.REGION = regionItem.BLAND
}
}
if (!this.terminalAdd.CITY_CODE && this.terminalAdd.CITY_TEXT) {
const cityItem = this.selectDataOptions['cityList'].find(item => item.CITY_NAME === this.terminalAdd.CITY_TEXT)
if (cityItem) {
this.terminalAdd.CITY_CODE = cityItem.CITY_CODE
}
}
if (!this.terminalAdd.STREET_CODE && this.terminalAdd.STREET_TEXT) {
const streetItem = this.selectDataOptions['streetList'].find(item => item.MC_STREET === this.terminalAdd.STREET_TEXT)
if (streetItem) {
this.terminalAdd.STREET_CODE = streetItem.STRT_CODE
}
}
// 调试日志
console.log('地址选择完成,发送数据:', this.terminalAdd)
console.log('isCommon:', this.isCommon)
// 根据 isCommon 参数决定发送哪个事件
if (this.isCommon) {
// 普通要货申请,发送 selectCommonAddress 事件
uni.$emit('selectCommonAddress', {
selectCommonAddress: { ...this.terminalAdd }
})
} else {
// 终端直配,发送 selectTerminalAddress 事件
uni.$emit('selectTerminalAddress', {
selectTerminalAddress: { ...this.terminalAdd }
})
}
uni.navigateBack()
},
}
...
...
store/index.js
View file @
a87452c2
...
...
@@ -12,7 +12,7 @@ try {
}
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
let
saveStateKeys
=
[
'vuex_user'
,
'vuex_token'
,
'userInfo'
,
'userBpData'
,
'isChildCustomer'
];
let
saveStateKeys
=
[
'vuex_user'
,
'vuex_token'
,
'userInfo'
,
'userBpData'
,
'isChildCustomer'
,
'customerDetails'
];
// 保存变量到本地存储中
const
saveLifeData
=
function
(
key
,
value
)
{
...
...
@@ -71,7 +71,11 @@ const store = new Vuex.Store({
'baseinfo'
:
{}
},
// 从本地存储恢复登录信息,避免热重载时丢失
isChildCustomer
:
lifeData
.
isChildCustomer
!==
undefined
?
lifeData
.
isChildCustomer
:
false
isChildCustomer
:
lifeData
.
isChildCustomer
!==
undefined
?
lifeData
.
isChildCustomer
:
false
,
// 客户详细信息,包含客户类型等信息
customerDetails
:
lifeData
.
customerDetails
?
lifeData
.
customerDetails
:
{
info
:
{}
}
},
getters
:
{
// 获取角色信息,包含 USER_BP 和 ROLE
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment