|
@@ -1,6 +1,7 @@
|
|
|
// pages/room/room.ts
|
|
|
|
|
|
import { fetchRoom, RoomDetailType } from '../../api/fetchRoom'
|
|
|
+import { shareRoom } from '../../api/shareRoom'
|
|
|
import { getRTCSig } from '../../api/sign'
|
|
|
import { server } from '../../config'
|
|
|
import { authorizeRecord } from '../../utils/util'
|
|
@@ -40,6 +41,10 @@ Page({
|
|
|
|
|
|
await this.autoLogin();
|
|
|
|
|
|
+ if (options.isTour) {
|
|
|
+ this.setData({ isTour: Number(options.isTour) })
|
|
|
+ }
|
|
|
+
|
|
|
if (options.role) {
|
|
|
this.setData({ role: options.role })
|
|
|
}
|
|
@@ -47,10 +52,6 @@ Page({
|
|
|
await this.setRole(options.roomId);
|
|
|
}
|
|
|
|
|
|
- if (options.isTour) {
|
|
|
- this.setData({ isTour: Number(options.isTour) })
|
|
|
- }
|
|
|
-
|
|
|
const isSuccess = await this.setWebViewUrl();
|
|
|
if (isSuccess) {
|
|
|
this.handleJoinSocket();
|
|
@@ -61,12 +62,42 @@ Page({
|
|
|
async setRole(roomId: string) {
|
|
|
let roomInfo: RoomDetailType
|
|
|
roomInfo = await fetchRoom(roomId);
|
|
|
- if (!roomInfo?.sceneData[0].num) {
|
|
|
- console.error('场景码不能为空!')
|
|
|
+ let num = roomInfo.sceneData && roomInfo.sceneData?.length ? roomInfo?.sceneData[0].num :'';
|
|
|
+ if (!num) {
|
|
|
+ console.error('场景码不能为空!');
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '服务器初始化异常,请稍后再试!',
|
|
|
+ showCancel: false,
|
|
|
+ success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ console.log('用户点击确定')
|
|
|
+
|
|
|
+ wx.redirectTo({
|
|
|
+ url:"/pages/myScene/myScene"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return
|
|
|
}
|
|
|
- this.setData({ roomDetail: roomInfo, roomId: roomId, m: roomInfo.sceneData[0].num })
|
|
|
- if (roomInfo && roomInfo.isHost === 1) {
|
|
|
+ this.setData({ roomDetail: roomInfo, roomId: roomId, m: num })
|
|
|
+
|
|
|
+
|
|
|
+ if (roomInfo && roomInfo.hostStatus === 0) {
|
|
|
+ this.setData({
|
|
|
+ isTour: 1
|
|
|
+ })
|
|
|
|
|
|
+ }
|
|
|
+ //1.是加入带看
|
|
|
+ if (roomInfo && roomInfo.hostStatus === 1) {
|
|
|
+ this.setData({
|
|
|
+ isTour: 0
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ if (roomInfo && roomInfo.isHost === 1) {
|
|
|
// wx.showModal({
|
|
|
// title: '测试',
|
|
|
// content: '当前是leader',
|
|
@@ -97,8 +128,8 @@ Page({
|
|
|
},
|
|
|
|
|
|
webViewParams() {
|
|
|
- const regex = /^[\u4E00-\u9FA5A-Za-z0-9]+$/
|
|
|
- '⎕'
|
|
|
+ // const regex = /^[\u4E00-\u9FA5A-Za-z0-9]+$/
|
|
|
+ // '⎕'
|
|
|
// if (!regex.test(this.data.userInfo.nickName)) {
|
|
|
// this.setData({
|
|
|
// 'userInfo.nickName': 'user_' + this.data.userInfo.wxUserId
|
|
@@ -108,10 +139,11 @@ Page({
|
|
|
const filterNickname = (value: string) => {
|
|
|
var reg = /\\|\/|\?|\?|\*|\"|\“|\”|\'|\‘|\’|\<|\>|\{|\}|\[|\]|\【|\】|\:|\:|\、|\^|\$|\#|\&|\%|\!|\~|\`|\|/g;
|
|
|
var temp = value.replace(reg, "◻");
|
|
|
+
|
|
|
this.setData({
|
|
|
- 'userInfo.nickName': encodeURIComponent(temp)
|
|
|
+ 'userInfo.nickName': temp
|
|
|
})
|
|
|
- console.log('filterNickname',temp);
|
|
|
+ console.log('filterNickname', temp);
|
|
|
|
|
|
}
|
|
|
filterNickname(this.data.userInfo.nickName);
|
|
@@ -121,7 +153,7 @@ Page({
|
|
|
roomId: `${this.data.roomId}`,
|
|
|
role: this.data.role,
|
|
|
avatar: encodeURIComponent(this.data.userInfo.avatarUrl),
|
|
|
- name: this.data.userInfo.nickName,
|
|
|
+ name: this.data.userInfo.nickName.length > 14 ? encodeURIComponent(this.data.userInfo.nickName.substr(0, 14) + '...') : encodeURIComponent(this.data.userInfo.nickName),
|
|
|
isTour: this.data.isTour,
|
|
|
m: this.data.m,
|
|
|
fromMiniApp: 1,
|
|
@@ -275,13 +307,18 @@ Page({
|
|
|
|
|
|
onShareAppMessage: function (res) {
|
|
|
const roomId = this.data.roomId
|
|
|
+ const userId = this.data.userInfo.wxUserId
|
|
|
const isTour = this.data.isTour
|
|
|
const newPicUrl = this.data.roomDetail.roomCoverUrl || 'http://video.cgaii.com/new4dage/images/images/home_2_a.jpg'
|
|
|
const base = {
|
|
|
imageUrl: newPicUrl,
|
|
|
path: `/pages/room/room?roomId=${roomId}&role=customer&isTour=${isTour}`
|
|
|
}
|
|
|
- console.error('share', base)
|
|
|
+ if (roomId && userId) {
|
|
|
+ shareRoom(roomId, userId);
|
|
|
+ }
|
|
|
+
|
|
|
+ console.error('share', base, roomId, userId);
|
|
|
if (res.from === 'button') {
|
|
|
this.setData({
|
|
|
showShare: false
|
|
@@ -306,14 +343,15 @@ Page({
|
|
|
case 'users-inviteMember':
|
|
|
this.handleInviteMember(action.userId, action.data)
|
|
|
break;
|
|
|
+ case 'changeScene':
|
|
|
+ this.audioManger.changeMute(true);
|
|
|
+ break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
},
|
|
|
handleSocketSignal(data) {
|
|
|
debugger
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
handleActionMuted(userId: string | undefined, muted: boolean | undefined) {
|
|
|
console.error('handleActionMuted');
|