From 105f75417d1e22934205559109390451ff0a9b20 Mon Sep 17 00:00:00 2001
From: wangzeyan <258785420@qq.com>
Date: Mon, 23 Jun 2025 13:32:05 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/util.js | 12 +-
pages/market/clue/add_clues.vue | 4 +-
pages/market/clue/edit_clues.vue | 192 ++++++++++++++++++-------
pages/market/clue/index.vue | 235 +++++++++++++++++++------------
4 files changed, 294 insertions(+), 149 deletions(-)
diff --git a/common/util.js b/common/util.js
index c2eee71..9295a69 100644
--- a/common/util.js
+++ b/common/util.js
@@ -1,5 +1,5 @@
import {img_domian} from "./config";
-import marketApi from '@/api/market.js';
+import marketApi from '@/api/apiRoute.js';
function formatTime(time) {
if (typeof time !== 'number' || time < 0) {
@@ -231,13 +231,17 @@ async function getDict(dictKey) {
return cache.data;
}
// 缓存无效,请求接口
- const res = await marketApi.common_Dictionary({ dictKey });
+ const res = await marketApi.common_Dictionary({ key: dictKey });
if (res && res.code === 1) {
+ // 处理接口返回的数据,确保返回格式一致
+ // 接口返回的是 [{name: "抖音", value: "1", sort: 0, memo: ""}, ...]
+ const formattedData = Array.isArray(res.data) ? res.data : [];
+
uni.setStorageSync(cacheKey, {
- data: res.data,
+ data: formattedData,
expire: now + 3600 * 1000
});
- return res.data;
+ return formattedData;
} else {
return [];
}
diff --git a/pages/market/clue/add_clues.vue b/pages/market/clue/add_clues.vue
index 5530eea..ec24fce 100644
--- a/pages/market/clue/add_clues.vue
+++ b/pages/market/clue/add_clues.vue
@@ -904,8 +904,8 @@ export default {
return
}
let arr = []
- // 兼容后端返回格式
- (dictionary.dictionary || dictionary).forEach((v)=>{
+ // 处理接口返回的数据结构 [{name: "抖音", value: "1", sort: 0, memo: ""}, ...]
+ dictionary.forEach((v) => {
arr.push({ text: v.name, value: v.value })
})
this.picker_config[inputName].options = arr
diff --git a/pages/market/clue/edit_clues.vue b/pages/market/clue/edit_clues.vue
index b3e4757..d0b77bb 100644
--- a/pages/market/clue/edit_clues.vue
+++ b/pages/market/clue/edit_clues.vue
@@ -27,6 +27,21 @@
+
+
+
+
+ {{ formData.source_channel ? picker_config.source_channel.text : '点击选择' }}
+
+
+
@@ -198,17 +213,17 @@
-
+
-
+
报名
-
+
未报名
@@ -463,18 +478,41 @@
methods: {
//初始化
async init() {
- await this.getDict('source_channel') //获取字典-来源渠道
- await this.getDict('source') //获取字典-来源
- await this.getDict('purchasing_power') //获取字典-购买力
- await this.getDict('initial_intent') //获取字典-客户初步意向度
- await this.getDict('cognitive_idea') //获取字典-认知理念
- await this.getDict('status') //获取字典-客户状态
- await this.getDict('decision_maker') //获取字典-决策人
- await this.getDict('distance') //获取字典-距离
- // this.getStaffList()//获取人员列表
- // this.getAreaTree()//获取地区树形结构
-
- await this.getInfo() //获取资源共享-详情(客户资源详情)
+ try {
+ uni.showLoading({
+ title: '加载中...',
+ mask: true
+ });
+
+ // 先加载所有字典数据
+ const dictPromises = [
+ this.getDict('source_channel'), //获取字典-来源渠道
+ this.getDict('source'), //获取字典-来源
+ this.getDict('purchasing_power'), //获取字典-购买力
+ this.getDict('initial_intent'), //获取字典-客户初步意向度
+ this.getDict('cognitive_idea'), //获取字典-认知理念
+ this.getDict('status'), //获取字典-客户状态
+ this.getDict('decision_maker'), //获取字典-决策人
+ this.getDict('distance'), //获取字典-距离
+ ];
+
+ await Promise.all(dictPromises);
+
+ // 加载校区列表
+ await this.get_campus_list();
+
+ // 获取资源共享详情并回显数据
+ await this.getInfo();
+
+ } catch (error) {
+ console.error('初始化失败:', error);
+ uni.showToast({
+ title: '加载数据失败,请重试',
+ icon: 'none'
+ });
+ } finally {
+ uni.hideLoading();
+ }
},
async get_campus_list(){
@@ -538,6 +576,7 @@
decision_maker: customerResource.decision_maker || '', //决策人
initial_intent: customerResource.initial_intent || '', //客户初步意向度: high-高, medium-中, low-低
status: customerResource.status || '', //客户状态: active-活跃, inactive-不活跃, pending-待定
+ campus: customerResource.campus || '', // 校区
//六要素信息
purchasing_power: sixSpeed.purchase_power || '', //购买力
@@ -554,24 +593,72 @@
this.formData.promised_visit_time = this.$util.formatToDateTime(sixSpeed.promised_visit_time,
'Y-m-d'); //格式化时间(Y-m-d H:i)
- this.formData.optional_class_time = this.$util.formatToDateTime(sixSpeed.promised_visit_time,
+ this.formData.optional_class_time = this.$util.formatToDateTime(sixSpeed.preferred_class_time,
'Y-m-d'); //格式化时间(Y-m-d H:i)
+
+ // 获取校区列表,确保校区选择器数据已加载
+ await this.get_campus_list()
+
+ // 等待所有字典数据加载完成后再进行回显
+ await this.setPickerText()
+ },
- //下拉窗文本回显
- this.picker_config.source_channel.text = customerResource.source_channel_name || '点击选择' //来源渠道
- this.picker_config.source.text = customerResource.source_name || '点击选择' //来源
- this.picker_config.consultant.text = customerResource.consultant_name || '点击选择' //顾问
- this.picker_config.initial_intent.text = customerResource.initial_intent_name || '点击选择' //客户初步意向度
- this.picker_config.status.text = customerResource.status_name || '点击选择' //客户状态
-
- this.picker_config.decision_maker.text = customerResource.decision_maker || '点击选择' //决策人
+ // 设置选择器文本回显
+ async setPickerText() {
+ const { customerResource = {}, sixSpeed = {} } = await this.getResourceDetail() || {}
+
+ // 设置选择器文本回显
+ this.setPickerTextByValue('source_channel', this.formData.source_channel, customerResource.source_channel_name)
+ this.setPickerTextByValue('source', this.formData.source, customerResource.source_name)
+ this.setPickerTextByValue('consultant', this.formData.consultant, customerResource.consultant_name)
+ this.setPickerTextByValue('initial_intent', this.formData.initial_intent, customerResource.initial_intent_name)
+ this.setPickerTextByValue('status', this.formData.status, customerResource.status_name)
+ this.setPickerTextByValue('decision_maker', this.formData.decision_maker, customerResource.decision_maker_name || customerResource.decision_maker)
+ this.setPickerTextByValue('campus', this.formData.campus, customerResource.campus_name)
+
+ // 六要素相关
+ this.setPickerTextByValue('purchasing_power', this.formData.purchasing_power, sixSpeed.purchase_power_name)
+ this.setPickerTextByValue('cognitive_idea', this.formData.cognitive_idea, sixSpeed.concept_awareness_name)
+ this.setPickerTextByValue('distance', this.formData.distance, sixSpeed.distance_name || sixSpeed.distance)
+ },
- //六要素相关
- this.picker_config.purchasing_power.text = sixSpeed.purchase_power_name || '点击选择' //购买力
- this.picker_config.cognitive_idea.text = sixSpeed.concept_awareness_name || '点击选择' //认知理念
- this.picker_config.distance.text = sixSpeed.distance || '点击选择' //距离
+ // 根据值设置选择器文本
+ setPickerTextByValue(pickerName, value, defaultText) {
+ if (!value) {
+ this.picker_config[pickerName].text = '点击选择'
+ return
+ }
+
+ // 先尝试从选项中找到匹配的文本
+ const options = this.picker_config[pickerName].options || []
+ const option = options.find(opt => opt.value == value)
+
+ if (option) {
+ this.picker_config[pickerName].text = option.text
+ } else if (defaultText) {
+ // 如果找不到匹配的选项但有默认文本,则使用默认文本
+ this.picker_config[pickerName].text = defaultText
+ } else {
+ this.picker_config[pickerName].text = '点击选择'
+ }
+ },
- await this.get_campus_list()//获取校区
+ // 获取资源详情(缓存数据,避免重复请求)
+ async getResourceDetail() {
+ if (this._resourceDetail) {
+ return this._resourceDetail
+ }
+
+ let params = {
+ resource_sharing_id: this.resource_sharing_id
+ }
+
+ let res = await apiRoute.xs_resourceSharingInfo(params)
+ if (res.code == 1) {
+ this._resourceDetail = res.data
+ return res.data
+ }
+ return null
},
//获取字典-课程id选择
@@ -705,25 +792,17 @@
return
}
-
- let res = await apiRoute.common_Dictionary({
- key: key
- })
- if (res.code != 1) {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
+ // 使用 util.getDict 获取并缓存字典
+ let dictionary = await this.$util.getDict(key)
+ if(!dictionary || !Array.isArray(dictionary) || dictionary.length === 0){
+ uni.showToast({ title: '暂无选项', icon: 'none' })
return
}
-
- let dictionary = res.data.dictionary
+
let arr = []
- dictionary.forEach((v, k) => {
- arr.push({
- text: v.name,
- value: v.value,
- })
+ // 处理接口返回的数据结构 [{name: "抖音", value: "1", sort: 0, memo: ""}, ...]
+ dictionary.forEach((v) => {
+ arr.push({ text: v.name, value: v.value })
})
if (inputName == 'source_channel') {
@@ -733,10 +812,6 @@
value: '0',
})
}
- if (inputName == 'status') {
- //插入到arr的头部
- console.log(arr)
- }
this.picker_config[inputName].options = arr
},
@@ -971,15 +1046,26 @@
changeCicker(e) {
console.log('监听-下拉选择器', this.picker_input_name, e)
let input_name = this.picker_input_name
+
+ // 更新表单数据
this.formData[input_name] = e.value
- this.picker_config[input_name]['text'] = e.text
+
+ // 更新选择器文本
+ this.picker_config[input_name].text = e.text
+
+ // 特殊处理:来源选择
if (input_name == 'source') {
- if (e.value != 1) {
- this.formData.source_channel = '0' //0=线下
+ if (e.value == 1) {
+ // 如果选择了线上,则清空来源渠道,等待用户选择
+ this.formData.source_channel = ''
+ this.picker_config.source_channel.text = '点击选择'
} else {
- this.formData.source_channel = '' //线下
+ // 如果选择了其他来源,则设置来源渠道为线下
+ this.formData.source_channel = '0' //0=线下
+ this.picker_config.source_channel.text = '线下'
}
}
+
this.cancelCicker()
},
//关闭下拉选择器
diff --git a/pages/market/clue/index.vue b/pages/market/clue/index.vue
index e039227..2d0c71b 100644
--- a/pages/market/clue/index.vue
+++ b/pages/market/clue/index.vue
@@ -15,57 +15,64 @@
-
-
-
-
-
+
+
+
+
+
+
+
+ {{ v.customerResource.name }}
+ {{ v.customerResource.phone_number }}
+
+
+ 所属校区:{{ v.customerResource.campus_name }}
+
+
+ 来源:{{ v.customerResource.source }}
+
+
+ 来源渠道:{{ v.customerResource.source_channel }}
- {{ v.customerResource.name }}
- {{ v.customerResource.phone_number }}
-
-
- 所属校区:{{ v.customerResource.campus_name }}
-
-
- 来源渠道:{{ v.customerResource.source_channel }}
+
+
+
+
+
+
+
+
+
+
+
@@ -81,22 +88,34 @@
-
-
-
-
-
+
+
+
+
+
+
+
+ {{v.customerResource.name}}
+
+
+
+ 决策人:{{v.customerResource.name}} {{v.customerResource.decision_maker}}
- {{v.customerResource.name}}
-
-
- 决策人:{{v.customerResource.name}} {{v.customerResource.decision_maker}}
+
+
+ 分配
+
+
+