gemercheung 2 anos atrás
pai
commit
98361183fa

+ 2 - 2
miniprogram/app.ts

@@ -97,10 +97,10 @@ App<IAppOption>({
       province: ''
     }
   },
-  async login() {
+  async login(slient: boolean = false) {
     let returnValue: undefined | GlobalUserInfo;
     const app = getApp<IAppOption>();
-    wx.showLoading({
+    !slient && wx.showLoading({
       title: "登录中..."
     })
     wx.login({

+ 2 - 2
miniprogram/components/profilePatch/profilePatch.wxml

@@ -30,7 +30,7 @@
       </view>
 
     </view>
-    <button wx:if="{{showPhone}}" class="button {{(phoneNumber.length> 0 && avatar.length> 0 && nickname.length> 0 ) ? 'enable':'disable'}}" bindtap="updateUserInfo">更新微信息1 </button>
-    <button wx:else class="button {{(avatar.length> 0 && nickname.length> 0 ) ? 'enable':'disable'}}" bindtap="updateUserInfo">更新微信息2 </button>
+    <button wx:if="{{showPhone}}" disabled="{{phoneNumber.length=== 0|| avatar.length === 0 || nickname.length === 0}}" class="button {{(phoneNumber.length> 0 && avatar.length> 0 && nickname.length> 0 ) ? 'enable':'disable'}}" bindtap="updateUserInfo">更新微信息1 </button>
+    <button  disabled="{{avatar.length === 0 || nickname.length === 0}}"  wx:else class="button {{(avatar.length> 0 && nickname.length> 0 ) ? 'enable':'disable'}}" bindtap="updateUserInfo">更新微信息2 </button>
   </view>
 </view>

+ 50 - 12
miniprogram/pages/room/room.ts

@@ -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();

+ 1 - 1
typings/index.d.ts

@@ -35,7 +35,7 @@ interface IAppOption {
   removeVoicePropsListener?: (cb: Function) => void
   setVoiceProps: (param: VoiceProps) => void
   setLogin: (status: boolean) => Promise<boolean>
-  login: () => Promise<GlobalUserInfo | undefined>
+  login: (slient?: boolean) => Promise<GlobalUserInfo | undefined>
   watch: (key: string, method: Function) => void
   unwatch: (key: string, method: Function) => void
   resetUserInfo: () => void