From 20bb9234947ec94b7981720dcd0b24cd7578bfdc Mon Sep 17 00:00:00 2001 From: lq Date: Sat, 30 Aug 2025 14:17:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E4=B8=9C=E8=A5=BF=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=BA=86?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 8 ++++++- pages/cate/index.vue | 4 ++-- pages/index/index.vue | 6 ++++-- request/api/request.js | 4 +++- subPackages/doctor/doctor-userinfo.vue | 10 ++++++++- subPackages/register/register.vue | 29 ++++++++++++++------------ utils/utils.js | 11 ++++++++++ 7 files changed, 52 insertions(+), 20 deletions(-) diff --git a/App.vue b/App.vue index 7ca8d8e..6642a82 100644 --- a/App.vue +++ b/App.vue @@ -3,6 +3,7 @@ getVersion } from './request/api/api' import { webSocketManager } from '@/utils/ws/websocket.js'; + import {checkDev} from "@/utils/utils"; export default { // //初始化状态-如果登录过,保持登录状态 onLaunch: async function() { @@ -30,11 +31,14 @@ + console.log('获取更新机制', uni.canIUse('getUpdateManager')) // 获取小程序更新机制兼容 if (uni.canIUse('getUpdateManager')) { const updateManager = uni.getUpdateManager() + console.log('updateManager', updateManager) // 检查是否有新版本发布 updateManager.onCheckForUpdate(function(res) { + console.log('检查是否有新版本发布', res) if (res.hasUpdate) { //小程序有新版本,则静默下载新版本,做好更新准备 updateManager.onUpdateReady(function() { @@ -83,7 +87,9 @@ }) } - this.initWebSocket(); + if (checkDev('open-im')) { + this.initWebSocket(); + } }, onShow: function(e) { diff --git a/pages/cate/index.vue b/pages/cate/index.vue index 3372122..f1a6383 100644 --- a/pages/cate/index.vue +++ b/pages/cate/index.vue @@ -104,8 +104,8 @@ if (res.data.errcode == 0) { // console.log(res, 'res'); this.categoryLists = res.data.data.list - this.cid = res.data.data.map(x => x.id) - this.num = res.data.data[0].id //初始选中 + this.cid = res.data.data.list.map(x => x.id) + this.num = res.data.data.list[0].id //初始选中 // this.current = res.data.data[0].subs[0].id //初始选中2 } }) diff --git a/pages/index/index.vue b/pages/index/index.vue index 3434ae3..150a373 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -85,7 +85,7 @@ - + 在线问诊 @@ -93,7 +93,7 @@ - + @@ -127,6 +127,7 @@ import { getseesionRead } from '../../request/api/api' import {getChatFriendsListApi} from "@/request/api/im"; +import {checkDev} from "@/utils/utils"; export default { data() { @@ -142,6 +143,7 @@ export default { }, methods: { + checkDev, // 清除未读信息 getClearInfo() { getseesionRead({ diff --git a/request/api/request.js b/request/api/request.js index 08c5057..b84db95 100644 --- a/request/api/request.js +++ b/request/api/request.js @@ -1,4 +1,5 @@ import {Base64} from "js-base64"; +import {checkDev} from "@/utils/utils"; const arr = [ @@ -18,13 +19,14 @@ const sensitiveData = [ 'idcard' ] -const isDev = true; +const isDev = checkDev('dev'); function request(url, params, method = 0) { let baseURL = isDev === true? 'http://127.0.0.1:18000/member': "https://app.xiaokang88.com/member" // let baseURL = "http://127.0.0.1:18000/member" if (url.split('/').indexOf('imApi') !== -1) { baseURL = "http://127.0.0.1:12080/api" + let baseURL = isDev === true? 'http://127.0.0.1:12080/api': "https://app.xiaokang88.com/member" } if (url.split('/').indexOf('newApi') !== -1) { baseURL = isDev === true? 'https://shop.xiaokang88.com/member': "https://shop.xiaokang88.com/member" diff --git a/subPackages/doctor/doctor-userinfo.vue b/subPackages/doctor/doctor-userinfo.vue index 22176d0..c0bdf13 100644 --- a/subPackages/doctor/doctor-userinfo.vue +++ b/subPackages/doctor/doctor-userinfo.vue @@ -38,7 +38,7 @@ @change="handleTypeChange" > 线下问诊 - 线上咨询 + 线上咨询 @@ -130,6 +130,7 @@ import { userEidtPatient, registe } from '@/request/api/api.js' +import {checkDev} from "@/utils/utils"; export default { data() { return { @@ -201,6 +202,7 @@ export default { } }, methods: { + checkDev, // 处理挂号类型切换 handleTypeChange(type) { this.registerType = type; @@ -302,6 +304,10 @@ export default { // 挂号 getAsk() { + uni.showLoading({ + title: "加载中...", + mask: true + }); registe({ method: "post", data: { @@ -341,6 +347,8 @@ export default { icon: false }) } + }).finally(() => { + uni.hideLoading(); }) }, diff --git a/subPackages/register/register.vue b/subPackages/register/register.vue index c02404e..3c7320c 100644 --- a/subPackages/register/register.vue +++ b/subPackages/register/register.vue @@ -136,6 +136,7 @@ service } from '../../request/api/api'; import {createRoomByDoctorIdApi, sendToUserApi} from "@/request/api/im"; + import {checkDev} from "@/utils/utils"; export default { data() { return { @@ -204,20 +205,22 @@ }); - createRoomByDoctorIdApi({ - doctor_id: that.currentDoctorId - }).then(result => { - sendToUserApi({ - room_id: result.data.result.room_id, - sender_user_id: that.currentUserId, - receiver_user_id: that.currentDoctorId, - message_type: 10, - message_content: JSON.stringify({ - id: that.register_id, - }), - duration: 0 + if (checkDev('open-im') && that.registList.register_type === 1) { + createRoomByDoctorIdApi({ + doctor_id: that.currentDoctorId + }).then(result => { + sendToUserApi({ + room_id: result.data.result.room_id, + sender_user_id: that.currentUserId, + receiver_user_id: that.currentDoctorId, + message_type: 10, + message_content: JSON.stringify({ + id: that.register_id, + }), + duration: 0 + }) }) - }) + } if (res.data.data.is_paid == 1) { setTimeout(() => { diff --git a/utils/utils.js b/utils/utils.js index e42c224..bc11277 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -1,4 +1,15 @@ export function checkImageUrl(url) { // 如果url包含http,则返回url,反之加上 data:image/jpeg;base64, return url.includes('http') ? url : 'data:image/jpeg;base64,' + url +}; +export function checkDev(key = '') { + // 判断某些模块是否开启 + switch (key) { + case 'dev': + return true; + case 'open-im': + return false; + default: + return false; + } }; \ No newline at end of file