Browse Source

修改 bug

master
王泽彦 6 months ago
parent
commit
9f909d60c3
  1. 2
      niucloud/app/api/controller/apiController/ResourceSharing.php
  2. 12
      niucloud/app/model/customer_resources/CustomerResources.php
  3. 8
      niucloud/app/service/api/apiService/ResourceSharingService.php
  4. 238
      uniapp/App.vue

2
niucloud/app/api/controller/apiController/ResourceSharing.php

@ -32,6 +32,7 @@ class ResourceSharing extends BaseApiService
$name = $request->param('name','');////客户资源表-姓名 $name = $request->param('name','');////客户资源表-姓名
$phone_number = $request->param('phone_number','');//客户资源表-手机号 $phone_number = $request->param('phone_number','');//客户资源表-手机号
$campus_name = $request->param('campus_name','');//客户资源表-校区 $campus_name = $request->param('campus_name','');//客户资源表-校区
$age = $request->param('age','');//客户资源表-年龄
// 新增搜索参数 // 新增搜索参数
$source = $request->param('source','');//来源类型 $source = $request->param('source','');//来源类型
@ -64,6 +65,7 @@ class ResourceSharing extends BaseApiService
'name'=>$name, 'name'=>$name,
'phone_number'=>$phone_number, 'phone_number'=>$phone_number,
'campus_name' => $campus_name, 'campus_name' => $campus_name,
'age' => $age,
'source' => $source, 'source' => $source,
'source_channel' => $source_channel, 'source_channel' => $source_channel,
'attendance_type' => $attendance_type, 'attendance_type' => $attendance_type,

12
niucloud/app/model/customer_resources/CustomerResources.php

