Browse Source

修改页面初始化的bug

master
王泽彦 9 months ago
parent
commit
9c692f4f96
  1. 8
      api/apiRoute.js
  2. 8
      api/market.js
  3. 5
      common/axios.js
  4. 34
      common/util.js
  5. 2
      components/AQ/AQTabber.vue
  6. 348
      pages/market/clue/clue_info.vue
  7. 262
      pages/market/clue/edit_clues.vue

8
api/apiRoute.js

@ -326,8 +326,12 @@ export default {
async xy_orderTableAdd(data = {}) { async xy_orderTableAdd(data = {}) {
return await http.post('/xy/orderTable/add', data); return await http.post('/xy/orderTable/add', data);
}, },
// 获取通话记录
async listCallUp(data={}) { async listCallUp(data={}) {
return await http.get('/member/list_call_up', data); return await http.get('/per_list_call_up', data);
},
// 更新通话记录
async updateCallUp(data={}) {
return await http.post('/per_update_call_up', data);
}, },
} }

8
api/market.js

@ -83,14 +83,6 @@ export default {
}) })
}, },
//拨打电话记录列表
listCallUp(data={}) {
let url = '/member/list_call_up'
return http.get(url, data).then(res => {
return res;
})
},
//公海-领取客户 //公海-领取客户
getSales(data = {}) { getSales(data = {}) {

5
common/axios.js

@ -135,6 +135,9 @@ export default {
}); });
console.log('请求配置:', interceptedConfig); console.log('请求配置:', interceptedConfig);
console.log('请求URL:', interceptedConfig.url);
console.log('请求方法:', interceptedConfig.method);
console.log('请求数据:', interceptedConfig.data);
uni.request({ uni.request({
...interceptedConfig, ...interceptedConfig,
@ -166,7 +169,7 @@ export default {
} }
}); });
}); });
}, 300), }, 100),
// 封装请求方法 // 封装请求方法
post(url, data = {}) { post(url, data = {}) {

34
common/util.js

@ -224,25 +224,57 @@ function loginOut() {
* @returns {Promise<Array|Object>} * @returns {Promise<Array|Object>}
*/ */
async function getDict(dictKey) { async function getDict(dictKey) {
console.log(`util.getDict - 开始获取字典: ${dictKey}`);
const cacheKey = `dict_${dictKey}`; const cacheKey = `dict_${dictKey}`;
const cache = uni.getStorageSync(cacheKey); const cache = uni.getStorageSync(cacheKey);
const now = Date.now(); const now = Date.now();
// 检查缓存是否有效
if (cache && cache.data && cache.expire > now) { if (cache && cache.data && cache.expire > now) {
console.log(`util.getDict - 使用缓存数据: ${dictKey}, 数据条数: ${cache.data.length}`);
return cache.data; return cache.data;
} }
console.log(`util.getDict - 缓存无效,请求接口: ${dictKey}`);
// 缓存无效,请求接口 // 缓存无效,请求接口
const res = await marketApi.common_Dictionary({ key: dictKey }); try {
console.log(`util.getDict - 调用API: common_Dictionary, key=${dictKey}`);
// 添加超时处理
const timeoutPromise = new Promise((_, reject) => {
setTimeout(() => reject(new Error(`字典加载超时: ${dictKey}`)), 3000);
});
// 实际API请求
const apiPromise = marketApi.common_Dictionary({ key: dictKey });
// 使用Promise.race来实现超时控制
const res = await Promise.race([apiPromise, timeoutPromise]);
console.log(`util.getDict - API响应:`, res);
if (res && res.code === 1) { if (res && res.code === 1) {
// 处理接口返回的数据,确保返回格式一致 // 处理接口返回的数据,确保返回格式一致
// 接口返回的是 [{name: "抖音", value: "1", sort: 0, memo: ""}, ...] // 接口返回的是 [{name: "抖音", value: "1", sort: 0, memo: ""}, ...]
const formattedData = Array.isArray(res.data) ? res.data : []; const formattedData = Array.isArray(res.data) ? res.data : [];
console.log(`util.getDict - 保存缓存: ${dictKey}, 数据条数: ${formattedData.length}`);
uni.setStorageSync(cacheKey, { uni.setStorageSync(cacheKey, {
data: formattedData, data: formattedData,
expire: now + 3600 * 1000 expire: now + 3600 * 1000
}); });
console.log(`util.getDict - 字典获取成功: ${dictKey}`);
return formattedData; return formattedData;
} else { } else {
console.error(`util.getDict - API请求失败: ${dictKey}`, res);
// 返回空数组而不是抛出异常,避免阻塞流程
return [];
}
} catch (error) {
console.error(`util.getDict - 异常: ${dictKey}`, error);
// 返回空数组,避免阻塞流程
return []; return [];
} }
} }

2
components/AQ/AQTabber.vue

@ -142,7 +142,7 @@
}, },
{ {
text: "数据", text: "数据",
urlPath: '/pages/market/data/index', // urlPath: '/pages/market/data/statistics', //
iconPath: util.img('/uniapp_src/static/images/tabbar/timetable.png'), iconPath: util.img('/uniapp_src/static/images/tabbar/timetable.png'),
selectedIconPath: util.img('/uniapp_src/static/images/tabbar/timetables.png'), selectedIconPath: util.img('/uniapp_src/static/images/tabbar/timetables.png'),
}, },

348
pages/market/clue/clue_info.vue

@ -10,17 +10,17 @@
<view class="course_box_top"> <view class="course_box_top">
<view class="course_box_top_top"> <view class="course_box_top_top">
<image class="pic" :src="$util.img('/uniapp_src/static/images/index/myk.png')"></image> <image class="pic" :src="$util.img('/uniapp_src/static/images/index/myk.png')"></image>
<view class="name">{{ clientInfo.customerResource.name }}</view> <view class="name">{{ safeGet(clientInfo, 'customerResource.name', '未知客户') }}</view>
</view> </view>
<view class="course_box_top_below"> <view class="course_box_top_below">
<view class="course_box_top_below-left"> <view class="course_box_top_below-left">
<view>{{ $util.formatToDateTime((clientInfo.customerResource.updated_at || ''),'m-d H:i') }} 跟进</view> <view>{{ $util.formatToDateTime((safeGet(clientInfo, 'customerResource.updated_at', '')),'m-d H:i') }} 跟进</view>
<view style="display: flex;align-items: center;"> <view style="display: flex;align-items: center;">
<view style="padding-left: 30rpx;"> <view style="padding-left: 30rpx;">
<image v-if="clientInfo.customerResource.initial_intent == 'high'" <image v-if="safeGet(clientInfo, 'customerResource.initial_intent') == 'high'"
:src="$util.img('/uniapp_src/static/images/index/lvs.png')" class="drop-image-x"></image> :src="$util.img('/uniapp_src/static/images/index/lvs.png')" class="drop-image-x"></image>
<image v-else-if="clientInfo.customerResource.initial_intent == 'medium'" <image v-else-if="safeGet(clientInfo, 'customerResource.initial_intent') == 'medium'"
:src="$util.img('/uniapp_src/static/images/index/intention2.png')" class="drop-image-x"></image> :src="$util.img('/uniapp_src/static/images/index/intention2.png')" class="drop-image-x"></image>
<image <image
v-else v-else
@ -37,7 +37,7 @@
<view class="btn-item" @click="handleMakeCall"> <view class="btn-item" @click="handleMakeCall">
<image class="btn-icon" :src="$util.img('/uniapp_src/static/images/index/phone.png')"></image> <image class="btn-icon" :src="$util.img('/uniapp_src/static/images/index/phone.png')"></image>
</view> </view>
<view class="btn-item" @click="handleSendMessage" v-if="this.clientInfo.customerResource.member_id"> <view class="btn-item" @click="handleSendMessage" v-if="safeGet(clientInfo, 'customerResource.member_id')">
<image class="btn-icon" :src="$util.img('/uniapp_src/static/images/index/message.png')"></image> <image class="btn-icon" :src="$util.img('/uniapp_src/static/images/index/message.png')"></image>
</view> </view>
</view> </view>
@ -68,23 +68,23 @@
<view class="basic-message-div"> <view class="basic-message-div">
<view class="basic-message-div-txt"> <view class="basic-message-div-txt">
<view>来源渠道</view> <view>来源渠道</view>
<view>{{clientInfo.customerResource.source_channel_name}}</view> <view>{{safeGet(clientInfo, 'customerResource.source_channel_name', '未知渠道')}}</view>
</view> </view>
<view class="basic-message-div-txt"> <view class="basic-message-div-txt">
<view>来源</view> <view>来源</view>
<view>{{clientInfo.customerResource.source_name}}</view> <view>{{safeGet(clientInfo, 'customerResource.source_name', '未知来源')}}</view>
</view> </view>
<view class="basic-message-div-txt"> <view class="basic-message-div-txt">
<view>顾问</view> <view>顾问</view>
<view>{{clientInfo.customerResource.consultant_name}}</view> <view>{{safeGet(clientInfo, 'customerResource.consultant_name', '未知顾问')}}</view>
</view> </view>
<view class="basic-message-div-txt"> <view class="basic-message-div-txt">
<view>学生姓名</view> <view>学生姓名</view>
<view>{{clientInfo.customerResource.name}}</view> <view>{{safeGet(clientInfo, 'customerResource.name', '未知学生')}}</view>
</view> </view>
<view class="basic-message-div-txt"> <view class="basic-message-div-txt">
<view>性别</view> <view>性别</view>
<view>{{clientInfo.customerResource.gender_name}}</view> <view>{{safeGet(clientInfo, 'customerResource.gender_name', '未知性别')}}</view>
</view> </view>
</view> </view>
@ -92,11 +92,11 @@
<view class="basic-message-div"> <view class="basic-message-div">
<view class="basic-message-div-txt" @click="openViewOrder()"> <view class="basic-message-div-txt" @click="openViewOrder()">
<view>已成交次数</view> <view>已成交次数</view>
<view>{{clientInfo.customerResource.cj_count || 0}}</view> <view>{{safeGet(clientInfo, 'customerResource.cj_count', 0)}}</view>
</view> </view>
<view class="basic-message-div-txt"> <view class="basic-message-div-txt">
<view>体验课程</view> <view>体验课程</view>
<view>{{clientInfo.customerResource.trial_class_count}}</view> <view>{{safeGet(clientInfo, 'customerResource.trial_class_count', 0)}}</view>
</view> </view>
</view> </view>
<view style="height: 200rpx;"></view> <view style="height: 200rpx;"></view>
@ -120,6 +120,10 @@
<!-- 通话记录--> <!-- 通话记录-->
<view class="call-log" v-if="switch_tags_type == 3"> <view class="call-log" v-if="switch_tags_type == 3">
<!-- 添加备注按钮 -->
<view style="width: 92%; margin: 20rpx auto; display: flex; justify-content: center;">
<button type="primary" style="background-color: #29D3B4; color: white;" @click="openAddRemark">添加备注</button>
</view>
<view style="margin-top: 20rpx" v-for="(v,k) in listCallUp" :key="k"> <view style="margin-top: 20rpx" v-for="(v,k) in listCallUp" :key="k">
<!-- <view class="basic-message">08-23</view>--> <!-- <view class="basic-message">08-23</view>-->
<view class="follow-records-list"> <view class="follow-records-list">
@ -128,8 +132,8 @@
<view>{{v.create_time}}</view> <view>{{v.create_time}}</view>
</view> </view>
<view style="display: flex;justify-content: space-between;padding: 16rpx 16rpx 16rpx 60rpx;"> <view style="display: flex;justify-content: space-between;padding: 16rpx 16rpx 16rpx 60rpx;">
<view>呼叫对象{{v.student_name}}</view> <view>呼叫时间{{v.created_at}}</view>
<view>呼叫号码{{v.student_phone}}</view> <view>呼叫备注{{v.remarks}}</view>
</view> </view>
</view> </view>
</view> </view>
@ -267,6 +271,21 @@
<view @click="openViewEditCluesLog()">修改记录</view> <view @click="openViewEditCluesLog()">修改记录</view>
<view @click="openViewOrder()">订单列表</view> <view @click="openViewOrder()">订单列表</view>
</view> </view>
<!-- 添加备注弹窗 -->
<uni-popup ref="remarkPopup" type="dialog">
<uni-popup-dialog
title="添加备注"
:before-close="true"
@confirm="confirmRemark"
@close="closeRemark">
<uni-easyinput
type="textarea"
v-model="remark_content"
placeholder="请输入备注内容">
</uni-easyinput>
</uni-popup-dialog>
</uni-popup>
</view> </view>
</view> </view>
</template> </template>
@ -297,51 +316,144 @@
// //
userInfo:{}, userInfo:{},
//
remark_content: '',
} }
}, },
onLoad(options) { onLoad(options) {
console.log('onLoad - 接收到参数:', options);
// optionsresource_sharing_id
if (!options || !options.resource_sharing_id) {
console.error('onLoad - 缺少必要参数resource_sharing_id');
uni.showToast({
title: '缺少必要参数',
icon: 'none'
});
//
setTimeout(() => {
uni.navigateBack();
}, 1500);
return;
}
this.resource_sharing_id = options.resource_sharing_id//id this.resource_sharing_id = options.resource_sharing_id//id
console.log('onLoad - 设置 resource_sharing_id:', this.resource_sharing_id);
}, },
onShow(){ onShow(){
console.log('onShow - 开始初始化');
this.init() this.init()
}, },
methods: { methods: {
async init(){ async init(){
await this.getInfo()// console.log('init - 开始初始化流程');
this.getUserInfo()//
this.getListCallUp()// //
try {
console.log('init - 开始预加载字典数据');
const dictPromises = [
this.$util.getDict('SourceChannel'), //
this.$util.getDict('source'), //
this.$util.getDict('preliminarycustomerintention'), //
this.$util.getDict('kh_status'), //
];
// 使Promise.all
const timeoutPromise = new Promise((_, reject) =>
setTimeout(() => reject(new Error('字典加载超时')), 5000)
);
await Promise.race([
Promise.all(dictPromises),
timeoutPromise
]).catch(err => {
console.warn('字典加载异常或超时,继续执行流程:', err);
});
console.log('init - 字典数据预加载完成或已超时');
} catch (error) {
console.warn('init - 字典数据预加载失败,继续执行流程:', error);
}
//
try {
//
console.log('init - 开始获取客户详情');
await this.getInfo();
console.log('init - 客户详情获取完成');
//
console.log('init - 开始获取员工信息和通话记录');
await Promise.all([
this.getUserInfo(),
this.getListCallUp()
]);
console.log('init - 员工信息和通话记录获取完成');
} catch (error) {
console.error('init - 数据加载出错:', error);
}
}, },
// //
async getUserInfo(){ async getUserInfo(){
console.log('getUserInfo - 开始获取员工信息');
try {
let res = await apiRoute.getPersonnelInfo({}) let res = await apiRoute.getPersonnelInfo({})
if (res.code != 1) { if (res.code != 1) {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
icon: 'none' icon: 'none'
}) })
return return false;
} }
this.userInfo = res.data this.userInfo = res.data
// console.log('',this.userInfo) console.log('getUserInfo - 员工信息获取成功');
return true;
} catch (error) {
console.error('getUserInfo - 获取员工信息失败:', error);
return false;
}
}, },
// //
async getInfo(){ async getInfo(){
console.log('getInfo - 开始获取客户详情, resource_sharing_id:', this.resource_sharing_id);
try {
// resource_sharing_id
if (!this.resource_sharing_id) {
console.error('getInfo - resource_sharing_id为空,无法获取客户详情');
uni.showToast({
title: '缺少必要参数',
icon: 'none'
});
return false;
}
let data = { let data = {
resource_sharing_id:this.resource_sharing_id//id resource_sharing_id:this.resource_sharing_id//id
} }
console.log('getInfo - 发起请求:', data);
let res = await apiRoute.xs_resourceSharingInfo(data) let res = await apiRoute.xs_resourceSharingInfo(data)
console.log('getInfo - 请求响应:', res);
if(res.code != 1){ if(res.code != 1){
console.error('getInfo - 请求失败:', res.msg);
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
icon: 'none' icon: 'none'
}) })
return return false;
} }
this.clientInfo = res.data this.clientInfo = res.data
console.log('详情',this.clientInfo) console.log('getInfo - 客户详情数据:', this.clientInfo);
console.log('getInfo - 客户详情获取完成');
return true;
} catch (error) {
console.error('getInfo - 获取客户详情失败:', error);
return false;
}
}, },
// //
@ -362,6 +474,14 @@
// //
async getListCallUp(){ async getListCallUp(){
console.log('getListCallUp - 开始获取通话记录');
try {
// resource_sharing_id
if (!this.resource_sharing_id) {
console.error('getListCallUp - resource_sharing_id为空,无法获取通话记录');
return false;
}
let data = { let data = {
sales_id:this.resource_sharing_id// sales_id:this.resource_sharing_id//
} }
@ -371,13 +491,29 @@
title: res.msg, title: res.msg,
icon: 'none' icon: 'none'
}) })
return return false;
} }
this.listCallUp = res.data this.listCallUp = res.data
console.log('getListCallUp - 通话记录获取成功');
return true;
} catch (error) {
console.error('getListCallUp - 获取通话记录失败:', error);
return false;
}
}, },
//- //-
openViewEditClues(){ openViewEditClues(){
// resource_sharing_id
if (!this.resource_sharing_id) {
console.error('openViewEditClues - resource_sharing_id为空,无法跳转');
uni.showToast({
title: '缺少必要参数',
icon: 'none'
});
return;
}
let resource_sharing_id = this.resource_sharing_id//id let resource_sharing_id = this.resource_sharing_id//id
this.$navigateTo({ this.$navigateTo({
url: `/pages/market/clue/edit_clues?resource_sharing_id=${resource_sharing_id}` url: `/pages/market/clue/edit_clues?resource_sharing_id=${resource_sharing_id}`
@ -386,7 +522,17 @@
//- //-
openViewEditCluesLog() { openViewEditCluesLog() {
let resource_id = this.clientInfo.resource_id // clientInfo.resource_id
const resource_id = this.safeGet(this.clientInfo, 'resource_id');
if (!resource_id) {
console.error('openViewEditCluesLog - resource_id为空,无法跳转');
uni.showToast({
title: '缺少必要参数',
icon: 'none'
});
return;
}
this.$navigateTo({ this.$navigateTo({
url: `/pages/market/clue/edit_clues_log?resource_id=${resource_id}` url: `/pages/market/clue/edit_clues_log?resource_id=${resource_id}`
}) })
@ -394,11 +540,20 @@
//- //-
openViewOrder() { openViewOrder() {
let resource_id = this.clientInfo.resource_id//id //
let resource_name = this.clientInfo.customerResource.name || ''//id const resource_id = this.safeGet(this.clientInfo, 'resource_id');
if (!resource_id) {
console.error('openViewOrder - resource_id为空,无法跳转');
uni.showToast({
title: '缺少必要参数',
icon: 'none'
});
return;
}
let staff_id = this.userInfo.id//id let resource_name = this.safeGet(this.clientInfo, 'customerResource.name', '')//id
let staff_id_name = this.userInfo.name || ''// let staff_id = this.safeGet(this.userInfo, 'id', '')//id
let staff_id_name = this.safeGet(this.userInfo, 'name', '')//
this.$navigateTo({ this.$navigateTo({
url: `/pages/market/clue/order_list?resource_id=${resource_id}&resource_name=${resource_name}&staff_id=${staff_id}&staff_id_name=${staff_id_name}` url: `/pages/market/clue/order_list?resource_id=${resource_id}&resource_name=${resource_name}&staff_id=${staff_id}&staff_id_name=${staff_id_name}`
@ -451,29 +606,100 @@
}) })
}, },
// //
openAddRemark() {
this.remark_content = '';
this.$refs.remarkPopup.open();
},
//
async confirmRemark() {
if (!this.remark_content.trim()) {
uni.showToast({
title: '请输入备注内容',
icon: 'none'
});
return;
}
try {
uni.showLoading({
title: '提交中...',
mask: true
});
const params = {
staff_id: this.userInfo.id, // id
resource_id: this.clientInfo.resource_id, // ID
resource_type: '', //
communication_type: 'note', // : phone-, note-
communication_result: 'success', //
remarks: this.remark_content, //
tag: null //
};
const res = await apiRoute.xs_communicationRecordsAdd(params);
if (res.code !== 1) {
uni.showToast({
title: res.msg || '添加备注失败',
icon: 'none'
});
return;
}
uni.showToast({
title: '添加备注成功',
icon: 'success'
});
//
this.getListCallUp();
} catch (error) {
console.error('添加备注失败:', error);
uni.showToast({
title: '添加备注失败,请重试',
icon: 'none'
});
} finally {
uni.hideLoading();
this.$refs.remarkPopup.close();
}
},
//
closeRemark() {
this.$refs.remarkPopup.close();
},
//
handleMakeCall() { handleMakeCall() {
if (!this.clientInfo.customerResource.phone_number) { if (!this.clientInfo.customerResource.phone) {
uni.showToast({ uni.showToast({
title: '电话号码为空', title: '电话号码为空',
icon: 'none' icon: 'none'
}); });
return; return;
} }
this.callTel(this.clientInfo.customerResource.phone_number); this.callTel(this.clientInfo.customerResource.phone);
}, },
// //
handleSendMessage() { handleSendMessage() {
if (!this.clientInfo.customerResource.staff_id) { if (!this.clientInfo.customerResource.member_id) {
uni.showToast({ uni.showToast({
title: '未找到相关人员', title: '该客户未注册账号,无法发送消息',
icon: 'none' icon: 'none'
}); });
return; return;
} }
let member_id = this.clientInfo.customerResource.member_id;
let member_name = this.clientInfo.customerResource.name || '';
this.$navigateTo({ this.$navigateTo({
url: `/pages/common/im_chat_info?hair_staff_id=${this.clientInfo.customerResource.staff_id}` url: `/pages/market/clue/chat?member_id=${member_id}&member_name=${member_name}`
}); });
}, },
@ -484,6 +710,20 @@
getSelect(type){ getSelect(type){
this.select_type = type this.select_type = type
}, },
// 访
safeGet(obj, path, defaultValue = '') {
if (!obj) return defaultValue;
const keys = path.split('.');
let result = obj;
for (const key of keys) {
if (result === null || result === undefined || !result.hasOwnProperty(key)) {
return defaultValue;
}
result = result[key];
}
return result || defaultValue;
},
} }
} }
</script> </script>
@ -501,6 +741,26 @@
min-height: 28vh; min-height: 28vh;
} }
//
.action-buttons {
display: flex;
align-items: center;
.btn-item {
width: 60rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
margin-left: 20rpx;
.btn-icon {
width: 40rpx;
height: 40rpx;
}
}
}
// //
.count_section { .count_section {
width: 100%; width: 100%;
@ -699,24 +959,4 @@
padding: 12rpx 8rpx; padding: 12rpx 8rpx;
text-align: center; text-align: center;
} }
.action-buttons {
display: flex;
gap: 20rpx;
align-items: center;
.btn-item {
display: flex;
align-items: center;
justify-content: center;
width: 60rpx;
height: 60rpx;
border-radius: 50%;
background: #f5f5f5;
.btn-icon {
width: 40rpx;
height: 40rpx;
}
}
}
</style> </style>

262
pages/market/clue/edit_clues.vue

@ -134,13 +134,13 @@
</view> </view>
</fui-form-item> </fui-form-item>
<!-- 客户分类 --> <!-- 客户分类 -->
<fui-form-item label="客户分类" labelSize='26' prop="customer_type" background='#434544' labelColor='#fff' :bottomBorder='false'> <!-- <fui-form-item label="客户分类" labelSize='26' prop="customer_type" background='#434544' labelColor='#fff' :bottomBorder='false'>
<view class="input-title" style="margin-right:14rpx;"> <view class="input-title" style="margin-right:14rpx;">
<view class="input-title" style="margin-right:14rpx;" @click="openCicker('customer_type')"> <view class="input-title" style="margin-right:14rpx;" @click="openCicker('customer_type')">
{{ formData.customer_type ? picker_config.customer_type.text : '点击选择' }} {{ formData.customer_type ? picker_config.customer_type.text : '点击选择' }}
</view> </view>
</view> </view>
</fui-form-item> </fui-form-item> -->
<!-- 预约体验课 --> <!-- 预约体验课 -->
<!-- <fui-form-item label="预约体验课" labelSize='26' prop="trial_lesson" background='#434544' labelColor='#fff' :bottomBorder='false'> <!-- <fui-form-item label="预约体验课" labelSize='26' prop="trial_lesson" background='#434544' labelColor='#fff' :bottomBorder='false'>
<view class="input-title" style="margin-right:14rpx;"> <view class="input-title" style="margin-right:14rpx;">
@ -470,20 +470,50 @@
} }
}, },
onLoad(options) { onLoad(options) {
this.resource_sharing_id = options.resource_sharing_id //id console.log('onLoad - 接收到参数:', options);
if (!options || !options.resource_sharing_id) {
console.error('缺少必要参数 resource_sharing_id');
uni.showToast({
title: '缺少必要参数',
icon: 'none'
});
setTimeout(() => {
uni.navigateBack();
}, 1500);
return;
}
this.resource_sharing_id = options.resource_sharing_id; //id
console.log('设置 resource_sharing_id:', this.resource_sharing_id);
}, },
onShow() { onShow() {
this.init() console.log('onShow - 开始初始化');
this.init();
}, },
methods: { methods: {
// //
async init() { async init() {
try { try {
console.log('init - 开始初始化流程');
if (!this.resource_sharing_id) {
console.error('resource_sharing_id 为空,无法初始化');
uni.showToast({
title: '缺少必要参数',
icon: 'none'
});
setTimeout(() => {
uni.navigateBack();
}, 1500);
return;
}
uni.showLoading({ uni.showLoading({
title: '加载中...', title: '加载中...',
mask: true mask: true
}); });
console.log('init - 开始加载字典数据');
// //
const dictPromises = [ const dictPromises = [
this.getDict('source_channel'), //- this.getDict('source_channel'), //-
@ -494,15 +524,21 @@
this.getDict('status'), //- this.getDict('status'), //-
this.getDict('decision_maker'), //- this.getDict('decision_maker'), //-
this.getDict('distance'), //- this.getDict('distance'), //-
// this.getDict('customer_type'), //-
]; ];
await Promise.all(dictPromises); await Promise.all(dictPromises);
console.log('init - 字典数据加载完成');
// //
console.log('init - 开始加载校区列表');
await this.get_campus_list(); await this.get_campus_list();
console.log('init - 校区列表加载完成');
// //
console.log('init - 开始获取客户详情');
await this.getInfo(); await this.getInfo();
console.log('init - 客户详情获取完成');
} catch (error) { } catch (error) {
console.error('初始化失败:', error); console.error('初始化失败:', error);
@ -543,24 +579,38 @@
//-() //-()
async getInfo() { async getInfo() {
try {
console.log('getInfo - 开始获取客户详情, resource_sharing_id:', this.resource_sharing_id);
if (!this.resource_sharing_id) {
console.error('getInfo - resource_sharing_id 为空,无法获取客户详情');
return;
}
let params = { let params = {
resource_sharing_id: this.resource_sharing_id resource_sharing_id: this.resource_sharing_id
} };
console.log('getInfo - 发起请求:', params);
let res = await apiRoute.xs_resourceSharingInfo(params); //-()
console.log('getInfo - 请求响应:', res);
let res = await apiRoute.xs_resourceSharingInfo(params) //-()
if (res.code != 1) { if (res.code != 1) {
console.error('getInfo - 请求失败:', res.msg);
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
icon: 'none' icon: 'none'
}) });
return return;
} }
let customerResource = res.data.customerResource || {} // let customerResource = res.data.customerResource || {}; //
let sixSpeed = res.data.customerResource.sixSpeed || {} // let sixSpeed = res.data.customerResource.sixSpeed || {}; //
console.log('12313', sixSpeed) console.log('getInfo - 客户资源详情:', customerResource);
console.log('详情', res.data) console.log('getInfo - 六要素详情:', sixSpeed);
//
this._resourceDetail = res.data;
this.formData = { this.formData = {
resource_sharing_id: this.resource_sharing_id, //id resource_sharing_id: this.resource_sharing_id, //id
@ -570,13 +620,14 @@
source: customerResource.source || '', // source: customerResource.source || '', //
name: customerResource.name || '', // name: customerResource.name || '', //
age: customerResource.age || '', // age: customerResource.age || '', //
gender: customerResource.gender || '', //|male-, female-, other- gender: customerResource.gender || 'male', //|male-, female-, other-
phone_number: customerResource.phone_number || '', // phone_number: customerResource.phone_number || '', //
demand: customerResource.demand || '', // demand: customerResource.demand || '', //
decision_maker: customerResource.decision_maker || '', // decision_maker: customerResource.decision_maker || '', //
initial_intent: customerResource.initial_intent || '', //: high-, medium-, low- initial_intent: customerResource.initial_intent || '', //: high-, medium-, low-
status: customerResource.status || '', //: active-, inactive-, pending- status: customerResource.status || '', //: active-, inactive-, pending-
campus: customerResource.campus || '', // campus: customerResource.campus || '', //
customer_type: customerResource.customer_type || '', //
// //
purchasing_power: sixSpeed.purchase_power || '', // purchasing_power: sixSpeed.purchase_power || '', //
@ -586,60 +637,102 @@
distance: sixSpeed.distance || '', // distance: sixSpeed.distance || '', //
promised_visit_time: sixSpeed.promised_visit_time || '', //访 promised_visit_time: sixSpeed.promised_visit_time || '', //访
optional_class_time: sixSpeed.preferred_class_time || '', // optional_class_time: sixSpeed.preferred_class_time || '', //
first_visit_time: sixSpeed.first_visit_time || '', // 访
first_visit_status: sixSpeed.first_visit_status || '', //访 first_visit_status: sixSpeed.first_visit_status || '', //访
second_visit_time: sixSpeed.second_visit_time || '', // 访
second_visit_status: sixSpeed.second_visit_status || '', //访 second_visit_status: sixSpeed.second_visit_status || '', //访
efficacious : sixSpeed.efficacious remark: sixSpeed.remark || '', //
consultation_remark: sixSpeed.consultation_remark || '', //
chasing_orders: sixSpeed.chasing_orders || '', //
is_bm: sixSpeed.is_bm || 2, //
efficacious: sixSpeed.efficacious || ''
};
console.log('getInfo - 表单数据设置完成:', this.formData);
//
if (sixSpeed.promised_visit_time) {
this.formData.promised_visit_time = this.$util.formatToDateTime(sixSpeed.promised_visit_time, 'Y-m-d');
}
if (sixSpeed.preferred_class_time) {
this.formData.optional_class_time = this.$util.formatToDateTime(sixSpeed.preferred_class_time, 'Y-m-d');
}
if (sixSpeed.first_visit_time) {
this.formData.first_visit_time = this.$util.formatToDateTime(sixSpeed.first_visit_time, 'Y-m-d');
} }
this.formData.promised_visit_time = this.$util.formatToDateTime(sixSpeed.promised_visit_time, if (sixSpeed.second_visit_time) {
'Y-m-d'); //(Y-m-d H:i) this.formData.second_visit_time = this.$util.formatToDateTime(sixSpeed.second_visit_time, 'Y-m-d');
this.formData.optional_class_time = this.$util.formatToDateTime(sixSpeed.preferred_class_time, }
'Y-m-d'); //(Y-m-d H:i)
console.log('getInfo - 日期格式化完成');
// //
await this.get_campus_list() console.log('getInfo - 开始设置选择器文本回显');
await this.setPickerText();
console.log('getInfo - 选择器文本回显完成');
// } catch (error) {
await this.setPickerText() console.error('获取客户详情失败:', error);
uni.showToast({
title: '获取客户详情失败,请重试',
icon: 'none'
});
}
}, },
// //
async setPickerText() { async setPickerText() {
const { customerResource = {}, sixSpeed = {} } = await this.getResourceDetail() || {} try {
const { customerResource = {}, sixSpeed = {} } = await this.getResourceDetail() || {};
// //
this.setPickerTextByValue('source_channel', this.formData.source_channel, customerResource.source_channel_name) this.setPickerTextByValue('source_channel', this.formData.source_channel, customerResource.source_channel_name);
this.setPickerTextByValue('source', this.formData.source, customerResource.source_name) this.setPickerTextByValue('source', this.formData.source, customerResource.source_name);
this.setPickerTextByValue('consultant', this.formData.consultant, customerResource.consultant_name) this.setPickerTextByValue('consultant', this.formData.consultant, customerResource.consultant_name);
this.setPickerTextByValue('initial_intent', this.formData.initial_intent, customerResource.initial_intent_name) this.setPickerTextByValue('initial_intent', this.formData.initial_intent, customerResource.initial_intent_name);
this.setPickerTextByValue('status', this.formData.status, customerResource.status_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('decision_maker', this.formData.decision_maker, customerResource.decision_maker_name);
this.setPickerTextByValue('campus', this.formData.campus, customerResource.campus_name) this.setPickerTextByValue('campus', this.formData.campus, customerResource.campus_name);
this.setPickerTextByValue('customer_type', this.formData.customer_type, customerResource.customer_type_name);
// //
this.setPickerTextByValue('purchasing_power', this.formData.purchasing_power, sixSpeed.purchase_power_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('cognitive_idea', this.formData.cognitive_idea, sixSpeed.concept_awareness_name);
this.setPickerTextByValue('distance', this.formData.distance, sixSpeed.distance_name || sixSpeed.distance) this.setPickerTextByValue('distance', this.formData.distance, sixSpeed.distance_name);
console.log('选择器文本回显完成');
} catch (error) {
console.error('设置选择器文本回显失败:', error);
}
}, },
// //
setPickerTextByValue(pickerName, value, defaultText) { setPickerTextByValue(pickerName, value, defaultText) {
if (!value) { if (!value) {
this.picker_config[pickerName].text = '点击选择' this.picker_config[pickerName] = this.picker_config[pickerName] || {};
return this.picker_config[pickerName].text = '点击选择';
return;
}
// picker_config[pickerName]
if (!this.picker_config[pickerName]) {
this.picker_config[pickerName] = { options: [] };
} }
// //
const options = this.picker_config[pickerName].options || [] const options = this.picker_config[pickerName].options || [];
const option = options.find(opt => opt.value == value) const option = options.find(opt => String(opt.value) === String(value));
if (option) { if (option) {
this.picker_config[pickerName].text = option.text this.picker_config[pickerName].text = option.text;
} else if (defaultText) { } else if (defaultText) {
// 使 // 使
this.picker_config[pickerName].text = defaultText this.picker_config[pickerName].text = defaultText;
} else { } else {
this.picker_config[pickerName].text = '点击选择' this.picker_config[pickerName].text = '点击选择';
} }
}, },
@ -753,67 +846,91 @@
// //
async getDict(inputName) { async getDict(inputName) {
let key = '' try {
console.log(`getDict - 开始获取字典数据: ${inputName}`);
let key = '';
switch (inputName) { switch (inputName) {
// //
case 'source_channel': case 'source_channel':
key = 'SourceChannel' key = 'SourceChannel';
break; break;
// //
case 'source': case 'source':
key = 'source' key = 'source';
break; break;
// //
case 'purchasing_power': case 'purchasing_power':
key = 'customer_purchasing_power' key = 'customer_purchasing_power';
break; break;
// //
case 'cognitive_idea': case 'cognitive_idea':
key = 'cognitive_concept' key = 'cognitive_concept';
break; break;
// //
case 'decision_maker': case 'decision_maker':
key = 'decision_maker' key = 'decision_maker';
break; break;
// //
case 'initial_intent': case 'initial_intent':
key = 'preliminarycustomerintention' key = 'preliminarycustomerintention';
break; break;
// //
case 'status': case 'status':
key = 'kh_status' key = 'kh_status';
break; break;
// //
case 'distance': case 'distance':
key = 'distance' key = 'distance';
break;
//
case 'customer_type':
key = 'customer_type';
break; break;
default:
console.warn(`未知的字典类型: ${inputName}`);
return;
} }
if (!key) {
return console.log(`getDict - 字典键值映射: ${inputName} -> ${key}`);
// picker_config[inputName]
if (!this.picker_config[inputName]) {
this.picker_config[inputName] = { options: [], text: '点击选择' };
} }
// 使 util.getDict // 使 util.getDict
let dictionary = await this.$util.getDict(key) console.log(`getDict - 调用 $util.getDict('${key}')`);
let dictionary = await this.$util.getDict(key);
console.log(`getDict - 字典数据获取结果:`, dictionary);
if(!dictionary || !Array.isArray(dictionary) || dictionary.length === 0){ if(!dictionary || !Array.isArray(dictionary) || dictionary.length === 0){
uni.showToast({ title: '暂无选项', icon: 'none' }) console.warn(`字典 ${key} 数据为空`);
return return;
} }
let arr = [] let arr = [];
// [{name: "", value: "1", sort: 0, memo: ""}, ...] // [{name: "", value: "1", sort: 0, memo: ""}, ...]
dictionary.forEach((v) => { dictionary.forEach((v) => {
arr.push({ text: v.name, value: v.value }) arr.push({ text: v.name, value: v.value });
}) });
if (inputName == 'source_channel') { if (inputName == 'source_channel') {
//arr // arr
arr.unshift({ arr.unshift({
text: '线下', text: '线下',
value: '0', value: '0',
}) });
} }
this.picker_config[inputName].options = arr this.picker_config[inputName].options = arr;
console.log(`getDict - 字典 ${inputName} 加载完成,选项数: ${arr.length}`);
return arr;
} catch (error) {
console.error(`获取字典 ${inputName} 失败:`, error);
return [];
}
}, },
//##### ##### //##### #####
@ -1044,29 +1161,30 @@
}, },
//- //-
changeCicker(e) { changeCicker(e) {
console.log('监听-下拉选择器', this.picker_input_name, e) console.log('监听-下拉选择器', this.picker_input_name, e);
let input_name = this.picker_input_name let input_name = this.picker_input_name;
// //
this.formData[input_name] = e.value 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 (input_name === 'source') {
if (e.value == 1) { // 线(1)
// 线 if (e.value === '1' || e.value === 1) {
this.formData.source_channel = '' //
this.picker_config.source_channel.text = '点击选择' this.formData.source_channel = '';
this.picker_config.source_channel.text = '点击选择';
} else { } else {
// 线 // 线
this.formData.source_channel = '0' //0=线 this.formData.source_channel = '0'; // 0=线
this.picker_config.source_channel.text = '线下' this.picker_config.source_channel.text = '线下';
} }
} }
this.cancelCicker() this.cancelCicker();
}, },
// //
cancelCicker() { cancelCicker() {

Loading…
Cancel
Save