socket.js 38 KB

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