socket.js 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588
  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. this.exitRoom();
  537. wx.showToast({
  538. title: '您已被踢出房间!',
  539. icon: 'none',
  540. complete: () => {
  541. setTimeout(() => {
  542. that.socketStop();
  543. wx.switchTab({
  544. url: '/pages/index/index',
  545. })
  546. }, 1000)
  547. }
  548. })
  549. }
  550. }
  551. });
  552. socket.on("roomMaximum", () => {
  553. this.setData({
  554. roomMaximum: true
  555. })
  556. });
  557. //全员退出
  558. socket.on('roomDisMiss', () => {
  559. // wx.showToast({
  560. // title: '全员退出',
  561. // });
  562. this.setData({
  563. roomDisMiss: true
  564. })
  565. // this.exitRoom();
  566. })
  567. //服务器未知错误重进
  568. socket.on('unKnowError', () => {
  569. this.setData({
  570. unKnowError: true
  571. })
  572. })
  573. //被动通知开关MIC 要3秒后
  574. socket.on('serverOnMic', ({
  575. voiceStatus
  576. }) => {
  577. setTimeout(() => {
  578. if (Number(voiceStatus) === 2) {
  579. // wx.showToast({
  580. // title: '开MIC',
  581. // icon:'none'
  582. // })
  583. this.openMic();
  584. }
  585. if (Number(voiceStatus) === 0) {
  586. // wx.showToast({
  587. // title: '关MIC',
  588. // icon:'none'
  589. // })
  590. this.closeMic();
  591. }
  592. }, 3000)
  593. });
  594. this.socketStop = () => {
  595. if (socket) {
  596. socket.close()
  597. console.error('断开 并滞空 socket Room', options.roomId)
  598. this.setData({
  599. socketStatus: 2
  600. })
  601. socket = null
  602. }
  603. }
  604. return options
  605. },
  606. getUrlCode(url) {
  607. this.socketSendMessage('clientSyncAction', {
  608. sender: 'wx',
  609. type: 'wx-subscribe-result',
  610. data: 3020
  611. })
  612. // wx.request({
  613. // url: url, //仅为示例,并非真实的接口地址
  614. // method: 'get',
  615. // success: (res) => {
  616. // let code = -1
  617. // if (typeof res.data.code != 'undefined') {
  618. // code = res.data.code
  619. // }
  620. // this.socketSendMessage('clientSyncAction', {
  621. // sender: 'wx',
  622. // type: 'wx-subscribe-result',
  623. // data: code
  624. // })
  625. // },
  626. // fail: (err) => {
  627. // console.log(err)
  628. // }
  629. // })
  630. },
  631. changeRoomEnableTalk(data) {
  632. console.log(data)
  633. let noMute = getApp().globalData.voiceProps.noMute
  634. getApp().globalData.voiceProps.force = data.enableTalk
  635. // noMute true 静音
  636. // enableTalk false 静音
  637. if (!!data.enableTalk === !!noMute) {
  638. this.mic()
  639. }
  640. },
  641. navigateToGoods({
  642. data
  643. }) {
  644. // wx.showToast({
  645. // title: JSON.stringify(data).substr(40)
  646. // })
  647. this.navigateToGoodsAction(data)
  648. },
  649. navigateToGoodsAction(id) {
  650. wx.navigateTo({
  651. url: '/pages/goods/goods?id=' + id,
  652. })
  653. },
  654. getUrl(url, socketOptions, isJoin) {
  655. url += '&room_id=' + socketOptions.roomId + '&user_id=' + socketOptions.userId + '&origin=fashilong'
  656. if (isJoin) {
  657. url += '&role=' + this.role + '&shopping'
  658. } else {
  659. url += '&role=' + this.role
  660. }
  661. console.error(url)
  662. console.log(isJoin)
  663. return url
  664. },
  665. navigateToMiniProgram(data) {
  666. wx.showModal({
  667. title: '温馨提示',
  668. content: '即将跳到其他小程序,是否继续?',
  669. showCancel: true, //是否显示取消按钮
  670. cancelText: "取消", //默认是“取消”
  671. confirmText: "确定", //默认是“确定”
  672. success: function (res) {
  673. if (res.cancel) {
  674. //点击取消,wx.navigateBack
  675. } else {
  676. wx.navigateToMiniProgram(data.data)
  677. }
  678. },
  679. fail: function (res) {
  680. //接口调用失败的回调函数,wx.navigateBack
  681. },
  682. complete: function (res) {
  683. //接口调用结束的回调函数(调用成功、失败都会执行)
  684. },
  685. })
  686. },
  687. async handleSomeOneInRoom(data) {
  688. if (data && data.user) {
  689. console.log('handleSomeOneInRoom', data)
  690. this.startCall(data)
  691. }
  692. },
  693. async startCall(data) {
  694. //TODO 触发三次
  695. console.log('startCall-data', data)
  696. // if( this.role =='leader'){
  697. this.setData({
  698. shareStatus: 1
  699. })
  700. if (!data) return;
  701. this.setData({
  702. surplus: this.data.peopleCount - data.roomsPerson.length
  703. })
  704. //undefined是未授权,状态为3
  705. let voiceStatus
  706. if (!this.isAuthorizeRecord) {
  707. const unAuth = await this.authorizeRecord();
  708. if (typeof unAuth === 'undefined') {
  709. // debugger
  710. voiceStatus = 3
  711. } else {
  712. voiceStatus = Number(unAuth)
  713. }
  714. }
  715. //限制只有主持人才可以开麦
  716. // if (this.role == 'leader') {
  717. // if (!this.isAuthorizeRecord) {
  718. // const voiceStatus = Number(await this.authorizeRecord())
  719. // this.isAuthorizeRecord = true
  720. // // getApp().setVoiceProps({
  721. // // noMute: !voiceStatus
  722. // // })
  723. // // console.log(getApp().globalData.voiceProps.noMute)
  724. // // this.socketSendMessage('changeVoiceStatus', {
  725. // // status: getApp().globalData.voiceProps.noMute ? 0 : 2
  726. // // })
  727. // // this.data.socketOptions.voiceStatus = 1
  728. // // this.socketSendMessage('changeVoiceStatus', {status: noMute ? 0 : 2})
  729. // }
  730. // }
  731. const socketOptions = this.data.socketOptions
  732. getApp().globalData.roomId = socketOptions.roomId
  733. const user = data.roomsPerson.find(user => user.userId == socketOptions.userId)
  734. if (!user) {
  735. return
  736. }
  737. //屏蔽有人进来才开麦克风
  738. // if (data.roomsPerson.length <= 1) {
  739. // return
  740. // }
  741. user.noMute = getApp().globalData.voiceProps.noMute
  742. getApp().setVoiceProps({
  743. ...user,
  744. action: 'startCall'
  745. })
  746. // this.socketSendMessage('changeVoiceStatus', {
  747. // status: getApp().globalData.voiceProps.noMute ? 0 : 2
  748. // })
  749. // }
  750. },
  751. stopCall() {
  752. console.error('stopCall')
  753. this.setData({
  754. shareStatus: 0
  755. })
  756. getApp().setVoiceProps({
  757. noMute: false,
  758. action: 'stopCall'
  759. })
  760. if (this.runManager) {
  761. // this.recorderManager.stop()
  762. this.runManager = false
  763. }
  764. },
  765. handleSomeOneLeave(data) {
  766. if (data.roomsPerson.length <= 1) {
  767. // this.stopCall()
  768. }
  769. this.setData({
  770. surplus: this.data.peopleCount - data.roomsPerson.length
  771. })
  772. },
  773. //deprecated
  774. async newRoomBk(data) {
  775. if (data.roomId) return;
  776. this.stopCall()
  777. getApp().globalData.rtcParams = []
  778. getApp().globalData.pusher = ''
  779. if (this.data.join && !this.options.join) {
  780. wx.switchTab({
  781. url: '/pages/index/index',
  782. })
  783. return;
  784. }
  785. this.role = this.data.canShow ? 'leader' : 'customer'
  786. let options = await this.getSocketOptions(this.mcode)
  787. this.socketSendMessage('clientSyncAction', {
  788. type: 'newRoom',
  789. data: options
  790. })
  791. setTimeout(async () => {
  792. this.wssSuccess = false
  793. this.socketStop && this.socketStop()
  794. this.data.many = !!this.data.canShow
  795. // this.setData({
  796. // // peopleCount: this.data.many ? manyCount : 5
  797. // peopleCount: manyCount
  798. // })
  799. let base = this.base
  800. let socketOptions = await this.socketStart({
  801. options
  802. })
  803. let url = this.getUrl(base, socketOptions, false) + (this.urlPj || '')
  804. this.base = base
  805. this.setData({
  806. url,
  807. socketOptions,
  808. })
  809. this.joinUrl()
  810. this.setData({
  811. socketOptions
  812. })
  813. this.loadConponSuccess = true
  814. this.readySendCouponCtrl()
  815. }, 300)
  816. },
  817. // 真正退出房间
  818. async exitRoom() {
  819. const roomId = this.data.socketOptions.roomId;
  820. const role = this.role;
  821. const result = await util.request(api.exitRoom, {
  822. businessId: roomId
  823. }, 'POST', 'application/json');
  824. this.socketSendMessage('stopCall', {
  825. from: 2
  826. })
  827. this.stopCall();
  828. this.socketStop();
  829. if (role === 'leader') {
  830. wx.redirectTo({
  831. url: '/pages/roomManger/roomManger',
  832. });
  833. } else {
  834. wx.switchTab({
  835. url: '/pages/index/index'
  836. });
  837. }
  838. },
  839. exitRoomApi() {
  840. const roomId = this.data.socketOptions.roomId;
  841. const role = this.role;
  842. util.request(api.exitRoom, {
  843. businessId: roomId
  844. }, 'POST', 'application/json');
  845. },
  846. async exit() {
  847. // this.stopCall()
  848. getApp().globalData.rtcParams = []
  849. getApp().globalData.pusher = ''
  850. this.socketStop && this.socketStop()
  851. this.role = 'leader'
  852. let base = this.base
  853. let socketOptions = await this.socketStart({
  854. sceneId: this.mcode
  855. })
  856. let url = this.getUrl(base, socketOptions, false) + (this.urlPj || '')
  857. this.base = base
  858. wx.nextTick(() => {
  859. setTimeout(() => {
  860. this.setData({
  861. url,
  862. loadUrl: true,
  863. socketOptions,
  864. showCommodityCtrl: false,
  865. hideWebView: false,
  866. reload: true
  867. })
  868. this.joinUrl()
  869. }, 500)
  870. })
  871. },
  872. clearDebuger() {
  873. this.setData({
  874. debugerInfo: ''
  875. })
  876. },
  877. async mic({
  878. data
  879. }) {
  880. if (Number(data.user.isAllowMic) === 1) {
  881. let noMute = getApp().globalData.voiceProps.noMute
  882. // debugger
  883. // noMute true 静音
  884. // enableTalk false 静音
  885. // if (!!getApp().globalData.voiceProps.force === !!noMute)
  886. // return
  887. // if (!getApp().globalData.voiceProps.force && (!this.data.socketOptions.voiceStatus || noMute)) return;
  888. if (!this.data.socketOptions.voiceStatus) {
  889. let voiceStatus = await this.authorizeRecord()
  890. if (voiceStatus) {
  891. this.data.socketOptions.voiceStatus = 1
  892. noMute = false
  893. } else {
  894. noMute = true
  895. }
  896. } else {
  897. noMute = !noMute
  898. }
  899. getApp().globalData.voiceProps.noMute = noMute
  900. this.socketSendMessage('changeVoiceStatus', {
  901. status: noMute ? 0 : 2,
  902. user: data.user
  903. })
  904. getApp().setVoiceProps({
  905. noMute
  906. })
  907. wx.showToast({
  908. title: `已${noMute ? '关闭' : '开启'}麦克风`,
  909. })
  910. }
  911. },
  912. closeMic() {
  913. getApp().globalData.voiceProps.noMute = true
  914. this.socketSendMessage('changeVoiceStatus', {
  915. status: 0,
  916. })
  917. getApp().setVoiceProps({
  918. noMute: true
  919. })
  920. },
  921. openMic() {
  922. getApp().globalData.voiceProps.noMute = false
  923. this.socketSendMessage('changeVoiceStatus', {
  924. status: 2,
  925. })
  926. getApp().setVoiceProps({
  927. noMute: false
  928. })
  929. },
  930. callPhone() {
  931. wx.makePhoneCall({
  932. phoneNumber: this.data.contractPhone,
  933. })
  934. this.setData({
  935. showContact: false
  936. })
  937. },
  938. /**
  939. * 用户点击右上角分享
  940. */
  941. onShareAppMessage: function (res) {
  942. let {
  943. id,
  944. newPicUrl
  945. } = this.data
  946. if (res.from === 'button') {
  947. this.setData({
  948. sendShare: false
  949. })
  950. return {
  951. title: '【好友推荐】一起来云逛吧',
  952. imageUrl: newPicUrl,
  953. path: `/pages/webview/index?id=${id}&type=${this.data.type}&join=true&roomId=${this.data.socketOptions.roomId}&many=${!!this.data.many}`,
  954. }
  955. } else {
  956. return {
  957. imageUrl: newPicUrl,
  958. path: `/pages/webview/index?id=${id}&type=${this.data.type}&join=false`,
  959. }
  960. }
  961. },
  962. /**
  963. * 生命周期函数--监听页面卸载
  964. */
  965. onUnload: function () {
  966. console.log('on onUnload')
  967. // this.socketSendMessage('stopCall', {})
  968. // this.stopCall()
  969. this.socketStop && this.socketStop()
  970. getApp().globalData.pusher = ''
  971. },
  972. cart(data) {
  973. this.setData({
  974. showCommodityCtrl: data.data
  975. })
  976. },
  977. share() {
  978. console.log('share-debug')
  979. const companyName = `指房宝(杭州)科技有限公司`
  980. const vrLink = `/pages/webview/index`
  981. const img_url = this.data.newPicUrl || 'http://video.cgaii.com/new4dage/images/images/home_2_a.jpg'
  982. const shareImg = img_url
  983. this.count = this.count || 0
  984. console.log('share-debug many:%s shareStatus: %s', !!this.data.many, this.data.shareStatus);
  985. if (this.data.many && this.data.shareStatus == 1) {
  986. //开启一起逛时候的分享
  987. 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}`)
  988. console.log('share-debug', this.data.socketOptions)
  989. wx.navigateTo({
  990. 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}`,
  991. })
  992. } else {
  993. 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}`);
  994. wx.navigateTo({
  995. 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}`,
  996. })
  997. }
  998. },
  999. back(data) {
  1000. if (data.sender !== 'h5') return;
  1001. wx.switchTab({
  1002. url: '/pages/index/index'
  1003. })
  1004. this.setData({
  1005. showCommodityCtrl: false
  1006. })
  1007. },
  1008. service() {
  1009. this.setData({
  1010. showContact: true,
  1011. showCommodity: false,
  1012. showCoupon: false
  1013. })
  1014. },
  1015. invite(data) {
  1016. if (data.sender !== 'h5') return;
  1017. // 分享房间进入统计
  1018. if (this.data.socketOptions.roomId !== '888888') {
  1019. util.request(api.trackRoom, {
  1020. roomId: this.data.socketOptions.roomId,
  1021. type: 1,
  1022. }, 'POST', 'application/json')
  1023. }
  1024. this.setData({
  1025. sendShare: true,
  1026. count: ++this.data.count
  1027. })
  1028. },
  1029. coupon(data) {
  1030. if (data.sender !== 'h5') return;
  1031. this.setData({
  1032. showContact: false,
  1033. showCommodity: false,
  1034. showCoupon: true
  1035. })
  1036. },
  1037. liveGotoGood(ev) {
  1038. let id = ev.currentTarget.dataset.item.goodsId
  1039. wx.navigateTo({
  1040. url: '/pages/goods/goods?id=' + id,
  1041. })
  1042. },
  1043. gotoGoodsDOM(event) {
  1044. this.gotoGoods(event.currentTarget.dataset.item.hotIdList[0])
  1045. },
  1046. gotoGoodsSocket(data) {
  1047. this.gotoGoods(data.data)
  1048. },
  1049. gotoGoods(id) {
  1050. console.log('---', id)
  1051. this.socketSendMessage('clientSyncAction', {
  1052. type: 'openTag',
  1053. data: id
  1054. })
  1055. this.setData({
  1056. showCommodity: false
  1057. })
  1058. this.joinUrl()
  1059. },
  1060. addCard(event) {
  1061. wx.navigateTo({
  1062. url: '/pages/goods/goods?id=' + event.currentTarget.dataset.id + '&oper=addCard',
  1063. })
  1064. },
  1065. buyGoods(event) {
  1066. wx.navigateTo({
  1067. url: '/pages/goods/goods?id=' + event.currentTarget.dataset.id + '&oper=buyGoods',
  1068. })
  1069. },
  1070. showCommodityFn() {
  1071. this.setData({
  1072. showCommodity: true,
  1073. showContact: false,
  1074. showCoupon: false
  1075. })
  1076. this.joinUrl()
  1077. },
  1078. hideComodity() {
  1079. this.setData({
  1080. showCommodity: false
  1081. })
  1082. this.joinUrl()
  1083. },
  1084. hideCoupon() {
  1085. this.setData({
  1086. showCoupon: !this.data.showCoupon
  1087. })
  1088. },
  1089. async receive(ev) {
  1090. let item = ev.target.dataset.item
  1091. try {
  1092. // wx.showToast({
  1093. // title: '领取优惠卷',
  1094. // })
  1095. // return;
  1096. if (item.hasReceived || item.number <= item.receiveNumber) return;
  1097. let res = await util.request(api.CouponExchange, {
  1098. couponId: item.id
  1099. })
  1100. if (res.code === 0) {
  1101. wx.showToast({
  1102. title: '已成功领取',
  1103. success: () => {
  1104. this.setData({
  1105. showCoupon: false
  1106. })
  1107. wx.nextTick(() => {
  1108. this.setData({
  1109. coupons: this.data.coupons.map(citem => {
  1110. return {
  1111. ...citem,
  1112. hasReceived: citem.id === item.id ? true : citem.hasReceived
  1113. }
  1114. }),
  1115. showCoupon: true
  1116. })
  1117. })
  1118. }
  1119. })
  1120. } else if (res.errno === 401) {
  1121. getApp().setLoginProps(false)
  1122. } else {
  1123. wx.showToast({
  1124. title: res.msg,
  1125. })
  1126. }
  1127. } catch (e) {
  1128. console.error(e)
  1129. wx.showToast({
  1130. icon: 'none',
  1131. title: '领取失败',
  1132. })
  1133. }
  1134. },
  1135. async getCouponList(id) {
  1136. const success = (res) => {
  1137. this.setData({
  1138. coupons: res.data.list.map(item => {
  1139. item.typeMoney = item.typeMoney.toString()
  1140. item.fontSize = item.typeMoney.length === 3 ? '90rpx' :
  1141. item.typeMoney.length === 4 ? '70rpx' : '130rpx'
  1142. return item
  1143. })
  1144. })
  1145. this.loadConponSuccess = true
  1146. this.readySendCouponCtrl()
  1147. }
  1148. let res = await util.request(api.BrandCouponList, {
  1149. brandId: id,
  1150. pageNum: 1,
  1151. pageSize: 10000
  1152. }, 'GET')
  1153. console.log(res)
  1154. if (res.code === 0) {
  1155. success(res)
  1156. } else {
  1157. let res = await util.request(api.UNBrandCouponList, {
  1158. brandId: id,
  1159. pageNum: 1,
  1160. pageSize: 10000
  1161. }, 'GET')
  1162. success(res)
  1163. }
  1164. },
  1165. ready() {
  1166. this.wssSuccess = true
  1167. this.readySendCouponCtrl()
  1168. },
  1169. readySendCouponCtrl() {
  1170. if (this.wssSuccess && this.loadConponSuccess) {
  1171. this.loadConponSuccess = false
  1172. this.socketSendMessage('clientSyncAction', {
  1173. type: 'showCoupon',
  1174. data: this.data.coupons.length > 0
  1175. })
  1176. }
  1177. },
  1178. getBrand: function (id, code) {
  1179. this.getGoodsCount(code, id)
  1180. return;
  1181. },
  1182. getGoodsCount(code, id) {
  1183. util.request(api.GoodsNumCount, {
  1184. isDelete: 0,
  1185. isOnSale: 1,
  1186. brandId: id
  1187. }, 'GET')
  1188. .then(res => {
  1189. if (res.errno === 0) {
  1190. this.setData({
  1191. goodsCount: res.data
  1192. })
  1193. }
  1194. this.getCouponList(id)
  1195. })
  1196. },
  1197. getGoodsList(id, category_id) {
  1198. var that = this;
  1199. if (!(this.data.navList && this.data.navList.length)) {
  1200. that.navDatas = {}
  1201. let navDatas = this.data.navList = this.data.comtypes
  1202. // util.request(api.GoodsCategory, { id: category_id })
  1203. // .then(function (res) {
  1204. // if (res.errno == 0) {
  1205. // let navDatas = res.data.brotherCategory
  1206. // that.setData({
  1207. // navList: navDatas,
  1208. // currTypeId: category_id
  1209. // });
  1210. that.navDatas = {}
  1211. navDatas.forEach(item => {
  1212. util.request(api.GoodsList, {
  1213. brandId: id,
  1214. categoryId: item.category_id,
  1215. page: that.data.page,
  1216. size: that.data.size
  1217. })
  1218. .then(res => {
  1219. if (res.errno === 0) {
  1220. that.navDatas[item.category_id] = res.data.goodsList
  1221. }
  1222. })
  1223. })
  1224. // }
  1225. // })
  1226. }
  1227. if (that.navDatas[category_id]) {
  1228. if (!isIos) {
  1229. let showCommodity = that.data.showCommodity
  1230. that.setData({
  1231. showCommodity: false
  1232. })
  1233. setTimeout(() => {
  1234. wx.nextTick(() => {
  1235. that.setData({
  1236. goodsList: that.navDatas[category_id],
  1237. currTypeId: category_id,
  1238. showCommodity: showCommodity
  1239. });
  1240. })
  1241. }, 500)
  1242. } else {
  1243. that.setData({
  1244. goodsList: that.navDatas[category_id],
  1245. currTypeId: category_id,
  1246. });
  1247. }
  1248. } else {
  1249. console.error('诱惑去啦')
  1250. util.request(api.GoodsList, {
  1251. brandId: id,
  1252. categoryId: category_id,
  1253. page: that.data.page,
  1254. size: that.data.size
  1255. })
  1256. .then(function (res) {
  1257. if (res.errno === 0) {
  1258. that.setData({
  1259. goodsList: res.data.goodsList,
  1260. currTypeId: category_id
  1261. });
  1262. // this.data.navList
  1263. }
  1264. });
  1265. }
  1266. },
  1267. getBrandDetail: function (id, type, cb) {
  1268. console.log('getBrandDetail-params', id, type)
  1269. util.request(api.BrandDetail, {
  1270. id: id,
  1271. type: type,
  1272. }).then((res) => {
  1273. console.log('getBrandDetail', res)
  1274. let base = res.data.brand.sceneUrl
  1275. // let base = 'http://192.168.0.112:8080/shop.html?m=t-7Uqj9Fq&origin=fashilong'
  1276. if (res.errno === 0) {
  1277. let url = base + "&sid=" + id
  1278. // debugger
  1279. this.setData({
  1280. id: id,
  1281. newPicUrl: res.data.brand.appListPicUrl,
  1282. sceneNum: res.data.brand.sceneNum,
  1283. canShow: res.data.brand.canShow,
  1284. contractPhone: res.data.brand.contractPhone,
  1285. contactInfo: {
  1286. contactPhone: res.data.brand.contactPhone || '',
  1287. contactHead: res.data.brand.contactHead || '',
  1288. contactCompanyName: res.data.brand.contactCompanyName || '',
  1289. contactNickName: res.data.brand.contactNickName || '',
  1290. brands: res.data.brand.brands || []
  1291. }
  1292. })
  1293. if (this.data.many === void 0) {
  1294. this.data.many = !!res.data.brand.canShow
  1295. }
  1296. this.setData({
  1297. // peopleCount: this.data.many ? manyCount : 5,
  1298. peopleCount: manyCount
  1299. })
  1300. if (!res.data.brand.canShow) {
  1301. this.role = 'customer'
  1302. } else if (!this.options.join) {
  1303. this.role = 'leader'
  1304. }
  1305. cb(url, urlToJson(url).m, )
  1306. }
  1307. });
  1308. },
  1309. sendContactInfo() {
  1310. // this.socketSendMessage('getContactInfo', {
  1311. // contactInfo: this.data.contactInfo,
  1312. // })
  1313. this.socketSendMessage('clientSyncAction', {
  1314. type: 'getContactInfo',
  1315. contactInfo: this.data.contactInfo
  1316. })
  1317. },
  1318. goToCase({
  1319. data
  1320. }) {
  1321. console.log('data', data)
  1322. wx.showModal({
  1323. title: '提示',
  1324. content: `是否跳转到新的场景?`,
  1325. showCancel: true,
  1326. confirmColor: "#52a2d8",
  1327. success: res => {
  1328. if (res.confirm) {
  1329. wx.navigateTo({
  1330. url: `/pages/webview/index?id=${data.id}&type=32`,
  1331. })
  1332. }
  1333. },
  1334. fail: () => {
  1335. }
  1336. })
  1337. },
  1338. selectType(ev) {
  1339. this.getGoodsList(this.options.id, ev.target.dataset.item.category_id)
  1340. },
  1341. hideCS() {
  1342. this.setData({
  1343. showCommodity: false,
  1344. showCoupon: false,
  1345. showContact: false
  1346. })
  1347. },
  1348. hideContact() {
  1349. this.setData({
  1350. showContact: false
  1351. })
  1352. },
  1353. calcShare() {
  1354. // this.exit()
  1355. this.setData({
  1356. sendShare: false
  1357. })
  1358. },
  1359. contactKf() {
  1360. let keys = Object.keys(this.navDatas)
  1361. let goodsId = this.navDatas[keys[0]][0].id
  1362. let user = wx.getStorageSync('userinfoDetail')
  1363. util.request(api.AddTalkCount, {
  1364. goodsId,
  1365. viewId: user && user.userId || '',
  1366. sceneNum: this.data.sceneNum
  1367. }, 'get')
  1368. this.hideAlert && this.hideAlert()
  1369. this.hideContact && this.hideContact()
  1370. },
  1371. onHide() {
  1372. this.socketSendMessage('changeOnlineStatus', {
  1373. status: 0
  1374. })
  1375. this.pauseVideo = true
  1376. this.joinUrl()
  1377. }
  1378. }