socket.js 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576
  1. const {
  2. io
  3. } = require('./socket.io-v4.msgpack.js');
  4. var user = require('./services/user.js');
  5. const api = require('/config/api.js');
  6. const util = require('/utils/util.js');
  7. const UNLOGIN = 'NO_LOGIN'
  8. const btoa = require('./utils/btoa');
  9. const manyCount = 50
  10. import remote from './config.js'
  11. var app = getApp();
  12. var isIos = false
  13. wx.getSystemInfo({
  14. success: function (res) {
  15. isIos = res.platform == "ios"
  16. }
  17. })
  18. const debounce = (fn, wait) => {
  19. let callback = fn;
  20. let timerId = null;
  21. function debounced() {
  22. let context = this;
  23. let args = arguments;
  24. clearTimeout(timerId);
  25. timerId = setTimeout(function () {
  26. callback.apply(context, args);
  27. }, wait);
  28. }
  29. return debounced;
  30. }
  31. let urlToJson = (url = window.location.href) => { // 箭头函数默认传值为当前页面url
  32. let obj = {},
  33. index = url.indexOf('?'), // 看url有没有参数
  34. params = url.substr(index + 1); // 截取url参数部分 id = 1 & type = 2
  35. if (index != -1) { // 有参数时
  36. let parr = params.split('&'); // 将参数分割成数组 ["id = 1 ", " type = 2"]
  37. for (let i of parr) { // 遍历数组
  38. let arr = i.split('='); // 1) i id = 1 arr = [id, 1] 2)i type = 2 arr = [type, 2]
  39. obj[arr[0]] = arr[1]; // obj[arr[0]] = id, obj.id = 1 obj[arr[0]] = type, obj.type = 2
  40. }
  41. }
  42. return obj;
  43. }
  44. export default {
  45. joinUrl() {
  46. let url = this.data.url;
  47. //隐藏部分
  48. // if (this.data.url && /smobile.html/.test(this.data.url)) {
  49. // const newUrl = this.data.url.replace('smobile.html', 'shop.html')
  50. // url = newUrl
  51. // this.setData({
  52. // url: newUrl
  53. // });
  54. // }
  55. let options = {
  56. API_BASE_URL: api.API_BASE_URL,
  57. "url": url,
  58. // "url": 'http://192.168.0.112:8080',
  59. "reload": this.data.reload,
  60. "token": wx.getStorageSync('token'),
  61. "code": this.mcode,
  62. "brandId": this.options.id,
  63. "open": this.data.showCommodity,
  64. "pauseVideo": this.pauseVideo,
  65. "bottom": this.data.bottom || 0,
  66. socket: {
  67. socketHost: remote.socketHost,
  68. path: '/new-zfb',
  69. options: {
  70. ...this.data.socketOptions,
  71. // nickname: encodeURI(encodeURI(this.data.socketOptions.nickname))
  72. nickname: encodeURIComponent(encodeURIComponent(this.data.socketOptions.nickname))
  73. }
  74. }
  75. }
  76. // let base = 'http://127.0.0.1:5500/index.html'
  77. // let base = remote.viewHost + '/shop-container/shop.html'
  78. let sponsor = !!this.data.canShow
  79. if (this.data.join && !this.options.join) {
  80. sponsor = false
  81. }
  82. // 33是从我的房间出来的
  83. if (Number(this.data.type) === 33) {
  84. sponsor = true;
  85. }
  86. // debugger
  87. // remote.viewHost
  88. let hostUrl
  89. if (options.url.indexOf('www.4dkankan.com') != -1) {
  90. hostUrl = 'https://www.4dkankan.com/shop-container-zfb/'
  91. } else if (options.url.indexOf('test.4dkankan.com') != -1) {
  92. hostUrl = 'https://test.4dkankan.com/shop-container-zfb/'
  93. } else {
  94. // hostUrl = 'https://zfb.4dkankan.com/shop-container/'
  95. // hostUrl = remote.viewHost + '/shop-container/'
  96. hostUrl = remote.viewHost + '/shop-container-v4/'
  97. }
  98. // let base = remote.viewHost + '/shop-container/fashilong.html?env=' + remote.env + '&sponsor=' + sponsor + '&many=' + this.data.many
  99. let base = hostUrl + 'fashilong.html?time=' + Date.now() + '&env=' + remote.env + '&sponsor=' + sponsor + '&many=' + this.data.many
  100. // let base = remote.viewHost + '/shop.html'
  101. this.data.reload = false
  102. this.data.showCommodity = false
  103. //上线前隐藏Vlog
  104. // options.url = options.url + '&vlog';
  105. if (!this.data.webviewUrl) {
  106. console.log(base)
  107. this.setData({
  108. 'webviewUrl': base + '#' + JSON.stringify(options)
  109. })
  110. } else {
  111. this.socketSendMessage('clientSyncAction', {
  112. sender: 'h5',
  113. type: 'hashChange',
  114. data: options
  115. })
  116. }
  117. },
  118. onShow() {
  119. this.setData({
  120. isIos,
  121. showComtypesAllTab: false
  122. })
  123. // wx.showToast({
  124. // title: '测试--socket.connected' + this.socket.connected,
  125. // })
  126. const onlineAction = () => {
  127. this.pauseVideo = false
  128. this.joinUrl()
  129. // debugger
  130. this.socketSendMessage('changeOnlineStatus', {
  131. status: 1
  132. })
  133. }
  134. console.warn("socketInstance-1", this.socketInstance);
  135. if (this.socketInstance) {
  136. if (!this.socketInstance.connected) {
  137. // wx.showToast({
  138. // title: 'socketInstance-2',
  139. // icon: 'none',
  140. // duration: 5000
  141. // })
  142. // this.socketInstance.connect();
  143. // wx.showModal({
  144. // title: '提示',
  145. // content: '欧克',
  146. // showCancel: false,
  147. // confirmColor: '#0075DC',
  148. // success: function (res) {}
  149. // })
  150. setTimeout(onlineAction, 300)
  151. } else {
  152. // wx.showToast({
  153. // title: 'socketInstance-3',
  154. // icon: 'none',
  155. // duration: 5000
  156. // })
  157. onlineAction();
  158. }
  159. }
  160. // if (this.socketSendMessage) {
  161. // this.pauseVideo = false
  162. // this.joinUrl()
  163. // // debugger
  164. // this.socketSendMessage('changeOnlineStatus', {
  165. // status: 1
  166. // })
  167. // }
  168. },
  169. changeShowComtypesAllTab(ev) {
  170. this.setData({
  171. showCommodity: false
  172. })
  173. setTimeout(() => {
  174. this.setData({
  175. showComtypesAllTab: ev.currentTarget.dataset.show,
  176. showCommodity: true
  177. })
  178. }, 100)
  179. },
  180. async authorizeRecord() {
  181. let isAuth = await new Promise((r, j) => {
  182. wx.authorize({
  183. scope: 'scope.record',
  184. success: () => r(true),
  185. fail: () => r(false)
  186. })
  187. })
  188. if (isAuth) return true
  189. let res = await new Promise(r => {
  190. wx.showModal({
  191. title: '提示',
  192. content: '您未授权录音,说话功能将无法使用',
  193. showCancel: true,
  194. confirmText: "授权",
  195. confirmColor: "#52a2d8",
  196. success: res => r(res),
  197. fail: () => r(false)
  198. })
  199. })
  200. if (!res || res.cancel) return;
  201. isAuth = await new Promise((r) => {
  202. wx.openSetting({
  203. success: res => r(res.authSetting['scope.record']),
  204. fail: () => r(false)
  205. })
  206. })
  207. return isAuth
  208. },
  209. // 获取录音权限状态
  210. async getAuthorizeRecordStatus() {
  211. const isAuth = await new Promise((r, j) => {
  212. wx.authorize({
  213. scope: 'scope.record',
  214. success: () => r(true),
  215. fail: () => r(false)
  216. })
  217. })
  218. return Promise.resolve(isAuth)
  219. },
  220. async agetUserInfo() {
  221. const res = await util.request(api.UserInfo)
  222. if (res.errno === 401) {
  223. return {
  224. userId: UNLOGIN,
  225. avatar: ''
  226. }
  227. } else {
  228. const data = res.data
  229. data.region = data.city ? data.city.split(',') : []
  230. data.birthday = data.birthday || '1990-01-01'
  231. return data
  232. }
  233. },
  234. async getUserInfo() {
  235. let userInfo = wx.getStorageSync('userInfo');
  236. let token = wx.getStorageSync('token');
  237. if (userInfo && userInfo.userId && token) {
  238. let info = await this.agetUserInfo()
  239. return {
  240. ...userInfo,
  241. ...info,
  242. avatarUrl: info.avatar
  243. };
  244. } else {
  245. return {
  246. userId: UNLOGIN,
  247. avatar: ''
  248. }
  249. }
  250. // let detail
  251. // let isAuth = await new Promise((r, j) => {
  252. // wx.authorize({
  253. // scope: 'scope.userInfo',
  254. // success: () => r(true),
  255. // fail: () => r(false)
  256. // })
  257. // })
  258. // if (!isAuth) {
  259. // this.setData({userAuth: true})
  260. // detail = await new Promise(r => {
  261. // this.bindGetUserInfo = (e) => {
  262. // if (e.detail.userInfo) {
  263. // this.setData({userAuth: false})
  264. // console.log('gei', e.detail)
  265. // r(e.detail)
  266. // }
  267. // }
  268. // })
  269. // } else {
  270. // detail = await new Promise(r => {
  271. // wx.getUserInfo({
  272. // success: res => r(res),
  273. // fail: () => r(false)
  274. // })
  275. // })
  276. // }
  277. // try {
  278. // let res = await user.loginByWeixin(detail)
  279. // app.globalData.userInfo = res.data.userInfo;
  280. // app.globalData.token = res.data.token;
  281. // return res.data.userInfo
  282. // } catch(e) {
  283. // return false
  284. // }
  285. },
  286. login() {
  287. getApp().setLoginProps(false)
  288. },
  289. async getSocketOptions(sceneId, roomId) {
  290. //TODO
  291. console.log('this.data.type', this.data.type)
  292. // debugger;
  293. let result
  294. if (Number(this.data.type) === 33) {
  295. result = await util.request(api.enterRoom, {
  296. businessId: roomId
  297. }, 'POST', 'application/json')
  298. if (result.code !== 200) {
  299. wx.showModal({
  300. content: result.error,
  301. complete: () => {
  302. if (result.message && result.message.isAnchor == 0) {
  303. wx.switchTab({
  304. url: '/pages/index/index',
  305. })
  306. } else {
  307. wx.redirectTo({
  308. url: '/pages/roomManger/roomManger',
  309. });
  310. }
  311. }
  312. })
  313. return
  314. }
  315. }
  316. const capacities = !!result ? result.message.capacities : 50 // 房间限制人数
  317. const {
  318. isAnchor,
  319. assistant,
  320. } = !!result ? result.message : {}
  321. let userInfo = await this.getUserInfo()
  322. // console.log('---', userInfo)
  323. // this.setData({
  324. // userInfoa: userInfo.nickname.split('').join(' ')
  325. // })
  326. userInfo.nickname = userInfo.nickname.replace(/[^\u4E00-\u9FA5A-Za-z0-9]/g, '')
  327. if (userInfo.nickname == "") {
  328. userInfo.nickname = "口"
  329. }
  330. // this.role !== 'leader'
  331. // let roomType
  332. // if ((!this.data.canShow && !this.data.join) || (this.data.join && !this.options.join)) {
  333. // // roomType = '1v1'
  334. // if (this.options.roomId) {
  335. // this.role = 'leader'
  336. // }
  337. // console.log('**************')
  338. // console.log(this.options)
  339. // }
  340. let isAllowMic // 真正MIC权, 房主与 授权一个 要在房间isAllowMic开启
  341. if (Number(isAnchor) === 1) {
  342. this.role = "leader"
  343. isAllowMic = 1
  344. } else {
  345. this.role = 'customer'
  346. isAllowMic = 0
  347. }
  348. // 助手改用isAssistant作为flag, role因为V3不能新增角色,只支持leader/customer。
  349. let isAssistant
  350. if (assistant && assistant.userId && assistant.userId == userInfo.userId) {
  351. isAssistant = true;
  352. } else {
  353. isAssistant = false
  354. }
  355. console.log('进入房间角色, 是否助手 %s', this.role, isAssistant);
  356. const isAuthMic = await this.getAuthorizeRecordStatus();
  357. // console.log('当前用户录音权限状态', isAuthMic)
  358. this.setData({
  359. isAllowMic,
  360. isAuthMic
  361. })
  362. const assistantId = (assistant && assistant.userId) ? assistant.userId : '';
  363. if (capacities) {
  364. this.setData({
  365. peopleCount: capacities
  366. })
  367. } else {
  368. this.setData({
  369. peopleCount: manyCount
  370. })
  371. }
  372. return {
  373. role: this.role,
  374. userId: userInfo.userId,
  375. // roomType,
  376. avatar: userInfo.avatarUrl,
  377. nickname: userInfo.nickname,
  378. voiceStatus: getApp().globalData.voiceProps.noMute ? 0 : 2,
  379. isAuthMic: isAuthMic ? 1 : 0,
  380. isAllowMic: isAllowMic,
  381. roomId: roomId,
  382. sceneNumber: sceneId,
  383. onlineStatus: 1,
  384. assistantId: assistantId,
  385. isAssistant: isAssistant ? 1 : 0,
  386. oid: userInfo.weixin_openid,
  387. userLimitNum: capacities || 50
  388. }
  389. },
  390. async socketStart({
  391. sceneId,
  392. roomId,
  393. options
  394. }) {
  395. if (!options) {
  396. options = await this.getSocketOptions(sceneId, roomId)
  397. }
  398. console.log('小程序参数', options)
  399. if (!options.roomId) {
  400. return Promise.resolve(false)
  401. }
  402. // 真正进入统计
  403. if (options.roomId !== '888888') {
  404. util.request(api.trackRoom, {
  405. roomId: options.roomId,
  406. type: 0
  407. }, 'POST', 'application/json')
  408. }
  409. let userInfo = await this.getUserInfo()
  410. let socket = io(remote.socketHost, {
  411. path: '/new-zfb',
  412. transport: ['websocket'],
  413. extraHeaders: {
  414. "oid": userInfo.weixin_openid
  415. },
  416. query: {
  417. ...options,
  418. isClient: true,
  419. from: 2
  420. }
  421. });
  422. this.socketInstance = socket
  423. console.error('新建socket Room', options.roomId)
  424. this.setData({
  425. socketStatus: 0,
  426. })
  427. socket.on('connect', () => this.setData({
  428. socketStatus: 1
  429. }))
  430. socket.on('connect_error', () => this.setData({
  431. socketStatus: -1
  432. }))
  433. socket.on('connect_timeout', () => this.setData({
  434. socketStatus: -1
  435. }))
  436. socket.on('disconnect', () => this.setData({
  437. socketStatus: -1
  438. }))
  439. socket.on('reconnect', () => {
  440. // wx.showToast({
  441. // title: '重连',
  442. // })
  443. this.setData({
  444. socketStatus: this.data.socketStatus
  445. })
  446. let noMute = getApp().globalData.voiceProps.noMute
  447. this.socketSendMessage('changeVoiceStatus', {
  448. status: noMute ? 0 : 2
  449. })
  450. this.socketSendMessage('changeOnlineStatus', {
  451. status: 1
  452. })
  453. })
  454. socket.on('reconnect_failed', () => this.setData({
  455. socketStatus: -1
  456. }))
  457. socket.on('error', () => this.setData({
  458. socketStatus: -1
  459. }))
  460. socket.on('roomIn', config => {
  461. let enableTalk = config.roomsConfig.enableTalk !== false
  462. let noMute = getApp().globalData.voiceProps.noMute
  463. getApp().globalData.voiceProps.force = enableTalk
  464. if (!enableTalk && !noMute) {
  465. if (this.role !== 'leader') {
  466. // this.mic()
  467. }
  468. }
  469. })
  470. this.socketSendMessage = (event, obj) => {
  471. console.error('发送 socket Room', options.roomId, event, obj)
  472. socket.emit(event, obj)
  473. }
  474. socket.on('clientSyncAction', (data) => {
  475. console.log('调用', data.type, '方法', data)
  476. if (this[data.type]) {
  477. this[data.type](data)
  478. } else if (data.type == 'wx-subscribe') {
  479. this.getUrlCode(data.data)
  480. } else {
  481. console.error('没有', data.type, '方法')
  482. }
  483. })
  484. socket.on('action', (data) => {
  485. if (data.type === 'navigateToGoods') {
  486. this.navigateToGoodsAction(data.data)
  487. }
  488. })
  489. socket.on('changeRoomEnableTalk', config => {
  490. if (this.role !== 'leader') {
  491. this.changeRoomEnableTalk(config)
  492. }
  493. })
  494. socket.on('startCall', this.startCall.bind(this))
  495. socket.on('stopCall', (data) => {
  496. console.log('on stopCall')
  497. this.stopCall(data)
  498. })
  499. this.handleSomeOneInRoom = this.handleSomeOneInRoom.bind(this)
  500. // socket.on('someOneInRoom', debounce(this.handleSomeOneInRoom, 100))
  501. socket.on('someOneInRoom', debounce(this.handleSomeOneInRoom, 100))
  502. socket.on('someOneLeaveRoom', (user, data) => {
  503. this.handleSomeOneLeave(user)
  504. })
  505. socket.on('roomClose', (data) => {
  506. console.log('on roomClose')
  507. this.stopCall(data)
  508. })
  509. socket.on('autoReJoin', (data) => {
  510. console.log('on autoReJoin')
  511. if ('roomId' in data) {
  512. options.roomId = Number(data.roomId)
  513. }
  514. })
  515. // 有MIC通知,主要是其他用户禁MIC 移到中间层处理。
  516. // socket.on('beHasMic', (data) => {
  517. // const socketOptions = this.data.socketOptions
  518. // if (data.user) {
  519. // const isOther = (socketOptions.role !== 'leader' && (Number(socketOptions.userId) !== Number(data.user.userId)));
  520. // if (isOther) {
  521. // this.closeMic();
  522. // // wx.showToast({
  523. // // title: '关mic' + isOther
  524. // // })
  525. // }
  526. // }
  527. // })
  528. socket.on("beKicked", data => {
  529. const that = this
  530. if (data.userId && data.roomId) {
  531. const socketOptions = this.data.socketOptions
  532. const userId = data.userId
  533. const roomId = data.roomId
  534. // debugger
  535. if (socketOptions.userId == userId && this.options.roomId == roomId) {
  536. wx.showToast({
  537. title: '您已被踢出房间!',
  538. icon: 'none',
  539. complete: () => {}
  540. })
  541. setTimeout(() => {
  542. that.socketStop();
  543. wx.switchTab({
  544. url: '/pages/index/index',
  545. })
  546. }, 1000)
  547. }
  548. }
  549. });
  550. socket.on("roomMaximum", () => {
  551. this.setData({
  552. roomMaximum: true
  553. })
  554. });
  555. //全员退出
  556. socket.on('roomDisMiss', () => {
  557. // wx.showToast({
  558. // title: '全员退出',
  559. // });
  560. this.setData({
  561. roomDisMiss: true
  562. })
  563. // this.exitRoom();
  564. })
  565. //服务器未知错误重进
  566. socket.on('unKnowError', () => {
  567. this.setData({
  568. unKnowError: true
  569. })
  570. })
  571. //被动通知开关MIC 要3秒后
  572. socket.on('serverOnMic', ({
  573. voiceStatus
  574. }) => {
  575. setTimeout(() => {
  576. if (Number(voiceStatus) === 2) {
  577. // wx.showToast({
  578. // title: '开MIC',
  579. // icon:'none'
  580. // })
  581. this.openMic();
  582. }
  583. if (Number(voiceStatus) === 0) {
  584. // wx.showToast({
  585. // title: '关MIC',
  586. // icon:'none'
  587. // })
  588. this.closeMic();
  589. }
  590. }, 3000)
  591. });
  592. this.socketStop = () => {
  593. if (socket) {
  594. socket.close()
  595. console.error('断开 并滞空 socket Room', options.roomId)
  596. this.setData({
  597. socketStatus: 2
  598. })
  599. socket = null
  600. }
  601. }
  602. return options
  603. },
  604. getUrlCode(url) {
  605. this.socketSendMessage('clientSyncAction', {
  606. sender: 'wx',
  607. type: 'wx-subscribe-result',
  608. data: 3020
  609. })
  610. // wx.request({
  611. // url: url, //仅为示例,并非真实的接口地址
  612. // method: 'get',
  613. // success: (res) => {
  614. // let code = -1
  615. // if (typeof res.data.code != 'undefined') {
  616. // code = res.data.code
  617. // }
  618. // this.socketSendMessage('clientSyncAction', {
  619. // sender: 'wx',
  620. // type: 'wx-subscribe-result',
  621. // data: code
  622. // })
  623. // },
  624. // fail: (err) => {
  625. // console.log(err)
  626. // }
  627. // })
  628. },
  629. changeRoomEnableTalk(data) {
  630. console.log(data)
  631. let noMute = getApp().globalData.voiceProps.noMute
  632. getApp().globalData.voiceProps.force = data.enableTalk
  633. // noMute true 静音
  634. // enableTalk false 静音
  635. if (!!data.enableTalk === !!noMute) {
  636. this.mic()
  637. }
  638. },
  639. navigateToGoods({
  640. data
  641. }) {
  642. // wx.showToast({
  643. // title: JSON.stringify(data).substr(40)
  644. // })
  645. this.navigateToGoodsAction(data)
  646. },
  647. navigateToGoodsAction(id) {
  648. wx.navigateTo({
  649. url: '/pages/goods/goods?id=' + id,
  650. })
  651. },
  652. getUrl(url, socketOptions, isJoin) {
  653. url += '&room_id=' + socketOptions.roomId + '&user_id=' + socketOptions.userId + '&origin=fashilong'
  654. if (isJoin) {
  655. url += '&role=' + this.role + '&shopping'
  656. } else {
  657. url += '&role=' + this.role
  658. }
  659. console.error(url)
  660. console.log(isJoin)
  661. return url
  662. },
  663. navigateToMiniProgram(data) {
  664. wx.showModal({
  665. title: '温馨提示',
  666. content: '即将跳到其他小程序,是否继续?',
  667. showCancel: true, //是否显示取消按钮
  668. cancelText: "取消", //默认是“取消”
  669. confirmText: "确定", //默认是“确定”
  670. success: function (res) {
  671. if (res.cancel) {
  672. //点击取消,wx.navigateBack
  673. } else {
  674. wx.navigateToMiniProgram(data.data)
  675. }
  676. },
  677. fail: function (res) {
  678. //接口调用失败的回调函数,wx.navigateBack
  679. },
  680. complete: function (res) {
  681. //接口调用结束的回调函数(调用成功、失败都会执行)
  682. },
  683. })
  684. },
  685. async handleSomeOneInRoom(data) {
  686. if (data && data.user) {
  687. console.log('handleSomeOneInRoom', data)
  688. this.startCall(data)
  689. }
  690. },
  691. async startCall(data) {
  692. //TODO 触发三次
  693. console.log('startCall-data', data)
  694. // if( this.role =='leader'){
  695. this.setData({
  696. shareStatus: 1
  697. })
  698. if (!data) return;
  699. this.setData({
  700. surplus: this.data.peopleCount - data.roomsPerson.length
  701. })
  702. //undefined是未授权,状态为3
  703. let voiceStatus
  704. if (!this.isAuthorizeRecord) {
  705. const unAuth = await this.authorizeRecord();
  706. if (typeof unAuth === 'undefined') {
  707. // debugger
  708. voiceStatus = 3
  709. } else {
  710. voiceStatus = Number(unAuth)
  711. }
  712. }
  713. //限制只有主持人才可以开麦
  714. // if (this.role == 'leader') {
  715. // if (!this.isAuthorizeRecord) {
  716. // const voiceStatus = Number(await this.authorizeRecord())
  717. // this.isAuthorizeRecord = true
  718. // // getApp().setVoiceProps({
  719. // // noMute: !voiceStatus
  720. // // })
  721. // // console.log(getApp().globalData.voiceProps.noMute)
  722. // // this.socketSendMessage('changeVoiceStatus', {
  723. // // status: getApp().globalData.voiceProps.noMute ? 0 : 2
  724. // // })
  725. // // this.data.socketOptions.voiceStatus = 1
  726. // // this.socketSendMessage('changeVoiceStatus', {status: noMute ? 0 : 2})
  727. // }
  728. // }
  729. const socketOptions = this.data.socketOptions
  730. getApp().globalData.roomId = socketOptions.roomId
  731. const user = data.roomsPerson.find(user => user.userId == socketOptions.userId)
  732. if (!user) {
  733. return
  734. }
  735. //屏蔽有人进来才开麦克风
  736. // if (data.roomsPerson.length <= 1) {
  737. // return
  738. // }
  739. user.noMute = getApp().globalData.voiceProps.noMute
  740. getApp().setVoiceProps({
  741. ...user,
  742. action: 'startCall'
  743. })
  744. // this.socketSendMessage('changeVoiceStatus', {
  745. // status: getApp().globalData.voiceProps.noMute ? 0 : 2
  746. // })
  747. // }
  748. },
  749. stopCall() {
  750. console.error('stopCall')
  751. this.setData({
  752. shareStatus: 0
  753. })
  754. getApp().setVoiceProps({
  755. noMute: false,
  756. action: 'stopCall'
  757. })
  758. if (this.runManager) {
  759. // this.recorderManager.stop()
  760. this.runManager = false
  761. }
  762. },
  763. handleSomeOneLeave(data) {
  764. if (data.roomsPerson.length <= 1) {
  765. // this.stopCall()
  766. }
  767. this.setData({
  768. surplus: this.data.peopleCount - data.roomsPerson.length
  769. })
  770. },
  771. //deprecated
  772. async newRoomBk(data) {
  773. if (data.roomId) return;
  774. this.stopCall()
  775. getApp().globalData.rtcParams = []
  776. getApp().globalData.pusher = ''
  777. if (this.data.join && !this.options.join) {
  778. wx.switchTab({
  779. url: '/pages/index/index',
  780. })
  781. return;
  782. }
  783. this.role = this.data.canShow ? 'leader' : 'customer'
  784. let options = await this.getSocketOptions(this.mcode)
  785. this.socketSendMessage('clientSyncAction', {
  786. type: 'newRoom',
  787. data: options
  788. })
  789. setTimeout(async () => {
  790. this.wssSuccess = false
  791. this.socketStop && this.socketStop()
  792. this.data.many = !!this.data.canShow
  793. // this.setData({
  794. // // peopleCount: this.data.many ? manyCount : 5
  795. // peopleCount: manyCount
  796. // })
  797. let base = this.base
  798. let socketOptions = await this.socketStart({
  799. options
  800. })
  801. let url = this.getUrl(base, socketOptions, false) + (this.urlPj || '')
  802. this.base = base
  803. this.setData({
  804. url,
  805. socketOptions,
  806. })
  807. this.joinUrl()
  808. this.setData({
  809. socketOptions
  810. })
  811. this.loadConponSuccess = true
  812. this.readySendCouponCtrl()
  813. }, 300)
  814. },
  815. // 真正退出房间
  816. async exitRoom() {
  817. const roomId = this.data.socketOptions.roomId;
  818. const role = this.role;
  819. const result = await util.request(api.exitRoom, {
  820. businessId: roomId
  821. }, 'POST', 'application/json');
  822. this.socketSendMessage('stopCall', {
  823. from: 2
  824. })
  825. this.stopCall();
  826. this.socketStop();
  827. if (role === 'leader') {
  828. wx.redirectTo({
  829. url: '/pages/roomManger/roomManger',
  830. });
  831. } else {
  832. wx.switchTab({
  833. url: '/pages/index/index'
  834. });
  835. }
  836. },
  837. async exit() {
  838. // this.stopCall()
  839. getApp().globalData.rtcParams = []
  840. getApp().globalData.pusher = ''
  841. this.socketStop && this.socketStop()
  842. this.role = 'leader'
  843. let base = this.base
  844. let socketOptions = await this.socketStart({
  845. sceneId: this.mcode
  846. })
  847. let url = this.getUrl(base, socketOptions, false) + (this.urlPj || '')
  848. this.base = base
  849. wx.nextTick(() => {
  850. setTimeout(() => {
  851. this.setData({
  852. url,
  853. loadUrl: true,
  854. socketOptions,
  855. showCommodityCtrl: false,
  856. hideWebView: false,
  857. reload: true
  858. })
  859. this.joinUrl()
  860. }, 500)
  861. })
  862. },
  863. clearDebuger() {
  864. this.setData({
  865. debugerInfo: ''
  866. })
  867. },
  868. async mic({
  869. data
  870. }) {
  871. if (Number(data.user.isAllowMic) === 1) {
  872. let noMute = getApp().globalData.voiceProps.noMute
  873. // debugger
  874. // noMute true 静音
  875. // enableTalk false 静音
  876. // if (!!getApp().globalData.voiceProps.force === !!noMute)
  877. // return
  878. // if (!getApp().globalData.voiceProps.force && (!this.data.socketOptions.voiceStatus || noMute)) return;
  879. if (!this.data.socketOptions.voiceStatus) {
  880. let voiceStatus = await this.authorizeRecord()
  881. if (voiceStatus) {
  882. this.data.socketOptions.voiceStatus = 1
  883. noMute = false
  884. } else {
  885. noMute = true
  886. }
  887. } else {
  888. noMute = !noMute
  889. }
  890. getApp().globalData.voiceProps.noMute = noMute
  891. this.socketSendMessage('changeVoiceStatus', {
  892. status: noMute ? 0 : 2,
  893. user: data.user
  894. })
  895. getApp().setVoiceProps({
  896. noMute
  897. })
  898. wx.showToast({
  899. title: `已${noMute ? '关闭' : '开启'}麦克风`,
  900. })
  901. }
  902. },
  903. closeMic() {
  904. getApp().globalData.voiceProps.noMute = true
  905. this.socketSendMessage('changeVoiceStatus', {
  906. status: 0,
  907. })
  908. getApp().setVoiceProps({
  909. noMute: true
  910. })
  911. },
  912. openMic() {
  913. getApp().globalData.voiceProps.noMute = false
  914. this.socketSendMessage('changeVoiceStatus', {
  915. status: 2,
  916. })
  917. getApp().setVoiceProps({
  918. noMute: false
  919. })
  920. },
  921. callPhone() {
  922. wx.makePhoneCall({
  923. phoneNumber: this.data.contractPhone,
  924. })
  925. this.setData({
  926. showContact: false
  927. })
  928. },
  929. /**
  930. * 用户点击右上角分享
  931. */
  932. onShareAppMessage: function (res) {
  933. let {
  934. id,
  935. newPicUrl
  936. } = this.data
  937. if (res.from === 'button') {
  938. this.setData({
  939. sendShare: false
  940. })
  941. return {
  942. title: '【好友推荐】一起来云逛吧',
  943. imageUrl: newPicUrl,
  944. path: `/pages/webview/index?id=${id}&type=${this.data.type}&join=true&roomId=${this.data.socketOptions.roomId}&many=${!!this.data.many}`,
  945. }
  946. } else {
  947. return {
  948. imageUrl: newPicUrl,
  949. path: `/pages/webview/index?id=${id}&type=${this.data.type}&join=false`,
  950. }
  951. }
  952. },
  953. /**
  954. * 生命周期函数--监听页面卸载
  955. */
  956. onUnload: function () {
  957. console.log('on onUnload')
  958. // this.socketSendMessage('stopCall', {})
  959. // this.stopCall()
  960. this.socketStop && this.socketStop()
  961. getApp().globalData.pusher = ''
  962. },
  963. cart(data) {
  964. this.setData({
  965. showCommodityCtrl: data.data
  966. })
  967. },
  968. share() {
  969. console.log('share-debug')
  970. const companyName = `指房宝(杭州)科技有限公司`
  971. const vrLink = `/pages/webview/index`
  972. const img_url = this.data.newPicUrl || 'http://video.cgaii.com/new4dage/images/images/home_2_a.jpg'
  973. const shareImg = img_url
  974. this.count = this.count || 0
  975. console.log('share-debug many:%s shareStatus: %s', !!this.data.many, this.data.shareStatus);
  976. if (this.data.many && this.data.shareStatus == 1) {
  977. //开启一起逛时候的分享
  978. console.log(`share-debug: /pages/shareRoom/shareRoom?img_url=${btoa(img_url)}&vrLink=${btoa(vrLink)}&id=${this.data.id}&type=${this.data.type}&roomId=${this.data.socketOptions.roomId}&many=${!!this.data.many}`)
  979. console.log('share-debug', this.data.socketOptions)
  980. wx.navigateTo({
  981. url: `/pages/shareRoom/shareRoom?img_url=${btoa(img_url)}&vrLink=${btoa(vrLink)}&id=${this.data.id}&type=${this.data.type}&roomId=${this.data.socketOptions.roomId}&many=${!!this.data.many}`,
  982. })
  983. } else {
  984. console.log(`share-debug: /pages/shared/shared?img_url=${btoa(img_url)}&shareImg=${btoa(shareImg)}&companyName=${companyName}&vrLink=${btoa(vrLink)}&id=${this.data.id}&type=${this.data.type}`);
  985. wx.navigateTo({
  986. url: `/pages/shared/shared?img_url=${btoa(img_url)}&shareImg=${btoa(shareImg)}&companyName=${companyName}&vrLink=${btoa(vrLink)}&id=${this.data.id}&type=${this.data.type}`,
  987. })
  988. }
  989. },
  990. back(data) {
  991. if (data.sender !== 'h5') return;
  992. wx.switchTab({
  993. url: '/pages/index/index'
  994. })
  995. this.setData({
  996. showCommodityCtrl: false
  997. })
  998. },
  999. service() {
  1000. this.setData({
  1001. showContact: true,
  1002. showCommodity: false,
  1003. showCoupon: false
  1004. })
  1005. },
  1006. invite(data) {
  1007. if (data.sender !== 'h5') return;
  1008. // 分享房间进入统计
  1009. if (this.data.socketOptions.roomId !== '888888') {
  1010. util.request(api.trackRoom, {
  1011. roomId: this.data.socketOptions.roomId,
  1012. type: 1,
  1013. }, 'POST', 'application/json')
  1014. }
  1015. this.setData({
  1016. sendShare: true,
  1017. count: ++this.data.count
  1018. })
  1019. },
  1020. coupon(data) {
  1021. if (data.sender !== 'h5') return;
  1022. this.setData({
  1023. showContact: false,
  1024. showCommodity: false,
  1025. showCoupon: true
  1026. })
  1027. },
  1028. liveGotoGood(ev) {
  1029. let id = ev.currentTarget.dataset.item.goodsId
  1030. wx.navigateTo({
  1031. url: '/pages/goods/goods?id=' + id,
  1032. })
  1033. },
  1034. gotoGoodsDOM(event) {
  1035. this.gotoGoods(event.currentTarget.dataset.item.hotIdList[0])
  1036. },
  1037. gotoGoodsSocket(data) {
  1038. this.gotoGoods(data.data)
  1039. },
  1040. gotoGoods(id) {
  1041. console.log('---', id)
  1042. this.socketSendMessage('clientSyncAction', {
  1043. type: 'openTag',
  1044. data: id
  1045. })
  1046. this.setData({
  1047. showCommodity: false
  1048. })
  1049. this.joinUrl()
  1050. },
  1051. addCard(event) {
  1052. wx.navigateTo({
  1053. url: '/pages/goods/goods?id=' + event.currentTarget.dataset.id + '&oper=addCard',
  1054. })
  1055. },
  1056. buyGoods(event) {
  1057. wx.navigateTo({
  1058. url: '/pages/goods/goods?id=' + event.currentTarget.dataset.id + '&oper=buyGoods',
  1059. })
  1060. },
  1061. showCommodityFn() {
  1062. this.setData({
  1063. showCommodity: true,
  1064. showContact: false,
  1065. showCoupon: false
  1066. })
  1067. this.joinUrl()
  1068. },
  1069. hideComodity() {
  1070. this.setData({
  1071. showCommodity: false
  1072. })
  1073. this.joinUrl()
  1074. },
  1075. hideCoupon() {
  1076. this.setData({
  1077. showCoupon: !this.data.showCoupon
  1078. })
  1079. },
  1080. async receive(ev) {
  1081. let item = ev.target.dataset.item
  1082. try {
  1083. // wx.showToast({
  1084. // title: '领取优惠卷',
  1085. // })
  1086. // return;
  1087. if (item.hasReceived || item.number <= item.receiveNumber) return;
  1088. let res = await util.request(api.CouponExchange, {
  1089. couponId: item.id
  1090. })
  1091. if (res.code === 0) {
  1092. wx.showToast({
  1093. title: '已成功领取',
  1094. success: () => {
  1095. this.setData({
  1096. showCoupon: false
  1097. })
  1098. wx.nextTick(() => {
  1099. this.setData({
  1100. coupons: this.data.coupons.map(citem => {
  1101. return {
  1102. ...citem,
  1103. hasReceived: citem.id === item.id ? true : citem.hasReceived
  1104. }
  1105. }),
  1106. showCoupon: true
  1107. })
  1108. })
  1109. }
  1110. })
  1111. } else if (res.errno === 401) {
  1112. getApp().setLoginProps(false)
  1113. } else {
  1114. wx.showToast({
  1115. title: res.msg,
  1116. })
  1117. }
  1118. } catch (e) {
  1119. console.error(e)
  1120. wx.showToast({
  1121. icon: 'none',
  1122. title: '领取失败',
  1123. })
  1124. }
  1125. },
  1126. async getCouponList(id) {
  1127. const success = (res) => {
  1128. this.setData({
  1129. coupons: res.data.list.map(item => {
  1130. item.typeMoney = item.typeMoney.toString()
  1131. item.fontSize = item.typeMoney.length === 3 ? '90rpx' :
  1132. item.typeMoney.length === 4 ? '70rpx' : '130rpx'
  1133. return item
  1134. })
  1135. })
  1136. this.loadConponSuccess = true
  1137. this.readySendCouponCtrl()
  1138. }
  1139. let res = await util.request(api.BrandCouponList, {
  1140. brandId: id,
  1141. pageNum: 1,
  1142. pageSize: 10000
  1143. }, 'GET')
  1144. console.log(res)
  1145. if (res.code === 0) {
  1146. success(res)
  1147. } else {
  1148. let res = await util.request(api.UNBrandCouponList, {
  1149. brandId: id,
  1150. pageNum: 1,
  1151. pageSize: 10000
  1152. }, 'GET')
  1153. success(res)
  1154. }
  1155. },
  1156. ready() {
  1157. this.wssSuccess = true
  1158. this.readySendCouponCtrl()
  1159. },
  1160. readySendCouponCtrl() {
  1161. if (this.wssSuccess && this.loadConponSuccess) {
  1162. this.loadConponSuccess = false
  1163. this.socketSendMessage('clientSyncAction', {
  1164. type: 'showCoupon',
  1165. data: this.data.coupons.length > 0
  1166. })
  1167. }
  1168. },
  1169. getBrand: function (id, code) {
  1170. this.getGoodsCount(code, id)
  1171. return;
  1172. },
  1173. getGoodsCount(code, id) {
  1174. util.request(api.GoodsNumCount, {
  1175. isDelete: 0,
  1176. isOnSale: 1,
  1177. brandId: id
  1178. }, 'GET')
  1179. .then(res => {
  1180. if (res.errno === 0) {
  1181. this.setData({
  1182. goodsCount: res.data
  1183. })
  1184. }
  1185. this.getCouponList(id)
  1186. })
  1187. },
  1188. getGoodsList(id, category_id) {
  1189. var that = this;
  1190. if (!(this.data.navList && this.data.navList.length)) {
  1191. that.navDatas = {}
  1192. let navDatas = this.data.navList = this.data.comtypes
  1193. // util.request(api.GoodsCategory, { id: category_id })
  1194. // .then(function (res) {
  1195. // if (res.errno == 0) {
  1196. // let navDatas = res.data.brotherCategory
  1197. // that.setData({
  1198. // navList: navDatas,
  1199. // currTypeId: category_id
  1200. // });
  1201. that.navDatas = {}
  1202. navDatas.forEach(item => {
  1203. util.request(api.GoodsList, {
  1204. brandId: id,
  1205. categoryId: item.category_id,
  1206. page: that.data.page,
  1207. size: that.data.size
  1208. })
  1209. .then(res => {
  1210. if (res.errno === 0) {
  1211. that.navDatas[item.category_id] = res.data.goodsList
  1212. }
  1213. })
  1214. })
  1215. // }
  1216. // })
  1217. }
  1218. if (that.navDatas[category_id]) {
  1219. if (!isIos) {
  1220. let showCommodity = that.data.showCommodity
  1221. that.setData({
  1222. showCommodity: false
  1223. })
  1224. setTimeout(() => {
  1225. wx.nextTick(() => {
  1226. that.setData({
  1227. goodsList: that.navDatas[category_id],
  1228. currTypeId: category_id,
  1229. showCommodity: showCommodity
  1230. });
  1231. })
  1232. }, 500)
  1233. } else {
  1234. that.setData({
  1235. goodsList: that.navDatas[category_id],
  1236. currTypeId: category_id,
  1237. });
  1238. }
  1239. } else {
  1240. console.error('诱惑去啦')
  1241. util.request(api.GoodsList, {
  1242. brandId: id,
  1243. categoryId: category_id,
  1244. page: that.data.page,
  1245. size: that.data.size
  1246. })
  1247. .then(function (res) {
  1248. if (res.errno === 0) {
  1249. that.setData({
  1250. goodsList: res.data.goodsList,
  1251. currTypeId: category_id
  1252. });
  1253. // this.data.navList
  1254. }
  1255. });
  1256. }
  1257. },
  1258. getBrandDetail: function (id, type, cb) {
  1259. console.log('getBrandDetail-params', id, type)
  1260. util.request(api.BrandDetail, {
  1261. id: id,
  1262. type: type,
  1263. }).then((res) => {
  1264. console.log('getBrandDetail', res)
  1265. let base = res.data.brand.sceneUrl
  1266. // let base = 'http://192.168.0.112:8080/shop.html?m=t-7Uqj9Fq&origin=fashilong'
  1267. if (res.errno === 0) {
  1268. let url = base + "&sid=" + id
  1269. // debugger
  1270. this.setData({
  1271. id: id,
  1272. newPicUrl: res.data.brand.appListPicUrl,
  1273. sceneNum: res.data.brand.sceneNum,
  1274. canShow: res.data.brand.canShow,
  1275. contractPhone: res.data.brand.contractPhone,
  1276. contactInfo: {
  1277. contactPhone: res.data.brand.contactPhone || '',
  1278. contactHead: res.data.brand.contactHead || '',
  1279. contactCompanyName: res.data.brand.contactCompanyName || '',
  1280. contactNickName: res.data.brand.contactNickName || '',
  1281. brands: res.data.brand.brands || []
  1282. }
  1283. })
  1284. if (this.data.many === void 0) {
  1285. this.data.many = !!res.data.brand.canShow
  1286. }
  1287. this.setData({
  1288. // peopleCount: this.data.many ? manyCount : 5,
  1289. peopleCount: manyCount
  1290. })
  1291. if (!res.data.brand.canShow) {
  1292. this.role = 'customer'
  1293. } else if (!this.options.join) {
  1294. this.role = 'leader'
  1295. }
  1296. cb(url, urlToJson(url).m, )
  1297. }
  1298. });
  1299. },
  1300. sendContactInfo() {
  1301. // this.socketSendMessage('getContactInfo', {
  1302. // contactInfo: this.data.contactInfo,
  1303. // })
  1304. this.socketSendMessage('clientSyncAction', {
  1305. type: 'getContactInfo',
  1306. contactInfo: this.data.contactInfo
  1307. })
  1308. },
  1309. goToCase({
  1310. data
  1311. }) {
  1312. console.log('data', data)
  1313. wx.showModal({
  1314. title: '提示',
  1315. content: `是否跳转到新的场景?`,
  1316. showCancel: true,
  1317. confirmColor: "#52a2d8",
  1318. success: res => {
  1319. if (res.confirm) {
  1320. wx.navigateTo({
  1321. url: `/pages/webview/index?id=${data.id}&type=32`,
  1322. })
  1323. }
  1324. },
  1325. fail: () => {
  1326. }
  1327. })
  1328. },
  1329. selectType(ev) {
  1330. this.getGoodsList(this.options.id, ev.target.dataset.item.category_id)
  1331. },
  1332. hideCS() {
  1333. this.setData({
  1334. showCommodity: false,
  1335. showCoupon: false,
  1336. showContact: false
  1337. })
  1338. },
  1339. hideContact() {
  1340. this.setData({
  1341. showContact: false
  1342. })
  1343. },
  1344. calcShare() {
  1345. // this.exit()
  1346. this.setData({
  1347. sendShare: false
  1348. })
  1349. },
  1350. contactKf() {
  1351. let keys = Object.keys(this.navDatas)
  1352. let goodsId = this.navDatas[keys[0]][0].id
  1353. let user = wx.getStorageSync('userinfoDetail')
  1354. util.request(api.AddTalkCount, {
  1355. goodsId,
  1356. viewId: user && user.userId || '',
  1357. sceneNum: this.data.sceneNum
  1358. }, 'get')
  1359. this.hideAlert && this.hideAlert()
  1360. this.hideContact && this.hideContact()
  1361. },
  1362. onHide() {
  1363. this.socketSendMessage('changeOnlineStatus', {
  1364. status: 0
  1365. })
  1366. this.pauseVideo = true
  1367. this.joinUrl()
  1368. }
  1369. }