gemercheung 1 год назад
Родитель
Сommit
9199c581a5

+ 13 - 2
miniprogram/api/fetchRoom.ts

@@ -1,6 +1,6 @@
 
 
-import { GET_ROOM } from '../utils/apiList'
+import { GET_ROOM, GET_ROOM_SHARECODE } from '../utils/apiList'
 import { request, Response } from '../utils/http'
 interface sceneType {
   num: string
@@ -26,15 +26,26 @@ export interface RoomDetailType {
   isHost: number
   updateTime: string
   hostStatus?: number
+  freeRoamLock?: boolean
+  takeLookLock?: boolean
+  head: string
 }
 type RoomDetailRes = Response & {
   data: RoomDetailType
 }
-export const fetchRoom = async (roomId: string): Promise<RoomDetailType> => {
 
+export const fetchRoom = async (roomId: string): Promise<RoomDetailType> => {
   const res = await request.get<RoomDetailRes>(GET_ROOM, {
     roomId: roomId
   })
   return res.data
 
 }
+
+export const fetchRoomMinCode = async (roomId: string): Promise<string> => {
+  const res = await request.get<RoomDetailRes>(GET_ROOM_SHARECODE, {
+    roomId: roomId
+  })
+  return res.data as unknown as string
+
+}

+ 2 - 1
miniprogram/api/user.ts

@@ -54,10 +54,11 @@ export const updateAvatar = async (avatarUrl: string): Promise<string> => {
     url: WX_UPLOAD_URL,
     success: async (res) => {
       const data = JSON.parse(res.data)
+      console.log('data', data)
       url = data.data
     }
   })
-  await sleep(500)
+  await sleep(1200)
   return Promise.resolve(url)
 
 }

+ 2 - 1
miniprogram/app.json

@@ -6,7 +6,8 @@
     "pages/mp/mp",
     "pages/about/about",
     "pages/room/room",
-    "pages/myScene/myScene"
+    "pages/myScene/myScene",
+    "pages/share/share"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 3 - 1
miniprogram/app.ts

@@ -122,6 +122,8 @@ App<IAppOption>({
               selector: '#t-toast',
               message: '登录失败 !',
             });
+            wx.setStorageSync('isLogin', false)
+            await app.setLogin(false)
             console.error('登录失败')
           }
         }
