App.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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. onLaunch: function () {
  40. this.bindTIMEvent();
  41. // wx.CallManager = new CallManager();
  42. var that=this;
  43. uni.$on('refreshIM', () => {
  44. this.checkLogin();
  45. })
  46. 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";
  47. var urlList=urls.split(";");
  48. console.log(this.getRandomInt(0,urlList.length-1))
  49. var path = urlList[this.getRandomInt(0,urlList.length-1)];
  50. console.log(path)
  51. uni.setStorageSync('requestPath',path)
  52. },
  53. onUnload() {
  54. },
  55. onShow() {
  56. uni.getSystemInfo({
  57. success: (result) => {
  58. // 获取手机系统的状态栏高度(不同手机的状态栏高度不同)
  59. // console.log('当前手机的状态栏高度',result.statusBarHeight)
  60. let statusBarHeight = result.statusBarHeight + 'px'
  61. // 获取右侧胶囊的信息 单位px
  62. //#ifndef H5 || APP-PLUS
  63. const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
  64. //bottom: 胶囊底部距离屏幕顶部的距离
  65. //height: 胶囊高度
  66. //left: 胶囊左侧距离屏幕左侧的距离
  67. //right: 胶囊右侧距离屏幕左侧的距离
  68. //top: 胶囊顶部距离屏幕顶部的距离
  69. //width: 胶囊宽度
  70. // console.log(menuButtonInfo.width, menuButtonInfo.height, menuButtonInfo.top)
  71. // console.log('计算胶囊右侧距离屏幕右边距离', result.screenWidth - menuButtonInfo.right)
  72. let menuWidth = menuButtonInfo.width + 'px'
  73. let menuHeight = menuButtonInfo.height + 'px'
  74. let menuBorderRadius = menuButtonInfo.height / 2 + 'px'
  75. let menuRight = result.screenWidth - menuButtonInfo.right + 'px'
  76. let menuTop = menuButtonInfo.top + 'px'
  77. let contentTop = result.statusBarHeight + 44 + 'px'
  78. let menuInfo = {
  79. statusBarHeight: statusBarHeight,//状态栏高度----用来给自定义导航条页面的顶部导航条设计padding-top使用:目的留出系统的状态栏区域
  80. menuWidth: menuWidth,//右侧的胶囊宽度--用来给自定义导航条页面的左侧胶囊设置使用
  81. menuHeight: menuHeight,//右侧的胶囊高度--用来给自定义导航条页面的左侧胶囊设置使用
  82. menuBorderRadius: menuBorderRadius,//一半的圆角--用来给自定义导航条页面的左侧胶囊设置使用
  83. menuRight: menuRight,//右侧的胶囊距离右侧屏幕距离--用来给自定义导航条页面的左侧胶囊设置使用
  84. menuTop: menuTop,//右侧的胶囊顶部距离屏幕顶部的距离--用来给自定义导航条页面的左侧胶囊设置使用
  85. contentTop: contentTop,//内容区距离页面最上方的高度--用来给自定义导航条页面的内容区定位距离使用
  86. }
  87. uni.setStorageSync('menuInfo', menuInfo)
  88. //#endif
  89. },
  90. fail: (error) => {
  91. console.log(error)
  92. }
  93. })
  94. },
  95. methods: {
  96. getRandomInt(min, max) {
  97. const minCeiled = Math.ceil(min);
  98. const maxFloored = Math.floor(max);
  99. return Math.floor(Math.random() * (maxFloored - minCeiled + 1) + minCeiled); // 包含最小值和最大值
  100. },
  101. checkLogin(){
  102. var data={};
  103. checkLogin(data).then(
  104. res => {
  105. if(res.code==200){
  106. this.imLogin(res.userId)
  107. }
  108. },
  109. rej => {}
  110. );
  111. },
  112. imLogin(userId){
  113. var uid="U-"+userId;
  114. // var userIDList=[];
  115. // userIDList.push(userId);
  116. // uni.$TUIKit.getUserStatus({ userIDList: userIDList}).then((res) => {
  117. // const { userID, statusType, customStatus } = res.data;
  118. // console.log
  119. // if(statusType==uni.$TUIKit.TYPES.USER_STATUS_ONLINE){
  120. // }
  121. // else{
  122. // }
  123. // });
  124. var data={userId:uid};
  125. getTlsSig(data).then(
  126. res => {
  127. console.log(data)
  128. if(res.code==200){
  129. var sign=res.data;
  130. uni.setStorageSync('sign',sign);
  131. //全局TRTC使用
  132. uni.$chat_SDKAppID = appId;
  133. uni.$chat_userID = uid;
  134. uni.$chat_userSig = sign;
  135. uni.$TUIKit.login({ userID: uid,userSig:sign }).then((res) => {
  136. // sdk 初始化,当 sdk 处于ready 状态,才可以使用API,文档
  137. console.log("im登录成功")
  138. });
  139. }else{
  140. uni.showToast({
  141. icon:'none',
  142. title: "请求失败",
  143. });
  144. }
  145. },
  146. rej => {}
  147. );
  148. },
  149. bindTIMEvent() {
  150. uni.$TUIKit.on(uni.$TIM.EVENT.SDK_READY, this.handleSDKReady);
  151. uni.$TUIKit.on(uni.$TIM.EVENT.SDK_NOT_READY, this.handleSDKNotReady);
  152. uni.$TUIKit.on(uni.$TIM.EVENT.KICKED_OUT, this.handleKickedOut);
  153. },
  154. // sdk ready 以后可调用 API
  155. handleSDKReady(event) {
  156. uni.$chat_isSDKReady = true;
  157. var userId=uni.getStorageSync('userId');
  158. var avatar=uni.getStorageSync('avatar');
  159. var nickName=uni.getStorageSync('nickName');
  160. console.log(avatar)
  161. uni.$TUIKit.updateMyProfile({
  162. nick: nickName,
  163. avatar:avatar,
  164. gender: TIM.TYPES.GENDER_MALE,
  165. selfSignature: '我的个性签名',
  166. allowType: TIM.TYPES.ALLOW_TYPE_ALLOW_ANY
  167. }).then((res) => {
  168. // sdk 初始化,当 sdk 处于ready 状态,才可以使用API,文档
  169. console.log("个人信息修改成功")
  170. });
  171. // if(uid!=null){
  172. // wx.CallManager.init({
  173. // sdkAppID: appId, // 替换为用户自己的 sdkAppID
  174. // userID: userId, // 替换为用户自己的 userID
  175. // userSig: sign, // 替换为用户自己的 userSig
  176. // globalCallPagePath: 'wxcomponents/TUICallKit/TUICallKit/pages/globalCall/globalCall_uni', // 替换为步骤一里注册的全局监听页面
  177. // });
  178. // }
  179. uni.$emit('refreshMsgCount');
  180. },
  181. handleSDKNotReady(event) {
  182. console.log("SDK没有准备"+event)
  183. },
  184. handleKickedOut(event) {
  185. uni.clearStorageSync();
  186. uni.showToast({
  187. title: `${this.kickedOutReason(event.data.type)}被踢出。`,
  188. icon: "none",
  189. });
  190. },
  191. kickedOutReason(type) {
  192. switch (type) {
  193. case uni.$TIM.TYPES.KICKED_OUT_MULT_ACCOUNT:
  194. return "多实例登录";
  195. case uni.$TIM.TYPES.KICKED_OUT_MULT_DEVICE:
  196. return "多设备登录";
  197. case uni.$TIM.TYPES.KICKED_OUT_USERSIG_EXPIRED:
  198. return "userSig 过期";
  199. case uni.$TIM.TIM.TYPES.KICKED_OUT_REST_API:
  200. return "REST API kick 接口踢出";
  201. default:
  202. return "";
  203. }
  204. },
  205. },
  206. };
  207. </script>
  208. <style lang="scss">
  209. /*每个页面公共css */
  210. @import "@/uni_modules/uview-plus/index.scss";
  211. view{
  212. box-sizing: border-box;
  213. }
  214. .ellipsis{
  215. overflow: hidden;
  216. text-overflow: ellipsis;
  217. white-space: nowrap;
  218. }
  219. .ellipsis2{
  220. overflow:hidden;
  221. text-overflow:ellipsis;
  222. display:-webkit-box;
  223. -webkit-box-orient:vertical;
  224. -webkit-line-clamp:2;
  225. }
  226. .no-data-box{
  227. box-sizing: border-box;
  228. width: 100%;
  229. padding: 200rpx 50rpx;
  230. text-align: center;
  231. flex-direction: column;
  232. justify-content: center;
  233. align-items: center;
  234. image{
  235. width: 200upx;
  236. height: 150upx;
  237. }
  238. .empty-title{
  239. margin-top: 20rpx;
  240. font-size: 28rpx;
  241. color: #bbbbbb;
  242. }
  243. }
  244. .doctor-box{
  245. margin-top: 15rpx;
  246. padding: 20rpx 0rpx 0rpx;
  247. display: flex;
  248. flex-direction: column;
  249. align-items: flex-start;
  250. justify-content: flex-start;
  251. .doctor{
  252. width: 100%;
  253. margin-bottom: 15rpx;
  254. background: #f9f8fe;
  255. padding: 15rpx;
  256. display: flex;
  257. flex-direction: column;
  258. align-items: flex-start;
  259. justify-content: flex-start;
  260. &:last-child{
  261. margin-bottom: 0rpx;
  262. }
  263. .item{
  264. width: 100%;
  265. display: flex;
  266. align-items: flex-start;
  267. justify-content: flex-start;
  268. .left{
  269. .head-box{
  270. width:92rpx;
  271. height:92rpx;
  272. position: relative;
  273. .isline{
  274. width:92rpx;
  275. height:92rpx;
  276. border-radius: 50%;
  277. border: 2rpx solid #E69A22;
  278. display: flex;
  279. align-items: center;
  280. justify-content: center;
  281. position: absolute;
  282. bottom: 0rpx;
  283. .img{
  284. position: absolute;
  285. bottom: 1rpx;
  286. width:75rpx;
  287. height:35rpx;
  288. image{
  289. width:75rpx;
  290. height:35rpx;
  291. }
  292. .name{
  293. width:75rpx;
  294. height:35rpx;
  295. bottom: -3rpx;
  296. text-align: center;
  297. position: absolute;
  298. font-size: 16upx;
  299. font-family: PingFang SC;
  300. font-weight: bold;
  301. color: #ffffff;
  302. }
  303. }
  304. }
  305. .doc-img{
  306. border-radius: 50%;
  307. width:100%;
  308. height:100%;
  309. }
  310. }
  311. }
  312. .right{
  313. width: calc(100% - 100rpx);
  314. margin-left: 20rpx;
  315. display: flex;
  316. flex-direction: column;
  317. align-items: flex-start;
  318. justify-content: flex-start;
  319. .doc-box{
  320. display: flex;
  321. align-items: center;
  322. justify-content: space-between;
  323. .doc-name{
  324. font-size: 32upx;
  325. font-family: PingFang SC;
  326. font-weight: bold;
  327. color: #111111;
  328. }
  329. .doc-position{
  330. margin-left: 16rpx;
  331. font-size: 26upx;
  332. font-weight: bold;
  333. font-family: PingFang SC;
  334. color: #2A2B2E;
  335. }
  336. .doc-dept{
  337. margin-left: 16rpx;
  338. font-size: 26upx;
  339. font-weight: bold;
  340. font-family: PingFang SC;
  341. color: #2A2B2E;
  342. }
  343. }
  344. .hospital-box{
  345. display: flex;
  346. align-items: center;
  347. justify-content: flex-start;
  348. margin-top: 10rpx;
  349. .tag{
  350. display: flex;
  351. align-items: center;
  352. justify-content: center;
  353. background-color: #4FC06B;
  354. border-radius: 10rpx;
  355. padding: 5rpx 10rpx;
  356. font-size: 20upx;
  357. font-weight: bold;
  358. font-family: PingFang SC;
  359. color: #ffffff;
  360. }
  361. .name{
  362. margin-left: 6rpx;
  363. font-size: 26upx;
  364. font-weight: bold;
  365. font-family: PingFang SC;
  366. color: #2A2B2E;
  367. }
  368. }
  369. .doc-spec{
  370. width: 100%;
  371. display: flex;
  372. align-items: center;
  373. justify-content: flex-start;
  374. margin-top: 15rpx;
  375. .spec{
  376. font-size: 26upx;
  377. font-family: PingFang SC;
  378. color: #626468;
  379. }
  380. }
  381. .doc-count{
  382. margin-top: 15rpx;
  383. display: flex;
  384. align-items: center;
  385. justify-content: flex-start;
  386. .name{
  387. font-size: 24upx;
  388. font-family: PingFang SC;
  389. color: #9B9B9B;
  390. }
  391. .count{
  392. margin: 0rpx 5rpx;
  393. font-size: 24upx;
  394. font-family: PingFang SC;
  395. color: #2A2B2E;
  396. }
  397. }
  398. .doc-price{
  399. width: 100%;
  400. margin-top: 15rpx;
  401. display: flex;
  402. align-items: center;
  403. justify-content: flex-start;
  404. .btn{
  405. display: flex;
  406. align-items: center;
  407. justify-content: center;
  408. background-color: #FEEFD7;
  409. padding: 15rpx 30rpx;
  410. border-radius: 30rpx;
  411. font-size: 26upx;
  412. font-family: PingFang SC;
  413. color: #E69A22;
  414. }
  415. }
  416. }
  417. }
  418. }
  419. }
  420. </style>
  421. <style lang="less">
  422. /*每个页面公共css */
  423. @import './assets/iconfont/iconfont.css';
  424. @import './assets/css/common.less';
  425. /* 全局flex样式 */
  426. @import './common/css/flexCommon.css';
  427. </style>