|
@@ -36,20 +36,14 @@ Page({
|
|
|
console.log('options', options)
|
|
|
const auth = await authorizeRecord();
|
|
|
console.log('auth', auth)
|
|
|
- let roomInfo: RoomDetailType
|
|
|
+
|
|
|
+ await this.autoLogin();
|
|
|
|
|
|
if (options.role) {
|
|
|
this.setData({ role: options.role })
|
|
|
}
|
|
|
if (options.roomId) {
|
|
|
- roomInfo = await fetchRoom(options.roomId);
|
|
|
-
|
|
|
- this.setData({ roomDetail: roomInfo, roomId: options.roomId, m: roomInfo.sceneData[0].num })
|
|
|
- if (roomInfo && roomInfo.isHost === 1) {
|
|
|
- this.setData({ role: 'leader' })
|
|
|
- } else {
|
|
|
- this.setData({ role: 'cusomter' })
|
|
|
- }
|
|
|
+ await this.setRole(options.roomId);
|
|
|
}
|
|
|
|
|
|
if (options.isTour) {
|
|
@@ -63,6 +57,44 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ async setRole(roomId: string) {
|
|
|
+ let roomInfo: RoomDetailType
|
|
|
+ roomInfo = await fetchRoom(roomId);
|
|
|
+ if (!roomInfo.sceneData[0].num) {
|
|
|
+ console.error('场景码不能为空!')
|
|
|
+ }
|
|
|
+ this.setData({ roomDetail: roomInfo, roomId: roomId, m: roomInfo.sceneData[0].num })
|
|
|
+ if (roomInfo && roomInfo.isHost === 1) {
|
|
|
+
|
|
|
+ // wx.showModal({
|
|
|
+ // title: '测试',
|
|
|
+ // content: '当前是leader',
|
|
|
+ // success(res) {
|
|
|
+ // if (res.confirm) {
|
|
|
+ // console.log('用户点击确定')
|
|
|
+ // } else if (res.cancel) {
|
|
|
+ // console.log('用户点击取消')
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+
|
|
|
+ this.setData({ role: 'leader' })
|
|
|
+ } else {
|
|
|
+ // wx.showModal({
|
|
|
+ // title: '测试',
|
|
|
+ // content: '当前不是leader',
|
|
|
+ // success(res) {
|
|
|
+ // if (res.confirm) {
|
|
|
+ // console.log('用户点击确定')
|
|
|
+ // } else if (res.cancel) {
|
|
|
+ // console.log('用户点击取消')
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ this.setData({ role: 'cusomter' })
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
webViewParams() {
|
|
|
const params: SocketParams = {
|
|
|
vruserId: `user_${this.data.userInfo.wxUserId}`,
|
|
@@ -82,19 +114,21 @@ Page({
|
|
|
|
|
|
},
|
|
|
|
|
|
- async setWebViewUrl() {
|
|
|
+ async autoLogin() {
|
|
|
const app = getApp<IAppOption>();
|
|
|
if (!app.globalData.isLogin) {
|
|
|
- const userInfo = await app.login()
|
|
|
+ const userInfo = await app.login(false)
|
|
|
console.log('hehe', userInfo)
|
|
|
userInfo && this.updateUserInfo(userInfo);
|
|
|
}
|
|
|
+ },
|
|
|
+ async setWebViewUrl() {
|
|
|
+ const app = getApp<IAppOption>();
|
|
|
if (!this.data.userInfo.nickName || !this.data.userInfo.avatarUrl) {
|
|
|
this.setData({
|
|
|
patchProfile: true
|
|
|
})
|
|
|
if (!this.data.userInfo.phoneNumber) {
|
|
|
-
|
|
|
this.setData({
|
|
|
patchProfilePhone: true
|
|
|
})
|
|
@@ -111,6 +145,10 @@ Page({
|
|
|
return Promise.resolve(true)
|
|
|
},
|
|
|
async handleProfilePatch() {
|
|
|
+ const app = getApp<IAppOption>();
|
|
|
+ const roomId = this.data.roomId
|
|
|
+ this.setRole(roomId);
|
|
|
+ await app.sleep(200);
|
|
|
const isSuccess = await this.setWebViewUrl();
|
|
|
if (isSuccess) {
|
|
|
this.handleJoinSocket();
|