@@ -130,7 +132,7 @@ App<IAppOption>({
     await sleep(1500)
     return Promise.resolve(returnValue)
   },
-  onLaunch() {
+  async onLaunch() {
 
 
   },

+ 30 - 12
miniprogram/components/agora/agora.ts

@@ -8,6 +8,7 @@ interface ConfigPropType {
   token: string
   chanelName: string
   userId: string
+  rtcSDKInit: boolean
 }
 type ConfigProp = {
   type: ObjectConstructor,
@@ -24,6 +25,10 @@ ComponentWithComputed({
       type: Object,
       value: {}
     },
+    init: {
+      type: Boolean,
+      value: false
+    },
     muted: {
       type: Boolean,
       value: false
@@ -31,13 +36,15 @@ ComponentWithComputed({
   },
 
   watch: {
-    'config': function (obj) {
-      console.error('watch', obj)
+    'config.**': function (obj) {
+      console.error('watch-config', obj)
       if (obj.sdkAppId.length > 0) {
         this.setData({
           config: obj
         }, () => {
-          this.initRTC();
+          if (obj.rtcSDKInit) {
+            this.initRTC();
+          }
         })
       }
     },
@@ -66,7 +73,12 @@ ComponentWithComputed({
     detached(): void {
       console.log('detached agrora');
       if (this.data.client) {
-        this.data.client.leave();
+        this.data.uid = ''
+        if ('leave' in this.data.client) {
+          this.data.client.leave();
+        }
+
+
       }
     }
   },
@@ -92,11 +104,17 @@ ComponentWithComputed({
           await client.init(this.data.config.sdkAppId);
           console.warn('join--config', this.data.config);
           await client.setRole('broadcaster')
-          const uid = await client.join(this.data.config.token, this.data.config.chanelName, this.data.config.userId, true, 1);
+          let uid
+          if (!this.data.isReconnect) {
+            uid = await client.join(this.data.config.token, this.data.config.chanelName, this.data.config.userId, true, 1);
+          } else {
+            uid = await client.rejoin(this.data.config.token, this.data.config.chanelName, this.data.config.userId, [this.data.config.userId], true, 1);
+          }
           let url = await client.publish();
           console.log('url', url)
           this.setData({
-            uid: uid
+            uid: uid,
+            isReconnect: false
           });
           let ts = new Date().getTime();
           this.data.uid = uid;
@@ -120,8 +138,8 @@ ComponentWithComputed({
       console.warn('reconnect');
       if (this.data.client) {
         this.data.client.destroy();
-        // this.data.client.
       }
+      await this.setDataAsync({ isReconnect: true });
       this.triggerEvent('reconnect');
       // await this.initRTC();
     },
@@ -327,11 +345,11 @@ ComponentWithComputed({
         let code = errObj.code || 0;
         let reason = errObj.reason || "";
         console.warn(`error: ${code}, reason: ${reason}`);
-        wx.showToast({
-          title: `argora有错误,code:${code}`,
-          icon: 'none',
-          duration: 5000
-        });
+        // wx.showToast({
+        //   title: `argora有错误,code:${code}`,
+        //   icon: 'none',
+        //   duration: 5000
+        // });
         if (code === 501 || code === 904) {
           this.reconnect();
         }

+ 4 - 0
miniprogram/pages/index/index.ts

@@ -26,6 +26,10 @@ Page({
     const t = wx.getAccountInfoSync()
     console.log('t', t)
 
+    // wx.navigateTo({
+    //   url: "/pages/share/share"
+    // })
+
   },
 
   async fetchRoomList() {

+ 2 - 0
miniprogram/pages/personal/personal.ts

@@ -181,6 +181,8 @@ Page({
     const {
       avatarUrl
     } = e.detail
+
+    console.log('e', e)
     const url = await updateAvatar(avatarUrl)
     console.log('url', url)
     const wxUserId = wx.getStorageSync('wxUserId');

+ 106 - 14
miniprogram/pages/room/room.ts

@@ -2,7 +2,7 @@
 
 import { fetchRoom, RoomDetailType } from '../../api/fetchRoom'
 import { shareRoom } from '../../api/shareRoom'
-import { getRTCSig, getArgoraRTCSig } from '../../api/sign'
+import { getRTCSig } from '../../api/sign'
 import { server } from '../../config'
 import { authorizeRecord } from '../../utils/util'
 import { audioManger, AudioManger } from './libs/audioManager'
@@ -28,9 +28,12 @@ Page({
     m: '',
     showShare: false,
     // roleId: ''
-    argoraConfig: { sdkAppId: '', token: '', chanelName: "", userId: "" },
+    argoraConfig: { sdkAppId: '', token: '', chanelName: "", userId: "", rtcSDKInit: false },
     muted: true,
     audioOperatorType: NaN,
+    roomHostName: '',
+    roomInfo: {} as RoomDetailType
+
   },
 
 
@@ -58,13 +61,33 @@ Page({
     const isSuccess = await this.setWebViewUrl();
     if (isSuccess) {
       this.handleJoinSocket();
-      this.handleJoinRTC();
+      if (!this.data.roomInfo.takeLookLock) {
+        this.handleJoinRTC();
+      }
+
     }
   },
 
   async setRole(roomId: string) {
     let roomInfo: RoomDetailType
     roomInfo = await fetchRoom(roomId);
+
+    this.setData({
+      roomInfo: roomInfo
+    })
+
+    if (roomInfo.takeLookLock) {
+      this.setData({
+        'argoraConfig.rtcSDKInit': false
+      })
+    } else {
+      this.setData({
+        'argoraConfig.rtcSDKInit': true
+      })
+    }
+
+
+
     if (!roomInfo) {
       wx.showModal({
         title: '提示',
@@ -103,6 +126,13 @@ Page({
       return
     }
     this.setData({ roomDetail: roomInfo, roomId: roomId, m: num })
+    if (roomInfo && roomInfo.roomHostName?.length) {
+      var reg = /\\|\/|\?|\?|\*|\"|\“|\”|\'|\‘|\’|\<|\>|\{|\}|\[|\]|\【|\】|\:|\:|\、|\^|\$|\#|\&|\%|\!|\~|\`|\|/g;
+      var temp = roomInfo.roomHostName.replace(reg, "◻");
+      this.setData({
+        roomHostName: temp.length > 14 ? encodeURIComponent(temp.substr(0, 14) + '...') : encodeURIComponent(temp)
+      })
+    }
 
 
     if (roomInfo && roomInfo.hostStatus === 0) {
@@ -130,6 +160,9 @@ Page({
       //     }
       //   }
       // });
+      if (roomInfo.head?.length) {
+        this.setData({ 'userInfo.avatarUrl': roomInfo.head })
+      }
 
       this.setData({ role: 'leader' })
     } else {
@@ -169,16 +202,24 @@ Page({
     }
     filterNickname(this.data.userInfo.nickName);
 
+    let userNickName = this.data.userInfo.nickName.length > 14 ? encodeURIComponent(this.data.userInfo.nickName.substr(0, 14) + '...') : encodeURIComponent(this.data.userInfo.nickName)
+
+    const token = wx.getStorageSync('token') || '';
+
     const params: SocketParams = {
       vruserId: `${this.data.userInfo.wxUserId}`,
       roomId: `${this.data.roomId}`,
       role: this.data.role,
       avatar: encodeURIComponent(this.data.userInfo.avatarUrl),
-      name: this.data.userInfo.nickName.length > 14 ? encodeURIComponent(this.data.userInfo.nickName.substr(0, 14) + '...') : encodeURIComponent(this.data.userInfo.nickName),
+      name: (this.data.roomHostName.length > 0 && this.data.role === 'leader') ? this.data.roomHostName : userNickName,
       isTour: this.data.isTour,
       m: this.data.m,
       fromMiniApp: 1,
+      vlog: 1,
+      wxToken: token
+
     }
+
     this.setData({
       webviewParams: params
     })
@@ -189,7 +230,8 @@ Page({
 
   async autoLogin() {
     const app = getApp<IAppOption>();
-    if (!app.globalData.isLogin) {
+   const isLogin = wx.getStorageSync("isLogin")
+    if (!app.globalData.isLogin || !isLogin) {
       const userInfo = await app.login(false)
       console.log('hehe', userInfo)
       userInfo && this.updateUserInfo(userInfo);
@@ -225,7 +267,9 @@ Page({
     const isSuccess = await this.setWebViewUrl();
     if (isSuccess) {
       this.handleJoinSocket();
-      this.handleJoinRTC();
+      if (!this.data.roomInfo.takeLookLock) {
+        this.handleJoinRTC();
+      }
     }
   },
   updateUserInfo(data?: any) {
@@ -272,15 +316,15 @@ Page({
       });
       switch (sign.operatorType) {
         case 0:
-          wx.showToast({
-            title: '当前语音:腾讯'
-          })
+          // wx.showToast({
+          //   title: '当前语音:腾讯'
+          // })
           this.handleJoinTRTCRTC(userId, roomId, String(sign.sdkAppId), sign.sign);
           break;
         case 1:
-          wx.showToast({
-            title: '当前语音:声网'
-          })
+          // wx.showToast({
+          //   title: '当前语音:声网'
+          // })
           this.handleJoinArgoraRTC(userId, roomId, String(sign.sdkAppId), sign.sign);
           break;
         default:
@@ -301,6 +345,7 @@ Page({
         chanelName: roomId,
         //@ts-ignore
         userId: userId as any,
+        rtcSDKInit: this.data.argoraConfig.rtcSDKInit
         // roleId: roleId as any
       }
     })
@@ -323,10 +368,26 @@ Page({
   /**
    * 生命周期函数--监听页面初次渲染完成
    */
-  onReady() {
+  async onReady() {
     const app = getApp<IAppOption>();
     app.watch('userInfo', this.updateUserInfo)
-
+    const systemInfo = await wx.getSystemInfo();
+    if (systemInfo.platform === 'windows') {
+      // debugger
+      wx.showModal({
+        title: '提示',
+        content: 'PC端暂不支持带看',
+        showCancel:false,
+        success(res) {
+          if (res.confirm) {
+            wx.switchTab({
+              url: "/pages/index/index"
+            })
+          }
+        }
+      })
+      return
+    }
   },
 
   /**
@@ -405,6 +466,9 @@ Page({
   handleSocketAction(action: SocketAction) {
     console.warn('action', action)
     switch (action.type) {
+      case 'confirm-password':
+        this.handleConfirmPassword(action.data)
+        break;
       case 'users-muted':
         this.handleActionMuted(action.userId, action.muted)
         break;
@@ -414,10 +478,38 @@ Page({
       case 'changeScene':
         this.hanldeAudioDefaultMuted(true);
         break;
+      case 'share':
+        this.handleShare(action.data);
+        break;
       default:
         break;
     }
   },
+  handleShare(data: any) {
+    const userId = data.userId || '';
+
+    const f_userId = userId.replace('user_', '')
+    const app = getApp<IAppOption>();
+    if (f_userId && app.globalData.userInfo?.wxUserId == f_userId) {
+
+      const url = `/pages/share/share?id=${this.data.roomId}`
+      console.log('url', url)
+      wx.navigateTo({
+        url: url
+      })
+    }
+  },
+  handleConfirmPassword(data: any) {
+    const userId = data.userId || '';
+    const f_userId = userId.replace('user_', '')
+    const app = getApp<IAppOption>();
+    if (f_userId && app.globalData.userInfo?.wxUserId == f_userId) {
+      this.setData({
+        'argoraConfig.rtcSDKInit': true
+      })
+      this.handleJoinRTC();
+    }
+  },
 
   hanldeAudioDefaultMuted(value: boolean) {
     switch (this.data.audioOperatorType) {

+ 4 - 0
miniprogram/pages/share/share.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 162 - 0
miniprogram/pages/share/share.scss

@@ -0,0 +1,162 @@
+/* pages/share/share.wxss */
+.container {
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 100%;
+  background-position: center center;
+  background-size: cover;
+  position: absolute;
+  // padding: 90rpx 0 0;
+  margin-top: 0;
+  // overflow-y: scroll;
+  z-index: 0;
+  background: #000;
+
+  &::after {
+    content: '';
+    display: block;
+    height: 380rpx
+  }
+
+  .mask {
+    position: fixed;
+    top: 0;
+    left: 0;
+    opacity: 0.5;
+    width: 100%;
+    height: 100%;
+    z-index: 10;
+    filter: blur(30px);
+  }
+
+  .content {
+    width: 540rpx;
+    height: 60%;
+    top: 90rpx;
+    left: 85rpx;
+    background: #fff;
+    position: absolute;
+    z-index: 10;
+    border-radius: 15rpx;
+    display: flex;
+    flex-direction: column;
+    overflow: hidden;
+    padding: 20rpx;
+
+    image {
+      flex: 1;
+      width: 100%;
+      object-fit: scale-down;
+      height: 80%;
+      border-radius: 15rpx;
+    }
+
+    .canvas {
+      position: absolute;
+      right: -9999px;
+      top: -9999px;
+      width: 100%;
+      height: 100%;
+      z-index: 100;
+    }
+
+    .info {
+      width: 100%;
+      height: 200rpx;
+      display: flex;
+      flex-direction: row;
+      padding: 10rpx 0;
+
+      .txt {
+        display: flex;
+        flex-direction: column;
+        flex: 1;
+        font-size: 24rpx;
+        justify-content: space-between;
+        padding: 10rpx 0;
+
+        .up {
+          display: flex;
+          flex-direction: column;
+
+          .desc-title {
+            font-size: 32rpx;
+            line-height: 40rpx;
+            margin-bottom: 40rpx;
+          }
+        }
+
+        .desc-little {
+          font-size: 20rpx;
+          color: #666666;
+        }
+      }
+
+      .qrcode {
+        margin-top: 10rpx;
+        width: 190rpx;
+        height: 190rpx;
+        flex: 0 0 190rpx;
+        object-fit: contain;
+      }
+
+
+    }
+  }
+
+  .bottom-tools {
+    width: 100%;
+    background: rgba(0, 0, 0, 0.8);
+    border-top-left-radius: 15rpx;
+    border-top-right-radius: 15rpx;
+    height: 340rpx;
+    position: absolute;
+    z-index: 10;
+    bottom: 0;
+    display: flex;
+    flex-direction: column;
+
+    .title {
+      color: #fff;
+      border: 1px solid rgba(255, 255, 255, 0.1);
+      text-align: center;
+      font-size: 40rpx;
+      height: 80rpx;
+      display: flex;
+      justify-content: center;
+      align-items: center;
+    }
+
+    .share_box {
+      width: 100%;
+      flex: 1;
+      display: flex;
+      flex-direction: row;
+      padding-top: 30rpx;
+
+      button {
+        background: #2D2D2D;
+        margin: 0 15rpx 0 30rpx;
+        border-radius: 10px 10px 10px 10px;
+        display: flex;
+        flex: 1;
+        opacity: 1;
+        color: #fff;
+        height: 100rpx;
+        text-align: center;
+        justify-content: center;
+        align-items: center;
+        line-height: 100rpx;
+
+        &:last-child {
+          margin: 0 30rpx 0 15rpx;
+        }
+      }
+    }
+  }
+}
+
+.container :not(not) {
+  filter: none;
+}

+ 281 - 0
miniprogram/pages/share/share.ts

@@ -0,0 +1,281 @@
+// pages/share/share.ts
+import { shareRoom } from '../../api/shareRoom'
+import { fetchRoom, fetchRoomMinCode, RoomDetailType } from '../../api/fetchRoom'
+
+Page({
+
+  /**
+   * 初始数据
+   */
+  data: {
+    shared_img: "",
+    shareMiniCode: '',
+    userInfo: {} as GlobalUserInfo,
+    roomDetail: {} as RoomDetailType,
+    roomId: '',
+    canvas: {} as WechatMiniprogram.Canvas,
+    canvasWidth: NaN,
+    canvasHeight: NaN,
+    context: {} as any,
+    save_url: ''
+  },
+
+  onLoad(option: any) {
+    console.log('query', option);
+    const { id } = option
+    if (id) {
+      this.setData({
+        roomId: id
+      })
+    } else {
+      wx.showToast({
+        title: "分享出错了~"
+      })
+    }
+  },
+  onReady() {
+    this.handleCanvasInit()
+  },
+
+  async onShow() {
+    const app = getApp<IAppOption>();
+    this.setData({
+      userInfo: app.globalData.userInfo
+    })
+    const roomInfo: RoomDetailType = await fetchRoom(this.data.roomId);
+    console.log('roomInfo', roomInfo)
+   
+    if (!roomInfo.roomHostCode) {
+      const url = await fetchRoomMinCode(this.data.roomId);
+      if (url) {
+        roomInfo.roomHostCode = url
+      }
+
+    }
+ 
+    this.setData({
+      roomDetail: roomInfo,
+      shareMiniCode: roomInfo.roomHostCode,
+      shared_img: roomInfo.roomCoverUrl,
+    })
+
+
+  },
+
+  async loadImage(url: string): Promise<HTMLImageElement> {
+    let src = await this.downloadFile(url)
+    return new Promise((resolve, reject) => {
+      const image = this.data.canvas.createImage();
+      image.onload = () => resolve(image);
+      image.onerror = reject;
+      image.src = src;
+    })
+  },
+
+  async handleSaveToAblum() {
+    await this.drawCover();
+    await this.drawDown();
+    wx.showLoading({
+      title: '保存中...',
+    });
+    setTimeout(() => {
+      this.handleSaveCanvasToTmp();
+    }, 1000)
+
+  },
+  async drawDown(): Promise<boolean> {
+    try {
+      const image = await this.loadImage(this.data.shareMiniCode);
+      const top = this.data.canvasHeight * 0.7 + 20
+      const left = this.data.canvasWidth - 110
+
+      console.log('logo', image, top, left)
+      this.data.context.drawImage(image, left, top, 100, 100);
+      this.data.context.drawImage(image, left, top, 100, 100);
+      //title
+
+      this.data.context.font = 'normal 800 15px sans-serif'
+      this.data.context.fillStyle = "#000";
+      let title = this.data.roomDetail.roomTitle || '四维带看'
+      if (title.length > 10) {
+         let fistTitle =  String(title).substring(0,10) 
+         let secTitle = String(title).substring(10,title.length) 
+         this.data.context.fillText(fistTitle, 10, top + 20)
+         this.data.context.fillText(secTitle, 10, top + 40)
+      }else{
+
+        this.data.context.fillText(title, 10, top + 20)
+      }
+
+
+      this.data.context.font = 'normal 400 12px sans-serif'
+      this.data.context.fillStyle = "#000";
+      this.data.context.fillText('语音云带看,邀您来参与', 10, top + 70)
+
+
+      this.data.context.font = 'normal 200 10px sans-serif'
+      this.data.context.fillStyle = "#666";
+      this.data.context.fillText('长按识别二维码参与带看', 10, top + 90)
+
+      this.data.context.restore()
+      return Promise.resolve(true);
+    } catch (error) {
+      return Promise.resolve(false);
+    }
+  },
+
+  async drawCover(): Promise<boolean> {
+    console.log(' this.data.context', this.data.context)
+    this.drawCard();
+    const cover = await this.loadImage(this.data.shared_img);
+    const img_width = this.data.canvasWidth * 0.8644,
+      img_height = this.data.canvasHeight * 0.8644;
+    // const left = (this.data.canvasWidth - img_width) / 2;
+    const dpr = wx.getSystemInfoSync().pixelRatio
+    console.log('cover', dpr, this.data.canvas, img_width, img_height);
+    this.data.context.save()
+    this.roundedImage(10, 10, this.data.canvasWidth - 20, this.data.canvasHeight * 0.7, 15);
+    this.data.context.clip()
+    this.data.context.drawImage(cover, 10, 10, this.data.canvasWidth - 20, this.data.canvasHeight * 0.7);
+    this.data.context.restore()
+    return Promise.resolve(true)
+  },
+
+  roundedImage(x: number, y: number, width: number, height: number, radius: number) {
+    this.data.context.beginPath();
+    this.data.context.moveTo(x + radius, y);
+    this.data.context.lineTo(x + width - radius, y);
+    this.data.context.quadraticCurveTo(x + width, y, x + width, y + radius);
+    this.data.context.lineTo(x + width, y + height - radius);
+    this.data.context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
+    this.data.context.lineTo(x + radius, y + height);
+    this.data.context.quadraticCurveTo(x, y + height, x, y + height - radius);
+    this.data.context.lineTo(x, y + radius);
+    this.data.context.quadraticCurveTo(x, y, x + radius, y);
+    this.data.context.closePath();
+  },
+
+
+  downloadFile(url: string): Promise<string> {
+    return new Promise(resolve => {
+      wx.downloadFile({
+        url: url,
+        success(res) {
+          resolve(res.tempFilePath)
+        },
+        async fail(res) {
+          console.log('下载失败,再触发下载一次', res)
+          wx.downloadFile({
+            url: url,
+            success(res) {
+              resolve(res.tempFilePath)
+            },
+            fail() {
+              console.log('二次下载失败', res)
+              resolve('')
+            }
+          })
+
+        }
+      })
+    })
+  },
+
+  async handleCanvasInit() {
+    const query = wx.createSelectorQuery()
+    query.select('#content')
+      .fields({ node: true, size: true })
+      .exec((res) => {
+        console.log('res', res)
+        const canvas = res[0].node
+        const ctx = canvas.getContext('2d')
+        const dpr = wx.getSystemInfoSync().pixelRatio
+
+        canvas.width = res[0].width * dpr
+        canvas.height = res[0].height * dpr
+
+        ctx.scale(dpr, dpr)
+        this.setData({
+          canvas: canvas,
+          context: ctx,
+          canvasWidth: res[0].width,
+          canvasHeight: res[0].height
+        })
+
+      });
+  },
+
+  drawCard() {
+    this.data.context.fillStyle = "#fff";
+    this.data.context.fillRect(0, 0, this.data.canvas.width, this.data.canvas.height);
+
+
+  },
+
+  handleSaveCanvasToTmp() {
+    wx.canvasToTempFilePath({
+      x: 0,
+      y: 0,
+      width: this.data.canvasWidth,
+      height: this.data.canvasHeight,
+      canvas: this.data.canvas,
+      success: (res) => {
+        this.setData({
+          save_url: res.tempFilePath
+        }, () => {
+          wx.saveImageToPhotosAlbum({
+            filePath: this.data.save_url,
+            success(res) {
+              wx.showModal({
+                title: '图片保存成功',
+                content: '图片已保存到相册,快去分享吧~',
+                showCancel: false,
+                confirmText: '好的',
+                confirmColor: '#72B9C3',
+                success: (res) => {
+                  if (res.confirm) { }
+                }
+              })
+            }
+          })
+        })
+        wx.hideLoading();
+
+      }
+    })
+  },
+
+  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}`
+    }
+    if (roomId && userId) {
+      shareRoom(roomId, userId);
+    }
+
+    console.error('share', base, roomId, userId);
+    if (res.from === 'button') {
+      this.setData({
+        showShare: false
+      })
+      return {
+        ...base,
+        title: '【好友邀请】一起来带看吧!',
+      }
+    } else {
+      return {
+        ...base,
+        title: '【好友邀请】一起来带看吧!',
+      }
+    }
+  },
+
+})

+ 29 - 0
miniprogram/pages/share/share.wxml

@@ -0,0 +1,29 @@
+<!--pages/share/share.wxml-->
+<view class="container">
+  <view class="mask" style="background-image: url({{shared_img}})"></view>
+  <view class="content">
+    <image src="{{shared_img}}" mode="aspectFill"></image>
+
+    <view class="info">
+      <view class="txt">
+        <view class="up">
+          <text class="desc-title">{{roomDetail.roomTitle}}</text>
+          <text class="desc-title-l">语音云带看,邀您来参与</text>
+        </view>
+
+        <text class="desc-little">长按识别二维码参与带看</text>
+      </view>
+      <image class="qrcode" show-menu-by-longpress='true' mode="aspectFit" src="{{shareMiniCode}}"></image>
+
+    </view>
+    <canvas id="content" type="2d" class="canvas"></canvas>
+  </view>
+
+  <view class="bottom-tools">
+    <view class="title">分享至</view>
+    <view class="share_box">
+      <button open-type='share'>微信好友</button>
+      <button bindtap="handleSaveToAblum"> 保存相册</button>
+    </view>
+  </view>
+</view>

+ 1 - 0
miniprogram/utils/apiList.ts

@@ -3,6 +3,7 @@ import { server } from '../config'
 export const GET_MY_ROOM_LIST = '/takelook/roomList'
 export const GET_HOME_ROOM_LIST = '/takelook/wxApi/roomList'
 export const GET_ROOM = '/takelook/roomInfo'
+export const GET_ROOM_SHARECODE = '/takelook/roomGetHostCode'
 export const GET_SIG = '/takelook/tencentYun/getSign'
 export const GET_COMMON_SIG = '/takelook/rtcMedia/getToken'
 export const GET_ARGOA_SIG = '/takelook/agoraIO/getAgoraToken'

+ 14 - 1
project.private.config.json

@@ -5,5 +5,18 @@
     "compileHotReLoad": false,
     "bigPackageSizeSupport": true
   },
-  "libVersion": "2.32.0"
+  "libVersion": "2.32.0",
+  "condition": {
+    "miniprogram": {
+      "list": [
+        {
+          "name": "",
+          "pathName": "pages/share/share",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        }
+      ]
+    }
+  }
 }

+ 2 - 0
typings/index.d.ts

@@ -51,6 +51,8 @@ interface SocketParams {
   isTour: number
   m: string
   fromMiniApp: number
+  vlog?: number
+  wxToken?: string
 }
 interface SocketAction {
   type: string