| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295 |
- <script>
- import { getDictByKey, getAppVersion, getRealLinkDomainName,getAppPageConfig } from '@/api/common.js';
- //参考文档 插件市场 https://ext.dcloud.net.cn/plugin?id=741
- import { appCheckUdate, openDownload } from '@/utils/APPUpdate.js';
- import { getUserInfo, getPushLogRead } from '@/api/user';
- import { getUserLiveInfo } from '@/api/living.js'
- import { healthButlerPop } from '@/utils/healthButlerPop.js';
- import { mapGetters, mapActions } from 'vuex';
- import IMSDK, { IMMethods, MessageReceiveOptType, MessageType, SessionType } from 'openim-uniapp-polyfill';
- import { config } from '@/pages_im/common/config';
- import { getDbDir, Igexin, toastWithCallback } from '@/pages_im/util/common.js';
- import { conversationSort, secFormat, callingModule, meetingModule, parseMessageByType, prepareConversationState } from '@/pages_im/util/imCommon';
- import { PageEvents, UpdateMessageTypes, CustomType, ContactChooseTypes } from '@/pages_im/constant';
- import { openImLoginApi,testImLoginApi } from '@/pages_im/api/imBll';
- import NotificationUtil from '@/pages_im/util/notification';
- import newMessage from '@/pages_im/static/audio/newMessage.wav';
- import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
- let cacheConversationList = [];
- let updateDownloadTask = null;
- let notificationIntance = null;
- let pausing = false;
- let innerAudioContext;
- let notification;
- let uPushPlugin;
- let connectStart=0;
- // #ifdef APP-PLUS
- import permision1 from '@/utils/permission.js';
- // notification = uni.requireNativePlugin('Tuoyun-OpenIMSDK-Notification');
- // #endif
- import { getTlsSig } from '@/api/common.js';
- import { qconfig } from './utils/config';
- import { premissionCheck } from '@/js_sdk/wa-permission/permission.js';
- import { updateMsgDot } from '@/utils/common.js';
- import { getImAdminToken } from '@/pages_im/api/imApi';
- import { ar } from 'date-fns/locale';
- let healthTimer = null;
- let tSeconds = 0;
- const healthSeconds = 180;
- let offlineMsg=null;
- let offlineHandleNewMsg=null;
- let failImConnTime=0;
- // #ifdef APP-PLUS
- let complaintView = null; // 悬浮窗视图(主图标)
- let complaintCloseView = null; // 关闭按钮视图
- let viewLeft = 0;
- let viewTop = 0;
- let complaintPositionTimer = null; // 位置检查定时器
- let lastRoute = ''; // 上次的路由
- // #endif
- export default {
- globalData: {
- wsUrl: 'ws://doctor.ai.cdwjyyh.com',
- danmuWSUrl:'wss://websocket.cdwjyyh.com',
- aiWSUrl:'ws://doctor.ai.cdwjyyh.com',
- kfurl: 'https://work.weixin.qq.com/kfid/kfc3731c5008ebd8906', //企业微信客服链接
- corpId: 'ww70ac72e824957fc9', //客服企业id
- miniprogamId:"gh_feb7753a310b", //gh_7a6a32e5ef61 御君方互医
- shareCorpId: '', // 分享企业id
- shareSchema:"", // 应用跳转标识,显示在具体应用下的 Schema字段
- shareAgentid:"", // 企业微信管理后台 应用唯一标识。显示在具体应用下的 AgentId字段
- shareAppid_gh:"", // 必须是应用关联的小程序,注意要有@app后缀
- },
- onLaunch: function (options) {
- let fontsize = uni.getStorageSync('fontSize');
- if (fontsize) {
- uni.setStorageSync('fontSize', fontsize);
- }
- else {
- let scale = this.getSystemFontScale();
- let oriFontSize = 18;
- fontsize = oriFontSize * scale;
- if (fontsize < oriFontSize) {
- fontsize = oriFontSize;
- }
- if (fontsize < 16) {
- fontsize = 16;
- }
- if (fontsize >= 21) {
- fontsize = 21;
- }
- uni.setStorageSync('fontSize', fontsize);
- }
-
- // //设置im字体
- let RootFontSize= uni.getStorageSync('RootFontSize');
- if(!RootFontSize){
- uni.setStorageSync('RootFontSize', "24px");
- this.$store.commit('user/SET_ROOT_FONT_SIZE', "24px");
- }
- uni.removeStorageSync('openUrl');
- this.initOpenIm();
- if (this.$isLogin()) {
- uni.setStorageSync("onLaunch",1);
- }
- let that = this;
- uni.$on('refreshIM', () => {
- if (that.$isLogin()) {
- that.openImLogin();
- }
- });
- // 监听隐藏/显示投诉悬浮按钮事件
- uni.$on('hideComplaintButton', () => {
- // #ifdef APP-PLUS
- if (complaintView) complaintView.hide();
- if (complaintCloseView) complaintCloseView.hide();
- // #endif
- });
- uni.$on('showComplaintButton', () => {
- // #ifdef APP-PLUS
- if (complaintView) complaintView.show();
- if (complaintCloseView) complaintCloseView.show();
- // #endif
- });
-
- // #ifdef APP-PLUS
-
- uni.$on('showHealthButler', () => {
- if (plus.runtime.channel == 'baidu' || plus.runtime.channel == 'yybadv' || plus.runtime.channel == 'yybadv1') {
- that.runTimer();
- }
- });
-
- //离线推送
- this.handlerLaunchMsg();
- uni.onPushMessage((res) => { //unipush2.0 应用处于激活 监听消息推送
- //console.log("qxj onPushMessage",res);
- this.handlePushMessage(res);
- this.$updateMsgDot();
- });
- //#endif
-
- //this.getAppPageConfig();
- },
- onLoad() {
- },
- onShow() {
- // #ifdef APP-PLUS
- this.getDictByKeyFun()
- // 如果浮标未创建,尝试创建(可能启动页在其他地方关闭)
- setTimeout(()=>{
- if (!complaintView) {
- this.createComplaintFloatAfterSplash();
- } else {
- // 启动位置检查定时器
- this.startComplaintPositionCheck();
- }
- },3000);
- // #endif
- this.geth5Path();
- var that = this;
- // #ifdef APP-PLUS
- plus.navigator.closeSplashscreen();
- if (this.$isAgreePrivacy()) {
- if (this.$isLogin()) {
- this.getUserInfo(); //检测jpushId是否被清空,若为空就重新绑定
- }
- this.$getRegistrationID('update');
- if (plus.runtime.channel == 'baidu' || plus.runtime.channel == 'yybadv' || plus.runtime.channel == 'yybadv1') {
- this.runTimer();
- }
- }
- if(uni.$u.os() === 'android'){
- this.checkUpdateApp();
- IMSDK.asyncApi(IMSDK.IMMethods.SetAppBackgroundStatus, IMSDK.uuid(), false);
- meetingModule?.onListenerAppBackground(false);
- }
- var args= plus.runtime.arguments;
- uni.setStorageSync("appIsOnShow",1);
- if(args){
- // 处理args参数,如直达到某新页面等
- if(args=="rtlive://course"){
- uni.switchTab({url: '/pages/course/index'});
- }
- else if(args=="rtlive://livingApp"){
- uni.switchTab({url: '/pages/course/video/living-app'});
- }
- else {
- let url = ''
- if(args.indexOf("rtlive://pagesApp") != -1) { // 打开对应pages
- console.log("11111");
- url=args.replace("rtlive://pagesApp?pagesUrl=","");
- url=decodeURIComponent(url);
- }
- else if (args.indexOf("rtlive://courseAnswer") != -1) { // 看课
- console.log("22222");
- url=args.replace("rtlive://courseAnswer","");
- url="/pages/courseAnswer/index"+url;
- }
- else if(args.indexOf("rtlive://") != -1&&url) {
- uni.setStorageSync("openUrl",url)
- if(this.$isLogin()){
- uni.navigateTo({
- url: url,
- success: function(res) {
- uni.removeStorageSync("openUrl")
- plus.runtime.arguments = ''
- }
- })
- }
- }
- else if(args.indexOf("contentType")!=-1){ //unipush2.0 App打开状态点击通知
- let newServerMsg=JSON.parse(args);
- let serverMsgID=uni.getStorageSync('serverMsgID');
- // console.log("44444 newServerMsg",newServerMsg);
- let newServerMsgData=JSON.parse(newServerMsg.data);
- if(serverMsgID!=newServerMsgData.serverMsgID){
- uni.$u.throttle(() => that.notifyGoToChat(newServerMsgData), 2000);
- uni.setStorageSync('serverMsgID', newServerMsgData.serverMsgID);
- }
- }
- else if(args.indexOf("messageId")!=-1){ //oppo离线推送
- console.log("55555");
- offlineMsg=args;
- }
- else if(args.indexOf("rtlive://course")!=-1){
- console.log("66666");
- url=args.replace("rtlive://course","");
- url="/pages/course/info"+url;
- }
- }
- }
- // #endif
- },
- onHide() {
- // #ifdef APP-PLUS
- // 应用进入后台时停止位置检查
- this.stopComplaintPositionCheck();
- // #endif
- uni.removeStorageSync('onLaunch');
- uni.setStorageSync("appIsOnShow",0);
- if(uni.$u.os() === 'android'){
- IMSDK.asyncApi(IMSDK.IMMethods.SetAppBackgroundStatus, IMSDK.uuid(), true);
- meetingModule?.onListenerAppBackground(true);
- }
-
- },
- computed: {
- ...mapGetters([
- 'storeConversationList',
- 'storeCurrentConversation',
- 'storeCurrentUserID',
- 'storeSelfInfo',
- 'storeRecvFriendApplications',
- 'storeRecvGroupApplications',
- 'storeHistoryMessageList',
- 'storeIsSyncing',
- 'storeGroupList'
- ]),
- contactBadgeRely() {
- return {
- recvFriendApplications: this.storeRecvFriendApplications,
- recvGroupApplications: this.storeRecvGroupApplications,
- userKey: this.storeCurrentUserID
- };
- }
-
- },
- methods: {
- ...mapActions('message', ['pushNewMessage', 'updateOneMessage', 'updateQuoteMessageRevoke', 'updateMessageNicknameAndFaceUrl']),
- ...mapActions('conversation', ['updateCurrentMemberInGroup']),
- ...mapActions('contact', [
- 'updateFriendInfo',
- 'pushNewFriend',
- 'updateBlackInfo',
- 'pushNewBlack',
- 'pushNewGroup',
- 'updateGroupInfo',
- 'pushNewRecvFriendApplition',
- 'updateRecvFriendApplition',
- 'pushNewSentFriendApplition',
- 'updateSentFriendApplition',
- 'pushNewRecvGroupApplition',
- 'updateRecvGroupApplition',
- 'pushNewSentGroupApplition',
- 'updateSentGroupApplition'
- ]),
- async getDictByKeyFun() {
- let data = {
- key: 'app_pay_config'
- }
- const res = await getDictByKey(data)
- if (res.code == 200 && res.data && res.data.length > 0 && res.data[0].dictValue) {
- getApp().globalData.miniprogamId = res.data[0].dictValue
- }
- },
- getAppPageConfig() {
- getAppPageConfig().then(res=>{
- if(res.code == 200) {
- uni.setStorageSync('appPageConfig',JSON.stringify(res.appPageConfig))
- }
- })
- },
- //投诉建议
- // 根据当前页面路径获取 marginBottom 值
- getComplaintMarginBottom() {
- let marginBottom = 100; // 默认距底部
- try {
- const pages = getCurrentPages();
- if (pages && pages.length > 0) {
- const curPage = pages[pages.length - 1];
- const route = curPage.route || '';
- //console.log('当前路由:', route, 'marginBottom:', marginBottom);
- if (route === 'pages/course/video/living-app') {
- marginBottom = 40;
- } else if (route === 'pages/user/integral/integralGoodsDetails') {
- marginBottom = 150;
- } else {
- // 其他页面使用默认值 100
- marginBottom = 100;
- }
- //console.log('最终 marginBottom:', marginBottom);
- }
- } catch (err) {
- //console.error('获取路由失败:', err);
- }
- return marginBottom;
- },
-
- // 计算浮标位置
- getComplaintPosition() {
- const ww = plus.screen.resolutionWidth;
- const wh = plus.screen.resolutionHeight;
- const width = 48;
- const height = 70;
- const marginRight = 10;
- let marginBottom = this.getComplaintMarginBottom();
- const closeSize = 16;
- let left = ww - width - marginRight;
- let top = wh - height - marginBottom;
- if(this.$isIos()){
- top-=20;
- }
- let hidden = false;
- try {
- const pages = getCurrentPages();
- if (pages && pages.length > 0) {
- const curPage = pages[pages.length - 1];
- const route = curPage.route || '';
- if (route === 'pages/auth/login' || route === 'pages/auth/loginIndex' || route === 'pages/user/feedback'||route === 'pages_live/index'
- //|| route === 'pages_im/pages/conversation/conversationList/index' || route === 'pages_im/pages/conversation/chating/index'
- || ((route === 'pages_im/pages/conversation/chating/index' || route ==='pages_im1/pages/conversation/chating1/index') && this.$companyUserIsLogin())) {
- hidden = true;
- }
- // if (route === 'pages_im/pages/conversation/chating/index' || route === 'pages_im/pages/conversation/chating1/index') {
- // top = top-uni.upx2px(300);
- // }
- if (route === 'pages/pointsMall/points') {
- top=top-uni.upx2px(90);
- if(this.$isIos()){
- top-=30;
- }
- }
- if (route === 'pages/pointsMall/points') {
- top=top-uni.upx2px(90);
- if(this.$isIos()){
- top-=30;
- }
- }
- if (route === 'pages/course/video/living-app') {
- top = uni.upx2px(300);
- hidden = false;
- }
- if (route === 'pages/courseAnswer/index') {
- top=top-uni.upx2px(200);
- hidden = false;
- }
-
- }
- } catch (err) {
- console.error('getComplaintPosition error:', err);
- }
- const closeLeft = left + (width - closeSize) / 2;
- const closeTop = top + height - closeSize;
- return { left, top, closeLeft, closeTop, width, height, closeSize, marginBottom, hidden };
- },
-
- // 绑定主图标点击事件
- bindComplaintViewClick() {
- complaintView.addEventListener('click', (e) => {
- let target = '/pages/user/feedback';
- try {
- const pages = getCurrentPages();
- if (pages && pages.length > 0) {
- const curPage = pages[pages.length - 1];
- const pageParams = curPage.options;
- const route = curPage.route || '';
- if (route === 'pages/course/info') {
- target = '/pages/user/courseFeedback?courseId='+pageParams.courseId;
- }
- }
- } catch (err) {
- console.error('获取路由失败:', err);
- }
- uni.navigateTo({
- url: target,
- fail: (err) => {
- console.error('跳转失败:', err);
- }
- });
- });
- },
-
- // 绑定关闭按钮点击事件
- bindComplaintCloseViewClick() {
- complaintCloseView.addEventListener('click', (e) => {
- complaintView.hide();
- complaintCloseView.hide();
- });
- },
-
- // 创建主图标视图
- createComplaintMainView(pos) {
- complaintView = new plus.nativeObj.View('complaint-float', {
- left: pos.left + 'px',
- top: pos.top + 'px',
- width: pos.width + 'px',
- height: pos.height + 'px',
- zIndex: 9999
- }, [
- {
- tag: 'img',
- id: 'icon',
- src: '/static/images/ad/complaints_suggestions.png',
- position: {
- left: '0px',
- top: '0px',
- width: '48px',
- height: '48px'
- }
- }
- ]);
- this.bindComplaintViewClick();
- if (!pos.hidden) {
- complaintView.show();
- }
- },
-
- // 创建关闭按钮视图
- createComplaintCloseView(pos) {
- complaintCloseView = new plus.nativeObj.View('complaint-close', {
- left: pos.closeLeft + 'px',
- top: pos.closeTop + 'px',
- width: pos.closeSize + 'px',
- height: pos.closeSize + 'px',
- zIndex: 10000
- }, [
- {
- tag: 'img',
- id: 'close',
- src: '/static/images/ad/complaints_suggestions_close.png',
- position: {
- left: '0px',
- top: '0px',
- width: pos.closeSize + 'px',
- height: pos.closeSize + 'px'
- }
- }
- ]);
- this.bindComplaintCloseViewClick();
- if (!pos.hidden) {
- complaintCloseView.show();
- }
- },
-
- // 检查并更新浮标位置
- checkAndUpdateComplaintPosition() {
- // #ifdef APP-PLUS
- if (!complaintView || !complaintCloseView) return;
-
- try {
- const pages = getCurrentPages();
- if (pages && pages.length > 0) {
- const curPage = pages[pages.length - 1];
- const currentRoute = curPage.route || '';
- // 如果路由发生变化,更新位置
- if (currentRoute !== lastRoute) {
- //console.log('路由变化:', lastRoute, '->', currentRoute);
- lastRoute = currentRoute;
- this.updateComplaintFloatPosition();
- }
- }
- } catch (err) {
- console.error('检查路由失败:', err);
- }
- // #endif
- },
-
- // 启动位置检查定时器
- startComplaintPositionCheck() {
- // #ifdef APP-PLUS
- // 清除旧定时器
- if (complaintPositionTimer) {
- clearInterval(complaintPositionTimer);
- }
- // 立即检查一次
- this.checkAndUpdateComplaintPosition();
-
- // 每500ms检查一次路由变化
- complaintPositionTimer = setInterval(() => {
- this.checkAndUpdateComplaintPosition();
- }, 500);
- // #endif
- },
-
- // 停止位置检查定时器
- stopComplaintPositionCheck() {
- // #ifdef APP-PLUS
- if (complaintPositionTimer) {
- clearInterval(complaintPositionTimer);
- complaintPositionTimer = null;
- }
- // #endif
- },
-
- // 更新浮标位置
- updateComplaintFloatPosition() {
- // #ifdef APP-PLUS
- if (!complaintView || !complaintCloseView) return;
- const pos = this.getComplaintPosition();
- // 隐藏旧视图
- complaintView.hide();
- complaintCloseView.hide();
- //console.log('更新浮标位置 - marginBottom:', pos.marginBottom, 'top:', pos.top, 'route:', lastRoute);
- // 重新创建视图(使用新位置)
- this.createComplaintMainView(pos);
- this.createComplaintCloseView(pos);
- // #endif
- },
-
- // 启动页关闭后创建浮标
- createComplaintFloatAfterSplash() {
- // #ifdef APP-PLUS
- // 避免重复创建
- if (complaintView) return;
-
- // 延迟创建,确保启动页完全关闭
- setTimeout(() => {
- this.createComplaintFloat();
- }, 300);
- // #endif
- },
-
- // 创建投诉建议浮标
- createComplaintFloat() {
- // #ifdef APP-PLUS
- // 避免重复创建
- if (complaintView) return;
-
- plus.navigator.getStatusbarHeight(); // 确保 plus 已初始化
-
- // 初始化路由记录
- try {
- const pages = getCurrentPages();
- if (pages && pages.length > 0) {
- const curPage = pages[pages.length - 1];
- lastRoute = curPage.route || '';
- }
- } catch (err) {
- console.error('初始化路由失败:', err);
- }
-
- const pos = this.getComplaintPosition();
- viewLeft = pos.left;
- viewTop = pos.top;
-
- // 创建主图标和关闭按钮
- this.createComplaintMainView(pos);
- this.createComplaintCloseView(pos);
-
- // 启动位置检查
- this.startComplaintPositionCheck();
- // #endif
- },
- handlePushMessage(res) { //unipush2.0
- const that = this;
- console.log("qxj handlePushMessage",res);
- if (res.type == 'click') { //unipush2.0在线推送 如果需要跳转app内指定页面,则自己实现下方的跳转代码。
- if (this.$isLogin()) {
- const url=this.$getCurrentPage();
- console.log("qxj handlePushMessage click url",url);
- const isOnLaunch = uni.getStorageSync('onLaunch');
- // 判断前一个页面路径是一样
- const payloadData=JSON.parse(res.data.payload.data);
- const flag = url.route && res.data.payload.url.indexOf(url.route);
- const isIM=payloadData.type!=undefined && payloadData.type=='im';
-
- if(isIM){
- if (isOnLaunch && isOnLaunch == 1) {
- //offlineMsg=res.data.payload;
- uni.removeStorageSync('onLaunch');
- }else{
- //console.log("qxj handlePushMessage payloadData",payloadData);
- uni.$u.throttle(() => that.notifyGoToChat(payloadData), 2000);
- }
- }
- else{
- if (isOnLaunch && isOnLaunch == 1) {
- uni.showLoading({ title: '处理中..' });
- setTimeout(() => {
- uni.hideLoading();
- if (flag == -1) {
- uni.navigateTo({
- url: res.data.payload.url,
- success: function () {
- uni.removeStorageSync('openUrl');
- that.setReadAll(res.data.payload.url);
- }
- });
- }
- else {
- uni.redirectTo({
- url: res.data.payload.url,
- success: function () {
- uni.removeStorageSync('openUrl');
- that.setReadAll(res.data.payload.url);
- }
- });
- }
- }, 1000);
- }
- else {
- uni.hideLoading();
- if (flag == -1) {
- uni.navigateTo({
- url: res.data.payload.url,
- success: function () {
- uni.removeStorageSync('openUrl');
- that.setReadAll(res.data.payload.url);
- }
- });
- } else {
- uni.redirectTo({
- url: res.data.payload.url,
- success: function () {
- uni.removeStorageSync('openUrl');
- that.setReadAll(res.data.payload.url);
- }
- });
- }
- }
- }
- }
- }
- if (res.type == 'receive') { //监听在线推送消息,若云函数设置了 "force_notification":true,则不会触发此 receive。
- // const pages = getCurrentPages();
- // const url = pages[ pages.length - 1];
- const url=this.$getCurrentPage();
- console.log("qxj receive url",url);
- if(url && (url.route!="pages_im/pages/conversation/chating/index" || url.route!="pages_im/pages/conversation/chating1/index") ){
- // 检查应用是否在前台
- const appIsOnShow = uni.getStorageSync('appIsOnShow');
-
- //if(!!appIsOnShow){ // 应用在前台,处理消息但不显示通知
- let payload=res.data.payload;
- if(!!payload && !!payload.data){
- let payloadData=JSON.parse(payload.data);
- if(payloadData.contentType && payloadData.contentType==1601 && appIsOnShow){
- return;
- }
- }
- console.log("qxj payload",payload);
- uni.createPushMessage({
- title: res.data.title,
- content: res.data.content,
- payload: res.data.payload,
- when: new Date(),
- icon:"",
- sound: 'system', // 默认值为system
- category: res.data.category,
- success: () => {
- console.log('创建在线推送消息成功: ');
- this.$store.commit('newMsg/SET_UPDATATIME', new Date().getTime());
- },
- fail: (err) => {
- console.log('创建在线推送消息失败: ', err);
- }
- });
- //}
-
- plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
- if (widgetInfo.visible) {
- // 应用在前台,处理消息但不显示通知
- uni.createPushMessage({
- title: res.data.title,
- content: res.data.content,
- payload: res.data.payload,
- sound: 'system', // 默认值为system
- category: res.data.category,
- success: () => {
- console.log('创建在线推送消息成功: ');
- this.$store.commit('newMsg/SET_UPDATATIME', new Date().getTime());
- },
- fail: (err) => {
- console.log('创建在线推送消息失败: ', err);
- }
- });
- } else {
- // 应用在后台,可以显示通知(如果需要)
-
- }
- });
- }
- }
- },
-
- handlerLaunchMsg() { // 处理Launch信息
- let that=this;
- // 监听通知点击事件
- plus.push.addEventListener('click', function (msg) { //unipush2.0 离线推送 (小米)
- console.log('应用通过点击通知启动:', msg);
- let newServerMsg=msg.payload;
- offlineMsg=msg;
- });
- // 获取启动时的通知
- plus.push.getClientInfoAsync(function(info) { //unipush2.0连离线推送/点击桌面启动 (小米)
- console.log("qxj getClientInfoAsync",info);
- if(info.id && info.id=="unipush"){ //unipush1.0 荣耀离线推送
- offlineMsg=info;
- }
- if (info.title && info.content && info.payload) {
- uni.switchTab({url: 'pages_im/pages/conversation/conversationList/index'});
- }
- if (info.launch && info.launch.payload) {
- let newServerMsg = info.launch.payload;
- console.log('应用通过通知启动:', info);
- uni.switchTab({url: 'pages_im/pages/conversation/conversationList/index'});
- //uni.$u.throttle(() => that.notifyGoToChat(newServerMsg), 1000);
- }
- }, function(err) {
- console.error("Error getting client info:", err);
- });
- },
-
- getSystemFontScale: function () {
- let scale = 1;
- if (uni.getSystemInfoSync) {
- let systemInfo = uni.getSystemInfoSync();
- if (systemInfo.fontSizeSetting) {
- scale = systemInfo.fontSizeSetting / 16; // 16 是默认字体大小
- }
- }
- return scale;
- },
- adjustFontSize: function () {
- let scale = this.getSystemFontScale();
- let rootElement = document.documentElement;
- rootElement.style.fontSize = 16 * scale + 'px';
- },
- setGlobalIMlistener() {
- const kickHander = (message) => {
- toastWithCallback(message, () => {
- uni.removeStorage({ key: 'IMToken' });
- uni.removeStorage({ key: 'BusinessToken' });
- callingModule?.endCall();
- meetingModule?.endCall();
- Igexin.unbindAlias(this.storeCurrentUserID);
- uni.$emit('loginOut');
- });
- };
-
- let that=this;
- IMSDK.subscribe(IMSDK.IMEvents.OnKickedOffline, (data) => {
- kickHander('您的账号在其他设备登录,请重新登录!');
- //that.removeImData();
- //that.openImLogin();
- });
-
- IMSDK.subscribe(IMSDK.IMEvents.OnUserTokenExpired, (data) => {
- kickHander('您的登录已过期,请重新登录!');
- //that.removeImData();
- //that.openImLogin();
- });
-
- IMSDK.subscribe(IMSDK.IMEvents.OnUserTokenInvalid, (data) => {
- kickHander('您的登录已无效,请重新登录!');
- //that.removeImData();
- //that.openImLogin();
- });
-
- // sync
- let lastSyncTime = 0;
- const syncStartHandler = ({ data }) => {
- this.$store.commit('user/SET_IS_SYNCING', true);
- this.$store.commit('user/SET_REINSTALL', data);
- this.$store.commit('user/SET_PROGRESS', 0);
- uni.setStorageSync("imSyncFinish",0);
- };
-
- const syncProgressHandler = ({ data }) => {
- const now = Date.now();
- if (now - lastSyncTime > 200 || data >= 100) {
- lastSyncTime = now;
- console.log("qxj syncProgressHandler",data);
- this.$store.commit('user/SET_PROGRESS', data);
- }
- };
-
- const syncFinishHandler = () => {
- this.$store.dispatch('conversation/getConversationList');
- this.$store.dispatch('contact/getFriendList');
- this.$store.dispatch('contact/getGrouplist');
- this.$store.dispatch('conversation/getUnReadCount');
- this.$store.commit('user/SET_IS_SYNCING', false);
- this.$store.commit('user/SET_PROGRESS', 100);
- //console.log("qxj syncFinishHandler offlineHandleNewMsg",offlineHandleNewMsg);
- //console.log("qxj syncFinishHandler offlineMsg",offlineMsg);
- uni.setStorageSync("imSyncFinish",1);
- if(offlineMsg!=null){
- uni.$u.throttle(() => this.notifyGoToChat(offlineHandleNewMsg), 1000);
- }
- uni.hideLoading();
- };
-
- const syncFailedHandler = () => {
- uni.hideLoading();
- //uni.$u.toast('同步消息失败');
- this.$store.dispatch('conversation/getConversationList');
- this.$store.dispatch('conversation/getUnReadCount');
- this.$store.commit('user/SET_IS_SYNCING', false);
- this.$store.commit('user/SET_PROGRESS', 0);
- uni.setStorageSync("imSyncFinish",0);
- };
-
- IMSDK.subscribe(IMSDK.IMEvents.OnSyncServerStart, syncStartHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnSyncServerFinish, syncFinishHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnSyncServerFailed, syncFailedHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnSyncServerProgress, syncProgressHandler);
-
- const setStateStart = () => {
- connectStart = 0;
- };
- const setStateSuccess= () => {
- IMSDK.asyncApi('getSignalingInvitationInfoStartApp', IMSDK.uuid()).then(({ data }) => {
- callingModule.launchLiveChat(data);
- });
- connectStart = 1;
- };
- const setStateError= () => {
- connectStart = -1;
- };
-
- IMSDK.subscribe(IMSDK.IMEvents.OnConnecting, setStateStart);
- //IMSDK.subscribe(IMSDK.IMEvents.OnConnectSuccess, setStateSuccess);
- IMSDK.subscribe(IMSDK.IMEvents.OnConnectFailed, setStateError);
-
- // self
- const selfInfoUpdateHandler = ({ data }) => {
- this.$store.commit('user/SET_SELF_INFO', {
- ...this.storeSelfInfo,
- ...data
- });
- this.updateMessageNicknameAndFaceUrl({
- sendID: data.userID,
- senderNickname: data.nickname,
- senderFaceUrl: data.faceURL
- });
- };
- IMSDK.subscribe(IMSDK.IMEvents.OnSelfInfoUpdated, selfInfoUpdateHandler);
-
- // message
- const newMessagesHandler = ({ data }) => {
- //console.log("-----qxj newMessagesHandler:",data);
- if(offlineMsg!=null){
- offlineHandleNewMsg=data[0];
- }
- if (this.storeIsSyncing) {
- return;
- }
- if(Array.isArray(data)){
- data.forEach(this.handleNewMessage);
- }else{
- this.handleNewMessage(data);
- }
- };
- const offlineMessageHandler = ({ data }) => {
- console.log("-----qxj offlineMessageHandler:"+JSON.stringify(data));
- };
- const offlineMessagesHandler = ({ data }) => {
- //console.log("------qxj offlineMessagesHandler:"+JSON.stringify(data));
- if (this.storeIsSyncing) {
- return;
- }
- data.forEach(this.handleOfflineMessages);
- };
- const c2cReadReceiptHandler = ({ data: receiptList }) => {
- if (receiptList[0].userID !== this.storeCurrentConversation.userID) {
- return;
- }
- receiptList.forEach((item) => {
- item.msgIDList.forEach((msgID) => {
- this.updateOneMessage({
- message: {
- clientMsgID: msgID
- },
- type: UpdateMessageTypes.KeyWords,
- keyWords: {
- key: 'isRead',
- value: true
- }
- });
- });
- });
- };
- const groupReadReceiptHandler = ({ data }) => {
- if (data.conversationID !== this.storeCurrentConversation.conversationID) {
- return;
- }
- data.groupMessageReadInfo.map((receipt) => {
- const oldMessage = this.storeHistoryMessageList.find((msg) => msg.clientMsgID === receipt.clientMsgID);
- if (oldMessage) {
- uni.$emit(PageEvents.GroupMessageReceipt, receipt);
- const newMessage = {
- ...oldMessage,
- isRead: true,
- attachedInfoElem: {
- ...oldMessage.attachedInfoElem,
- groupHasReadInfo: {
- hasReadCount: receipt.hasReadCount,
- unreadCount: receipt.unreadCount
- }
- }
- };
- console.log(newMessage);
- this.updateOneMessage({ message: newMessage });
- }
- });
- console.log(data);
- };
- const newRecvMessageRevokedHandler = ({ data: revokedMessage }) => {
- if (!this.storeCurrentConversation.conversationID) {
- return;
- }
- this.updateOneMessage({
- message: { clientMsgID: revokedMessage.clientMsgID },
- type: UpdateMessageTypes.KeyWords,
- keyWords: [
- {
- key: 'contentType',
- value: MessageType.RevokeMessage
- },
- {
- key: 'notificationElem',
- value: {
- detail: JSON.stringify(revokedMessage)
- }
- }
- ]
- });
- this.updateQuoteMessageRevoke({
- clientMsgID: revokedMessage.clientMsgID
- });
- };
- const inputStatusChanged = ({ data }) => {
- if (data.userID === this.storeCurrentConversation.userID && data.conversationID === this.storeCurrentConversation.conversationID) {
- if (data.platformIDs.length > 0) {
- uni.$emit(PageEvents.TypingUpdate);
- }
- }
- };
-
- IMSDK.subscribe(IMSDK.IMEvents.OnRecvOfflineNewMessage, offlineMessageHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnRecvOfflineNewMessages, offlineMessagesHandler);
-
- IMSDK.subscribe(IMSDK.IMEvents.OnRecvNewMessages, newMessagesHandler);
- IMSDK.subscribe("OnInputStatusChanged", inputStatusChanged);
- IMSDK.subscribe(IMSDK.IMEvents.OnRecvC2CReadReceipt, c2cReadReceiptHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnRecvGroupReadReceipt, groupReadReceiptHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnNewRecvMessageRevoked, newRecvMessageRevokedHandler);
-
- // friend
- const friendInfoChangeHandler = ({ data }) => {
- uni.$emit(IMSDK.IMEvents.OnFriendInfoChanged, { data });
- if (data.userID === this.storeCurrentConversation?.userID) {
- this.updateMessageNicknameAndFaceUrl({
- sendID: data.userID,
- senderNickname: data.remark || data.nickname,
- senderFaceUrl: data.faceURL
- });
- this.$store.commit('conversation/SET_CURRENT_CONVERSATION', { ...this.storeCurrentConversation, showName: data.remark || data.nickname });
- }
- //console.log(this.storeConversationList);
- this.updateFriendInfo({
- friendInfo: data
- });
- };
- const friendAddedHandler = ({ data }) => {
- this.pushNewFriend(data);
- };
- const friendDeletedHander = ({ data }) => {
- this.updateFriendInfo({
- friendInfo: data,
- isRemove: true
- });
- };
-
- IMSDK.subscribe(IMSDK.IMEvents.OnFriendInfoChanged, friendInfoChangeHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnFriendAdded, friendAddedHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnFriendDeleted, friendDeletedHander);
-
- // blacklist
- const blackAddedHandler = ({ data }) => {
- this.pushNewBlack(data);
- };
-
- const blackDeletedHandler = ({ data }) => {
- this.updateBlackInfo({
- blackInfo: data,
- isRemove: true
- });
- };
-
- IMSDK.subscribe(IMSDK.IMEvents.OnBlackAdded, blackAddedHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnBlackDeleted, blackDeletedHandler);
-
- // group
- const joinedGroupAddedHandler = ({ data }) => {
- uni.$emit(IMSDK.IMEvents.OnJoinedGroupAdded, { data });
- this.pushNewGroup(data);
- };
-
- const joinedGroupDeletedHandler = ({ data }) => {
- uni.$emit(IMSDK.IMEvents.OnJoinedGroupDeleted, { data });
- this.updateGroupInfo({
- groupInfo: data,
- isRemove: true
- });
- };
- const groupInfoChangedHandler = ({ data }) => {
- this.updateGroupInfo({
- groupInfo: data
- });
- };
- const groupMemberInfoChangedHandler = ({ data }) => {
- uni.$emit(IMSDK.IMEvents.OnGroupMemberInfoChanged, { data });
- if (data.groupID === this.storeCurrentConversation?.groupID) {
- this.updateMessageNicknameAndFaceUrl({
- sendID: data.userID,
- senderNickname: data.nickname,
- senderFaceUrl: data.faceURL
- });
- this.updateCurrentMemberInGroup(data);
- }
- };
-
- IMSDK.subscribe(IMSDK.IMEvents.OnJoinedGroupAdded, joinedGroupAddedHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnJoinedGroupDeleted, joinedGroupDeletedHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnGroupInfoChanged, groupInfoChangedHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnGroupMemberInfoChanged, groupMemberInfoChangedHandler);
-
- // application
- const friendApplicationNumHandler = ({ data }) => {
- console.log("qxj friendApplicationNumHandler");
- const isRecv = data.toUserID === this.storeCurrentUserID;
- if (isRecv) {
- this.pushNewRecvFriendApplition(data);
- } else {
- this.pushNewSentFriendApplition(data);
- }
- };
- const friendApplicationAccessHandler = ({ data }) => {
- console.log("qxj friendApplicationAccessHandler");
- const isRecv = data.toUserID === this.storeCurrentUserID;
- if (isRecv) {
- this.updateRecvFriendApplition({
- application: data
- });
- } else {
- this.updateSentFriendApplition({
- application: data
- });
- }
- };
- const groupApplicationNumHandler = ({ data }) => {
- console.log("qxj groupApplicationNumHandler");
- const isRecv = data.userID !== this.storeCurrentUserID;
- if (isRecv) {
- this.pushNewRecvGroupApplition(data);
- } else {
- this.pushNewSentGroupApplition(data);
- }
- };
- const groupApplicationAccessHandler = ({ data }) => {
- console.log("qxj groupApplicationAccessHandler");
- const isRecv = data.userID !== this.storeCurrentUserID;
- if (isRecv) {
- this.updateRecvGroupApplition({application: data});
- } else {
- this.updateSentGroupApplition({application: data});
- }
- };
-
- IMSDK.subscribe(IMSDK.IMEvents.OnFriendApplicationAdded, friendApplicationNumHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnFriendApplicationAccepted, friendApplicationAccessHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnFriendApplicationRejected, friendApplicationAccessHandler);
-
- IMSDK.subscribe(IMSDK.IMEvents.OnGroupApplicationAdded, groupApplicationNumHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnGroupApplicationAccepted, groupApplicationAccessHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnGroupApplicationRejected, groupApplicationAccessHandler);
-
- // conversation
- const totalUnreadCountChangedHandler = ({ data }) => {
- if (this.storeIsSyncing) {
- return;
- }
- this.$store.commit('conversation/SET_UNREAD_COUNT', data);
- };
- const newConversationHandler = ({ data }) => {
- console.log("qxj newConversationHandler");
- if (this.storeIsSyncing) {
- return;
- }
- const result = [...data, ...this.storeConversationList];
- this.$store.commit('conversation/SET_CONVERSATION_LIST', conversationSort(result));
- };
- const conversationChangedHandler = ({ data }) => {
- if (this.storeIsSyncing) {
- return;
- }
- let filterArr = [];
- //console.log("qxj conversationChangedHandler:::",data);
- const chids = data.map((ch) => ch.conversationID);
- filterArr = this.storeConversationList.filter((tc) => !chids.includes(tc.conversationID));
- const idx = data.findIndex((c) => c.conversationID === this.storeCurrentConversation.conversationID);
- if (idx !== -1) this.$store.commit('conversation/SET_CURRENT_CONVERSATION', data[idx]);
- const result = [...data, ...filterArr];
- this.$store.commit('conversation/SET_CONVERSATION_LIST', conversationSort(result));
- };
-
- IMSDK.subscribe(IMSDK.IMEvents.OnTotalUnreadMessageCountChanged, totalUnreadCountChangedHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnNewConversation, newConversationHandler);
- IMSDK.subscribe(IMSDK.IMEvents.OnConversationChanged, conversationChangedHandler);
-
- const insertInCurrentConversation = (newServerMsg) => {
- return newServerMsg.sendID === this.$store.getters.storeCurrentConversation.userID || newServerMsg.recvID === this.$store.getters.storeCurrentConversation.userID;
- };
-
- const onNativeCallEndHandler = async ({ invitation, duration, status }) => {
- uni.$emit(PageEvents.NativeCallEnd);
- if (!status || invitation.groupID) {
- return;
- }
- const type = invitation.mediaType === 'video' ? CustomType.VideoCall : CustomType.VoiceCall;
- const customData = {
- customType: CustomType.Call,
- data: { type, duration: secFormat(duration), status }
- };
-
- const nativeCallList = uni.getStorageSync(`${this.$store.getters.storeCurrentUserID}_nativecall`) || [];
- const isSelf = invitation.inviterUserID === this.$store.getters.storeCurrentUserID;
- const data = { ...invitation, duration, isSelf, type, time: new Date().getTime() };
- uni.setStorage({
- key: `${this.$store.getters.storeCurrentUserID}_nativecall`,
- data: [...nativeCallList, data]
- });
- const message = await IMSDK.asyncApi(IMMethods.CreateCustomMessage, IMSDK.uuid(), {
- data: JSON.stringify(customData),
- extension: '',
- description: 'RTC'
- });
- const recvID = invitation.inviteeUserIDList[0];
- IMSDK.asyncApi(IMSDK.IMMethods.InsertSingleMessageToLocalStorage, IMSDK.uuid(), {
- message,
- recvID,
- sendID: invitation.inviterUserID
- }).then(({ data }) => {
- if (insertInCurrentConversation(data)) {
- this.$store.dispatch('message/pushNewMessage', data);
- setTimeout(() => uni.$emit(PageEvents.ScrollToBottom, true));
- }
- }).catch((err) => {
- console.log(err);
- });
- };
- const onNativeInviteHandler = async (data) => {
- // uni.$u.toast("onNativeInviteHandler")
- uni.$u.route('/pages_im/pages/common/contactChoose/index', {
- type: ContactChooseTypes.InviteMeeting,
- forwardMessage: encodeURIComponent(JSON.stringify(data.data))
- });
- };
- IMSDK.subscribe('onNativeCallEnd', onNativeCallEndHandler);
- IMSDK.subscribe('Native_InviteUser', onNativeInviteHandler);
-
- },
- initOpenIm() {
- innerAudioContext = uni.createInnerAudioContext();
- innerAudioContext.autoplay = false;
- innerAudioContext.src = newMessage;
- // #ifdef APP-PLUS
- Igexin.turnOnPush();
- // #endif
- this.setGlobalIMlistener();
- this.tryLogin();
- //this.testTryLogin("U4056541205");
- },
- openImLogin() {
- let that = this;
- var uid="";
- var nickName="";
- var avatar="";
- if(this.$companyUserIsLogin()){
- var user = JSON.parse(uni.getStorageSync('companyUser'));
- uid = 'C' + user.userId;
- nickName=user.imNickName || user.nickName;
- avatar=user.avatar;
- }
- else{
- var user = JSON.parse(uni.getStorageSync('userInfo'));
- uid = 'U' + user.userId;
- nickName=user.nickName;
- avatar=user.avatar;
- }
- if(this.$isEmpty(avatar)){
- avatar="https://cos.his.cdwjyyh.com/fs/20250519/4e7c1c2de4b54ec4aaf1047394592a42.png";
- }
- let IMToken = uni.getStorageSync('IMToken');
- let IMUserID = uid;
- let reqData = { userID:uid, nickName:nickName, avatar:avatar };
- openImLoginApi(reqData,IMToken,IMUserID,function (token) {
- setTimeout(()=>{
- that.tryLogin();
- },100);
- },
- function () {
- uni.$u.toast('IM登录失败!');
- }
- );
- },
-
- tryLogin() {
- const initStore = () => {
- this.$store.dispatch('user/initCache');
- this.$store.dispatch('user/getSelfInfo');
- this.$store.dispatch('conversation/getConversationList');
- this.$store.dispatch('conversation/getUnReadCount');
- this.$store.dispatch("contact/getFriendList");
- this.$store.dispatch("contact/getGrouplist");
-
- //this.$store.dispatch('contact/getBlacklist');
-
- this.$store.dispatch('contact/getRecvFriendApplications');
- this.$store.dispatch('contact/getSentFriendApplications');
- this.$store.dispatch('contact/getRecvGroupApplications');
- this.$store.dispatch('contact/getSentGroupApplications');
-
- // #ifdef APP-PLUS
- plus.navigator.closeSplashscreen();
- // 启动页关闭后创建浮标
- this.createComplaintFloatAfterSplash();
- // #endif
- };
- let IMToken = uni.getStorageSync('IMToken');
- let IMUserID = uni.getStorageSync('IMUserID');
- //console.log("qxj IMToken:"+IMToken+" IMUserID:"+IMUserID);
- // #ifdef APP-PLUS
- getDbDir().then(async (path) => {
- let platformID=uni.$u.os() === 'ios' ? 1 : 2;
- const flag = await IMSDK.asyncApi(IMMethods.InitSDK, IMSDK.uuid(), {
- systemType: 'uni-app',
- platformID:platformID,
- apiAddr: config.getApiUrl(),
- wsAddr: config.getWsUrl(),
- dataDir: path, // 数据存储路径
- logLevel: 2,//正式环境2或者3 测试:5
- logFilePath: path,
- isLogStandardOutput: true // 是否输出到控制台
- });
- if (!flag) {
- // #ifdef APP-PLUS
- plus.navigator.closeSplashscreen();
- // 启动页关闭后创建浮标
- this.createComplaintFloatAfterSplash();
- // #endif
- uni.$u.toast('初始化IMSDK失败!');
- return;
- }
- //1 未登录 2 登录中 3 已登录
- const loginStatus = await IMSDK.asyncApi(IMSDK.IMMethods.GetLoginStatus, IMSDK.uuid());
- if (loginStatus === 3) {
- initStore();
- return;
- }
- callingModule?.initModule();
- if (IMToken && IMUserID) {
- await IMSDK.asyncApi(IMSDK.IMMethods.Login, IMSDK.uuid(), {
- userID: IMUserID,
- token: IMToken,
- }).then(initStore).catch((err) => {
- console.log('qxj initStore err:' + JSON.stringify(err));
- uni.$u.toast('初始化IMSDK异常:'+JSON.stringify(err));
- uni.removeStorage({ key: 'IMToken' });
- // #ifdef APP-PLUS
- plus.navigator.closeSplashscreen();
- // 启动页关闭后创建浮标
- this.createComplaintFloatAfterSplash();
- // #endif
- });
- } else {
- if(this.$isLogin()){
- this.openImLogin();
- }
- // #ifdef APP-PLUS
- plus.navigator.closeSplashscreen();
- // 启动页关闭后创建浮标
- this.createComplaintFloatAfterSplash();
- // #endif
- }
- }).catch((err) => {
- console.log('get dir failed');
- console.log(err);
- // #ifdef APP-PLUS
- plus.navigator.closeSplashscreen();
- // 启动页关闭后创建浮标
- this.createComplaintFloatAfterSplash();
- // #endif
- });
-
- // #endif
- // #ifdef H5
- console.log("qxj IMTokenUserId",IMToken,IMUserID);
- if (IMToken && IMUserID) {
- IMSDK.asyncApi(IMSDK.IMMethods.Login, IMSDK.uuid(), {
- userID: IMUserID,
- token: IMToken,
- platformID:5,
- logLevel: 2,
- apiAddr: config.getApiUrl(),
- wsAddr: config.getWsUrl(),
- }).then(initStore).catch((err) => {
- console.log('qxj initStore:',err);
- uni.removeStorage({ key: 'IMToken' });
- });
- return;
- }
- else{
- if(this.$isLogin()){
- this.openImLogin();
- }
- }
- // #endif
- },
-
- testTryLogin(uid){
- uni.setStorageSync('IMToken',null);
- let IMToken = uni.getStorageSync('IMToken');
- let IMUserID = uid;
- let reqData = { userID:uid, nickName:"" };
- let that=this;
- testImLoginApi(reqData,IMToken,IMUserID,function (token) {
- setTimeout(()=>{
- that.tryLogin();
- },100);
- },
- function () {
- uni.$u.toast('IM登录失败!');
- }
- );
- },
-
- async newMessageNotify(newServerMsg) {
- if (this.storeIsSyncing) {
- return;
- }
- //console.log("qxj newMessageNotify1");
- const disableNotify = uni.getStorageSync(`${this.storeCurrentUserID}_DisableNotify`);
- if (disableNotify || this.storeSelfInfo.globalRecvMsgOpt !== MessageReceiveOptType.Nomal) {
- return;
- }
- //console.log("qxj newMessageNotify2");
- let cveItem = [...this.storeConversationList, ...cacheConversationList].find((conversation) => {
- if (newServerMsg.sessionType === SessionType.WorkingGroup) {
- return newServerMsg.groupID === conversation.groupID;
- }
- return newServerMsg.sendID === conversation.userID;
- });
- //console.log("qxj newMessageNotify3");
- if (!cveItem) {
- try {
- const { data } = await IMSDK.asyncApi(IMSDK.IMMethods.GetOneConversation, IMSDK.uuid(), {
- sourceID: newServerMsg.groupID || newServerMsg.sendID,
- sessionType: newServerMsg.sessionType
- });
- cveItem = data;
- cacheConversationList = [...cacheConversationList, data];
- } catch (e) {
- return;
- }
- }
- //console.log("qxj newMessageNotify4");
- if (cveItem.recvMsgOpt !== MessageReceiveOptType.Normal) {
- return;
- }
- //console.log("qxj newMessageNotify5");
- const notificationFun = () => {
- const isSelf = newServerMsg.sendID === this.$store.getters.storeCurrentUserID;
- if (isSelf) return;
- // const pages = getCurrentPages();
- // const url = pages[ pages.length - 1];
- const url=this.$getCurrentPage();
- if(url&& (url.route=="pages_im/pages/conversation/conversationList/index"
- || url.route=="pages_im/pages/conversation/chating/index") ){
- return;
- }
-
- // uni.createPushMessage({
- // content: `${newServerMsg.senderNickname}: ${parseMessageByType(newServerMsg)}`,
- // payload: {
- // sessionType: newServerMsg.sessionType,
- // sourceID: newServerMsg.groupID || newServerMsg.sendID,
- // }
- // });
-
- const isSingle = newServerMsg.groupID ? false : true;
- console.log(this.storeGroupList, newServerMsg);
- const group = this.storeGroupList.filter((group) => group.groupID === newServerMsg.groupID);
- const title = isSingle ? newServerMsg.senderNickname : group[0].groupName;
- const desc = parseMessageByType(newServerMsg);
- console.log('notification', title, desc);
-
- // notificationIntance = new NotificationUtil();
- // let tickerTips="通知提示";
- // let notifyId=10001;
- // let config={ title, desc,tickerTips,notifyId };
- // notificationIntance.createNotification(config);
-
- // setTimeout(()=>{
- // notificationIntance.clearNotification(10001);
- // },10000);
-
- // notification.showNotice(0, title, desc, () => {
- // prepareConversationState(cveItem);
- // });
- };
- //notificationFun();
- const platform = uni.getSystemInfoSync().platform;
- if (platform == 'ios') {
- if (this.storeSelfInfo.allowVibration === 1) {
- plus.device.vibrate();
- }
- if (this.storeSelfInfo.allowBeep === 1) {
- innerAudioContext.play();
- // plus.device.beep();
- }
- }
- else if (platform == 'android') {
- if (this.storeSelfInfo.allowVibration === 1) {
- plus.device.vibrate(500);
- }
- if (this.storeSelfInfo.allowBeep === 1) {
- let main = plus.android.runtimeMainActivity();
- let RingtoneManager = plus.android.importClass('android.media.RingtoneManager');
- let uri = RingtoneManager.getActualDefaultRingtoneUri(main, RingtoneManager.TYPE_NOTIFICATION);
- let MediaPlayer = plus.android.importClass('android.media.MediaPlayer');
- let player = MediaPlayer.create(main, uri);
- player.setLooping(false);
- player.prepare();
- player.start();
- }
- }
- },
-
- async notifyGoToChat(newServerMsg){
- console.log("qxj notifyGoToChat",newServerMsg);
- if (this.storeIsSyncing) {
- return;
- }
- offlineHandleNewMsg=null;
- offlineMsg=null;
- // const disableNotify = uni.getStorageSync(`${this.storeCurrentUserID}_DisableNotify`);
- // if (disableNotify || this.storeSelfInfo.globalRecvMsgOpt !== MessageReceiveOptType.Nomal) {
- // return;
- // }
- let cveItem = [...this.storeConversationList, ...cacheConversationList].find((conversation) => {
- if (newServerMsg.sessionType === SessionType.WorkingGroup) {
- return newServerMsg.groupID === conversation.groupID;
- }
- return newServerMsg.sendID === conversation.userID;
- });
- console.log("qxj notifyGoToChat cveItem",cveItem);
- if (!cveItem) {
- try {
- const { data } = await IMSDK.asyncApi(IMSDK.IMMethods.GetOneConversation, IMSDK.uuid(), {
- sourceID: newServerMsg.groupID || newServerMsg.sendID,
- sessionType: newServerMsg.sessionType
- });
- cveItem = data;
- cacheConversationList = [...cacheConversationList, data];
- } catch (e) {
- return;
- }
- }
- if (cveItem.recvMsgOpt !== MessageReceiveOptType.Normal) {
- return;
- }
- const isSelf = newServerMsg.sendID === this.$store.getters.storeCurrentUserID;
- if (isSelf) return;
- // const pages = getCurrentPages();
- // const url = pages[ pages.length - 1];
- const url=this.$getCurrentPage();
- if(url && (url.route=="pages_im/pages/conversation/chating/index" || url.route=="pages_im/pages/conversation/chating1/index") ){
- return;
- }
- this.handlerConversation(cveItem);
- setTimeout(()=>{
- prepareConversationState(cveItem);
- //uni.removeStorageSync("serverMsgID");
- },200);
- },
-
- handlerConversation(source){
- let userId=source.userID;
- let isDoctor=false;
- if(userId!=undefined && (userId!="" || userId.length>0)){
- if(userId.indexOf('D')!==-1){
- isDoctor=true;
- }
- }
- if(this.$companyUserIsLogin() || !isDoctor){
- this.$store.commit("timStore/setImType",1);
- }
- else{
- let ex=source.ex;
- if(source.latestMsg!=null && source.latestMsg!=''){
- let latestMsg=JSON.parse(source.latestMsg);
- if(!!latestMsg.ex && latestMsg.ex!=''){
- ex=latestMsg.ex;
- }
- }
- if(ex!=null || ex!=''){
- try{
- var json=JSON.parse(ex);
- this.$store.commit("timStore/setImType", json.imType);
- this.$store.commit("timStore/setOrderType", json.orderType);
- this.$store.commit("timStore/setOrderId", json.orderId);
- this.$store.commit("timStore/setFollowId", json.followId);
- this.$store.commit("timStore/setType", json.type);
- }
- catch(e){
-
- }
- }
- }
- this.$store.commit("timStore/setConversationID", source.conversationID);
- },
-
- handleNewMessage(newServerMsg) {
- //console.log("---qxj handleNewMessage",newServerMsg);
- if (this.inCurrentConversation(newServerMsg)) {
- const isSingleMessage = newServerMsg.sessionType === SessionType.Single;
- if (isSingleMessage) {
- uni.$u.throttle(() => uni.$emit(PageEvents.OnlineStateCheck), 2000);
- if(newServerMsg.ex!=null&&newServerMsg.ex!=''){
- var json=JSON.parse(newServerMsg.ex);
- this.$store.commit("timStore/setType",json.type);
- this.$store.commit("timStore/setImType", json.imType);
- this.$store.commit("timStore/setOrderId",json.orderId);
- this.$store.commit("timStore/setOrderType",json.orderType);
- this.$store.commit("timStore/setFollowId",json.followId);
- if(json.type==="finishInquiry"){
- this.$store.commit("timStore/setImType", 0);
- uni.navigateTo({ url: "/pages_order/pingOrder?orderId="+json.orderId })
- }
- else if(json.type==="startInquiry"){
-
- }
- else if(json.type==="inquiry"){
-
- }
- else if(json.type==="startFollow"){
-
- }
- else if(json.type==="follow"){
-
- }
- else if(json.type==="finishFollow"){
-
- }
- else if(json.type==="startDrugReport"){
-
- }
- else if(json.type==="finishDrugReport"){
-
- }
- else if(json.type==="drugReport"){
-
- }
- }
- }
- if (newServerMsg.contentType === MessageType.TypingMessage) {
- if (isSingleMessage) {
- uni.$emit(PageEvents.TypingUpdate);
- }
- }
- else {
- if (newServerMsg.contentType != MessageType.RevokeMessage) {
- newServerMsg.isAppend = true;
- this.pushNewMessage(newServerMsg);
- setTimeout(() => uni.$emit(PageEvents.ScrollToBottom, true));
- }
- uni.$u.debounce(this.markConversationAsRead, 2000);
- }
- }
- else {
- if (newServerMsg.contentType !== MessageType.TypingMessage) {
- uni.$u.throttle(() => this.newMessageNotify(newServerMsg), 1000);
- setTimeout(() => {
- this.$store.dispatch('conversation/getUnReadCount');
- },500);
- }
- }
- },
-
- handleOfflineMessages(newServerMsg){ //后台运行
- const isSingle = newServerMsg.groupID ? false : true;
- const group = this.storeGroupList.filter((group) => group.groupID === newServerMsg.groupID);
- const title = isSingle ? newServerMsg.senderNickname : group[0].groupName;
- const desc = parseMessageByType(newServerMsg);
-
- // if(notification){
- // notification.showNotice(0, title, desc, () => {
- // console.log('qxj showNotice:', title);
- // setTimeout(() => {
- // uni.switchTab({url: 'pages_im/pages/conversation/conversationList/index'});
- // },2000);
- // });
- // }
-
- // const options = {
- // title: title,
- // content: desc,
- // payload: newServerMsg, // 自定义参数,点击通知时传递给应用
- // sound: 'default', // 通知声音
- // cover: false, // 是否覆盖之前的通知
- // //when: new Date(),
- // icon:"",
- // extras: {
- // android: {
- // importance: "high", // 高优先级
- // channelId: "IM通知", // 必须配置通知渠道
- // smallIcon: "transparent",
- // showWhen: false,
- // }
- // }
- // };
- // plus.push.createMessage(options.content, options.payload, options);
-
- // let when=new Date();
- // uni.createPushMessage({
- // title:title,
- // content:desc,
- // payload: newServerMsg,
- // cover: false, // 是否覆盖之前的通知
- // when: new Date()
- // });
-
- },
-
- inCurrentConversation(newServerMsg) {
- switch (newServerMsg.sessionType) {
- case SessionType.Single:
- return (
- newServerMsg.sendID === this.storeCurrentConversation.userID ||
- (newServerMsg.sendID === this.storeCurrentUserID && newServerMsg.recvID === this.storeCurrentConversation.userID)
- );
- case SessionType.WorkingGroup:
- return newServerMsg.groupID === this.storeCurrentConversation.groupID;
- case SessionType.Notification:
- return newServerMsg.sendID === this.storeCurrentConversation.userID;
- default:
- return false;
- }
- },
-
- markConversationAsRead() {
- IMSDK.asyncApi(IMSDK.IMMethods.MarkConversationMessageAsRead, IMSDK.uuid(), this.storeCurrentConversation.conversationID);
- },
-
- removeImData(){
- uni.removeStorage({ key: 'IMToken' });
- uni.removeStorage({ key: 'IMUserID' });
- },
-
- async cidBindAlias(alias){
- let registrationID=uni.getStorageSync("registrationID");
- let params=[{
- "cid":registrationID,
- "alias":alias
- }];
- console.log("qxj cidBindAlias params:"+JSON.stringify(params));
- await uniPush.cidBindAlias(params);
- },
- runTimer() {
- let that = this;
- let dateNowDay = this.$dateFormatStr('YYYY-mm-dd', new Date());
- let healthButler = uni.getStorageSync('healthButler');
- let userInfo = uni.getStorageSync('userInfo');
- console.log('------qxj dateStr:' + dateNowDay + ' healthButler:' + healthButler);
- let dayNum = 0;
- if (userInfo != null && userInfo.isAddQw) {
- //已加过企微不在弹窗
- return;
- }
- if (!!healthButler) {
- healthButler = JSON.parse(healthButler);
- dayNum = healthButler.dayNum;
- if (healthButler.day == dateNowDay) {
- //今天已经弹窗过 防止再弹窗
- return;
- }
- }
- if (dayNum == 0) {
- //第一天下载App
- if (this.$qconfig.healthTimer == null) {
- this.$qconfig.healthTimer = setInterval(() => {
- if (this.$qconfig.healthSeconds == healthSeconds) {
- this.$qconfig.healthSeconds = 0;
- healthButlerPop(function (data) {
- if (data == 1) {
- that.bdAdvFeedback();
- clearInterval(that.$qconfig.healthTimer);
- } else {
- that.resetTimer();
- that.$showLoginPage();
- }
- });
- }
- this.$qconfig.healthSeconds++;
- //console.log("healthTimer tSeconds:"+this.$qconfig.healthSeconds);
- }, 1000);
- }
- }
- else {
- //第二天,第三天,,
- healthButlerPop(function (data) {
- if (data == 1) {
- clearInterval(that.$qconfig.healthTimer);
- } else {
- that.$showLoginPage();
- }
- });
- }
- },
- resetTimer() {
- clearInterval(this.$qconfig.healthTimer);
- this.$qconfig.healthTimer = null; //重置定时器
- this.$qconfig.healthSeconds = healthSeconds;
- },
- getUserInfo(healthButler) {
- getUserInfo().then((res) => {
- if (res.code == 200) {
- if (res.user != null) {
- let registrationID=uni.getStorageSync("registrationID");
- let userInfo = res.user;
- uni.setStorageSync('userInfo', JSON.stringify(res.user));
- if(!userInfo.jpushId || registrationID!=userInfo.jpushId){
- uni.setStorageSync("registrationID","");
- }
- if(!!healthButler){
- healthButler.isAddQw = userInfo.isAddQw;
- uni.setStorageSync('healthButler', JSON.stringify(healthButler));
- }
- }
- }else if(res.code == 500){
- uni.showToast({
- title:"当前用户被禁用",
- icon:"none",
- duration:5000
- });
- setTimeout(()=>{
- uni.$emit('loginOut');
- },5500);
- }
- },
- (rej) => {}
- );
- },
-
- jumpToNotificationSettings() {
- uni.request({
- url: 'content://settings/action/notification_settings',
- success: function (res) {
- console.log('跳转成功:', res);
- },
- fail: function (err) {
- console.log('跳转失败:', err);
- }
- });
- },
- bdAdvFeedback() {
- // #ifdef APP-PLUS
- if (this.$isAgreePrivacy()) {
- if (plus.runtime.channel == 'baidu') {
- let bdCmdType = uni.getStorageSync('bdCmdType');
- if (this.$isEmpty(bdCmdType)) {
- this.$registerIdCode('goToQw', 4, 0);
- }
- }
- }
- // #endif
- },
-
- async checkPush() {
- //检测是否开启推送通知
- const notificationAuthorized = uni.getAppAuthorizeSetting().notificationAuthorized;
- if (notificationAuthorized == 'denied') {
- uni.showModal({
- title: '提示',
- content: '是否前往打开通知权限',
- success: (res) => {
- if (res.confirm) {
- let status = this.checkPermission();
- if (status !== 1) {
- console.log('未开启权限');
- }
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- }
- },
- async checkPermission() {
- let status = permision1.isIOS ? await permision1.requestIOS('push') :
- await permision1.requestAndroid('android.permission.REQUEST_NOTIFICATION_POLICY');
- if (status === null || status === 1) {
- status = 1;
- } else if (status === 2) {
- uni.showModal({
- content: '系统通知已关闭',
- confirmText: '确定',
- showCancel: false,
- success: function (res) {}
- });
- } else if (status.code) {
- uni.showModal({
- content: status.message
- });
- } else {
- uni.showModal({
- content: '需要通知权限',
- confirmText: '设置',
- success: function (res) {
- if (res.confirm) {
- permision1.gotoAppSetting();
- }
- }
- });
- }
- return status;
- },
- geth5Path() {
- getRealLinkDomainName().then((res) => {
- if (res.code == 200) {
- uni.setStorageSync('h5Path', res.data);
- }
- });
- },
- // 系统通知全部已读
- setReadAll(url) {
- if (url && url.indexOf('/pages/courseAnswer/index') == -1) {
- getPushLogRead([]).then((res) => {
- if (res.code == 200) {
- this.$updateMsgDot();
- }
- });
- }
- },
- // 获取剪贴板内容跳转到看课
- getClipboardData() {
- // #ifdef APP-PLUS
- console.log('获取剪贴板内容跳转到看课==========');
- const course = {};
- coursePopup(course, () => {
- // uni.getClipboardData({
- // success: function (res) {
- // console.log("res.data===",res);
- // let Context = plus.android.importClass("android.content.Context");
- // let main = plus.android.runtimeMainActivity();
- // let clip = main.getSystemService(Context.CLIPBOARD_SERVICE);
- // plus.android.invoke(clip,"setText","");
- // }
- // });
- });
- // #endif
- },
- getRuntimePlatform() {
- const systemInfo = uni.getSystemInfoSync();
- const compilePlatform = process.env.UNI_PLATFORM;
- //1:iOS,2:Android,3:Windows,4:OSX,5:WEB,6:小程序,7:linux,8:AndroidPad,9:IPad,10:Admin
- let platformType=5;
- // H5 环境
- if (compilePlatform === 'h5') platformType= 5;
-
- // 小程序环境
- if (compilePlatform.startsWith('mp-')) {
- const mpType = compilePlatform.split('-')[1]; // 如 weixin/alipay
- platformType=6;
- // return `小程序(${mpType})- ${systemInfo.platform}`;
- }
- // App 环境
- if (compilePlatform === 'app-plus') {
- if(systemInfo.platform.toLowerCase() === 'android'){
- platformType=2;
- }
- if(systemInfo.platform.toLowerCase() === 'ios'){
- platformType=1;
- }
- }
- //uni.showToast({ title:" platformType:"+platformType,icon:'none', duration: 2000 });
- return platformType;
- },
- /* 检查更新 在线更新 */
- checkUpdateApp() {
- //uni wgt包版本检测更新
- //checkUpdate();
- let that = this;
- plus.runtime.getProperty(plus.runtime.appid, function (widgetinfo) {
- if (widgetinfo.name == qconfig.appName) { //APP名称
- let platform = uni.getSystemInfoSync().platform;
- let isAndroid = platform == 'android';
- let type = isAndroid ? 1 : 2;
- getAppVersion(type).then((srcData) => {
- //console.log("qxj getAppVersion srcData",srcData);
- if (srcData.code == 200) {
- if(isAndroid){
- uni.setStorageSync('aVersion', JSON.stringify(srcData));
- }
- let data = srcData.data;
- let version = widgetinfo.versionCode, //用户当前app版本
- appVersion = data.versionCode, //升级包版本
- appName = widgetinfo.name, //app名称
- isForce = data.isForce, //是否强制热更新
- updateConfig = JSON.parse(data.updateConfig),
- appurl = data.url, //升级包地址
- intro = data.note; //升级包提示
- //如果用户版本号小于升级包版本号,先升级
- let afterVer = false;
- if (plus.runtime.channel == 'baidu') {
- afterVer = that.$qconfig.isAppStore ? updateConfig.baidu : false;
- } else if (plus.runtime.channel == 'huawei') {
- afterVer = that.$qconfig.isAppStore ? updateConfig.huawei : false;
- } else if (plus.runtime.channel == 'xiaomi') {
- afterVer = that.$qconfig.isAppStore ? updateConfig.xiaomi : false;
- } else if (plus.runtime.channel == 'yyb') {
- afterVer = that.$qconfig.isAppStore ? updateConfig.yyb : false;
- } else {
- afterVer = that.$qconfig.isAppStore ? isForce : true;
- }
- if (data && version < appVersion && afterVer) {
- uni.showModal({
- title: '更新提示',
- confirmText: '立即升级',
- content: intro,
- cancelText: '确定',
- confirmText: '取消',
- success: (res) => {
- if (res.cancel) {
- openDownload(srcData.data);
- } else if (res.confirm) {
- if (isForce == 1) {
- uni.showToast({ title: '请先升级APP版本', icon: 'none', duration: 2000 });
- //退出app
- setTimeout(function () {
- plus.runtime.quit();
- }, 2000);
- }
- }
- },
- fail: () => {
- uni.hideLoading();
- }
- });
- }
- }
- },
- (rej) => {}
- ).catch(() => {
- //联网失败, 结束加载
- this.mescroll.endErr();
- });
- }
- });
- }
-
- },
- watch: {
- storeCurrentUserID(newVal) {
- if (newVal) {
- cacheConversationList = [];
- }
- },
- contactBadgeRely: {
- handler(newValue) {
- //console.log("qxj contactBadgeRely newValue",newValue);
- const { recvFriendApplications, recvGroupApplications, userKey } = newValue;
- if (!userKey) return;
- const accessedFriendApplications = uni.getStorageSync(`${userKey}_accessedFriendApplications`) || [];
- //console.log("qxj accessedFriendApplications",accessedFriendApplications);
- let unHandleFriendApplicationNum = recvFriendApplications.filter(
- (application) => application.handleResult === 0 && !accessedFriendApplications.includes(`${application.fromUserID}_${application.createTime}`)
- ).length;
- const accessedGroupApplications = uni.getStorageSync(`${userKey}_accessedGroupApplications`) || [];
- let unHandleGroupApplicationNum = recvGroupApplications.filter(
- (application) => application.handleResult === 0 && !accessedGroupApplications.includes(`${application.userID}_${application.createTime}`)
- ).length;
- //console.log("qxj unHandleFriendApplicationNum",unHandleFriendApplicationNum);
- const total = unHandleFriendApplicationNum + unHandleGroupApplicationNum;
- // if (total) {
- // uni.setTabBarBadge({ index: 0, text: total < 99 ? total + '' : '99+' });
- // } else {
- // uni.removeTabBarBadge({ index: 0 });
- // }
- this.$store.commit('contact/SET_UNHANDLE_FRIEND_APPLICATION_NUM', unHandleFriendApplicationNum);
- this.$store.commit('contact/SET_UNHANDLE_GROUP_APPLICATION_NUM', unHandleGroupApplicationNum);
- },
- deep: true
- }
- }
- };
- </script>
- <style lang="scss">
- /*每个页面公共css */
- @import '@/uni_modules/uview-plus/index.scss';
- /*#ifndef APP-NVUE*/
- view {
- box-sizing: border-box;
- }
- .ellipsis {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .ellipsis2 {
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- }
- uni-modal {
- z-index: 1100;
- }
- // 猜你喜欢样式
- .like-box {
- display: flex;
- align-items: center;
- justify-content: center;
- image {
- height: 40upx;
- width: 40upx;
- }
- .text {
- font-size: 28upx;
- color: #000;
- font-weight: bold;
- margin: 0 10upx;
- }
- }
- .no-data-box {
- height: 100%;
- width: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
- flex-direction: column;
- image {
- width: 264upx;
- height: 212upx;
- }
- .empty-title {
- margin-top: 20rpx;
- font-size: 28rpx;
- color: gray;
- }
- }
- .doctor-box {
- margin-top: 15rpx;
- padding: 20rpx 0rpx 0rpx;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: flex-start;
- .doctor {
- width: 100%;
- margin-bottom: 15rpx;
- background: #f9f8fe;
- padding: 15rpx;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: flex-start;
- &:last-child {
- margin-bottom: 0rpx;
- }
- .item {
- width: 100%;
- display: flex;
- align-items: flex-start;
- justify-content: flex-start;
- .left {
- .head-box {
- width: 92rpx;
- height: 92rpx;
- position: relative;
- .isline {
- width: 92rpx;
- height: 92rpx;
- border-radius: 50%;
- border: 2rpx solid #e69a22;
- display: flex;
- align-items: center;
- justify-content: center;
- position: absolute;
- bottom: 0rpx;
- .img {
- position: absolute;
- bottom: 1rpx;
- width: 75rpx;
- height: 35rpx;
- image {
- width: 75rpx;
- height: 35rpx;
- }
- .name {
- width: 75rpx;
- height: 35rpx;
- bottom: -3rpx;
- text-align: center;
- position: absolute;
- font-size: 16upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #ffffff;
- }
- }
- }
- .doc-img {
- border-radius: 50%;
- width: 100%;
- height: 100%;
- }
- }
- }
- .right {
- width: calc(100% - 100rpx);
- margin-left: 20rpx;
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- justify-content: flex-start;
- .doc-box {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .doc-name {
- font-size: 32upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #111111;
- }
- .doc-position {
- margin-left: 16rpx;
- font-size: 26upx;
- font-weight: bold;
- font-family: PingFang SC;
- color: #2a2b2e;
- }
- .doc-dept {
- margin-left: 16rpx;
- font-size: 26upx;
- font-weight: bold;
- font-family: PingFang SC;
- color: #2a2b2e;
- }
- }
- .hospital-box {
- display: flex;
- align-items: center;
- justify-content: flex-start;
- margin-top: 10rpx;
- .tag {
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #4fc06b;
- border-radius: 10rpx;
- padding: 5rpx 10rpx;
- font-size: 20upx;
- font-weight: bold;
- font-family: PingFang SC;
- color: #ffffff;
- }
- .name {
- margin-left: 6rpx;
- font-size: 26upx;
- font-weight: bold;
- font-family: PingFang SC;
- color: #2a2b2e;
- }
- }
- .doc-spec {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: flex-start;
- margin-top: 15rpx;
- .spec {
- font-size: 26upx;
- font-family: PingFang SC;
- color: #626468;
- }
- }
- .doc-count {
- margin-top: 15rpx;
- display: flex;
- align-items: center;
- justify-content: flex-start;
- .name {
- font-size: 24upx;
- font-family: PingFang SC;
- color: #9b9b9b;
- }
- .count {
- margin: 0rpx 5rpx;
- font-size: 24upx;
- font-family: PingFang SC;
- color: #2a2b2e;
- }
- }
- .doc-price {
- width: 100%;
- margin-top: 15rpx;
- display: flex;
- align-items: center;
- justify-content: flex-start;
- .btn {
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #feefd7;
- padding: 15rpx 30rpx;
- border-radius: 30rpx;
- font-size: 26upx;
- font-family: PingFang SC;
- color: #e69a22;
- }
- }
- }
- }
- }
- }
- /*#endif*/
- </style>
- <style lang="less">
- /*每个页面公共css */
- // @import './assets/iconfont/iconfont.css';
- @import './assets/css/common.less';
- /* 全局flex样式 */
- @import './common/css/flexCommon.css';
- /*引入全局补充样式*/
- @import './assets/css/czy/es.1.base.css';
- @import './assets/css/czy/es.2.color.css';
- @import './assets/css/czy/es.3.icon.css';
- @import './assets/css/czy/es.4.view.css';
- .textOne {
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- }
- .textTwo {
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- </style>
|