|
@@ -5,6 +5,8 @@ const util = require('/utils/util.js');
|
|
|
const UNLOGIN = 'NO_LOGIN'
|
|
|
const btoa = require('./utils/btoa')
|
|
|
|
|
|
+const manyCount = 30
|
|
|
+
|
|
|
import remote from './config.js'
|
|
|
var app = getApp();
|
|
|
var isIos = false
|
|
@@ -34,11 +36,11 @@ let urlToJson = (url = window.location.href) => { // 箭头函数默认传值为
|
|
|
|
|
|
|
|
|
export default {
|
|
|
-
|
|
|
joinUrl() {
|
|
|
let options = {
|
|
|
API_BASE_URL: api.API_BASE_URL,
|
|
|
"url": this.data.url,
|
|
|
+ // "url": 'http://192.168.0.109:8080',
|
|
|
"reload": this.data.reload,
|
|
|
"token": wx.getStorageSync('token'),
|
|
|
"code": this.mcode,
|
|
@@ -48,7 +50,7 @@ export default {
|
|
|
"bottom": this.data.bottom || 0,
|
|
|
socket: {
|
|
|
socketHost: remote.socketHost,
|
|
|
- path: '/vr-node',
|
|
|
+ path: '/fsl-node',
|
|
|
options: {
|
|
|
...this.data.socketOptions,
|
|
|
nickname: encodeURI(encodeURI(this.data.socketOptions.nickname))
|
|
@@ -57,7 +59,15 @@ export default {
|
|
|
}
|
|
|
console.error('joinurl', options)
|
|
|
// let base = 'http://127.0.0.1:5500/index.html'
|
|
|
- let base = remote.viewHost + '/shop-container/index.html?m=' + Date.now()
|
|
|
+ // let base = remote.viewHost + '/shop-container/shop.html'
|
|
|
+ let sponsor = !!this.data.canShow
|
|
|
+ if (this.data.join && !this.options.join) {
|
|
|
+ sponsor = false
|
|
|
+ }
|
|
|
+
|
|
|
+ // remote.viewHost
|
|
|
+ let base = remote.viewHost + '/shop-container/fashilong.html?env='+remote.env+'&sponsor=' + sponsor + '&many=' + this.data.many
|
|
|
+ // let base = 'http://192.168.0.109:8081/shop-container/fashilong.html?env='+remote.env+'&sponsor=' + sponsor + '&many=' + this.data.many
|
|
|
// let base = remote.viewHost + '/shop.html'
|
|
|
|
|
|
this.data.reload = false
|
|
@@ -76,7 +86,6 @@ export default {
|
|
|
},
|
|
|
|
|
|
onShow() {
|
|
|
-
|
|
|
this.setData({
|
|
|
isIos,
|
|
|
showComtypesAllTab: false
|
|
@@ -225,16 +234,25 @@ export default {
|
|
|
// userInfoa: userInfo.nickname.split('').join(' ')
|
|
|
// })
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ this.role !== 'leader'
|
|
|
+ let roomType
|
|
|
+ if ((!this.data.canShow && !this.data.join) || (this.data.join && !this.options.join)) {
|
|
|
+ roomType = '1v1'
|
|
|
+ }
|
|
|
return {
|
|
|
role: this.role || 'leader',
|
|
|
userId: userInfo.userId,
|
|
|
+ roomType,
|
|
|
avatar: userInfo.avatarUrl,
|
|
|
nickname: userInfo.nickname,
|
|
|
voiceStatus: getApp().globalData.voiceProps.noMute ? 0 : 2,
|
|
|
+ enableTalk: this.role === 'leader' ? true : undefined,
|
|
|
roomId: room,
|
|
|
- sceneNumber: '',
|
|
|
+ sceneNumber: sceneId,
|
|
|
onlineStatus: true,
|
|
|
- userLimitNum: 5
|
|
|
+ userLimitNum: this.data.peopleCount
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -249,7 +267,7 @@ export default {
|
|
|
|
|
|
console.log('小程序参数', options)
|
|
|
let socket = io(remote.socketHost, {
|
|
|
- path: '/vr-node',
|
|
|
+ path: '/fsl-node',
|
|
|
query: {
|
|
|
...options,
|
|
|
isClient: true
|
|
@@ -261,12 +279,9 @@ export default {
|
|
|
socketStatus: 0
|
|
|
})
|
|
|
|
|
|
- socket.on('connect', () => {
|
|
|
- console.log('socket connect...')
|
|
|
- this.setData({
|
|
|
- socketStatus: 1
|
|
|
- })
|
|
|
- })
|
|
|
+ socket.on('connect', () => this.setData({
|
|
|
+ socketStatus: 1
|
|
|
+ }))
|
|
|
socket.on('connect_error', () => this.setData({
|
|
|
socketStatus: -1
|
|
|
}))
|
|
@@ -281,7 +296,6 @@ export default {
|
|
|
socketStatus: 0
|
|
|
})
|
|
|
|
|
|
-
|
|
|
let noMute = getApp().globalData.voiceProps.noMute
|
|
|
this.socketSendMessage('changeVoiceStatus', {
|
|
|
status: noMute ? 0 : 2
|
|
@@ -294,10 +308,26 @@ export default {
|
|
|
socket.on('error', () => this.setData({
|
|
|
socketStatus: -1
|
|
|
}))
|
|
|
+ socket.on('roomIn', config => {
|
|
|
+ let enableTalk = config.roomsConfig.enableTalk !== false
|
|
|
+ let noMute = getApp().globalData.voiceProps.noMute
|
|
|
+ getApp().globalData.voiceProps.force = enableTalk
|
|
|
+ if (!enableTalk && !noMute) {
|
|
|
+ this.mic()
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
this.socketSendMessage = (event, obj) => {
|
|
|
- console.error('发送 socket Room', options.roomId, event, obj)
|
|
|
- socket.emit(event, obj)
|
|
|
+ let socket = this.socket
|
|
|
+ console.error('发送 socket Room', options.roomId, event, obj, socket)
|
|
|
+ try {
|
|
|
+ socket.emit(event, obj)
|
|
|
+ } catch (e) {
|
|
|
+ console.error(e, '试图重新发送')
|
|
|
+ setTimeout(() => {
|
|
|
+ this.socketSendMessage(event, obj)
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
socket.on('clientSyncAction', (data) => {
|
|
@@ -310,10 +340,14 @@ export default {
|
|
|
})
|
|
|
|
|
|
socket.on('action', (data) => {
|
|
|
- console.log('打开action', data)
|
|
|
if (data.type === 'navigateToGoods') {
|
|
|
this.navigateToGoodsAction(data.data)
|
|
|
-
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ socket.on('changeRoomEnableTalk', config => {
|
|
|
+ if (this.role !== 'leader') {
|
|
|
+ this.changeRoomEnableTalk(config)
|
|
|
}
|
|
|
})
|
|
|
|
|
@@ -340,11 +374,21 @@ export default {
|
|
|
socket = null
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ this.socket = socket
|
|
|
|
|
|
return options
|
|
|
},
|
|
|
|
|
|
+ changeRoomEnableTalk(data) {
|
|
|
+ console.log(data)
|
|
|
+ let noMute = getApp().globalData.voiceProps.noMute
|
|
|
+ getApp().globalData.voiceProps.force = data.enableTalk
|
|
|
+ // noMute true 静音
|
|
|
+ // enableTalk false 静音
|
|
|
+ if (!!data.enableTalk === !!noMute) {
|
|
|
+ this.mic()
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
navigateToGoods({
|
|
|
data
|
|
@@ -362,13 +406,17 @@ export default {
|
|
|
},
|
|
|
|
|
|
getUrl(url, socketOptions, isJoin) {
|
|
|
-
|
|
|
- url += '&room_id=' + socketOptions.roomId + '&user_id=' + socketOptions.userId + '&API_BASE_URL=' + api.API_BASE_URL + '&X-Nideshop-Token=' + wx.getStorageSync('token') + '&special=' + ~this.data.handleScenes.indexOf(this.data.sceneNumber)
|
|
|
+ url += '&room_id=' + socketOptions.roomId + '&user_id=' + socketOptions.userId + '&API_BASE_URL=' + api.API_BASE_URL + '&X-Nideshop-Token=' + wx.getStorageSync('token') + '&special=' + ~this.data.handleScenes.indexOf(this.data.sceneNumber) + '&canShow=' + this.data.canShow
|
|
|
+
|
|
|
|
|
|
if (isJoin) {
|
|
|
- url += '&role=customer&shopping'
|
|
|
+ url += '&role=' + this.role + '&shopping'
|
|
|
+ } else {
|
|
|
+ url += '&role=' + this.role
|
|
|
}
|
|
|
|
|
|
+ console.error(url)
|
|
|
+ console.log(isJoin)
|
|
|
return url
|
|
|
},
|
|
|
|
|
@@ -396,27 +444,30 @@ export default {
|
|
|
},
|
|
|
|
|
|
async startCall(data) {
|
|
|
- console.error(data, 'startcall')
|
|
|
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)
|
|
|
+ // 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.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)
|
|
|
- console.log(user, data.roomsPerson, 'staer')
|
|
|
if (!user) {
|
|
|
return
|
|
|
}
|
|
@@ -428,9 +479,9 @@ export default {
|
|
|
...user,
|
|
|
action: 'startCall'
|
|
|
})
|
|
|
- this.socketSendMessage('changeVoiceStatus', {
|
|
|
- status: getApp().globalData.voiceProps.noMute ? 0 : 2
|
|
|
- })
|
|
|
+ // this.socketSendMessage('changeVoiceStatus', {
|
|
|
+ // status: getApp().globalData.voiceProps.noMute ? 0 : 2
|
|
|
+ // })
|
|
|
},
|
|
|
|
|
|
stopCall() {
|
|
@@ -455,10 +506,17 @@ export default {
|
|
|
this.stopCall()
|
|
|
getApp().globalData.rtcParams = []
|
|
|
getApp().globalData.pusher = ''
|
|
|
- this.role = 'leader'
|
|
|
+
|
|
|
+ if (this.data.join && !this.options.join) {
|
|
|
+ wx.switchTab({
|
|
|
+ url: '/pages/index/index',
|
|
|
+ })
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.role = this.data.canShow ? 'leader' : 'customer'
|
|
|
let options = await this.getSocketOptions(this.mcode)
|
|
|
|
|
|
- console.error('发送H5 newRoom', options)
|
|
|
this.socketSendMessage('clientSyncAction', {
|
|
|
type: 'newRoom',
|
|
|
data: options
|
|
@@ -467,6 +525,11 @@ export default {
|
|
|
setTimeout(async () => {
|
|
|
this.wssSuccess = false
|
|
|
this.socketStop && this.socketStop()
|
|
|
+ this.data.many = !!this.data.canShow
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ peopleCount: this.data.many ? manyCount : 5
|
|
|
+ })
|
|
|
|
|
|
let base = this.base
|
|
|
let socketOptions = await this.socketStart({
|
|
@@ -517,8 +580,22 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ clearDebuger() {
|
|
|
+ this.setData({
|
|
|
+ debugerInfo: ''
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
async mic() {
|
|
|
let noMute = getApp().globalData.voiceProps.noMute
|
|
|
+
|
|
|
+
|
|
|
+ // noMute true 静音
|
|
|
+ // enableTalk false 静音
|
|
|
+ // if (!!getApp().globalData.voiceProps.force === !!noMute)
|
|
|
+ // return
|
|
|
+ // if (!getApp().globalData.voiceProps.force && (!this.data.socketOptions.voiceStatus || noMute)) return;
|
|
|
+
|
|
|
if (!this.data.socketOptions.voiceStatus) {
|
|
|
let voiceStatus = await this.authorizeRecord()
|
|
|
if (voiceStatus) {
|
|
@@ -568,10 +645,11 @@ export default {
|
|
|
this.setData({
|
|
|
sendShare: false
|
|
|
})
|
|
|
+
|
|
|
return {
|
|
|
title: '【好友邀请】一起来逛店吧!',
|
|
|
imageUrl: newPicUrl,
|
|
|
- path: `/pages/webview/index?id=${id}&join=true&roomId=${this.data.socketOptions.roomId}`,
|
|
|
+ path: `/pages/webview/index?id=${id}&join=true&roomId=${this.data.socketOptions.roomId}&many=${!!this.data.many}`,
|
|
|
}
|
|
|
} else {
|
|
|
return {
|
|
@@ -599,18 +677,20 @@ export default {
|
|
|
},
|
|
|
|
|
|
|
|
|
- share(data) {
|
|
|
-
|
|
|
+ share() {
|
|
|
const companyName = `良房一廳`
|
|
|
const vrLink = `/pages/webview/index`
|
|
|
const img_url = this.data.newPicUrl || 'http://video.cgaii.com/new4dage/images/images/home_2_a.jpg'
|
|
|
const shareImg = img_url
|
|
|
|
|
|
- let id = data.data || this.data.id
|
|
|
+ let id = this.data.id
|
|
|
this.count = this.count || 0
|
|
|
- wx.navigateTo({
|
|
|
- url: `/pages/shared/shared?img_url=${btoa(img_url)}&shareImg=${btoa(shareImg)}&companyName=${companyName}&vrLink=${btoa(vrLink)}&id=${id}`,
|
|
|
- })
|
|
|
+
|
|
|
+ console.log(`/pages/shared/shared?img_url=${btoa(img_url)}&shareImg=${btoa(shareImg)}&companyName=${companyName}&vrLink=${btoa(vrLink)}&id=${this.data.id}`);
|
|
|
+
|
|
|
+ wx.navigateTo({
|
|
|
+ url: `/pages/shared/shared?img_url=${btoa(img_url)}&shareImg=${btoa(shareImg)}&companyName=${companyName}&vrLink=${btoa(vrLink)}&id=${id}`,
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
|
|
@@ -635,7 +715,6 @@ export default {
|
|
|
},
|
|
|
|
|
|
invite(data) {
|
|
|
- console.log('---', data)
|
|
|
if (data.sender !== 'h5') return;
|
|
|
|
|
|
this.setData({
|
|
@@ -677,7 +756,6 @@ export default {
|
|
|
this.joinUrl()
|
|
|
},
|
|
|
|
|
|
-
|
|
|
// 加入购物车
|
|
|
addCard(data) {
|
|
|
wx.navigateTo({
|
|
@@ -685,6 +763,7 @@ export default {
|
|
|
// url: '/pages/goods/goods?id=' + data.data + '&oper=addCard',
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
// 立即购买
|
|
|
buyGoods(data) {
|
|
|
wx.navigateTo({
|
|
@@ -693,18 +772,6 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- // addCard(event) {
|
|
|
- // wx.navigateTo({
|
|
|
- // url: '/pages/goods/goods?id=' + event.currentTarget.dataset.id + '&oper=addCard',
|
|
|
- // })
|
|
|
- // },
|
|
|
-
|
|
|
- // buyGoods(event) {
|
|
|
- // wx.navigateTo({
|
|
|
- // url: '/pages/goods/goods?id=' + event.currentTarget.dataset.id + '&oper=buyGoods',
|
|
|
- // })
|
|
|
- // },
|
|
|
-
|
|
|
|
|
|
showCommodityFn() {
|
|
|
this.setData({
|
|
@@ -954,16 +1021,32 @@ export default {
|
|
|
id: id
|
|
|
}).then((res) => {
|
|
|
let base = res.data.brand.sceneUrl
|
|
|
- console.error(base)
|
|
|
- // let base = 'http://192.168.0.109:8080/grave.html' + res.data.brand.sceneUrl.substr(res.data.brand.sceneUrl.indexOf('?'))
|
|
|
- // let base = 'http://192.168.0.109:8080/grave.html?m=t-9EtLj36&origin=4Dplaza"'
|
|
|
+ // let base = 'http://192.168.0.109:8081' + res.data.brand.sceneUrl.substr(res.data.brand.sceneUrl.indexOf('/grave.html'))
|
|
|
+ // let base = 'http://192.168.0.109:8080/shop.html?m=t-7Uqj9Fq&origin=fashilong'
|
|
|
+ res.data.brand.canShow = !!res.data.brand.canShow
|
|
|
+ // res.data.brand.canShow = false
|
|
|
if (res.errno === 0) {
|
|
|
let url = base + "&sid=" + id
|
|
|
this.setData({
|
|
|
id: id,
|
|
|
newPicUrl: res.data.brand.appListPicUrl,
|
|
|
- sceneNum: res.data.brand.sceneNum
|
|
|
+ sceneNum: res.data.brand.sceneNum,
|
|
|
+ canShow: res.data.brand.canShow,
|
|
|
+ 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,
|
|
|
})
|
|
|
+
|
|
|
+ if (!res.data.brand.canShow) {
|
|
|
+ this.role = 'customer'
|
|
|
+ } else if (!this.options.join){
|
|
|
+ this.role = 'leader'
|
|
|
+ }
|
|
|
cb(url, urlToJson(url).m, )
|
|
|
}
|
|
|
});
|