@ -149,6 +149,18 @@ class CustomerResources extends BaseModel
} }
} }
/**
* 搜索器:年龄 - 支持模糊匹配(如4可匹配4.1、4.12、14、24等)
* @param $value
* @param $data
*/
public function searchAgeAttr($query, $value, $data)
{
if ($value !== '' && $value !== null) {
$query->where("age", 'like', '%' . trim($value) . '%');
}
}
/** /**
* 搜索器:黑名单状态 * 搜索器:黑名单状态
* @param $value * @param $value

8
niucloud/app/service/api/apiService/ResourceSharingService.php

@ -348,9 +348,9 @@ class ResourceSharingService extends BaseApiService
$resource_conditions[] = ['source_channel', 'like', '%' . $where['source_channel'] . '%']; $resource_conditions[] = ['source_channel', 'like', '%' . $where['source_channel'] . '%'];
} }
// 年龄查询 // 年龄查询 - varchar类型使用like查询,支持模糊匹配(如4可匹配4.1、4.12、14、24等)
if (isset($where['age']) && $where['age'] !== '' && $where['age'] !== null) { if (isset($where['age']) && $where['age'] !== '' && $where['age'] !== null) {
$resource_conditions[] = ['age', '=', $where['age']]; $resource_conditions[] = ['age', 'like', '%' . trim($where['age']) . '%'];
} }
// 黑名单状态查询 // 黑名单状态查询
@ -992,9 +992,9 @@ class ResourceSharingService extends BaseApiService
$resource_conditions[] = ['source_channel', 'like', '%' . $where['source_channel'] . '%']; $resource_conditions[] = ['source_channel', 'like', '%' . $where['source_channel'] . '%'];
} }
// 年龄查询 // 年龄查询 - varchar类型使用like查询,支持模糊匹配(如4可匹配4.1、4.12、14、24等)
if (isset($where['age']) && $where['age'] !== '' && $where['age'] !== null) { if (isset($where['age']) && $where['age'] !== '' && $where['age'] !== null) {
$resource_conditions[] = ['age', '=', $where['age']]; $resource_conditions[] = ['age', 'like', '%' . trim($where['age']) . '%'];
} }
// 黑名单状态查询 // 黑名单状态查询

238
uniapp/App.vue

@ -2,13 +2,14 @@
import { import {
WxToken WxToken
} from './common/wx_token.js' } from './common/wx_token.js'
// import user from '@/api/user.js'
import Api_url from '@/common/config.js' import Api_url from '@/common/config.js'
var wxtoken = new WxToken(); var wxtoken = new WxToken();
export default { export default {
async onLaunch() { async onLaunch() {
// //
this.initializeVersionInfo();
//
this.checkForUpdate(); this.checkForUpdate();
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
@ -46,6 +47,22 @@
onHide: function() {}, onHide: function() {},
methods: { methods: {
/**
* 初始化版本信息
*/
initializeVersionInfo() {
//
const appVersion = '1.0.0'; //
const buildTime = Date.now();
//
if (!uni.getStorageSync('app_version')) {
uni.setStorageSync('app_version', appVersion);
uni.setStorageSync('build_time', buildTime);
console.log(`初始化版本信息: ${appVersion}`);
}
},
/** /**
* 检查小程序更新 * 检查小程序更新
*/ */
@ -185,6 +202,24 @@
}); });
}, },
/**
* 统一的版本检查方法支持多平台
*/
checkVersionUpdate() {
//
const reminderTime = uni.getStorageSync('update_reminder_time');
const now = Date.now();
// 24
if (reminderTime && (now - reminderTime < 24 * 60 * 60 * 1000)) {
console.log('用户选择稍后更新,暂不提示');
return;
}
//
this.checkVersionFromServer();
},
/** /**
* H5环境下的更新检查可选功能 * H5环境下的更新检查可选功能
*/ */
@ -196,60 +231,193 @@
const buildTime = uni.getStorageSync('build_time') || Date.now(); const buildTime = uni.getStorageSync('build_time') || Date.now();
const now = Date.now(); const now = Date.now();
// // 30
if (now - buildTime > 60 * 60 * 1000) { if (now - buildTime > 30 * 60 * 1000) {
console.log('H5环境检查更新'); console.log('H5环境检查更新');
// API this.checkVersionUpdate();
//
this.checkVersionFromServer();
} }
} catch (error) { } catch (error) {
console.error('H5更新检查失败:', error); console.error('H5更新检查失败:', error);
} }
// #endif // #endif
// #ifdef MP-WEIXIN
//
this.checkVersionUpdate();
// #endif
}, },
/** /**
* 从服务器检查版本信息H5环境 * 从服务器检查版本信息通用
*/ */
async checkVersionFromServer() { async checkVersionFromServer() {
try { try {
// API const currentVersion = uni.getStorageSync('app_version') || '1.0.0';
// const response = await uni.request({ const platform = this.getPlatform();
// url: Api_url.domain + '/api/app/version',
// method: 'GET' console.log(`检查版本更新 - 当前版本: ${currentVersion}, 平台: ${platform}`);
// });
// // API
// if (response.data.code === 1) { const response = await uni.request({
// const serverVersion = response.data.data.version; url: Api_url.domain + '/api/app/version',
// const currentVersion = uni.getStorageSync('app_version') || '1.0.0'; method: 'GET',
// data: {
// if (this.compareVersion(serverVersion, currentVersion) > 0) { platform: platform,
// this.showH5UpdateDialog(); version: currentVersion
// } }
// } });
console.log('从服务器检查H5版本更新'); if (response.data && response.data.code === 1) {
const versionData = response.data.data;
const serverVersion = versionData.version;
const forceUpdate = versionData.force_update || false;
const updateLog = versionData.update_log || '';
console.log(`服务器版本: ${serverVersion}, 强制更新: ${forceUpdate}`);
if (this.compareVersion(serverVersion, currentVersion) > 0) {
//
uni.setStorageSync('latest_version', serverVersion);
uni.setStorageSync('update_log', updateLog);
uni.setStorageSync('force_update', forceUpdate);
// #ifdef MP-WEIXIN
//
this.showVersionUpdateDialog(serverVersion, updateLog, forceUpdate);
// #endif
// #ifdef H5
// H5
this.showH5UpdateDialog(serverVersion, updateLog, forceUpdate);
// #endif
} else {
console.log('当前版本已是最新');
//
uni.removeStorageSync('latest_version');
uni.removeStorageSync('update_log');
uni.removeStorageSync('force_update');
}
} else {
console.warn('获取版本信息失败:', response.data?.msg || '未知错误');
}
} catch (error) { } catch (error) {
console.error('服务器版本检查失败:', error); console.error('服务器版本检查失败:', error);
} }
}, },
/**
* 获取当前平台标识
*/
getPlatform() {
// #ifdef MP-WEIXIN
return 'mp-weixin';
// #endif
// #ifdef H5
return 'h5';
// #endif
// #ifdef APP-PLUS
return 'app';
// #endif
return 'unknown';
},
/**
* 显示版本更新对话框微信小程序
*/
showVersionUpdateDialog(newVersion, updateLog, forceUpdate) {
const content = `发现新版本 ${newVersion}\n${updateLog}`;
if (forceUpdate) {
//
uni.showModal({
title: '重要更新',
content: content + '\n\n此为重要更新,必须立即更新才能继续使用。',
showCancel: false,
confirmText: '立即更新',
success: () => {
this.triggerWeChatUpdate();
}
});
} else {
//
uni.showModal({
title: '发现新版本',
content: content,
confirmText: '立即更新',
cancelText: '稍后更新',
success: (res) => {
if (res.confirm) {
this.triggerWeChatUpdate();
} else {
// 24
uni.setStorageSync('update_reminder_time', Date.now());
}
}
});
}
},
/**
* 触发微信小程序更新检查
*/
triggerWeChatUpdate() {
// #ifdef MP-WEIXIN
try {
if (typeof uni !== 'undefined' && typeof uni.getUpdateManager === 'function') {
const updateManager = uni.getUpdateManager();
if (updateManager && typeof updateManager.checkForUpdate === 'function') {
updateManager.checkForUpdate();
}
}
} catch (error) {
console.error('触发微信更新失败:', error);
uni.showToast({
title: '请手动删除小程序重新进入',
icon: 'none',
duration: 3000
});
}
// #endif
},
/** /**
* 显示H5更新对话框 * 显示H5更新对话框
*/ */
showH5UpdateDialog() { showH5UpdateDialog(newVersion, updateLog, forceUpdate) {
uni.showModal({ const content = `发现新版本 ${newVersion}\n${updateLog}\n\n检测到新版本,建议刷新页面以获得最佳体验`;
title: '发现新版本',
content: '检测到新版本,建议刷新页面以获得最佳体验', if (forceUpdate) {
confirmText: '立即刷新', //
cancelText: '稍后刷新', uni.showModal({
success: (res) => { title: '重要更新',
if (res.confirm) { content: content + '\n\n此为重要更新,必须立即刷新才能继续使用。',
showCancel: false,
confirmText: '立即刷新',
success: () => {
location.reload(); location.reload();
} }
} });
}); } else {
//
uni.showModal({
title: '发现新版本',
content: content,
confirmText: '立即刷新',
cancelText: '稍后刷新',
success: (res) => {
if (res.confirm) {
location.reload();
} else {
// 24
uni.setStorageSync('update_reminder_time', Date.now());
}
}
});
}
}, },
/** /**

Loading…
Cancel
Save