Procházet zdrojové kódy

feat:屏蔽socket特殊字符

jinx před 3 roky
rodič
revize
01257b698b
3 změnil soubory, kde provedl 65 přidání a 67 odebrání
  1. 6 6
      config.js
  2. 7 8
      pages/webview/index.js
  3. 52 53
      socket.js

+ 6 - 6
config.js

@@ -16,12 +16,12 @@ const mal = {
   env: 'pro',
   socketHost: 'wss://shop.4dkankan.com',
   // socketHost: 'wss://192.168.0.79:3031',
-  requestHost: 'https://plaza-cszfb.4dkankan.com', // 测试环境
-  viewChildHost: 'https://cszfb.4dkankan.com', //测试环境
-  viewHost: 'https://cszfb.4dkankan.com'//测试环境
-  // requestHost: 'https://plaza.4dkankan.com',
-  // viewChildHost: 'https://zfb.4dkankan.com',
-  // viewHost: 'https://zfb.4dkankan.com'
+  // requestHost: 'https://plaza-cszfb.4dkankan.com', // 测试环境
+  // viewChildHost: 'https://cszfb.4dkankan.com', //测试环境
+  // viewHost: 'https://cszfb.4dkankan.com'//测试环境
+  requestHost: 'https://plaza.4dkankan.com',
+  viewChildHost: 'https://zfb.4dkankan.com',
+  viewHost: 'https://zfb.4dkankan.com'
 }
 
 

+ 7 - 8
pages/webview/index.js

