Commit a87452c2 authored by chicheng's avatar chicheng

要货添加企业团购渠道相关逻辑

parent dbdccfc4
...@@ -20,12 +20,16 @@ ...@@ -20,12 +20,16 @@
"type" : "uni-app:app-android" "type" : "uni-app:app-android"
}, },
{ {
"playground" : "custom", "playground" : "standard",
"type" : "uni-app:app-ios" "type" : "uni-app:app-ios"
}, },
{ {
"openVueDevtools" : false, "openVueDevtools" : false,
"type" : "uni-app:h5" "type" : "uni-app:h5"
},
{
"playground" : "standard",
"type" : "uni-app:app-ios_simulator"
} }
] ]
} }
...@@ -355,6 +355,13 @@ ...@@ -355,6 +355,13 @@
name: 'isChildCustomer', name: 'isChildCustomer',
value: isChildCustomer value: isChildCustomer
}); });
// 保存客户详细信息,包含客户类型等信息
if (res.data.customerDetails) {
this.$uStore({
name: 'customerDetails',
value: res.data.customerDetails
});
}
this.$uStore({ this.$uStore({
name: 'vuex_token', name: 'vuex_token',
value: res.data.token value: res.data.token
......
...@@ -38,9 +38,9 @@ ...@@ -38,9 +38,9 @@
<view class="middle-date-address uni-list picker-year"> <view class="middle-date-address uni-list picker-year">
<view class="uni-list-cell"> <view class="uni-list-cell">
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<picker class="picker-block" @change="bindPickerChange($event,'channelType')" :value="orderItem.channelsType" <picker class="picker-block" @change="bindPickerChange($event,'channelType')" :value="channelTypeIndex"
range-key='name' mode="selector" :range="channelTypeArr"> range-key='name' mode="selector" :range="channelTypeArr" :disabled="isV032NormalApply">
<text class="uni-input">{{orderItem.channelTypeName}}</text> <text class="uni-input">{{orderItem.channelTypeName || '请选择'}}</text>
</picker> </picker>
</view> </view>
</view> </view>
...@@ -237,7 +237,8 @@ ...@@ -237,7 +237,8 @@
significanceArr : [], significanceArr : [],
marketPlaceArr : [], marketPlaceArr : [],
manifestArr : [], manifestArr : [],
pcjArr: [{value:'0',name: '否'}, {value:'1',name: '是'}] pcjArr: [{value:'0',name: '否'}, {value:'1',name: '是'}],
channelTypeIndex: 0 // 渠道类型选择器的索引
} }
}, },
props: { props: {
...@@ -269,7 +270,13 @@ ...@@ -269,7 +270,13 @@
'height': `${this.sysinfo.safeArea.top + 44}px` '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() { mounted() {
console.log('监听到事件来自 update'); console.log('监听到事件来自 update');
...@@ -293,6 +300,38 @@ ...@@ -293,6 +300,38 @@
_this.orderItem.city = data.selectTerminal.cityName _this.orderItem.city = data.selectTerminal.cityName
_this.orderItem.district = data.selectTerminal.districtName _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() { onUnload() {
uni.$off('selectSalePlaceAccountInfo') uni.$off('selectSalePlaceAccountInfo')
...@@ -319,6 +358,63 @@ ...@@ -319,6 +358,63 @@
// 'orderItem.planType':function(res,res1){ // 'orderItem.planType':function(res,res1){
// res && this.getChannelType() // 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: { methods: {
goTerminal() { goTerminal() {
...@@ -381,6 +477,11 @@ ...@@ -381,6 +477,11 @@
this.orderItem.planType = this.deliveryPlanArr[index].name this.orderItem.planType = this.deliveryPlanArr[index].name
break; break;
case 'channelType': case 'channelType':
// V032普通要货申请不允许修改渠道类型
if (this.isV032NormalApply) {
return
}
this.channelTypeIndex = index
this.orderItem.channelsType = this.channelTypeArr[index].value this.orderItem.channelsType = this.channelTypeArr[index].value
this.orderItem.channelTypeName = this.channelTypeArr[index].name this.orderItem.channelTypeName = this.channelTypeArr[index].name
// 渠道类型变化时,如果是终端要货则清空终端信息 // 渠道类型变化时,如果是终端要货则清空终端信息
...@@ -454,10 +555,49 @@ ...@@ -454,10 +555,49 @@
}, },
async getChannelType(){ async getChannelType(){
const res = await getChannelType({'salePlan': this.orderItem.planType}) const res = await getChannelType({'salePlan': this.orderItem.planType})
this.channelTypeArr = res.data this.channelTypeArr = res.data || []
if (!this.channelTypeArr.length) { if (!this.channelTypeArr.length) {
this.channelTypeArr = [{ value: 'S', name: '社会化渠道' }] 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端逻辑 // 渠道类型变化处理,参考PC端逻辑
onChannelsTypeChange(value) { onChannelsTypeChange(value) {
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
<view class="middle-date-des uni-list picker-year"> <view class="middle-date-des uni-list picker-year">
<view class="uni-list-cell"> <view class="uni-list-cell">
<view class="uni-list-cell-db"> <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']"> 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> </picker>
</view> </view>
</view> </view>
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
<view class="middle-date-des uni-list picker-year"> <view class="middle-date-des uni-list picker-year">
<view class="uni-list-cell"> <view class="uni-list-cell">
<view class="uni-list-cell-db"> <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']"> 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> </picker>
</view> </view>
</view> </view>
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
<view class="middle-date-des uni-list picker-year"> <view class="middle-date-des uni-list picker-year">
<view class="uni-list-cell"> <view class="uni-list-cell">
<view class="uni-list-cell-db"> <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']"> 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> </picker>
</view> </view>
</view> </view>
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
export default { export default {
data() { data() {
return { return {
isCommon: false, // 是否为普通要货申请的地址选择
terminalAdd: { terminalAdd: {
REGION: '', REGION: '',
REGION_TEXT: '', REGION_TEXT: '',
...@@ -81,13 +82,18 @@ ...@@ -81,13 +82,18 @@
CITY_TEXT: '', CITY_TEXT: '',
STREET_CODE: '', STREET_CODE: '',
STREET_TEXT: '', STREET_TEXT: '',
STREET: '' STREET: '',
CONTACT_PERSON: '', // 联系人
CONTACT_NUMBER: '' // 联系电话
}, },
selectDataOptions: { selectDataOptions: {
cityList: [], cityList: [],
streetList: [], streetList: [],
regionList: [] regionList: []
}, },
regionIndex: 0,
cityIndex: 0,
streetIndex: 0
} }
}, },
computed: { computed: {
...@@ -109,7 +115,39 @@ ...@@ -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() { created() {
this.getAreaArr() this.getAreaArr()
...@@ -117,36 +155,79 @@ ...@@ -117,36 +155,79 @@
methods: { methods: {
// 省 // 省
async getAreaArr(){ 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 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) { async changeArea(e, type) {
if (e) { if (e) {
console.log('picker发送选择改变,携带值为', e.detail.value) console.log('picker发送选择改变,携带值为', e.detail.value)
const index = e.detail.value || 0 const index = e.detail.value || 0
// 普通要货申请不传 ZDZG 参数
const mode = this.isCommon ? '' : 'ZDZG'
if (type === 'city') { if (type === 'city') {
const code = this.selectDataOptions['regionList'][index].BLAND const code = this.selectDataOptions['regionList'][index].BLAND
const { DATA } = await getArea(code, type,"ZDZG") this.terminalAdd.REGION = code
this.selectDataOptions.cityList = DATA this.regionIndex = index
this.terminalAdd.REGION_TEXT = this.selectDataOptions['regionList'].find(v => v.BLAND === code)?.BEZEI 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.CITY_CODE = ''
this.terminalAdd.STREET_CODE = '' this.terminalAdd.STREET_CODE = ''
this.terminalAdd.CITY_TEXT = '' this.terminalAdd.CITY_TEXT = ''
this.terminalAdd.STREET_TEXT = '' this.terminalAdd.STREET_TEXT = ''
this.terminalAdd.STREET = '' this.terminalAdd.STREET = ''
this.selectDataOptions.streetList = [] this.selectDataOptions.streetList = []
this.cityIndex = 0
this.streetIndex = 0
} else if (type === 'street') { } else if (type === 'street') {
const code = this.selectDataOptions['cityList'][index].CITY_CODE const code = this.selectDataOptions['cityList'][index].CITY_CODE
const { DATA } = await getArea(code, type) this.terminalAdd.CITY_CODE = code
this.selectDataOptions.streetList = DATA this.cityIndex = index
const { DATA } = await getArea(code, type, mode)
this.selectDataOptions.streetList = DATA || []
this.terminalAdd.STREET_CODE = '' this.terminalAdd.STREET_CODE = ''
this.terminalAdd.STREET_TEXT = '' this.terminalAdd.STREET_TEXT = ''
this.terminalAdd.STREET = '' 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 { } else {
const code = this.selectDataOptions['streetList'][index].STRT_CODE 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 @@ ...@@ -183,9 +264,44 @@
}); });
return return
} }
// 确保所有编码字段都已保存
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', { uni.$emit('selectTerminalAddress', {
selectTerminalAddress: this.terminalAdd selectTerminalAddress: { ...this.terminalAdd }
}) })
}
uni.navigateBack() uni.navigateBack()
}, },
} }
......
...@@ -12,7 +12,7 @@ try { ...@@ -12,7 +12,7 @@ try {
} }
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名 // 需要永久存储,且下次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) { const saveLifeData = function(key, value) {
...@@ -71,7 +71,11 @@ const store = new Vuex.Store({ ...@@ -71,7 +71,11 @@ const store = new Vuex.Store({
'baseinfo': {} 'baseinfo': {}
}, },
// 从本地存储恢复登录信息,避免热重载时丢失 // 从本地存储恢复登录信息,避免热重载时丢失
isChildCustomer: lifeData.isChildCustomer !== undefined ? lifeData.isChildCustomer : false isChildCustomer: lifeData.isChildCustomer !== undefined ? lifeData.isChildCustomer : false,
// 客户详细信息,包含客户类型等信息
customerDetails: lifeData.customerDetails ? lifeData.customerDetails : {
info: {}
}
}, },
getters: { getters: {
// 获取角色信息,包含 USER_BP 和 ROLE // 获取角色信息,包含 USER_BP 和 ROLE
......
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