gemercheung 2 år sedan
förälder
incheckning
6b31794efe
6 ändrade filer med 151 tillägg och 56 borttagningar
  1. 2 2
      app.js
  2. 8 8
      config.js
  3. 3 0
      config/api.js
  4. 12 0
      pages/shareRoom/shareRoom.js
  5. 46 40
      pages/webview/index.js
  6. 80 6
      socket.js

+ 2 - 2
app.js

@@ -30,9 +30,9 @@ const api = require('./config/api');
     }
 
     let onShow = pageConfig.onShow
-    pageConfig.onShow = function (...args) {
+    pageConfig.onShow = function () {
       getApp().setLoginProps(true)
-      return onShow.call(this, ...args)
+      return onShow.apply(this, arguments)
     }
 
     PageTmp(pageConfig);

+ 8 - 8
config.js

@@ -17,15 +17,15 @@ const mal = {
 
   // socketHost: 'ws://127.0.0.1:12000',
   // socketHost: 'wss://192.168.0.79:3031',
-  // socketHost: 'wss://test-socket.4dkankan.com',// 测试环境
-  // requestHost: 'https://plaza-cszfb.4dkankan.com', // 测试环境
-  // viewChildHost: 'https://cszfb.4dkankan.com', //测试环境
-  // viewHost: 'https://cszfb.4dkankan.com'//测试环境
+  socketHost: 'wss://test-socket.4dkankan.com',// 测试环境
+  requestHost: 'https://plaza-cszfb.4dkankan.com', // 测试环境
+  viewChildHost: 'https://cszfb.4dkankan.com', //测试环境
+  viewHost: 'https://cszfb.4dkankan.com'//测试环境
 
-  socketHost: 'wss://rtc-zfb.4dkankan.com/', //正式环境
-  requestHost: 'https://plaza.4dkankan.com', //正式环境
-  viewChildHost: 'https://zfb.4dkankan.com', //正式环境
-  viewHost: 'https://zfb.4dkankan.com' //正式环境
+  // socketHost: 'wss://rtc-zfb.4dkankan.com/', //正式环境
+  // requestHost: 'https://plaza.4dkankan.com', //正式环境
+  // viewChildHost: 'https://zfb.4dkankan.com', //正式环境
+  // viewHost: 'https://zfb.4dkankan.com' //正式环境
 }
 
 

+ 3 - 0
config/api.js

@@ -137,4 +137,7 @@ module.exports = {
     roomChatList: API_BASE_URL + 'liveRoom/list',
     enterRoom: API_BASE_URL + 'liveRoom/enter',
     exitRoom: API_BASE_URL + 'liveRoom/exit',
+    
+    //统计Track
+    trackRoom: API_BASE_URL + 'liveRoom/statics/add',
 };

+ 12 - 0
pages/shareRoom/shareRoom.js

@@ -16,6 +16,7 @@ Page({
     loadHot: false
   },
 
+
   /**
    * 生命周期函数--监听页面加载
    */
@@ -60,6 +61,16 @@ Page({
 
     // this.getMIniCode =remote.requestHost+'/statics/tmp/images/1634032649766.png'
 
+
+    // trackRoom share
+
+    // 分享房间进入统计
+    util.request(api.trackRoom, {
+      roomId: roomId,
+      type: 1,
+    }, 'POST', 'application/json')
+
+
     try {
       let codeData = await this.generateMicroAppCode(params)
       if (codeData) {
@@ -91,6 +102,7 @@ Page({
     })
   },
 
+  onShow() {},
   getCompanyDetail() {
     // CompanyApi.getCompanyDetail(this.companyId).then(res => {
     //   console.log(res, 'company')

+ 46 - 40
pages/webview/index.js

@@ -119,57 +119,28 @@ Page({
   //   })
   // },
   async init() {
-    try {
-      let options = this.options
-      console.log('webview-option', options)
+    let options = this.options
+    console.log('webview-option', options)
+    let base, m
 
+    // 只catch getBrandDetail 是因为分享进来的会出现问题
+    try {
       let {
-        url: base,
-        obj: m
+        url,
+        obj
       } = await new Promise(r => this.getBrandDetail(options.id, options.type, (url, obj) => r({
         url,
         obj
       })))
+      base = url
+      m = obj
 
-      this.getBrand(options.id, m)
-      this.mcode = m
-      //TODO 有问题, 其他模式的房间号如何处理?
-      let socketOptions = await this.socketStart({
-        sceneId: this.mcode,
-        roomId: options.roomId || '888888'
-      })
-
-      let url = this.getUrl(base, socketOptions, this.data.join) + this.urlPj
-
-      this.base = base
-      // socketOptions.nickname = socketOptions.nickname.replace(/[^\u4E00-\u9FA5A-Za-z0-9]/g, '')
-      this.setData({
-        urlTemp: url.split('').join(' ')
-      })
-      this.setData({
-        url,
-        loadUrl: true,
-        socketOptions,
-        reload: true,
-        hideWebView: false,
-        // debugerInfo: JSON.stringify({
-        //   userId: socketOptions.userId,
-        //   roomId: socketOptions.roomId,
-        //   num: socketOptions.sceneNumber,
-        //   userLimitNum: socketOptions.userLimitNum,
-        //   isAssistant: socketOptions.isAssistant,
-        //   role: socketOptions.role,
-        //   assistantId: socketOptions.assistantId
-        // })
-      })
-      this.recorderManager = wx.getRecorderManager()
-      this.brandId = options.id
-      this.joinUrl()
-      
     } catch (error) {
       this.setData({
         hideWebView: true,
       })
+      console.log(error)
+      // debugger
       wx.showModal({
         title: '提示',
         content: '场景初始化有误,请稍后重试',
@@ -184,6 +155,41 @@ Page({
       })
     }
 
+    this.getBrand(options.id, m)
+    this.mcode = m
+    //TODO 有问题, 其他模式的房间号如何处理?
+    let socketOptions = await this.socketStart({
+      sceneId: this.mcode,
+      roomId: options.roomId || '888888'
+    })
+
+
+    let url = this.getUrl(base, socketOptions, this.data.join) + this.urlPj
+
+    this.base = base
+    // socketOptions.nickname = socketOptions.nickname.replace(/[^\u4E00-\u9FA5A-Za-z0-9]/g, '')
+    this.setData({
+      urlTemp: url.split('').join(' ')
+    })
+    this.setData({
+      url,
+      loadUrl: true,
+      socketOptions,
+      reload: true,
+      hideWebView: false,
+      // debugerInfo: JSON.stringify({
+      //   userId: socketOptions.userId,
+      //   roomId: socketOptions.roomId,
+      //   num: socketOptions.sceneNumber,
+      //   userLimitNum: socketOptions.userLimitNum,
+      //   isAssistant: socketOptions.isAssistant,
+      //   role: socketOptions.role,
+      //   assistantId: socketOptions.assistantId
+      // })
+    })
+    this.recorderManager = wx.getRecorderManager()
+    this.brandId = options.id
+    this.joinUrl()
     // this.mic()
   },
 

+ 80 - 6
socket.js

@@ -135,8 +135,11 @@ export default {
       showComtypesAllTab: false
     })
 
+    // wx.showToast({
+    //   title: '测试--socket.connected' + this.socket.connected,
+    // })
 
-    if (this.socketSendMessage) {
+    const onlineAction = () => {
       this.pauseVideo = false
       this.joinUrl()
       // debugger
@@ -144,6 +147,44 @@ export default {
         status: 1
       })
     }
+
+    console.warn("socketInstance-1", this.socketInstance);
+
+    if (this.socketInstance) {
+      if (!this.socketInstance.connected) {
+
+        // wx.showToast({
+        //   title: 'socketInstance-2',
+        //   icon: 'none',
+        //   duration: 5000
+        // })
+        // this.socketInstance.connect();
+        // wx.showModal({
+        //   title: '提示',
+        //   content: '欧克',
+        //   showCancel: false,
+        //   confirmColor: '#0075DC',
+        //   success: function (res) {}
+        // })
+        setTimeout(onlineAction, 300)
+      } else {
+        // wx.showToast({
+        //   title: 'socketInstance-3',
+        //   icon: 'none',
+        //   duration: 5000
+        // })
+        onlineAction();
+      }
+    }
+
+    // if (this.socketSendMessage) {
+    //   this.pauseVideo = false
+    //   this.joinUrl()
+    //   // debugger
+    //   this.socketSendMessage('changeOnlineStatus', {
+    //     status: 1
+    //   })
+    // }
   },
 
   changeShowComtypesAllTab(ev) {
@@ -413,8 +454,14 @@ export default {
 
     console.log('小程序参数', options)
     if (!options.roomId) {
-      return
+      return Promise.resolve(false)
     }
+    // 真正进入统计
+    util.request(api.trackRoom, {
+      roomId: options.roomId,
+      type: 0
+    }, 'POST', 'application/json')
+
     let userInfo = await this.getUserInfo()
 
     let socket = io(remote.socketHost, {
@@ -428,11 +475,12 @@ export default {
         isClient: true,
         from: 2
       }
-    })
+    });
+    this.socketInstance = socket
 
     console.error('新建socket Room', options.roomId)
     this.setData({
-      socketStatus: 0
+      socketStatus: 0,
     })
 
     socket.on('connect', () => this.setData({
@@ -1102,6 +1150,16 @@ export default {
   invite(data) {
     if (data.sender !== 'h5') return;
 
+    // 分享房间进入统计
+    if (this.data.socketOptions.roomId !== '888888') {
+      util.request(api.trackRoom, {
+        roomId: this.data.socketOptions.roomId,
+        type: 1,
+      }, 'POST', 'application/json')
+    }
+
+
+
     this.setData({
       sendShare: true,
       count: ++this.data.count
@@ -1384,15 +1442,24 @@ export default {
       // let base = 'http://192.168.0.112:8080/shop.html?m=t-7Uqj9Fq&origin=fashilong'
       if (res.errno === 0) {
         let url = base + "&sid=" + id
+        // debugger
         this.setData({
           id: id,
           newPicUrl: res.data.brand.appListPicUrl,
           sceneNum: res.data.brand.sceneNum,
           canShow: res.data.brand.canShow,
-          contractPhone: res.data.brand.contractPhone
+          contractPhone: res.data.brand.contractPhone,
+
+          contactInfo: {
+            contactPhone: res.data.brand.contactPhone || '',
+            contactHead: res.data.brand.contactHead || '',
+            contactCompanyName: res.data.brand.contactCompanyName || '',
+            contactNickName: res.data.brand.contactNickName || '',
+            brands: res.data.brand.brands || []
+          }
 
         })
-        // debugger
+
         if (this.data.many === void 0) {
           this.data.many = !!res.data.brand.canShow
         }
@@ -1412,6 +1479,13 @@ export default {
     });
   },
 
+
+  sendContactInfo() {
+    this.socketSendMessage('getContactInfo', {
+      contactInfo: this.data.contactInfo,
+    })
+
+  },
   selectType(ev) {
     this.getGoodsList(this.options.id, ev.target.dataset.item.category_id)
   },