@@ -49,7 +49,7 @@ Page({
 
     // setTimeout(() => this.login(), 3000)
     this.setData({
-      type: options.type || this.options.type ,
+      type: options.type || this.options.type,
       join: false,
       imgServer: util.imgServer,
       showGuide: false,
@@ -75,7 +75,7 @@ Page({
 
     // console.log(options)
     // options.id = '1046098'
- 
+
     if (this.options.roomId) {
       this.data.join = true
     }
@@ -85,11 +85,11 @@ Page({
     } else {
       this.role = 'leader'
     }
-   
-    if (options.many !== void 0 ) {
+
+    if (options.many !== void 0) {
       this.data.many = options.many
     }
-    if(this.options.many){
+    if (this.options.many) {
       this.data.many = this.options.many
     }
     console.log(this.options.many)
@@ -113,7 +113,6 @@ Page({
   // },
   async init() {
     let options = this.options
-    console.log('********')
     console.log(options)
 
     let {
@@ -133,7 +132,7 @@ Page({
     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(' ')
     })
@@ -208,7 +207,7 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: async function () {
-   
+
     getApp().updateCardCount()
 
 

+ 52 - 53
socket.js

@@ -68,12 +68,11 @@ export default {
     let hostUrl
     if (options.url.indexOf('www.4dkankan.com') != -1) {
       hostUrl = 'https://www.4dkankan.com/shop-container-zfb/'
-    } else if(options.url.indexOf('test.4dkankan.com') != -1){
+    } else if (options.url.indexOf('test.4dkankan.com') != -1) {
       hostUrl = 'https://test.4dkankan.com/shop-container-zfb/'
-    }else
-    {
+    } else {
       // hostUrl = 'https://zfb.4dkankan.com/shop-container/'
-      hostUrl = remote.viewHost+'/shop-container/'
+      hostUrl = remote.viewHost + '/shop-container/'
     }
     // let base = remote.viewHost + '/shop-container/fashilong.html?env=' + remote.env + '&sponsor=' + sponsor + '&many=' + this.data.many
     let base = hostUrl + 'fashilong.html?time=' + Date.now() + '&env=' + remote.env + '&sponsor=' + sponsor + '&many=' + this.data.many
@@ -249,7 +248,7 @@ export default {
     //   userInfoa: userInfo.nickname.split('').join(' ')
     // })
 
-
+    userInfo.nickname = userInfo.nickname.replace(/[^\u4E00-\u9FA5A-Za-z0-9]/g, '')
 
     // this.role !== 'leader'
     let roomType
@@ -264,7 +263,7 @@ export default {
     // wx.showToast({
     //   title: this.data.peopleCount.toString(),
     // })
-   
+
     return {
       role: this.role || 'leader',
       userId: userInfo.userId,
@@ -341,12 +340,12 @@ export default {
       let enableTalk = config.roomsConfig.enableTalk !== false
       let noMute = getApp().globalData.voiceProps.noMute
       getApp().globalData.voiceProps.force = enableTalk
-     
+
       if (!enableTalk && !noMute) {
         if (this.role !== 'leader') {
           // this.mic()
         }
-       
+
       }
     })
 
@@ -500,50 +499,50 @@ export default {
 
   async startCall(data) {
     // if( this.role =='leader'){
-      this.setData({
-        shareStatus: 1
-      })
-      if (!data) return;
-  
-      this.setData({
-        surplus: this.data.peopleCount - data.roomsPerson.length
-      })
-      if (!this.isAuthorizeRecord) {
-        const voiceStatus = Number(await this.authorizeRecord())
-        this.isAuthorizeRecord = true
-  
-        // getApp().setVoiceProps({
-        //   noMute: !voiceStatus
-        // })
-  
-        // console.log(getApp().globalData.voiceProps.noMute)
-        // this.socketSendMessage('changeVoiceStatus', {
-        //   status: getApp().globalData.voiceProps.noMute ? 0 : 2
-        // })
-        // this.data.socketOptions.voiceStatus = 1
-        // this.socketSendMessage('changeVoiceStatus', {status: noMute ? 0 : 2})
-      }
-  
-      const socketOptions = this.data.socketOptions
-      getApp().globalData.roomId = socketOptions.roomId
-      const user = data.roomsPerson.find(user => user.userId == socketOptions.userId)
-      if (!user) {
-        return
-      }
-      //屏蔽有人进来才开麦克风
-      // if (data.roomsPerson.length <= 1) {
-      //   return
-      // }
-      user.noMute = getApp().globalData.voiceProps.noMute
-      getApp().setVoiceProps({
-        ...user,
-        action: 'startCall'
-      })
+    this.setData({
+      shareStatus: 1
+    })
+    if (!data) return;
+
+    this.setData({
+      surplus: this.data.peopleCount - data.roomsPerson.length
+    })
+    if (!this.isAuthorizeRecord) {
+      const voiceStatus = Number(await this.authorizeRecord())
+      this.isAuthorizeRecord = true
+
+      // getApp().setVoiceProps({
+      //   noMute: !voiceStatus
+      // })
+
+      // console.log(getApp().globalData.voiceProps.noMute)
       // this.socketSendMessage('changeVoiceStatus', {
       //   status: getApp().globalData.voiceProps.noMute ? 0 : 2
       // })
+      // this.data.socketOptions.voiceStatus = 1
+      // this.socketSendMessage('changeVoiceStatus', {status: noMute ? 0 : 2})
+    }
+
+    const socketOptions = this.data.socketOptions
+    getApp().globalData.roomId = socketOptions.roomId
+    const user = data.roomsPerson.find(user => user.userId == socketOptions.userId)
+    if (!user) {
+      return
+    }
+    //屏蔽有人进来才开麦克风
+    // if (data.roomsPerson.length <= 1) {
+    //   return
     // }
-    
+    user.noMute = getApp().globalData.voiceProps.noMute
+    getApp().setVoiceProps({
+      ...user,
+      action: 'startCall'
+    })
+    // this.socketSendMessage('changeVoiceStatus', {
+    //   status: getApp().globalData.voiceProps.noMute ? 0 : 2
+    // })
+    // }
+
   },
 
   stopCall() {
@@ -594,7 +593,7 @@ export default {
       this.wssSuccess = false
       this.socketStop && this.socketStop()
       this.data.many = !!this.data.canShow
-     
+
       this.setData({
         // peopleCount: this.data.many ? manyCount : 5
         peopleCount: this.data.many ? manyCount : 2
@@ -658,7 +657,7 @@ export default {
   },
 
   async mic() {
-    
+
     let noMute = getApp().globalData.voiceProps.noMute
 
 
@@ -712,7 +711,7 @@ export default {
       newPicUrl
     } = this.data
 
-   
+
     if (res.from === 'button') {
       this.setData({
         sendShare: false
@@ -1108,11 +1107,11 @@ export default {
           contractPhone: res.data.brand.contractPhone
 
         })
-     
+
         if (this.data.many === void 0) {
           this.data.many = !!res.data.brand.canShow
         }
-        
+
         this.setData({
           // peopleCount: this.data.many ? manyCount : 5,
           peopleCount: this.data.many ? manyCount : 2,