tremble 3 years ago
parent
commit
4c4c692efd

+ 2 - 2
config/index.js

@@ -1,4 +1,4 @@
-export const API_BASE_URL = "ws://192.168.0.134:7015";
+export const API_BASE_URL = "ws://192.168.0.151:9999";
 // ws://192.168.0.134:7015
 // wss://4dart.4dage.com/4dart
 // 88888888
@@ -6,7 +6,7 @@ export const VIDEO_BASE_URL = "https://houseoss.4dkankan.com/";
 export const CDN_URL = "https://culture.4dage.com/air_show/resource";
 
 export let app = {
-  id: "77777777",
+  id: "88888888",
   longtime:null,
   websocket: null,
   is_connect_ok: null,

+ 66 - 0
config/socket-handle.js

@@ -0,0 +1,66 @@
+const socket_io = require('./utils/socket.io-mp.js')
+
+let io = ''
+export function initSocket(page, options) {
+  const defaultOpts = {
+    customerId: '',
+    agentId: '',
+    role:'agent',
+    nickName: '',
+    roomId:'',
+    isClient: true
+  }
+  
+  io = socket_io(IM_HOST, {
+    path: '/vr-node',
+    query: Object.assign(defaultOpts, options)
+  })
+  const eventName = {
+    startPlay: 'answer', // 开始语音
+    someoneInRoom: 'vr_request', // 有人加入房间
+    someoneLeaveRoom: 'putup' // 有人离开房间
+  }
+  // 事件监听
+  io.on(eventName.startPlay, function (data) {
+    console.log(data, 'socket')
+    page.startPlay(data)
+  })
+
+  io.on(eventName.someoneInRoom, function (data) {
+    data.persons = data.persons.filter(item => item.userId !== getApp().globalData.userinfo.user_id)
+    page.createLivePull(data)
+  })
+
+  io.on(eventName.someoneLeaveRoom, function (data) {
+    page.someoneLeave(data)
+  })
+  return io
+}
+
+export function emitSendMsg (target_id) {
+  let app = getApp()
+  io.emit('sendMsg', {
+    user_id: app.globalData.userinfo.user_id,
+    target_id: target_id
+  })
+}
+
+export function emitInRoom () {
+  let app = getApp()
+  io.emit('inRoom', {
+    user_id: app.globalData.userinfo.user_id,
+    room_id: app.globalData.room_id
+  })
+}
+
+export function emitLeaveRoom () {
+  let app = getApp()
+  io.emit('leaveRoom', {
+    user_id: app.globalData.userinfo.user_id,
+    room_id: app.globalData.room_id
+  })
+}
+
+export function disconnect () {
+  return io.disconnect()
+}

+ 66 - 0
pages/test/test.js

@@ -0,0 +1,66 @@
+// pages/test/test.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 3 - 0
pages/test/test.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 1 - 0
pages/test/test.wxml

@@ -0,0 +1 @@
+<web-view src="https://cgaii.8thwall.app/slam/"></web-view>

+ 1 - 0
pages/test/test.wxss

@@ -0,0 +1 @@
+/* pages/test/test.wxss */

+ 3 - 2
project.config.json

@@ -31,14 +31,15 @@
       "outputPath": ""
     },
     "enableEngineNative": false,
-    "useIsolateContext": true,
+    "useIsolateContext": false,
     "userConfirmedBundleSwitch": false,
     "packNpmManually": false,
     "packNpmRelationList": [],
     "minifyWXSS": true,
     "disableUseStrict": false,
     "showES6CompileOption": false,
-    "useCompilerPlugins": false
+    "useCompilerPlugins": false,
+    "minifyWXML": true
   },
   "compileType": "miniprogram",
   "libVersion": "2.19.5",

+ 3 - 3
project.private.config.json

@@ -13,9 +13,9 @@
     "miniprogram": {
       "list": [
         {
-          "name": "pages/select/index",
-          "pathName": "pages/select/index",
-          "query": "id=2",
+          "name": "pages/test/index",
+          "pathName": "pages/test/test",
+          "query": "",
           "scene": null
         },
         {

File diff suppressed because it is too large
+ 10 - 0
utils/socket.io-mp.js