App.vue 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225
  1. <script>
  2. import {
  3. getDictByKey,
  4. getAppVersion,
  5. getRealLinkDomainName
  6. } from '@/api/common';
  7. //参考文档 插件市场 https://ext.dcloud.net.cn/plugin?id=741
  8. import {
  9. appCheckUdate,
  10. openDownload
  11. } from '@/utils/APPUpdate.js';
  12. import {
  13. getUserInfo,
  14. getPushLogRead
  15. } from '@/api/user';
  16. import {
  17. healthButlerPop
  18. } from '@/utils/healthButlerPop.js';
  19. // import store from "@/store";
  20. import {
  21. mapGetters,
  22. mapActions
  23. } from 'vuex';
  24. import IMSDK, {
  25. IMMethods,
  26. MessageReceiveOptType,
  27. MessageType,
  28. SessionType
  29. } from 'openim-uniapp-polyfill';
  30. import {
  31. config
  32. } from '@/pages_im/common/config';
  33. import {
  34. getDbDir,
  35. Igexin,
  36. toastWithCallback
  37. } from '@/pages_im/util/common.js';
  38. import {
  39. conversationSort,
  40. secFormat,
  41. callingModule,
  42. meetingModule,
  43. parseMessageByType,
  44. prepareConversationState
  45. } from '@/pages_im/util/imCommon';
  46. import {
  47. PageEvents,
  48. UpdateMessageTypes,
  49. CustomType,
  50. ContactChooseTypes
  51. } from '@/pages_im/constant';
  52. import {
  53. openImLoginApi
  54. } from '@/pages_im/api/imBll';
  55. import NotificationUtil from '@/pages_im/util/notification';
  56. import newMessage from '@/pages_im/static/audio/newMessage.wav';
  57. import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
  58. let cacheConversationList = [];
  59. let updateDownloadTask = null;
  60. let notificationIntance = null;
  61. let pausing = false;
  62. let innerAudioContext;
  63. let notification;
  64. let uPushPlugin;
  65. // #ifdef APP-PLUS
  66. import permision1 from '@/utils/permission.js';
  67. uPushPlugin = uni.requireNativePlugin('DCloud-PushSound');
  68. notification = uni.requireNativePlugin('Tuoyun-OpenIMSDK-Notification');
  69. // #endif
  70. import {
  71. getTlsSig
  72. } from '@/api/common.js';
  73. import {
  74. qconfig
  75. } from './utils/config';
  76. import {
  77. premissionCheck
  78. } from '@/js_sdk/wa-permission/permission.js';
  79. import {
  80. updateMsgDot
  81. } from '@/utils/common.js';
  82. import {
  83. getImAdminToken
  84. } from '@/pages_im/api/imApi';
  85. import {
  86. ar
  87. } from 'date-fns/locale';
  88. let healthTimer = null;
  89. let tSeconds = 0;
  90. const healthSeconds = 180;
  91. let offlineMsg = null;
  92. let offlineHandleNewMsg = null;
  93. const baseUrl = 'https://userapp.zkhj6.com'
  94. export default {
  95. globalData: {
  96. wsUrl: 'ws://webim.zkhj6.com',
  97. danmuWSUrl: 'wss://webim.zkhj6.com',
  98. aiWSUrl: 'ws://webim.zkhj6.com',
  99. kfurl: 'https://work.weixin.qq.com/kfid/kfc3731c5008ebd8906', //企业微信客服链接
  100. corpId: 'ww70ac72e824957fc9', //客服企业id
  101. miniprogamId: 'gh_5db2859e4e72',
  102. shareCorpId: '', // 分享企业id
  103. shareSchema: "", // 应用跳转标识,显示在具体应用下的 Schema字段
  104. shareAgentid: "", // 企业微信管理后台 应用唯一标识。显示在具体应用下的 AgentId字段
  105. shareAppid_gh: "", // 必须是应用关联的小程序,注意要有@app后缀
  106. privacyPolicy: baseUrl + "/web/privacyPolicy", //隐私政策
  107. userAgreement: baseUrl + "/web/userAgreement", //用户协议
  108. baseUrl: baseUrl,
  109. activityId: 1,
  110. },
  111. onLaunch: function(options) {
  112. uni.getClipboardData({
  113. success: (res) => {
  114. const resutl = this.getUrlParam(res.data, 'android_schema')
  115. if (resutl) {
  116. uni.navigateTo({
  117. url: resutl
  118. })
  119. }
  120. }
  121. });
  122. //设置字体大小
  123. let fontsize = uni.getStorageSync('fontSize');
  124. if (fontsize) {
  125. //store.commit("timStore/setScaleFontSize", fontsize);
  126. uni.setStorageSync('fontSize', fontsize);
  127. } else {
  128. let scale = this.getSystemFontScale();
  129. let oriFontSize = 18;
  130. fontsize = oriFontSize * scale;
  131. if (fontsize < oriFontSize) {
  132. fontsize = oriFontSize;
  133. }
  134. if (fontsize < 16) {
  135. fontsize = 16;
  136. }
  137. if (fontsize >= 21) {
  138. fontsize = 21;
  139. }
  140. uni.setStorageSync('fontSize', fontsize);
  141. }
  142. //设置im字体
  143. let RootFontSize = uni.getStorageSync('RootFontSize');
  144. if (!RootFontSize) {
  145. uni.setStorageSync('RootFontSize', "24px");
  146. this.$store.commit('user/SET_ROOT_FONT_SIZE', "24px");
  147. }
  148. uni.removeStorageSync('openUrl');
  149. this.initOpenIm();
  150. if (this.$isLogin()) {
  151. uni.setStorageSync("onLaunch", 1);
  152. //this.getClipboardData();
  153. }
  154. let that = this;
  155. uni.$on('refreshIM', () => {
  156. if (that.$isLogin()) {
  157. that.openImLogin();
  158. }
  159. });
  160. // #ifdef APP-PLUS
  161. uni.$on('showHealthButler', () => {
  162. if (plus.runtime.channel == 'baidu' || plus.runtime.channel == 'yybadv' || plus.runtime
  163. .channel == 'yybadv1') {
  164. that.runTimer();
  165. }
  166. });
  167. //离线推送
  168. this.handlerLaunchMsg();
  169. uni.onPushMessage((res) => { //unipush2.0 应用处于激活 监听消息推送
  170. //console.log("qxj onPushMessage",res);
  171. this.handlePushMessage(res);
  172. this.$updateMsgDot();
  173. });
  174. //#endif
  175. },
  176. onLoad() {
  177. },
  178. onShow() {
  179. this.getDictByKeyFun()
  180. this.geth5Path();
  181. var that = this;
  182. if (that.$isLogin()) {
  183. //that.$getRegistrationID('update');
  184. }
  185. // #ifdef APP-PLUS
  186. if (plus.runtime.isAgreePrivacy()) {
  187. //this.$getRegistrationID();
  188. if (plus.runtime.channel == 'baidu' || plus.runtime.channel == 'yybadv' || plus.runtime.channel ==
  189. 'yybadv1') {
  190. this.runTimer();
  191. }
  192. }
  193. if (uni.$u.os() === 'android') {
  194. this.checkUpdateApp();
  195. IMSDK.asyncApi(IMSDK.IMMethods.SetAppBackgroundStatus, IMSDK.uuid(), false);
  196. meetingModule?.onListenerAppBackground(false);
  197. }
  198. var args = plus.runtime.arguments;
  199. uni.setStorageSync("appIsOnShow", 1);
  200. if (args) {
  201. // 处理args参数,如直达到某新页面等
  202. if (args == "rtlive://course") {
  203. uni.switchTab({
  204. url: '/pages/course/index'
  205. });
  206. } else if (args == "rtlive://livingApp") {
  207. uni.switchTab({
  208. url: '/pages/course/video/living-app'
  209. });
  210. } else {
  211. let url = ''
  212. if (args.indexOf("rtlive://pagesApp") != -1) { // 打开对应pages
  213. url = args.replace("rtlive://pagesApp?pagesUrl=", "");
  214. url = decodeURIComponent(url);
  215. } else if (args.indexOf("rtlive://courseAnswer") != -1) { // 看课
  216. url = args.replace("rtlive://courseAnswer", "");
  217. url = "/pages/courseAnswer/index" + url;
  218. } else if (args.indexOf("rtlive://") != -1 && url) {
  219. uni.setStorageSync("openUrl", url)
  220. if (this.$isLogin()) {
  221. uni.navigateTo({
  222. url: url,
  223. success: function(res) {
  224. uni.removeStorageSync("openUrl")
  225. plus.runtime.arguments = ''
  226. }
  227. });
  228. }
  229. } else if (args.indexOf("contentType") != -1) { //unipush2.0 App打开状态点击通知
  230. let newServerMsg = JSON.parse(args);
  231. let serverMsgID = uni.getStorageSync('serverMsgID');
  232. if (serverMsgID != newServerMsg.data.serverMsgID) {
  233. uni.$u.throttle(() => that.notifyGoToChat(newServerMsg), 2000);
  234. uni.setStorageSync('serverMsgID', newServerMsg.data.serverMsgID);
  235. }
  236. } else if (args.indexOf("messageId") != -1) { //oppo离线推送
  237. offlineMsg = args;
  238. } else if (args.indexOf("rtlive://course") != -1) {
  239. url = args.replace("rtlive://course", "");
  240. url = "/pages/course/info" + url;
  241. }
  242. }
  243. }
  244. //#endif
  245. },
  246. onHide() {
  247. uni.removeStorageSync('onLaunch');
  248. uni.removeStorageSync('appIsOnShow');
  249. if (uni.$u.os() === 'android') {
  250. IMSDK.asyncApi(IMSDK.IMMethods.SetAppBackgroundStatus, IMSDK.uuid(), true);
  251. meetingModule?.onListenerAppBackground(true);
  252. }
  253. },
  254. computed: {
  255. ...mapGetters([
  256. 'storeConversationList',
  257. 'storeCurrentConversation',
  258. 'storeCurrentUserID',
  259. 'storeSelfInfo',
  260. 'storeRecvFriendApplications',
  261. 'storeRecvGroupApplications',
  262. 'storeHistoryMessageList',
  263. 'storeIsSyncing',
  264. 'storeGroupList'
  265. ]),
  266. contactBadgeRely() {
  267. return {
  268. recvFriendApplications: this.storeRecvFriendApplications,
  269. recvGroupApplications: this.storeRecvGroupApplications,
  270. userKey: this.storeCurrentUserID
  271. };
  272. }
  273. },
  274. methods: {
  275. ...mapActions('message', ['pushNewMessage', 'updateOneMessage', 'updateQuoteMessageRevoke',
  276. 'updateMessageNicknameAndFaceUrl'
  277. ]),
  278. ...mapActions('conversation', ['updateCurrentMemberInGroup']),
  279. ...mapActions('contact', [
  280. 'updateFriendInfo',
  281. 'pushNewFriend',
  282. 'updateBlackInfo',
  283. 'pushNewBlack',
  284. 'pushNewGroup',
  285. 'updateGroupInfo',
  286. 'pushNewRecvFriendApplition',
  287. 'updateRecvFriendApplition',
  288. 'pushNewSentFriendApplition',
  289. 'updateSentFriendApplition',
  290. 'pushNewRecvGroupApplition',
  291. 'updateRecvGroupApplition',
  292. 'pushNewSentGroupApplition',
  293. 'updateSentGroupApplition'
  294. ]),
  295. getUrlParam(paramStr, key) {
  296. // 1. 将参数字符串拆分为键值对数组
  297. const paramPairs = paramStr.split('&');
  298. let result = '';
  299. // 2. 遍历查找目标参数
  300. for (const pair of paramPairs) {
  301. const [paramKey, paramValue] = pair.split('=');
  302. // 匹配目标参数名
  303. if (paramKey == key && paramValue) {
  304. // 3. 对参数值进行URL解码(处理%2F、%3F等编码字符)
  305. result = decodeURIComponent(paramValue);
  306. break;
  307. }
  308. }
  309. return result;
  310. },
  311. async getDictByKeyFun() {
  312. let data = {
  313. key: 'app_pay_config'
  314. }
  315. const res = await getDictByKey(data)
  316. if (res.code == 200 && res.data && res.data.length > 0 && res.data[0].dictValue) {
  317. getApp().globalData.miniprogamId = res.data[0].dictValue
  318. }
  319. },
  320. getCid() {
  321. document.addEventListener('plusready', function() {
  322. console.log("plusready");
  323. //页面加载时触发
  324. plus.push.getClientInfoAsync((info) => {
  325. let cid = info["clientid"];
  326. console.log("qxj getClientInfoAsync info:" + JSON.stringify(info));
  327. });
  328. }, false);
  329. },
  330. handlePushMessage(res) { //unipush2.0
  331. const that = this;
  332. console.log("qxj handlePushMessage", res);
  333. if (res.type == 'click') { //unipush2.0在线推送 如果需要跳转app内指定页面,则自己实现下方的跳转代码。
  334. if (this.$isLogin()) {
  335. const pages = getCurrentPages();
  336. const url = pages[pages.length - 1];
  337. const isOnLaunch = uni.getStorageSync('onLaunch');
  338. // 判断前一个页面路径是一样
  339. const payloadData = JSON.parse(res.data.payload.data);
  340. const flag = pages && url.route && res.data.payload.url.indexOf(url.route);
  341. const isIM = payloadData.type != undefined && payloadData.type == 'im';
  342. if (isIM) {
  343. if (isOnLaunch && isOnLaunch == 1) {
  344. //offlineMsg=res.data.payload;
  345. uni.removeStorageSync('onLaunch');
  346. } else {
  347. uni.$u.throttle(() => that.notifyGoToChat(payloadData), 2000);
  348. }
  349. } else {
  350. if (isOnLaunch && isOnLaunch == 1) {
  351. uni.showLoading({
  352. title: '处理中..'
  353. });
  354. setTimeout(() => {
  355. uni.hideLoading();
  356. if (flag == -1) {
  357. uni.navigateTo({
  358. url: res.data.payload.url,
  359. success: function() {
  360. uni.removeStorageSync('openUrl');
  361. that.setReadAll(res.data.payload.url);
  362. }
  363. });
  364. } else {
  365. uni.redirectTo({
  366. url: res.data.payload.url,
  367. success: function() {
  368. uni.removeStorageSync('openUrl');
  369. that.setReadAll(res.data.payload.url);
  370. }
  371. });
  372. }
  373. }, 1000);
  374. } else {
  375. uni.hideLoading();
  376. if (flag == -1) {
  377. uni.navigateTo({
  378. url: res.data.payload.url,
  379. success: function() {
  380. uni.removeStorageSync('openUrl');
  381. that.setReadAll(res.data.payload.url);
  382. }
  383. });
  384. } else {
  385. uni.redirectTo({
  386. url: res.data.payload.url,
  387. success: function() {
  388. uni.removeStorageSync('openUrl');
  389. that.setReadAll(res.data.payload.url);
  390. }
  391. });
  392. }
  393. }
  394. }
  395. }
  396. }
  397. if (res.type == 'receive') { //监听在线推送消息,若云函数设置了 "force_notification":true,则不会触发此 receive。
  398. const pages = getCurrentPages();
  399. const url = pages[pages.length - 1];
  400. if (url && (url.route != "pages_im/pages/conversation/chating/index")) {
  401. // 检查应用是否在前台
  402. const appIsOnShow = uni.getStorageSync('appIsOnShow');
  403. //if(!!appIsOnShow){ // 应用在前台,处理消息但不显示通知
  404. uni.createPushMessage({
  405. title: res.data.title,
  406. content: res.data.content,
  407. payload: res.data.payload,
  408. when: new Date(),
  409. icon: "",
  410. sound: 'system', // 默认值为system
  411. category: res.data.category,
  412. success: () => {
  413. console.log('创建在线推送消息成功: ');
  414. this.$store.commit('newMsg/SET_UPDATATIME', new Date().getTime());
  415. },
  416. fail: (err) => {
  417. console.log('创建在线推送消息失败: ', err);
  418. }
  419. });
  420. //}
  421. plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
  422. if (widgetInfo.visible) {
  423. // 应用在前台,处理消息但不显示通知
  424. uni.createPushMessage({
  425. title: res.data.title,
  426. content: res.data.content,
  427. payload: res.data.payload,
  428. sound: 'system', // 默认值为system
  429. category: res.data.category,
  430. success: () => {
  431. console.log('创建在线推送消息成功: ');
  432. this.$store.commit('newMsg/SET_UPDATATIME', new Date()
  433. .getTime());
  434. },
  435. fail: (err) => {
  436. console.log('创建在线推送消息失败: ', err);
  437. }
  438. });
  439. } else {
  440. // 应用在后台,可以显示通知(如果需要)
  441. }
  442. });
  443. }
  444. }
  445. },
  446. // 处理Launch信息
  447. handlerLaunchMsg() {
  448. let that = this;
  449. // 监听通知点击事件
  450. plus.push.addEventListener('click', function(msg) { //unipush2.0 离线推送 (小米)
  451. let newServerMsg = msg.payload;
  452. offlineMsg = msg;
  453. });
  454. // 获取启动时的通知
  455. plus.push.getClientInfoAsync(function(info) { //unipush2.0连离线推送/点击桌面启动 (小米)
  456. console.log("qxj getClientInfoAsync", info);
  457. if (info.id && info.id == "unipush") { //unipush1.0 荣耀离线推送
  458. offlineMsg = info;
  459. }
  460. if (info.title && info.content && info.payload) {
  461. uni.switchTab({
  462. url: 'pages_im/pages/conversation/conversationList/index'
  463. });
  464. }
  465. if (info.launch && info.launch.payload) {
  466. let newServerMsg = info.launch.payload;
  467. console.log('应用通过通知启动:', info);
  468. uni.switchTab({
  469. url: 'pages_im/pages/conversation/conversationList/index'
  470. });
  471. //uni.$u.throttle(() => that.notifyGoToChat(newServerMsg), 1000);
  472. }
  473. }, function(err) {
  474. });
  475. },
  476. getSystemFontScale: function() {
  477. let scale = 1;
  478. if (uni.getSystemInfoSync) {
  479. let systemInfo = uni.getSystemInfoSync();
  480. if (systemInfo.fontSizeSetting) {
  481. scale = systemInfo.fontSizeSetting / 16; // 16 是默认字体大小
  482. }
  483. }
  484. return scale;
  485. },
  486. adjustFontSize: function() {
  487. let scale = this.getSystemFontScale();
  488. let rootElement = document.documentElement;
  489. rootElement.style.fontSize = 16 * scale + 'px';
  490. },
  491. setGlobalIMlistener() {
  492. const kickHander = (message) => {
  493. toastWithCallback(message, () => {
  494. uni.removeStorage({
  495. key: 'IMToken'
  496. });
  497. uni.removeStorage({
  498. key: 'BusinessToken'
  499. });
  500. callingModule?.endCall();
  501. meetingModule?.endCall();
  502. Igexin.unbindAlias(this.storeCurrentUserID);
  503. uni.$emit('loginOut');
  504. // uni.$u.route({url: "/pages/login/index",type: "redirect"});
  505. });
  506. };
  507. let that = this;
  508. IMSDK.subscribe(IMSDK.IMEvents.OnKickedOffline, (data) => {
  509. kickHander('您的账号在其他设备登录,请重新登录!');
  510. setTimeout(() => {
  511. uni.clearStorage()
  512. that.$logout();
  513. }, 1000)
  514. //that.removeImData();
  515. //that.openImLogin();
  516. });
  517. IMSDK.subscribe(IMSDK.IMEvents.OnUserTokenExpired, (data) => {
  518. kickHander('您的登录已过期,请重新登录!');
  519. setTimeout(() => {
  520. uni.clearStorage()
  521. that.$logout();
  522. }, 1000)
  523. //that.removeImData();
  524. //that.openImLogin();
  525. });
  526. IMSDK.subscribe(IMSDK.IMEvents.OnUserTokenInvalid, (data) => {
  527. kickHander('您的登录已无效,请重新登录!');
  528. setTimeout(() => {
  529. uni.clearStorage()
  530. that.$logout();
  531. }, 1000)
  532. //that.removeImData();
  533. //that.openImLogin();
  534. });
  535. // sync
  536. const syncStartHandler = ({
  537. data
  538. }) => {
  539. this.$store.commit('user/SET_IS_SYNCING', true);
  540. this.$store.commit('user/SET_REINSTALL', data);
  541. };
  542. const syncProgressHandler = ({
  543. data
  544. }) => {
  545. this.$store.commit('user/SET_PROGRESS', data);
  546. };
  547. const syncFinishHandler = () => {
  548. this.$store.dispatch('conversation/getConversationList');
  549. this.$store.dispatch('contact/getFriendList');
  550. this.$store.dispatch('contact/getGrouplist');
  551. this.$store.dispatch('conversation/getUnReadCount');
  552. this.$store.commit('user/SET_IS_SYNCING', false);
  553. if (offlineMsg != null) {
  554. uni.$u.throttle(() => this.notifyGoToChat(offlineHandleNewMsg), 500);
  555. }
  556. uni.hideLoading();
  557. };
  558. const syncFailedHandler = () => {
  559. uni.hideLoading();
  560. //uni.$u.toast('同步消息失败');
  561. this.$store.dispatch('conversation/getConversationList');
  562. this.$store.dispatch('conversation/getUnReadCount');
  563. this.$store.commit('user/SET_IS_SYNCING', false);
  564. };
  565. IMSDK.subscribe(IMSDK.IMEvents.OnSyncServerStart, syncStartHandler);
  566. IMSDK.subscribe(IMSDK.IMEvents.OnSyncServerFinish, syncFinishHandler);
  567. IMSDK.subscribe(IMSDK.IMEvents.OnSyncServerFailed, syncFailedHandler);
  568. IMSDK.subscribe(IMSDK.IMEvents.OnSyncServerProgress, syncProgressHandler);
  569. // self
  570. const selfInfoUpdateHandler = ({
  571. data
  572. }) => {
  573. this.$store.commit('user/SET_SELF_INFO', {
  574. ...this.storeSelfInfo,
  575. ...data
  576. });
  577. this.updateMessageNicknameAndFaceUrl({
  578. sendID: data.userID,
  579. senderNickname: data.nickname,
  580. senderFaceUrl: data.faceURL
  581. });
  582. };
  583. IMSDK.subscribe(IMSDK.IMEvents.OnSelfInfoUpdated, selfInfoUpdateHandler);
  584. // message
  585. const newMessagesHandler = ({
  586. data
  587. }) => {
  588. console.log("-----qxj newMessagesHandler:" + JSON.stringify(data));
  589. if (offlineMsg != null) {
  590. offlineHandleNewMsg = data[0];
  591. }
  592. if (this.storeIsSyncing) {
  593. return;
  594. }
  595. data.forEach(this.handleNewMessage);
  596. };
  597. const offlineMessageHandler = ({
  598. data
  599. }) => {
  600. console.log("-----qxj offlineMessageHandler:" + JSON.stringify(data));
  601. };
  602. const offlineMessagesHandler = ({
  603. data
  604. }) => {
  605. console.log("------offlineMessagesHandler:" + JSON.stringify(data));
  606. if (this.storeIsSyncing) {
  607. return;
  608. }
  609. data.forEach(this.handleOfflineMessages);
  610. };
  611. const c2cReadReceiptHandler = ({
  612. data: receiptList
  613. }) => {
  614. if (receiptList[0].userID !== this.storeCurrentConversation.userID) {
  615. return;
  616. }
  617. receiptList.forEach((item) => {
  618. item.msgIDList.forEach((msgID) => {
  619. this.updateOneMessage({
  620. message: {
  621. clientMsgID: msgID
  622. },
  623. type: UpdateMessageTypes.KeyWords,
  624. keyWords: {
  625. key: 'isRead',
  626. value: true
  627. }
  628. });
  629. });
  630. });
  631. };
  632. const groupReadReceiptHandler = ({
  633. data
  634. }) => {
  635. if (data.conversationID !== this.storeCurrentConversation.conversationID) {
  636. return;
  637. }
  638. data.groupMessageReadInfo.map((receipt) => {
  639. const oldMessage = this.storeHistoryMessageList.find((msg) => msg.clientMsgID ===
  640. receipt.clientMsgID);
  641. if (oldMessage) {
  642. uni.$emit(PageEvents.GroupMessageReceipt, receipt);
  643. const newMessage = {
  644. ...oldMessage,
  645. isRead: true,
  646. attachedInfoElem: {
  647. ...oldMessage.attachedInfoElem,
  648. groupHasReadInfo: {
  649. hasReadCount: receipt.hasReadCount,
  650. unreadCount: receipt.unreadCount
  651. }
  652. }
  653. };
  654. console.log(newMessage);
  655. this.updateOneMessage({
  656. message: newMessage
  657. });
  658. }
  659. });
  660. };
  661. const newRecvMessageRevokedHandler = ({
  662. data: revokedMessage
  663. }) => {
  664. if (!this.storeCurrentConversation.conversationID) {
  665. return;
  666. }
  667. this.updateOneMessage({
  668. message: {
  669. clientMsgID: revokedMessage.clientMsgID
  670. },
  671. type: UpdateMessageTypes.KeyWords,
  672. keyWords: [{
  673. key: 'contentType',
  674. value: MessageType.RevokeMessage
  675. },
  676. {
  677. key: 'notificationElem',
  678. value: {
  679. detail: JSON.stringify(revokedMessage)
  680. }
  681. }
  682. ]
  683. });
  684. this.updateQuoteMessageRevoke({
  685. clientMsgID: revokedMessage.clientMsgID
  686. });
  687. };
  688. const inputStatusChanged = ({
  689. data
  690. }) => {
  691. if (data.userID === this.storeCurrentConversation.userID && data.conversationID === this
  692. .storeCurrentConversation.conversationID) {
  693. if (data.platformIDs.length > 0) {
  694. uni.$emit(PageEvents.TypingUpdate);
  695. }
  696. }
  697. };
  698. IMSDK.subscribe(IMSDK.IMEvents.OnRecvOfflineNewMessage, offlineMessageHandler);
  699. IMSDK.subscribe(IMSDK.IMEvents.OnRecvOfflineNewMessages, offlineMessagesHandler);
  700. IMSDK.subscribe(IMSDK.IMEvents.OnRecvNewMessages, newMessagesHandler);
  701. IMSDK.subscribe("OnInputStatusChanged", inputStatusChanged);
  702. IMSDK.subscribe(IMSDK.IMEvents.OnRecvC2CReadReceipt, c2cReadReceiptHandler);
  703. IMSDK.subscribe(IMSDK.IMEvents.OnRecvGroupReadReceipt, groupReadReceiptHandler);
  704. IMSDK.subscribe(IMSDK.IMEvents.OnNewRecvMessageRevoked, newRecvMessageRevokedHandler);
  705. // friend
  706. const friendInfoChangeHandler = ({
  707. data
  708. }) => {
  709. uni.$emit(IMSDK.IMEvents.OnFriendInfoChanged, {
  710. data
  711. });
  712. if (data.userID === this.storeCurrentConversation?.userID) {
  713. this.updateMessageNicknameAndFaceUrl({
  714. sendID: data.userID,
  715. senderNickname: data.remark || data.nickname,
  716. senderFaceUrl: data.faceURL
  717. });
  718. this.$store.commit('conversation/SET_CURRENT_CONVERSATION', {
  719. ...this.storeCurrentConversation,
  720. showName: data.remark || data.nickname
  721. });
  722. }
  723. console.log(this.storeConversationList);
  724. this.updateFriendInfo({
  725. friendInfo: data
  726. });
  727. };
  728. const friendAddedHandler = ({
  729. data
  730. }) => {
  731. this.pushNewFriend(data);
  732. };
  733. const friendDeletedHander = ({
  734. data
  735. }) => {
  736. this.updateFriendInfo({
  737. friendInfo: data,
  738. isRemove: true
  739. });
  740. };
  741. IMSDK.subscribe(IMSDK.IMEvents.OnFriendInfoChanged, friendInfoChangeHandler);
  742. IMSDK.subscribe(IMSDK.IMEvents.OnFriendAdded, friendAddedHandler);
  743. IMSDK.subscribe(IMSDK.IMEvents.OnFriendDeleted, friendDeletedHander);
  744. // blacklist
  745. const blackAddedHandler = ({
  746. data
  747. }) => {
  748. this.pushNewBlack(data);
  749. };
  750. const blackDeletedHandler = ({
  751. data
  752. }) => {
  753. this.updateBlackInfo({
  754. blackInfo: data,
  755. isRemove: true
  756. });
  757. };
  758. IMSDK.subscribe(IMSDK.IMEvents.OnBlackAdded, blackAddedHandler);
  759. IMSDK.subscribe(IMSDK.IMEvents.OnBlackDeleted, blackDeletedHandler);
  760. // group
  761. const joinedGroupAddedHandler = ({
  762. data
  763. }) => {
  764. uni.$emit(IMSDK.IMEvents.OnJoinedGroupAdded, {
  765. data
  766. });
  767. this.pushNewGroup(data);
  768. };
  769. const joinedGroupDeletedHandler = ({
  770. data
  771. }) => {
  772. uni.$emit(IMSDK.IMEvents.OnJoinedGroupDeleted, {
  773. data
  774. });
  775. this.updateGroupInfo({
  776. groupInfo: data,
  777. isRemove: true
  778. });
  779. };
  780. const groupInfoChangedHandler = ({
  781. data
  782. }) => {
  783. this.updateGroupInfo({
  784. groupInfo: data
  785. });
  786. };
  787. const groupMemberInfoChangedHandler = ({
  788. data
  789. }) => {
  790. uni.$emit(IMSDK.IMEvents.OnGroupMemberInfoChanged, {
  791. data
  792. });
  793. if (data.groupID === this.storeCurrentConversation?.groupID) {
  794. this.updateMessageNicknameAndFaceUrl({
  795. sendID: data.userID,
  796. senderNickname: data.nickname,
  797. senderFaceUrl: data.faceURL
  798. });
  799. this.updateCurrentMemberInGroup(data);
  800. }
  801. };
  802. IMSDK.subscribe(IMSDK.IMEvents.OnJoinedGroupAdded, joinedGroupAddedHandler);
  803. IMSDK.subscribe(IMSDK.IMEvents.OnJoinedGroupDeleted, joinedGroupDeletedHandler);
  804. IMSDK.subscribe(IMSDK.IMEvents.OnGroupInfoChanged, groupInfoChangedHandler);
  805. IMSDK.subscribe(IMSDK.IMEvents.OnGroupMemberInfoChanged, groupMemberInfoChangedHandler);
  806. // application
  807. const friendApplicationNumHandler = ({
  808. data
  809. }) => {
  810. const isRecv = data.toUserID === this.storeCurrentUserID;
  811. if (isRecv) {
  812. this.pushNewRecvFriendApplition(data);
  813. } else {
  814. this.pushNewSentFriendApplition(data);
  815. }
  816. };
  817. const friendApplicationAccessHandler = ({
  818. data
  819. }) => {
  820. const isRecv = data.toUserID === this.storeCurrentUserID;
  821. if (isRecv) {
  822. this.updateRecvFriendApplition({
  823. application: data
  824. });
  825. } else {
  826. this.updateSentFriendApplition({
  827. application: data
  828. });
  829. }
  830. };
  831. const groupApplicationNumHandler = ({
  832. data
  833. }) => {
  834. const isRecv = data.userID !== this.storeCurrentUserID;
  835. if (isRecv) {
  836. this.pushNewRecvGroupApplition(data);
  837. } else {
  838. this.pushNewSentGroupApplition(data);
  839. }
  840. };
  841. const groupApplicationAccessHandler = ({
  842. data
  843. }) => {
  844. const isRecv = data.userID !== this.storeCurrentUserID;
  845. if (isRecv) {
  846. this.updateRecvGroupApplition({
  847. application: data
  848. });
  849. } else {
  850. this.updateSentGroupApplition({
  851. application: data
  852. });
  853. }
  854. };
  855. IMSDK.subscribe(IMSDK.IMEvents.OnFriendApplicationAdded, friendApplicationNumHandler);
  856. IMSDK.subscribe(IMSDK.IMEvents.OnFriendApplicationAccepted, friendApplicationAccessHandler);
  857. IMSDK.subscribe(IMSDK.IMEvents.OnFriendApplicationRejected, friendApplicationAccessHandler);
  858. IMSDK.subscribe(IMSDK.IMEvents.OnGroupApplicationAdded, groupApplicationNumHandler);
  859. IMSDK.subscribe(IMSDK.IMEvents.OnGroupApplicationAccepted, groupApplicationAccessHandler);
  860. IMSDK.subscribe(IMSDK.IMEvents.OnGroupApplicationRejected, groupApplicationAccessHandler);
  861. // conversation
  862. const totalUnreadCountChangedHandler = ({
  863. data
  864. }) => {
  865. if (this.storeIsSyncing) {
  866. return;
  867. }
  868. this.$store.commit('conversation/SET_UNREAD_COUNT', data);
  869. };
  870. const newConversationHandler = ({
  871. data
  872. }) => {
  873. console.log("qxj newConversationHandler");
  874. if (this.storeIsSyncing) {
  875. return;
  876. }
  877. const result = [...data, ...this.storeConversationList];
  878. this.$store.commit('conversation/SET_CONVERSATION_LIST', conversationSort(result));
  879. };
  880. const conversationChangedHandler = ({
  881. data
  882. }) => {
  883. if (this.storeIsSyncing) {
  884. return;
  885. }
  886. let filterArr = [];
  887. console.log("qxj conversationChangedHandler:::", data);
  888. const chids = data.map((ch) => ch.conversationID);
  889. filterArr = this.storeConversationList.filter((tc) => !chids.includes(tc.conversationID));
  890. const idx = data.findIndex((c) => c.conversationID === this.storeCurrentConversation
  891. .conversationID);
  892. if (idx !== -1) this.$store.commit('conversation/SET_CURRENT_CONVERSATION', data[idx]);
  893. const result = [...data, ...filterArr];
  894. this.$store.commit('conversation/SET_CONVERSATION_LIST', conversationSort(result));
  895. };
  896. IMSDK.subscribe(IMSDK.IMEvents.OnTotalUnreadMessageCountChanged, totalUnreadCountChangedHandler);
  897. IMSDK.subscribe(IMSDK.IMEvents.OnNewConversation, newConversationHandler);
  898. IMSDK.subscribe(IMSDK.IMEvents.OnConversationChanged, conversationChangedHandler);
  899. const insertInCurrentConversation = (newServerMsg) => {
  900. return newServerMsg.sendID === this.$store.getters.storeCurrentConversation.userID || newServerMsg
  901. .recvID === this.$store.getters.storeCurrentConversation.userID;
  902. };
  903. const onNativeCallEndHandler = async ({
  904. invitation,
  905. duration,
  906. status
  907. }) => {
  908. uni.$emit(PageEvents.NativeCallEnd);
  909. if (!status || invitation.groupID) {
  910. return;
  911. }
  912. const type = invitation.mediaType === 'video' ? CustomType.VideoCall : CustomType.VoiceCall;
  913. const customData = {
  914. customType: CustomType.Call,
  915. data: {
  916. type,
  917. duration: secFormat(duration),
  918. status
  919. }
  920. };
  921. const nativeCallList = uni.getStorageSync(
  922. `${this.$store.getters.storeCurrentUserID}_nativecall`) || [];
  923. const isSelf = invitation.inviterUserID === this.$store.getters.storeCurrentUserID;
  924. const data = {
  925. ...invitation,
  926. duration,
  927. isSelf,
  928. type,
  929. time: new Date().getTime()
  930. };
  931. uni.setStorage({
  932. key: `${this.$store.getters.storeCurrentUserID}_nativecall`,
  933. data: [...nativeCallList, data]
  934. });
  935. const message = await IMSDK.asyncApi(IMMethods.CreateCustomMessage, IMSDK.uuid(), {
  936. data: JSON.stringify(customData),
  937. extension: '',
  938. description: 'RTC'
  939. });
  940. const recvID = invitation.inviteeUserIDList[0];
  941. IMSDK.asyncApi(IMSDK.IMMethods.InsertSingleMessageToLocalStorage, IMSDK.uuid(), {
  942. message,
  943. recvID,
  944. sendID: invitation.inviterUserID
  945. }).then(({
  946. data
  947. }) => {
  948. if (insertInCurrentConversation(data)) {
  949. this.$store.dispatch('message/pushNewMessage', data);
  950. setTimeout(() => uni.$emit(PageEvents.ScrollToBottom, true));
  951. }
  952. }).catch((err) => {
  953. console.log(err);
  954. });
  955. };
  956. const onNativeInviteHandler = async (data) => {
  957. // uni.$u.toast("onNativeInviteHandler")
  958. uni.$u.route('/pages_im/pages/common/contactChoose/index', {
  959. type: ContactChooseTypes.InviteMeeting,
  960. forwardMessage: encodeURIComponent(JSON.stringify(data.data))
  961. });
  962. };
  963. IMSDK.subscribe('onNativeCallEnd', onNativeCallEndHandler);
  964. IMSDK.subscribe('Native_InviteUser', onNativeInviteHandler);
  965. },
  966. initOpenIm() {
  967. innerAudioContext = uni.createInnerAudioContext();
  968. innerAudioContext.autoplay = false;
  969. innerAudioContext.src = newMessage;
  970. // #ifdef APP-PLUS
  971. //Igexin.turnOnPush();
  972. //#endif
  973. this.setGlobalIMlistener();
  974. this.tryLogin();
  975. },
  976. openImLogin() {
  977. let that = this;
  978. var uid = "";
  979. var nickName = "";
  980. var avatar = "";
  981. if (this.$companyUserIsLogin()) {
  982. var user = JSON.parse(uni.getStorageSync('companyUser'));
  983. uid = 'C' + user.userId;
  984. nickName = user.imNickName || user.nickName || user.nickname;
  985. avatar = user.avatar;
  986. } else {
  987. var user = JSON.parse(uni.getStorageSync('userInfo'));
  988. uid = 'U' + user.userId;
  989. nickName = user.nickName || user.nickname;
  990. avatar = user.avatar;
  991. }
  992. if (this.$isEmpty(avatar)) {
  993. avatar =
  994. "https://fbylive.obs.cn-southwest-2.myhuaweicloud.com/app/appimgs/4e7c1c2de4b54ec4aaf1047394592a42.png";
  995. }
  996. let IMToken = uni.getStorageSync('IMToken');
  997. let IMUserID = uid;
  998. let reqData = {
  999. userID: uid,
  1000. nickName: nickName,
  1001. avatar: avatar
  1002. };
  1003. openImLoginApi(reqData, IMToken, IMUserID, function(token) {
  1004. setTimeout(() => {
  1005. that.tryLogin();
  1006. }, 100);
  1007. },
  1008. function() {
  1009. //uni.$u.toast('IM登录失败');
  1010. }
  1011. );
  1012. },
  1013. tryLogin() {
  1014. const initStore = () => {
  1015. this.$store.dispatch('user/initCache');
  1016. this.$store.dispatch('user/getSelfInfo');
  1017. this.$store.dispatch('conversation/getConversationList');
  1018. this.$store.dispatch('conversation/getUnReadCount');
  1019. // this.$store.dispatch("contact/getFriendList");
  1020. // this.$store.dispatch("contact/getGrouplist");
  1021. this.$store.dispatch('contact/getBlacklist');
  1022. this.$store.dispatch('contact/getRecvFriendApplications');
  1023. this.$store.dispatch('contact/getSentFriendApplications');
  1024. this.$store.dispatch('contact/getRecvGroupApplications');
  1025. this.$store.dispatch('contact/getSentGroupApplications');
  1026. // #ifdef APP-PLUS
  1027. //Igexin.bindAlias(IMUserID);
  1028. plus.navigator.closeSplashscreen();
  1029. // #endif
  1030. };
  1031. let IMToken = uni.getStorageSync('IMToken');
  1032. let IMUserID = uni.getStorageSync('IMUserID');
  1033. // #ifdef APP-PLUS
  1034. getDbDir().then(async (path) => {
  1035. let platformID = uni.$u.os() === 'ios' ? 1 : 2;
  1036. const flag = await IMSDK.asyncApi(IMMethods.InitSDK, IMSDK.uuid(), {
  1037. systemType: 'uni-app',
  1038. platformID: platformID,
  1039. apiAddr: config.getApiUrl(),
  1040. wsAddr: config.getWsUrl(),
  1041. dataDir: path, // 数据存储路径
  1042. logLevel: 1,
  1043. logFilePath: path,
  1044. isLogStandardOutput: false // 是否输出到控制台
  1045. });
  1046. if (!flag) {
  1047. // #ifdef APP-PLUS
  1048. plus.navigator.closeSplashscreen();
  1049. // #endif
  1050. uni.$u.toast('初始化IMSDK失败!');
  1051. return;
  1052. }
  1053. //1 未登录 2 登录中 3 已登录
  1054. const loginStatus = await IMSDK.asyncApi(IMSDK.IMMethods.GetLoginStatus, IMSDK.uuid());
  1055. if (loginStatus === 3) {
  1056. initStore();
  1057. return;
  1058. }
  1059. callingModule?.initModule();
  1060. if (IMToken && IMUserID) {
  1061. await IMSDK.asyncApi(IMSDK.IMMethods.Login, IMSDK.uuid(), {
  1062. userID: IMUserID,
  1063. token: IMToken,
  1064. }).then(initStore).catch((err) => {
  1065. console.log('qxj initStore err:' + JSON.stringify(err));
  1066. uni.$u.toast('初始化IMSDK异常:' + JSON.stringify(err));
  1067. uni.removeStorage({
  1068. key: 'IMToken'
  1069. });
  1070. // #ifdef APP-PLUS
  1071. plus.navigator.closeSplashscreen();
  1072. // #endif
  1073. });
  1074. } else {
  1075. if (this.$isLogin()) {
  1076. this.openImLogin();
  1077. }
  1078. // #ifdef APP-PLUS
  1079. plus.navigator.closeSplashscreen();
  1080. // #endif
  1081. }
  1082. }).catch((err) => {
  1083. console.log('get dir failed');
  1084. console.log(err);
  1085. // #ifdef APP-PLUS
  1086. plus.navigator.closeSplashscreen();
  1087. // #endif
  1088. });
  1089. // #endif
  1090. // #ifdef H5
  1091. if (IMToken && IMUserID) {
  1092. IMSDK.asyncApi(IMSDK.IMMethods.Login, IMSDK.uuid(), {
  1093. userID: IMUserID,
  1094. token: IMToken,
  1095. platformID: 5,
  1096. logLevel: 3,
  1097. apiAddr: config.getApiUrl(),
  1098. wsAddr: config.getWsUrl(),
  1099. }).then(initStore).catch((err) => {
  1100. uni.removeStorage({
  1101. key: 'IMToken'
  1102. });
  1103. });
  1104. } else {
  1105. if (this.$isLogin()) {
  1106. this.openImLogin();
  1107. }
  1108. }
  1109. // #endif
  1110. },
  1111. async newMessageNotify(newServerMsg) {
  1112. if (this.storeIsSyncing) {
  1113. return;
  1114. }
  1115. console.log("qxj newMessageNotify1");
  1116. const disableNotify = uni.getStorageSync(`${this.storeCurrentUserID}_DisableNotify`);
  1117. if (disableNotify || this.storeSelfInfo.globalRecvMsgOpt !== MessageReceiveOptType.Nomal) {
  1118. return;
  1119. }
  1120. console.log("qxj newMessageNotify2");
  1121. let cveItem = [...this.storeConversationList, ...cacheConversationList].find((conversation) => {
  1122. if (newServerMsg.sessionType === SessionType.WorkingGroup) {
  1123. return newServerMsg.groupID === conversation.groupID;
  1124. }
  1125. return newServerMsg.sendID === conversation.userID;
  1126. });
  1127. console.log("qxj newMessageNotify3");
  1128. if (!cveItem) {
  1129. try {
  1130. const {
  1131. data
  1132. } = await IMSDK.asyncApi(IMSDK.IMMethods.GetOneConversation, IMSDK.uuid(), {
  1133. sourceID: newServerMsg.groupID || newServerMsg.sendID,
  1134. sessionType: newServerMsg.sessionType
  1135. });
  1136. cveItem = data;
  1137. cacheConversationList = [...cacheConversationList, data];
  1138. } catch (e) {
  1139. return;
  1140. }
  1141. }
  1142. console.log("qxj newMessageNotify4");
  1143. if (cveItem.recvMsgOpt !== MessageReceiveOptType.Nomal) {
  1144. return;
  1145. }
  1146. console.log("qxj newMessageNotify5");
  1147. const notificationFun = () => {
  1148. const isSelf = newServerMsg.sendID === this.$store.getters.storeCurrentUserID;
  1149. if (isSelf) return;
  1150. const pages = getCurrentPages();
  1151. const url = pages[pages.length - 1];
  1152. console.log("qxj route:" + url.route);
  1153. if (url && (url.route == "pages_im/pages/conversation/conversationList/index" ||
  1154. url.route == "pages_im/pages/conversation/chating/index")) {
  1155. return;
  1156. }
  1157. // uni.createPushMessage({
  1158. // content: `${newServerMsg.senderNickname}: ${parseMessageByType(newServerMsg)}`,
  1159. // payload: {
  1160. // sessionType: newServerMsg.sessionType,
  1161. // sourceID: newServerMsg.groupID || newServerMsg.sendID,
  1162. // }
  1163. // });
  1164. const isSingle = newServerMsg.groupID ? false : true;
  1165. console.log(this.storeGroupList, newServerMsg);
  1166. const group = this.storeGroupList.filter((group) => group.groupID === newServerMsg.groupID);
  1167. const title = isSingle ? newServerMsg.senderNickname : group[0].groupName;
  1168. const desc = parseMessageByType(newServerMsg);
  1169. console.log('notification', title, desc);
  1170. // notificationIntance = new NotificationUtil();
  1171. // let tickerTips="通知提示";
  1172. // let notifyId=10001;
  1173. // let config={ title, desc,tickerTips,notifyId };
  1174. // notificationIntance.createNotification(config);
  1175. // setTimeout(()=>{
  1176. // notificationIntance.clearNotification(10001);
  1177. // },10000);
  1178. // notification.showNotice(0, title, desc, () => {
  1179. // prepareConversationState(cveItem);
  1180. // });
  1181. };
  1182. //notificationFun();
  1183. const platform = uni.getSystemInfoSync().platform;
  1184. if (platform == 'ios') {
  1185. if (this.storeSelfInfo.allowVibration === 1) {
  1186. plus.device.vibrate();
  1187. }
  1188. if (this.storeSelfInfo.allowBeep === 1) {
  1189. innerAudioContext.play();
  1190. // plus.device.beep();
  1191. }
  1192. } else if (platform == 'android') {
  1193. if (this.storeSelfInfo.allowVibration === 1) {
  1194. plus.device.vibrate(500);
  1195. }
  1196. if (this.storeSelfInfo.allowBeep === 1) {
  1197. let main = plus.android.runtimeMainActivity();
  1198. let RingtoneManager = plus.android.importClass('android.media.RingtoneManager');
  1199. let uri = RingtoneManager.getActualDefaultRingtoneUri(main, RingtoneManager.TYPE_NOTIFICATION);
  1200. let MediaPlayer = plus.android.importClass('android.media.MediaPlayer');
  1201. let player = MediaPlayer.create(main, uri);
  1202. player.setLooping(false);
  1203. player.prepare();
  1204. player.start();
  1205. }
  1206. }
  1207. },
  1208. async notifyGoToChat(newServerMsg) {
  1209. if (this.storeIsSyncing) {
  1210. return;
  1211. }
  1212. offlineHandleNewMsg = null;
  1213. offlineMsg = null;
  1214. const disableNotify = uni.getStorageSync(`${this.storeCurrentUserID}_DisableNotify`);
  1215. if (disableNotify || this.storeSelfInfo.globalRecvMsgOpt !== MessageReceiveOptType.Nomal) {
  1216. return;
  1217. }
  1218. let cveItem = [...this.storeConversationList, ...cacheConversationList].find((conversation) => {
  1219. if (newServerMsg.sessionType === SessionType.WorkingGroup) {
  1220. return newServerMsg.groupID === conversation.groupID;
  1221. }
  1222. return newServerMsg.sendID === conversation.userID;
  1223. });
  1224. if (!cveItem) {
  1225. try {
  1226. const {
  1227. data
  1228. } = await IMSDK.asyncApi(IMSDK.IMMethods.GetOneConversation, IMSDK.uuid(), {
  1229. sourceID: newServerMsg.groupID || newServerMsg.sendID,
  1230. sessionType: newServerMsg.sessionType
  1231. });
  1232. cveItem = data;
  1233. cacheConversationList = [...cacheConversationList, data];
  1234. } catch (e) {
  1235. return;
  1236. }
  1237. }
  1238. if (cveItem.recvMsgOpt !== MessageReceiveOptType.Nomal) {
  1239. return;
  1240. }
  1241. const isSelf = newServerMsg.sendID === this.$store.getters.storeCurrentUserID;
  1242. if (isSelf) return;
  1243. const pages = getCurrentPages();
  1244. const url = pages[pages.length - 1];
  1245. if (url && (url.route == "pages_im/pages/conversation/chating/index")) {
  1246. return;
  1247. }
  1248. this.handlerConversation(cveItem);
  1249. prepareConversationState(cveItem);
  1250. },
  1251. handlerConversation(source) {
  1252. let userId = source.userID;
  1253. let isDoctor = false;
  1254. if (userId != undefined && (userId != "" || userId.length > 0)) {
  1255. if (userId.indexOf('D') !== -1) {
  1256. isDoctor = true;
  1257. }
  1258. }
  1259. if (this.$companyUserIsLogin() || !isDoctor) {
  1260. this.$store.commit("timStore/setImType", 1);
  1261. } else {
  1262. let ex = source.ex;
  1263. if (source.latestMsg != null && source.latestMsg != '') {
  1264. let latestMsg = JSON.parse(source.latestMsg);
  1265. if (!!latestMsg.ex && latestMsg.ex != '') {
  1266. ex = latestMsg.ex;
  1267. }
  1268. }
  1269. if (ex != null || ex != '') {
  1270. try {
  1271. var json = JSON.parse(ex);
  1272. this.$store.commit("timStore/setImType", json.imType);
  1273. this.$store.commit("timStore/setOrderType", json.orderType);
  1274. this.$store.commit("timStore/setOrderId", json.orderId);
  1275. this.$store.commit("timStore/setFollowId", json.followId);
  1276. this.$store.commit("timStore/setType", json.type);
  1277. } catch (e) {
  1278. }
  1279. }
  1280. }
  1281. this.$store.commit("timStore/setConversationID", source.conversationID);
  1282. },
  1283. handleNewMessage(newServerMsg) {
  1284. console.log("---qxj newServerMsg", newServerMsg);
  1285. if (this.inCurrentConversation(newServerMsg)) {
  1286. console.log("---qxj inCurrentConversation");
  1287. const isSingleMessage = newServerMsg.sessionType === SessionType.Single;
  1288. if (isSingleMessage) {
  1289. uni.$u.throttle(() => uni.$emit(PageEvents.OnlineStateCheck), 2000);
  1290. if (newServerMsg.ex != null && newServerMsg.ex != '') {
  1291. var json = JSON.parse(newServerMsg.ex);
  1292. this.$store.commit("timStore/setType", json.type);
  1293. this.$store.commit("timStore/setImType", json.imType);
  1294. this.$store.commit("timStore/setOrderId", json.orderId);
  1295. this.$store.commit("timStore/setOrderType", json.orderType);
  1296. this.$store.commit("timStore/setFollowId", json.followId);
  1297. if (json.type === "finishInquiry") {
  1298. this.$store.commit("timStore/setImType", 0);
  1299. uni.navigateTo({
  1300. url: "/pages_order/pingOrder?orderId=" + json.orderId
  1301. })
  1302. } else if (json.type === "startInquiry") {
  1303. } else if (json.type === "inquiry") {
  1304. } else if (json.type === "startFollow") {
  1305. } else if (json.type === "follow") {
  1306. } else if (json.type === "finishFollow") {
  1307. } else if (json.type === "startDrugReport") {
  1308. } else if (json.type === "finishDrugReport") {
  1309. } else if (json.type === "drugReport") {
  1310. }
  1311. }
  1312. }
  1313. if (newServerMsg.contentType === MessageType.TypingMessage) {
  1314. if (isSingleMessage) {
  1315. uni.$emit(PageEvents.TypingUpdate);
  1316. }
  1317. } else {
  1318. if (newServerMsg.contentType === MessageType.RevokeMessage) {
  1319. } else {
  1320. newServerMsg.isAppend = true;
  1321. this.pushNewMessage(newServerMsg);
  1322. setTimeout(() => uni.$emit(PageEvents.ScrollToBottom, true));
  1323. }
  1324. uni.$u.debounce(this.markConversationAsRead, 2000);
  1325. }
  1326. } else {
  1327. if (newServerMsg.contentType !== MessageType.TypingMessage) {
  1328. uni.$u.throttle(() => this.newMessageNotify(newServerMsg), 1000);
  1329. setTimeout(() => {
  1330. this.$store.dispatch('conversation/getUnReadCount');
  1331. }, 500);
  1332. }
  1333. }
  1334. },
  1335. handleOfflineMessages(newServerMsg) { //后台运行
  1336. const isSingle = newServerMsg.groupID ? false : true;
  1337. console.log(this.storeGroupList, newServerMsg);
  1338. const group = this.storeGroupList.filter((group) => group.groupID === newServerMsg.groupID);
  1339. const title = isSingle ? newServerMsg.senderNickname : group[0].groupName;
  1340. const desc = parseMessageByType(newServerMsg);
  1341. // if(notification){
  1342. // notification.showNotice(0, title, desc, () => {
  1343. // console.log('qxj showNotice:', title);
  1344. // //prepareConversationState(cveItem);
  1345. // });
  1346. // }
  1347. // const options = {
  1348. // title: title,
  1349. // content: desc,
  1350. // payload: newServerMsg, // 自定义参数,点击通知时传递给应用
  1351. // sound: 'default', // 通知声音
  1352. // cover: false, // 是否覆盖之前的通知
  1353. // //when: new Date(),
  1354. // icon:"",
  1355. // extras: {
  1356. // android: {
  1357. // importance: "high", // 高优先级
  1358. // channelId: "sticky_channel", // 必须配置通知渠道
  1359. // smallIcon: "transparent",
  1360. // showWhen: false,
  1361. // }
  1362. // }
  1363. // };
  1364. // plus.push.createMessage(options.content, options.payload, options);
  1365. // let when=new Date();
  1366. // uni.createPushMessage({
  1367. // title:title,
  1368. // content:desc,
  1369. // payload: newServerMsg,
  1370. // cover: false, // 是否覆盖之前的通知
  1371. // when: new Date()
  1372. // });
  1373. },
  1374. inCurrentConversation(newServerMsg) {
  1375. switch (newServerMsg.sessionType) {
  1376. case SessionType.Single:
  1377. return (
  1378. newServerMsg.sendID === this.storeCurrentConversation.userID ||
  1379. (newServerMsg.sendID === this.storeCurrentUserID && newServerMsg.recvID === this
  1380. .storeCurrentConversation.userID)
  1381. );
  1382. case SessionType.WorkingGroup:
  1383. return newServerMsg.groupID === this.storeCurrentConversation.groupID;
  1384. case SessionType.Notification:
  1385. return newServerMsg.sendID === this.storeCurrentConversation.userID;
  1386. default:
  1387. return false;
  1388. }
  1389. },
  1390. markConversationAsRead() {
  1391. IMSDK.asyncApi(IMSDK.IMMethods.MarkConversationMessageAsRead, IMSDK.uuid(), this.storeCurrentConversation
  1392. .conversationID);
  1393. },
  1394. removeImData() {
  1395. uni.removeStorage({
  1396. key: 'IMToken'
  1397. });
  1398. uni.removeStorage({
  1399. key: 'IMUserID'
  1400. });
  1401. },
  1402. async cidBindAlias(alias) {
  1403. let registrationID = uni.getStorageSync("registrationID");
  1404. let params = [{
  1405. "cid": registrationID,
  1406. "alias": alias
  1407. }];
  1408. console.log("qxj cidBindAlias params:" + JSON.stringify(params));
  1409. await uniPush.cidBindAlias(params);
  1410. },
  1411. runTimer() {
  1412. let that = this;
  1413. let dateNowDay = this.$dateFormatStr('YYYY-mm-dd', new Date());
  1414. let healthButler = uni.getStorageSync('healthButler');
  1415. let userInfo = uni.getStorageSync('userInfo');
  1416. console.log('------qxj dateStr:' + dateNowDay + ' healthButler:' + healthButler);
  1417. let dayNum = 0;
  1418. if (userInfo != null && userInfo.isAddQw) {
  1419. //已加过企微不在弹窗
  1420. return;
  1421. }
  1422. if (!!healthButler) {
  1423. healthButler = JSON.parse(healthButler);
  1424. dayNum = healthButler.dayNum;
  1425. if (healthButler.day == dateNowDay) {
  1426. //今天已经弹窗过 防止再弹窗
  1427. return;
  1428. }
  1429. }
  1430. if (dayNum == 0) {
  1431. //第一天下载App
  1432. if (this.$qconfig.healthTimer == null) {
  1433. this.$qconfig.healthTimer = setInterval(() => {
  1434. if (this.$qconfig.healthSeconds == healthSeconds) {
  1435. this.$qconfig.healthSeconds = 0;
  1436. healthButlerPop(function(data) {
  1437. if (data == 1) {
  1438. that.bdAdvFeedback();
  1439. clearInterval(that.$qconfig.healthTimer);
  1440. } else {
  1441. that.resetTimer();
  1442. that.$showLoginPage();
  1443. }
  1444. });
  1445. }
  1446. this.$qconfig.healthSeconds++;
  1447. //console.log("healthTimer tSeconds:"+this.$qconfig.healthSeconds);
  1448. }, 1000);
  1449. }
  1450. } else {
  1451. //第二天,第三天,,
  1452. healthButlerPop(function(data) {
  1453. if (data == 1) {
  1454. clearInterval(that.$qconfig.healthTimer);
  1455. } else {
  1456. that.$showLoginPage();
  1457. }
  1458. });
  1459. }
  1460. },
  1461. resetTimer() {
  1462. clearInterval(this.$qconfig.healthTimer);
  1463. this.$qconfig.healthTimer = null; //重置定时器
  1464. this.$qconfig.healthSeconds = healthSeconds;
  1465. },
  1466. getUserInfo(healthButler) {
  1467. getUserInfo().then((res) => {
  1468. if (res.code == 200) {
  1469. if (res.user != null) {
  1470. uni.setStorageSync('userInfo', JSON.stringify(res.user));
  1471. let userInfo = res.user;
  1472. healthButler.isAddQw = userInfo.isAddQw;
  1473. uni.setStorageSync('healthButler', JSON.stringify(healthButler));
  1474. }
  1475. }
  1476. },
  1477. (rej) => {}
  1478. );
  1479. },
  1480. jumpToNotificationSettings() {
  1481. uni.request({
  1482. url: 'content://settings/action/notification_settings',
  1483. success: function(res) {
  1484. console.log('跳转成功:', res);
  1485. },
  1486. fail: function(err) {
  1487. console.log('跳转失败:', err);
  1488. }
  1489. });
  1490. },
  1491. bdAdvFeedback() {
  1492. // #ifdef APP-PLUS
  1493. if (plus.runtime.isAgreePrivacy()) {
  1494. if (plus.runtime.channel == 'baidu') {
  1495. let bdCmdType = uni.getStorageSync('bdCmdType');
  1496. if (this.$isEmpty(bdCmdType)) {
  1497. this.$registerIdCode('goToQw', 4, 0);
  1498. }
  1499. }
  1500. }
  1501. // #endif
  1502. },
  1503. async checkPush1() {
  1504. let result = await premissionCheck("PUSH");
  1505. if (result == 1) {
  1506. }
  1507. // uPushPlugin.setCustomPushChannel({
  1508. // soundName: "",
  1509. // channelId: "133898",
  1510. // channelDesc:"看课提醒",
  1511. // enableLights:true,
  1512. // enableVibration:true,
  1513. // importance:4,
  1514. // lockscreenVisibility:1
  1515. // });
  1516. // uPushPlugin.getAllChannels((p) => {
  1517. // console.log("qxj push channels :" + JSON.stringify(p));//返回数组
  1518. // });
  1519. // const manager = uni.getChannelManager()
  1520. // manager.setPushChannel({
  1521. // "channelId":"Push",
  1522. // "channelDesc":"消息推送",
  1523. // "enableLights":true,
  1524. // "importance":4,
  1525. // "lockscreenVisibility":1
  1526. // //soundName: "pushsound" // 已经把声音文件存储到/res/raw/pushsound.mp3
  1527. // });
  1528. },
  1529. async checkPush() {
  1530. //检测是否开启推送通知
  1531. const notificationAuthorized = uni.getAppAuthorizeSetting().notificationAuthorized;
  1532. if (notificationAuthorized == 'denied') {
  1533. uni.showModal({
  1534. title: '提示',
  1535. content: '是否前往打开通知权限',
  1536. success: (res) => {
  1537. if (res.confirm) {
  1538. let status = this.checkPermission();
  1539. if (status !== 1) {
  1540. console.log('未开启权限');
  1541. }
  1542. } else if (res.cancel) {
  1543. console.log('用户点击取消');
  1544. }
  1545. }
  1546. });
  1547. }
  1548. },
  1549. async checkPermission() {
  1550. let status = permision1.isIOS ? await permision1.requestIOS('push') :
  1551. await permision1.requestAndroid('android.permission.REQUEST_NOTIFICATION_POLICY');
  1552. if (status === null || status === 1) {
  1553. status = 1;
  1554. } else if (status === 2) {
  1555. uni.showModal({
  1556. content: '系统通知已关闭',
  1557. confirmText: '确定',
  1558. showCancel: false,
  1559. success: function(res) {}
  1560. });
  1561. } else if (status.code) {
  1562. uni.showModal({
  1563. content: status.message
  1564. });
  1565. } else {
  1566. uni.showModal({
  1567. content: '需要通知权限',
  1568. confirmText: '设置',
  1569. success: function(res) {
  1570. if (res.confirm) {
  1571. permision1.gotoAppSetting();
  1572. }
  1573. }
  1574. });
  1575. }
  1576. return status;
  1577. },
  1578. geth5Path() {
  1579. this.handlePushMessage()
  1580. getRealLinkDomainName().then((res) => {
  1581. if (res.code == 200) {
  1582. uni.setStorageSync('h5Path', res.data);
  1583. }
  1584. });
  1585. },
  1586. handlePushMessage(res) {
  1587. const that = this;
  1588. if (res.type == 'click') {
  1589. // 如果需要跳转app内指定页面,则自己实现下方的跳转代码。
  1590. if (this.$isLogin()) {
  1591. const pages = getCurrentPages();
  1592. const url = pages[pages.length - 1];
  1593. const isOnLaunch = uni.getStorageSync('onLaunch');
  1594. // 判断前一个页面路径是一样
  1595. const flag = pages && url.route && res.data.payload.url.indexOf(url.route);
  1596. // console.log("点击===========",url.route,flag)
  1597. if (isOnLaunch && isOnLaunch == 1) {
  1598. uni.hideLoading({
  1599. title: '处理中..'
  1600. });
  1601. setTimeout(() => {
  1602. uni.hideLoading();
  1603. if (flag == -1) {
  1604. uni.navigateTo({
  1605. url: res.data.payload.url,
  1606. success: function() {
  1607. uni.removeStorageSync('openUrl');
  1608. that.setReadAll(res.data.payload.url);
  1609. }
  1610. });
  1611. } else {
  1612. uni.redirectTo({
  1613. url: res.data.payload.url,
  1614. success: function() {
  1615. uni.removeStorageSync('openUrl');
  1616. that.setReadAll(res.data.payload.url);
  1617. }
  1618. });
  1619. }
  1620. }, 1000);
  1621. } else {
  1622. uni.hideLoading();
  1623. if (flag == -1) {
  1624. uni.navigateTo({
  1625. url: res.data.payload.url,
  1626. success: function() {
  1627. uni.removeStorageSync('openUrl');
  1628. that.setReadAll(res.data.payload.url);
  1629. }
  1630. });
  1631. } else {
  1632. uni.redirectTo({
  1633. url: res.data.payload.url,
  1634. success: function() {
  1635. uni.removeStorageSync('openUrl');
  1636. that.setReadAll(res.data.payload.url);
  1637. }
  1638. });
  1639. }
  1640. }
  1641. }
  1642. } else if (res.type == 'receive') {
  1643. //监听在线推送消息,若云函数设置了 "force_notification":true,则不会触发此 receive。
  1644. }
  1645. },
  1646. // 系统通知全部已读
  1647. setReadAll(url) {
  1648. if (url && url.indexOf('/pages/courseAnswer/index') == -1) {
  1649. getPushLogRead([]).then((res) => {
  1650. if (res.code == 200) {
  1651. this.$updateMsgDot();
  1652. }
  1653. });
  1654. }
  1655. },
  1656. // 获取剪贴板内容跳转到看课
  1657. getClipboardData() {
  1658. // #ifdef APP-PLUS
  1659. const course = {};
  1660. coursePopup(course, () => {
  1661. // uni.getClipboardData({
  1662. // success: function (res) {
  1663. // console.log("res.data===",res);
  1664. // let Context = plus.android.importClass("android.content.Context");
  1665. // let main = plus.android.runtimeMainActivity();
  1666. // let clip = main.getSystemService(Context.CLIPBOARD_SERVICE);
  1667. // plus.android.invoke(clip,"setText","");
  1668. // }
  1669. // });
  1670. });
  1671. // #endif
  1672. },
  1673. getRuntimePlatform() {
  1674. const systemInfo = uni.getSystemInfoSync();
  1675. const compilePlatform = process.env.UNI_PLATFORM;
  1676. //1:iOS,2:Android,3:Windows,4:OSX,5:WEB,6:小程序,7:linux,8:AndroidPad,9:IPad,10:Admin
  1677. let platformType = 5;
  1678. // H5 环境
  1679. if (compilePlatform === 'h5') platformType = 5;
  1680. // 小程序环境
  1681. if (compilePlatform.startsWith('mp-')) {
  1682. const mpType = compilePlatform.split('-')[1]; // 如 weixin/alipay
  1683. platformType = 6;
  1684. // return `小程序(${mpType})- ${systemInfo.platform}`;
  1685. }
  1686. // App 环境
  1687. if (compilePlatform === 'app-plus') {
  1688. if (systemInfo.platform.toLowerCase() === 'android') {
  1689. platformType = 2;
  1690. }
  1691. if (systemInfo.platform.toLowerCase() === 'ios') {
  1692. platformType = 1;
  1693. }
  1694. }
  1695. return platformType;
  1696. },
  1697. /* 检查更新 在线更新 */
  1698. checkUpdateApp() {
  1699. //uni wgt包版本检测更新
  1700. checkUpdate();
  1701. let that = this;
  1702. plus.runtime.getProperty(plus.runtime.appid, function(widgetinfo) {
  1703. if (widgetinfo.name == qconfig.appName) {
  1704. let platform = uni.getSystemInfoSync().platform;
  1705. let isAndroid = platform == 'android';
  1706. let type = isAndroid ? 1 : 2;
  1707. getAppVersion(type).then((srcData) => {
  1708. if (srcData.code == 200) {
  1709. let data = srcData.data;
  1710. let version = widgetinfo.versionCode, //用户当前app版本
  1711. appVersion = data.versionCode, //升级包版本
  1712. appName = widgetinfo.name, //app名称
  1713. isForce = data.isForce, //是否强制热更新
  1714. updateConfig = JSON.parse(data.updateConfig),
  1715. appurl = data.url, //升级包地址
  1716. intro = data.note; //升级包提示
  1717. //如果用户版本号小于升级包版本号,先升级
  1718. let afterVer = false;
  1719. if (plus.runtime.channel == 'baidu') {
  1720. afterVer = that.$qconfig.isAppStore ? updateConfig.baidu : false;
  1721. } else if (plus.runtime.channel == 'huawei') {
  1722. afterVer = that.$qconfig.isAppStore ? updateConfig.huawei : false;
  1723. } else if (plus.runtime.channel == 'xiaomi') {
  1724. afterVer = that.$qconfig.isAppStore ? updateConfig.xiaomi : false;
  1725. } else if (plus.runtime.channel == 'yyb') {
  1726. afterVer = that.$qconfig.isAppStore ? updateConfig.yyb : false;
  1727. } else {
  1728. afterVer = that.$qconfig.isAppStore ? isForce : true;
  1729. }
  1730. if (data && version < appVersion && afterVer) {
  1731. uni.showModal({
  1732. title: '更新提示',
  1733. confirmText: '立即升级',
  1734. content: intro,
  1735. cancelText: '确定',
  1736. confirmText: '取消',
  1737. success: (res) => {
  1738. if (res.cancel) {
  1739. openDownload(srcData.data);
  1740. } else if (res.confirm) {
  1741. if (isForce == 1) {
  1742. uni.showToast({
  1743. title: '请先升级APP版本',
  1744. icon: 'none',
  1745. duration: 2000
  1746. });
  1747. //退出app
  1748. setTimeout(function() {
  1749. plus.runtime.quit();
  1750. }, 2000);
  1751. }
  1752. }
  1753. },
  1754. fail: () => {
  1755. uni.hideLoading();
  1756. }
  1757. });
  1758. }
  1759. }
  1760. },
  1761. (rej) => {}
  1762. )
  1763. .catch(() => {
  1764. //联网失败, 结束加载
  1765. this.mescroll.endErr();
  1766. });
  1767. }
  1768. });
  1769. }
  1770. },
  1771. watch: {
  1772. storeCurrentUserID(newVal) {
  1773. if (newVal) {
  1774. cacheConversationList = [];
  1775. }
  1776. },
  1777. contactBadgeRely: {
  1778. handler(newValue) {
  1779. const {
  1780. recvFriendApplications,
  1781. recvGroupApplications,
  1782. userKey
  1783. } = newValue;
  1784. if (!userKey) return;
  1785. const accessedFriendApplications = uni.getStorageSync(`${userKey}_accessedFriendApplications`) || [];
  1786. let unHandleFriendApplicationNum = recvFriendApplications.filter(
  1787. (application) => application.handleResult === 0 && !accessedFriendApplications.includes(
  1788. `${application.fromUserID}_${application.createTime}`)
  1789. ).length;
  1790. const accessedGroupApplications = uni.getStorageSync(`${userKey}_accessedGroupApplications`) || [];
  1791. let unHandleGroupApplicationNum = recvGroupApplications.filter(
  1792. (application) => application.handleResult === 0 && !accessedGroupApplications.includes(
  1793. `${application.userID}_${application.createTime}`)
  1794. ).length;
  1795. const total = unHandleFriendApplicationNum + unHandleGroupApplicationNum;
  1796. if (total) {
  1797. uni.setTabBarBadge({
  1798. index: 0,
  1799. text: total < 99 ? total + '' : '99+'
  1800. });
  1801. } else {
  1802. uni.removeTabBarBadge({
  1803. index: 0
  1804. });
  1805. }
  1806. this.$store.commit('contact/SET_UNHANDLE_FRIEND_APPLICATION_NUM', unHandleFriendApplicationNum);
  1807. this.$store.commit('contact/SET_UNHANDLE_GROUP_APPLICATION_NUM', unHandleGroupApplicationNum);
  1808. },
  1809. deep: true
  1810. }
  1811. }
  1812. };
  1813. </script>
  1814. <style lang="scss">
  1815. /*每个页面公共css */
  1816. @import '@/uni_modules/uview-plus/index.scss';
  1817. /*#ifndef APP-NVUE*/
  1818. view {
  1819. box-sizing: border-box;
  1820. }
  1821. .ellipsis {
  1822. overflow: hidden;
  1823. text-overflow: ellipsis;
  1824. white-space: nowrap;
  1825. }
  1826. .ellipsis2 {
  1827. overflow: hidden;
  1828. text-overflow: ellipsis;
  1829. display: -webkit-box;
  1830. -webkit-box-orient: vertical;
  1831. -webkit-line-clamp: 2;
  1832. }
  1833. uni-modal {
  1834. z-index: 1100;
  1835. }
  1836. // 猜你喜欢样式
  1837. .like-box {
  1838. display: flex;
  1839. align-items: center;
  1840. justify-content: center;
  1841. image {
  1842. height: 40upx;
  1843. width: 40upx;
  1844. }
  1845. .text {
  1846. font-size: 28upx;
  1847. color: #000;
  1848. font-weight: bold;
  1849. margin: 0 10upx;
  1850. }
  1851. }
  1852. .no-data-box {
  1853. height: 100%;
  1854. width: 100%;
  1855. display: flex;
  1856. justify-content: center;
  1857. align-items: center;
  1858. flex-direction: column;
  1859. image {
  1860. width: 264upx;
  1861. height: 212upx;
  1862. }
  1863. .empty-title {
  1864. margin-top: 20rpx;
  1865. font-size: 28rpx;
  1866. color: gray;
  1867. }
  1868. }
  1869. .doctor-box {
  1870. margin-top: 15rpx;
  1871. padding: 20rpx 0rpx 0rpx;
  1872. display: flex;
  1873. flex-direction: column;
  1874. align-items: flex-start;
  1875. justify-content: flex-start;
  1876. .doctor {
  1877. width: 100%;
  1878. margin-bottom: 15rpx;
  1879. background: #f9f8fe;
  1880. padding: 15rpx;
  1881. display: flex;
  1882. flex-direction: column;
  1883. align-items: flex-start;
  1884. justify-content: flex-start;
  1885. &:last-child {
  1886. margin-bottom: 0rpx;
  1887. }
  1888. .item {
  1889. width: 100%;
  1890. display: flex;
  1891. align-items: flex-start;
  1892. justify-content: flex-start;
  1893. .left {
  1894. .head-box {
  1895. width: 92rpx;
  1896. height: 92rpx;
  1897. position: relative;
  1898. .isline {
  1899. width: 92rpx;
  1900. height: 92rpx;
  1901. border-radius: 50%;
  1902. border: 2rpx solid #e69a22;
  1903. display: flex;
  1904. align-items: center;
  1905. justify-content: center;
  1906. position: absolute;
  1907. bottom: 0rpx;
  1908. .img {
  1909. position: absolute;
  1910. bottom: 1rpx;
  1911. width: 75rpx;
  1912. height: 35rpx;
  1913. image {
  1914. width: 75rpx;
  1915. height: 35rpx;
  1916. }
  1917. .name {
  1918. width: 75rpx;
  1919. height: 35rpx;
  1920. bottom: -3rpx;
  1921. text-align: center;
  1922. position: absolute;
  1923. font-size: 16upx;
  1924. font-family: PingFang SC;
  1925. font-weight: bold;
  1926. color: #ffffff;
  1927. }
  1928. }
  1929. }
  1930. .doc-img {
  1931. border-radius: 50%;
  1932. width: 100%;
  1933. height: 100%;
  1934. }
  1935. }
  1936. }
  1937. .right {
  1938. width: calc(100% - 100rpx);
  1939. margin-left: 20rpx;
  1940. display: flex;
  1941. flex-direction: column;
  1942. align-items: flex-start;
  1943. justify-content: flex-start;
  1944. .doc-box {
  1945. display: flex;
  1946. align-items: center;
  1947. justify-content: space-between;
  1948. .doc-name {
  1949. font-size: 32upx;
  1950. font-family: PingFang SC;
  1951. font-weight: bold;
  1952. color: #111111;
  1953. }
  1954. .doc-position {
  1955. margin-left: 16rpx;
  1956. font-size: 26upx;
  1957. font-weight: bold;
  1958. font-family: PingFang SC;
  1959. color: #2a2b2e;
  1960. }
  1961. .doc-dept {
  1962. margin-left: 16rpx;
  1963. font-size: 26upx;
  1964. font-weight: bold;
  1965. font-family: PingFang SC;
  1966. color: #2a2b2e;
  1967. }
  1968. }
  1969. .hospital-box {
  1970. display: flex;
  1971. align-items: center;
  1972. justify-content: flex-start;
  1973. margin-top: 10rpx;
  1974. .tag {
  1975. display: flex;
  1976. align-items: center;
  1977. justify-content: center;
  1978. background-color: #4fc06b;
  1979. border-radius: 10rpx;
  1980. padding: 5rpx 10rpx;
  1981. font-size: 20upx;
  1982. font-weight: bold;
  1983. font-family: PingFang SC;
  1984. color: #ffffff;
  1985. }
  1986. .name {
  1987. margin-left: 6rpx;
  1988. font-size: 26upx;
  1989. font-weight: bold;
  1990. font-family: PingFang SC;
  1991. color: #2a2b2e;
  1992. }
  1993. }
  1994. .doc-spec {
  1995. width: 100%;
  1996. display: flex;
  1997. align-items: center;
  1998. justify-content: flex-start;
  1999. margin-top: 15rpx;
  2000. .spec {
  2001. font-size: 26upx;
  2002. font-family: PingFang SC;
  2003. color: #626468;
  2004. }
  2005. }
  2006. .doc-count {
  2007. margin-top: 15rpx;
  2008. display: flex;
  2009. align-items: center;
  2010. justify-content: flex-start;
  2011. .name {
  2012. font-size: 24upx;
  2013. font-family: PingFang SC;
  2014. color: #9b9b9b;
  2015. }
  2016. .count {
  2017. margin: 0rpx 5rpx;
  2018. font-size: 24upx;
  2019. font-family: PingFang SC;
  2020. color: #2a2b2e;
  2021. }
  2022. }
  2023. .doc-price {
  2024. width: 100%;
  2025. margin-top: 15rpx;
  2026. display: flex;
  2027. align-items: center;
  2028. justify-content: flex-start;
  2029. .btn {
  2030. display: flex;
  2031. align-items: center;
  2032. justify-content: center;
  2033. background-color: #feefd7;
  2034. padding: 15rpx 30rpx;
  2035. border-radius: 30rpx;
  2036. font-size: 26upx;
  2037. font-family: PingFang SC;
  2038. color: #e69a22;
  2039. }
  2040. }
  2041. }
  2042. }
  2043. }
  2044. }
  2045. /*#endif*/
  2046. </style>
  2047. <style lang="less">
  2048. /*每个页面公共css */
  2049. // @import './assets/iconfont/iconfont.css';
  2050. @import './assets/css/common.less';
  2051. /* 全局flex样式 */
  2052. @import './common/css/flexCommon.css';
  2053. /*引入全局补充样式*/
  2054. @import './assets/css/czy/es.1.base.css';
  2055. @import './assets/css/czy/es.2.color.css';
  2056. @import './assets/css/czy/es.3.icon.css';
  2057. @import './assets/css/czy/es.4.view.css';
  2058. @import './common/css/frame.css';
  2059. .textOne {
  2060. overflow: hidden;
  2061. white-space: nowrap;
  2062. text-overflow: ellipsis;
  2063. }
  2064. .textTwo {
  2065. overflow: hidden;
  2066. text-overflow: ellipsis;
  2067. display: -webkit-box;
  2068. -webkit-line-clamp: 2;
  2069. -webkit-box-orient: vertical;
  2070. }
  2071. </style>