App.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <script>
  2. // #ifdef APP-PLUS
  3. import TIM from "tim-wx-sdk";
  4. import TIMUploadPlugin from "tim-upload-plugin";
  5. import Aegis from "aegis-weex-sdk";
  6. export { TIM, TIMUploadPlugin, Aegis };
  7. // #endif
  8. // #ifdef H5
  9. import TIM from "tim-js-sdk";
  10. import TIMUploadPlugin from "tim-upload-plugin";
  11. import Aegis from "aegis-web-sdk";
  12. export { TIM, TIMUploadPlugin, Aegis };
  13. // #endif
  14. // #ifdef MP-WEIXIN
  15. // import TIM from "tim-js-sdk";
  16. const TIM = require('tim-wx-sdk');
  17. import TIMUploadPlugin from "tim-upload-plugin";
  18. // import Aegis from "aegis-mp-sdk";
  19. export { TIM, TIMUploadPlugin };
  20. // #endif
  21. import { TUIConversationServer, TUIProfileServer } from "@/pages/TUIKit/TUICore/server";
  22. var appId=1400825410
  23. // var appId=1600023785;
  24. // 创建 sdk 实例
  25. uni.$TUIKit = TIM.create({
  26. SDKAppID: appId,
  27. });
  28. uni.$TIM = TIM;
  29. // 注册文件上传插件
  30. uni.$TUIKit.registerPlugin({
  31. "tim-upload-plugin": TIMUploadPlugin,
  32. });
  33. uni.$TUIKit.TUIConversationServer = new TUIConversationServer();
  34. uni.$TUIKit.TUIProfileServer = new TUIProfileServer();
  35. const { CallManager } = require ('./wxcomponents/TUICallKit/TUICallKit/serve/callManager');
  36. import { getTlsSig } from '@/api/common.js'
  37. import { checkLogin } from '@/api/user.js'
  38. export default {
  39. globalData: {
  40. danmuWSUrl:'wss://h5api.his.cdwjyyh.com',
  41. },
  42. onLaunch: function () {
  43. this.bindTIMEvent();
  44. // wx.CallManager = new CallManager();
  45. var that=this;
  46. uni.$on('refreshIM', () => {
  47. this.checkLogin();
  48. })
  49. var urls="https://1701081189.cdwjyyh.com;https://1696746017.cdwjyyh.com;https://1708196565.cdwjyyh.com;https://1700206673.cdwjyyh.com;https://1723317680.cdwjyyh.com;https://1700575323.cdwjyyh.com;https://1706979252.cdwjyyh.com;https://1697148962.cdwjyyh.com;https://1722131630.cdwjyyh.com;https://1716969562.cdwjyyh.com;https://1695072024.cdwjyyh.com;https://1720639647.cdwjyyh.com;https://1695440159.cdwjyyh.com;https://1707741400.cdwjyyh.com;https://1708937934.cdwjyyh.com;https://1718087536.cdwjyyh.com;https://1724494814.cdwjyyh.com;https://1703101076.cdwjyyh.com;https://1712251670.cdwjyyh.com;https://1701764981.cdwjyyh.com;https://1709430520.cdwjyyh.com;https://1716356434.cdwjyyh.com;https://1716808011.cdwjyyh.com;https://1710609621.cdwjyyh.com;https://1705257092.cdwjyyh.com;https://1721137588.cdwjyyh.com;https://1703567784.cdwjyyh.com;https://1721509816.cdwjyyh.com;https://1720396718.cdwjyyh.com;https://1721936263.cdwjyyh.com;https://1716050799.cdwjyyh.com;https://1713109810.cdwjyyh.com;https://1725223167.cdwjyyh.com;https://1722019208.cdwjyyh.com;https://1702848339.cdwjyyh.com;https://1707911907.cdwjyyh.com;https://1717849419.cdwjyyh.com;https://1703809724.cdwjyyh.com;https://1724650239.cdwjyyh.com;https://1707113459.cdwjyyh.com;https://1715669104.cdwjyyh.com;https://1710051545.cdwjyyh.com;https://1722269330.cdwjyyh.com;https://1710003925.cdwjyyh.com;https://1714555145.cdwjyyh.com;https://1720634288.cdwjyyh.com;https://1696593184.cdwjyyh.com;https://1704962208.cdwjyyh.com;https://1703146177.cdwjyyh.com;https://1704346325.cdwjyyh.com;https://1697387624.cdwjyyh.com;https://1702551094.cdwjyyh.com;https://1720523201.cdwjyyh.com;https://1714391651.cdwjyyh.com;https://1698957834.cdwjyyh.com;https://1710582715.cdwjyyh.com;https://1696073814.cdwjyyh.com;https://1701427000.cdwjyyh.com;https://1703620825.cdwjyyh.com;https://1716954881.cdwjyyh.com;https://1709258681.cdwjyyh.com;https://1702178349.cdwjyyh.com;https://1696037454.cdwjyyh.com;https://1707163288.cdwjyyh.com;https://1698272613.cdwjyyh.com;https://1695736399.cdwjyyh.com;https://1707979666.cdwjyyh.com;https://1699631662.cdwjyyh.com;https://1725584568.cdwjyyh.com;https://1709711499.cdwjyyh.com;https://1707988905.cdwjyyh.com;https://1709289861.cdwjyyh.com;https://1720027873.cdwjyyh.com;https://1723979172.cdwjyyh.com;https://1711804525.cdwjyyh.com;https://1702653210.cdwjyyh.com;https://1711075739.cdwjyyh.com;https://1710979987.cdwjyyh.com;https://1724292527.cdwjyyh.com;https://1704964596.cdwjyyh.com;https://1703840482.cdwjyyh.com;https://1709061808.cdwjyyh.com;https://1718492957.cdwjyyh.com;https://1708829102.cdwjyyh.com;https://1716362553.cdwjyyh.com;https://1710541443.cdwjyyh.com;https://1715811900.cdwjyyh.com;https://1718208786.cdwjyyh.com;https://1704651745.cdwjyyh.com;https://1699759405.cdwjyyh.com;https://1713080422.cdwjyyh.com;https://1715403843.cdwjyyh.com;https://1696900518.cdwjyyh.com;https://1707770189.cdwjyyh.com;https://1700034515.cdwjyyh.com;https://1715466167.cdwjyyh.com;https://1709976677.cdwjyyh.com;https://1712370330.cdwjyyh.com;https://1706087997.cdwjyyh.com;https://1703496196.cdwjyyh.com;https://1712266369.cdwjyyh.com;https://1712318592.cdwjyyh.com;https://1712812440.cdwjyyh.com;https://1715678161.cdwjyyh.com;https://1702028001.cdwjyyh.com;https://1721667850.cdwjyyh.com;https://1696462985.cdwjyyh.com;https://1707192149.cdwjyyh.com;https://1704821512.cdwjyyh.com;https://1723797034.cdwjyyh.com;https://1704429569.cdwjyyh.com;https://1709243255.cdwjyyh.com;https://1722028860.cdwjyyh.com;https://1712967809.cdwjyyh.com;https://1705848887.cdwjyyh.com;https://1695675535.cdwjyyh.com;https://1725746755.cdwjyyh.com;https://1723025937.cdwjyyh.com;https://1723488798.cdwjyyh.com;https://1700104177.cdwjyyh.com;https://1724293219.cdwjyyh.com;https://1726204998.cdwjyyh.com;https://1714031757.cdwjyyh.com;https://1713130421.cdwjyyh.com;https://1723148318.cdwjyyh.com;https://1725755505.cdwjyyh.com;https://1720760127.cdwjyyh.com;https://1709058929.cdwjyyh.com;https://1706935822.cdwjyyh.com;https://1698429582.cdwjyyh.com;https://1725312611.cdwjyyh.com;https://1709158760.cdwjyyh.com;https://1712496042.cdwjyyh.com;https://1707326074.cdwjyyh.com;https://1704652832.cdwjyyh.com;https://1722471447.cdwjyyh.com;https://1715081607.cdwjyyh.com;https://1722709008.cdwjyyh.com;https://1705411096.cdwjyyh.com;https://1722112356.cdwjyyh.com;https://1713176285.cdwjyyh.com;https://1710638388.cdwjyyh.com;https://1703201862.cdwjyyh.com;https://1716520084.cdwjyyh.com;https://1716201102.cdwjyyh.com;https://1714278120.cdwjyyh.com;https://1695811036.cdwjyyh.com;https://1696612587.cdwjyyh.com;https://1720738395.cdwjyyh.com;https://1722208363.cdwjyyh.com;https://1697138661.cdwjyyh.com;https://1717887413.cdwjyyh.com;https://1715113705.cdwjyyh.com;https://1696048580.cdwjyyh.com;https://1696166861.cdwjyyh.com;https://1707853597.cdwjyyh.com;https://1709274679.cdwjyyh.com;https://1722858089.cdwjyyh.com;https://1715419874.cdwjyyh.com;https://1715116007.cdwjyyh.com;https://1722314568.cdwjyyh.com;https://1724746541.cdwjyyh.com;https://1718762128.cdwjyyh.com;https://1720163684.cdwjyyh.com;https://1724770857.cdwjyyh.com;https://1708580403.cdwjyyh.com;https://1705948747.cdwjyyh.com;https://1700682425.cdwjyyh.com;https://1702858903.cdwjyyh.com;https://1725605169.cdwjyyh.com;https://1699065003.cdwjyyh.com;https://1696786637.cdwjyyh.com;https://1708356387.cdwjyyh.com;https://1699525562.cdwjyyh.com;https://1720968292.cdwjyyh.com;https://1710909698.cdwjyyh.com;https://1700467361.cdwjyyh.com;https://1695683561.cdwjyyh.com;https://1725858080.cdwjyyh.com;https://1702911871.cdwjyyh.com";
  50. var urlList=urls.split(";");
  51. console.log(this.getRandomInt(0,urlList.length-1))
  52. var path = urlList[this.getRandomInt(0,urlList.length-1)];
  53. console.log(path)
  54. uni.setStorageSync('requestPath',path)
  55. },
  56. onUnload() {
  57. },
  58. onShow() {
  59. uni.getSystemInfo({
  60. success: (result) => {
  61. // 获取手机系统的状态栏高度(不同手机的状态栏高度不同)
  62. // console.log('当前手机的状态栏高度',result.statusBarHeight)
  63. let statusBarHeight = result.statusBarHeight + 'px'
  64. // 获取右侧胶囊的信息 单位px
  65. //#ifndef H5 || APP-PLUS
  66. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  67. //bottom: 胶囊底部距离屏幕顶部的距离
  68. //height: 胶囊高度
  69. //left: 胶囊左侧距离屏幕左侧的距离
  70. //right: 胶囊右侧距离屏幕左侧的距离
  71. //top: 胶囊顶部距离屏幕顶部的距离
  72. //width: 胶囊宽度
  73. // console.log(menuButtonInfo.width, menuButtonInfo.height, menuButtonInfo.top)
  74. // console.log('计算胶囊右侧距离屏幕右边距离', result.screenWidth - menuButtonInfo.right)
  75. let menuWidth = menuButtonInfo.width + 'px'
  76. let menuHeight = menuButtonInfo.height + 'px'
  77. let menuBorderRadius = menuButtonInfo.height / 2 + 'px'
  78. let menuRight = result.screenWidth - menuButtonInfo.right + 'px'
  79. let menuTop = menuButtonInfo.top + 'px'
  80. let contentTop = result.statusBarHeight + 44 + 'px'
  81. let menuInfo = {
  82. statusBarHeight: statusBarHeight,//状态栏高度----用来给自定义导航条页面的顶部导航条设计padding-top使用:目的留出系统的状态栏区域
  83. menuWidth: menuWidth,//右侧的胶囊宽度--用来给自定义导航条页面的左侧胶囊设置使用
  84. menuHeight: menuHeight,//右侧的胶囊高度--用来给自定义导航条页面的左侧胶囊设置使用
  85. menuBorderRadius: menuBorderRadius,//一半的圆角--用来给自定义导航条页面的左侧胶囊设置使用
  86. menuRight: menuRight,//右侧的胶囊距离右侧屏幕距离--用来给自定义导航条页面的左侧胶囊设置使用
  87. menuTop: menuTop,//右侧的胶囊顶部距离屏幕顶部的距离--用来给自定义导航条页面的左侧胶囊设置使用
  88. contentTop: contentTop,//内容区距离页面最上方的高度--用来给自定义导航条页面的内容区定位距离使用
  89. }
  90. uni.setStorageSync('menuInfo', menuInfo)
  91. //#endif
  92. },
  93. fail: (error) => {
  94. console.log(error)
  95. }
  96. })
  97. },
  98. methods: {
  99. getRandomInt(min, max) {
  100. const minCeiled = Math.ceil(min);
  101. const maxFloored = Math.floor(max);
  102. return Math.floor(Math.random() * (maxFloored - minCeiled + 1) + minCeiled); // 包含最小值和最大值
  103. },
  104. checkLogin(){
  105. var data={};
  106. checkLogin(data).then(
  107. res => {
  108. if(res.code==200){
  109. this.imLogin(res.userId)
  110. }
  111. },
  112. rej => {}
  113. );
  114. },
  115. imLogin(userId){
  116. var uid="U-"+userId;
  117. // var userIDList=[];
  118. // userIDList.push(userId);
  119. // uni.$TUIKit.getUserStatus({ userIDList: userIDList}).then((res) => {
  120. // const { userID, statusType, customStatus } = res.data;
  121. // console.log
  122. // if(statusType==uni.$TUIKit.TYPES.USER_STATUS_ONLINE){
  123. // }
  124. // else{
  125. // }
  126. // });
  127. var data={userId:uid};
  128. getTlsSig(data).then(
  129. res => {
  130. console.log(data)
  131. if(res.code==200){
  132. var sign=res.data;
  133. uni.setStorageSync('sign',sign);
  134. //全局TRTC使用
  135. uni.$chat_SDKAppID = appId;
  136. uni.$chat_userID = uid;
  137. uni.$chat_userSig = sign;
  138. uni.$TUIKit.login({ userID: uid,userSig:sign }).then((res) => {
  139. // sdk 初始化,当 sdk 处于ready 状态,才可以使用API,文档
  140. console.log("im登录成功")
  141. });
  142. }else{
  143. uni.showToast({
  144. icon:'none',
  145. title: "请求失败",
  146. });
  147. }
  148. },
  149. rej => {}
  150. );
  151. },
  152. bindTIMEvent() {
  153. uni.$TUIKit.on(uni.$TIM.EVENT.SDK_READY, this.handleSDKReady);
  154. uni.$TUIKit.on(uni.$TIM.EVENT.SDK_NOT_READY, this.handleSDKNotReady);
  155. uni.$TUIKit.on(uni.$TIM.EVENT.KICKED_OUT, this.handleKickedOut);
  156. },
  157. // sdk ready 以后可调用 API
  158. handleSDKReady(event) {
  159. uni.$chat_isSDKReady = true;
  160. var userId=uni.getStorageSync('userId');
  161. var avatar=uni.getStorageSync('avatar');
  162. var nickName=uni.getStorageSync('nickName');
  163. console.log(avatar)
  164. uni.$TUIKit.updateMyProfile({
  165. nick: nickName,
  166. avatar:avatar,
  167. gender: TIM.TYPES.GENDER_MALE,
  168. selfSignature: '我的个性签名',
  169. allowType: TIM.TYPES.ALLOW_TYPE_ALLOW_ANY
  170. }).then((res) => {
  171. // sdk 初始化,当 sdk 处于ready 状态,才可以使用API,文档
  172. console.log("个人信息修改成功")
  173. });
  174. // if(uid!=null){
  175. // wx.CallManager.init({
  176. // sdkAppID: appId, // 替换为用户自己的 sdkAppID
  177. // userID: userId, // 替换为用户自己的 userID
  178. // userSig: sign, // 替换为用户自己的 userSig
  179. // globalCallPagePath: 'wxcomponents/TUICallKit/TUICallKit/pages/globalCall/globalCall_uni', // 替换为步骤一里注册的全局监听页面
  180. // });
  181. // }
  182. uni.$emit('refreshMsgCount');
  183. },
  184. handleSDKNotReady(event) {
  185. console.log("SDK没有准备"+event)
  186. },
  187. handleKickedOut(event) {
  188. uni.clearStorageSync();
  189. uni.showToast({
  190. title: `${this.kickedOutReason(event.data.type)}被踢出。`,
  191. icon: "none",
  192. });
  193. },
  194. kickedOutReason(type) {
  195. switch (type) {
  196. case uni.$TIM.TYPES.KICKED_OUT_MULT_ACCOUNT:
  197. return "多实例登录";
  198. case uni.$TIM.TYPES.KICKED_OUT_MULT_DEVICE:
  199. return "多设备登录";
  200. case uni.$TIM.TYPES.KICKED_OUT_USERSIG_EXPIRED:
  201. return "userSig 过期";
  202. case uni.$TIM.TIM.TYPES.KICKED_OUT_REST_API:
  203. return "REST API kick 接口踢出";
  204. default:
  205. return "";
  206. }
  207. },
  208. },
  209. };
  210. </script>
  211. <style lang="scss">
  212. /*每个页面公共css */
  213. @import "@/uni_modules/uview-plus/index.scss";
  214. view{
  215. box-sizing: border-box;
  216. }
  217. .ellipsis{
  218. overflow: hidden;
  219. text-overflow: ellipsis;
  220. white-space: nowrap;
  221. }
  222. .ellipsis2{
  223. overflow:hidden;
  224. text-overflow:ellipsis;
  225. display:-webkit-box;
  226. -webkit-box-orient:vertical;
  227. -webkit-line-clamp:2;
  228. }
  229. .no-data-box{
  230. box-sizing: border-box;
  231. width: 100%;
  232. padding: 200rpx 50rpx;
  233. text-align: center;
  234. flex-direction: column;
  235. justify-content: center;
  236. align-items: center;
  237. image{
  238. width: 200upx;
  239. height: 150upx;
  240. }
  241. .empty-title{
  242. margin-top: 20rpx;
  243. font-size: 28rpx;
  244. color: #bbbbbb;
  245. }
  246. }
  247. .doctor-box{
  248. margin-top: 15rpx;
  249. padding: 20rpx 0rpx 0rpx;
  250. display: flex;
  251. flex-direction: column;
  252. align-items: flex-start;
  253. justify-content: flex-start;
  254. .doctor{
  255. width: 100%;
  256. margin-bottom: 15rpx;
  257. background: #f9f8fe;
  258. padding: 15rpx;
  259. display: flex;
  260. flex-direction: column;
  261. align-items: flex-start;
  262. justify-content: flex-start;
  263. &:last-child{
  264. margin-bottom: 0rpx;
  265. }
  266. .item{
  267. width: 100%;
  268. display: flex;
  269. align-items: flex-start;
  270. justify-content: flex-start;
  271. .left{
  272. .head-box{
  273. width:92rpx;
  274. height:92rpx;
  275. position: relative;
  276. .isline{
  277. width:92rpx;
  278. height:92rpx;
  279. border-radius: 50%;
  280. border: 2rpx solid #E69A22;
  281. display: flex;
  282. align-items: center;
  283. justify-content: center;
  284. position: absolute;
  285. bottom: 0rpx;
  286. .img{
  287. position: absolute;
  288. bottom: 1rpx;
  289. width:75rpx;
  290. height:35rpx;
  291. image{
  292. width:75rpx;
  293. height:35rpx;
  294. }
  295. .name{
  296. width:75rpx;
  297. height:35rpx;
  298. bottom: -3rpx;
  299. text-align: center;
  300. position: absolute;
  301. font-size: 16upx;
  302. font-family: PingFang SC;
  303. font-weight: bold;
  304. color: #ffffff;
  305. }
  306. }
  307. }
  308. .doc-img{
  309. border-radius: 50%;
  310. width:100%;
  311. height:100%;
  312. }
  313. }
  314. }
  315. .right{
  316. width: calc(100% - 100rpx);
  317. margin-left: 20rpx;
  318. display: flex;
  319. flex-direction: column;
  320. align-items: flex-start;
  321. justify-content: flex-start;
  322. .doc-box{
  323. display: flex;
  324. align-items: center;
  325. justify-content: space-between;
  326. .doc-name{
  327. font-size: 32upx;
  328. font-family: PingFang SC;
  329. font-weight: bold;
  330. color: #111111;
  331. }
  332. .doc-position{
  333. margin-left: 16rpx;
  334. font-size: 26upx;
  335. font-weight: bold;
  336. font-family: PingFang SC;
  337. color: #2A2B2E;
  338. }
  339. .doc-dept{
  340. margin-left: 16rpx;
  341. font-size: 26upx;
  342. font-weight: bold;
  343. font-family: PingFang SC;
  344. color: #2A2B2E;
  345. }
  346. }
  347. .hospital-box{
  348. display: flex;
  349. align-items: center;
  350. justify-content: flex-start;
  351. margin-top: 10rpx;
  352. .tag{
  353. display: flex;
  354. align-items: center;
  355. justify-content: center;
  356. background-color: #4FC06B;
  357. border-radius: 10rpx;
  358. padding: 5rpx 10rpx;
  359. font-size: 20upx;
  360. font-weight: bold;
  361. font-family: PingFang SC;
  362. color: #ffffff;
  363. }
  364. .name{
  365. margin-left: 6rpx;
  366. font-size: 26upx;
  367. font-weight: bold;
  368. font-family: PingFang SC;
  369. color: #2A2B2E;
  370. }
  371. }
  372. .doc-spec{
  373. width: 100%;
  374. display: flex;
  375. align-items: center;
  376. justify-content: flex-start;
  377. margin-top: 15rpx;
  378. .spec{
  379. font-size: 26upx;
  380. font-family: PingFang SC;
  381. color: #626468;
  382. }
  383. }
  384. .doc-count{
  385. margin-top: 15rpx;
  386. display: flex;
  387. align-items: center;
  388. justify-content: flex-start;
  389. .name{
  390. font-size: 24upx;
  391. font-family: PingFang SC;
  392. color: #9B9B9B;
  393. }
  394. .count{
  395. margin: 0rpx 5rpx;
  396. font-size: 24upx;
  397. font-family: PingFang SC;
  398. color: #2A2B2E;
  399. }
  400. }
  401. .doc-price{
  402. width: 100%;
  403. margin-top: 15rpx;
  404. display: flex;
  405. align-items: center;
  406. justify-content: flex-start;
  407. .btn{
  408. display: flex;
  409. align-items: center;
  410. justify-content: center;
  411. background-color: #FEEFD7;
  412. padding: 15rpx 30rpx;
  413. border-radius: 30rpx;
  414. font-size: 26upx;
  415. font-family: PingFang SC;
  416. color: #E69A22;
  417. }
  418. }
  419. }
  420. }
  421. }
  422. }
  423. </style>
  424. <style lang="less">
  425. /*每个页面公共css */
  426. @import './assets/iconfont/iconfont.css';
  427. @import './assets/css/common.less';
  428. /* 全局flex样式 */
  429. @import './common/css/flexCommon.css';
  430. </style>