tremble 3 年之前
父節點
當前提交
ccdc6d41bc

+ 6 - 7
src/app.vue

@@ -103,8 +103,8 @@ const musicPlayer = useMusicPlayer();
 let app = null;
 
 let tagid = browser.getURLParam("tagid");
-const role = ref(browser.getURLParam("role"));
-const userName = ref(browser.getURLParam("name"));
+
+const role = computed(() => store.getters["rtc/role"]);
 
 const closetagtype = () => {
   store.commit("tag/setTagClickType", {
@@ -171,10 +171,11 @@ const resize = () => {
 watch(
   () => isshoppingguide.value,
   (val, old) => {
+    console.log(isshoppingguide.value, "isshoppingguide.value,isshoppingguide.value,isshoppingguide.value,");
     let $minmap = document.querySelector("[xui_min_map]");
     if ($minmap) {
       setTimeout(async () => {
-        if (role.value == "leader") {
+        if (role.value == "leader" || !role.value) {
           return;
         }
         await nextTick();
@@ -265,10 +266,8 @@ const onClickTagInfo = (el) => {
     });
   } else if (item.type == "link_scene") {
     guideclicktag(item);
-    setTimeout(() => {
-      let sceneFirstView = item.hotContent.sceneFirstView;
-      window.location.href = jumpNewScene(sceneFirstView);
-    }, 100);
+    let sceneFirstView = item.hotContent.sceneFirstView;
+    window.location.href = jumpNewScene(sceneFirstView);
   }
 };
 

+ 2 - 0
src/components/RTC/PageRtcLive.vue

@@ -557,6 +557,7 @@ const startFollow = (app) => {
           val: user_info.value.UserId,
         },
       ]);
+      
     } else {
       tmp = getUrl(window.location.href, [
         {
@@ -566,6 +567,7 @@ const startFollow = (app) => {
       ]);
     }
     console.log("創建房間後更新url", tmp);
+    store.commit("rtc/setRole", user_info.value.Role)
     history.replaceState(null, null, tmp);
   });
 

+ 1 - 0
src/components/RTC/Trtccom.vue

@@ -222,6 +222,7 @@ async function handleLeave() {
   try {
     uninstallEventHandlers();
     await localClient.leave();
+    invitedRemoteStreams.value = []
     if (localStream) {
       localStream.stop();
       localStream.close();

+ 45 - 36
src/components/RTC/dialog/createdRoom.vue

@@ -30,6 +30,7 @@
 <script>
 import { Dialog } from "@/global_components/";
 import browser from "@/utils/browser";
+import { useStore } from "vuex";
 
 export default {
   data() {
@@ -46,6 +47,7 @@ export default {
           title: "多人模式",
         },
       ],
+      store:useStore(),
       userName: "",
       roomId: browser.getURLParam("roomId"),
     };
@@ -56,18 +58,17 @@ export default {
   // created: {},
   // mounted:{},
   methods: {
-    getUrl(href,queryArr){
-
-      queryArr.forEach(item=>{
+    getUrl(href, queryArr) {
+      queryArr.forEach((item) => {
         if (!browser.hasURLParam(item.key)) {
-          let ttt = href.split('index.html?')
+          let ttt = href.split("index.html?");
           href = `${ttt[0]}index.html?${item.key}=${item.val}&${ttt[1]}`;
         } else {
           href = browser.replaceQueryString(href, item.key, item.val);
         }
-      })
-      
-      return href
+      });
+
+      return href;
     },
 
     chooseMode(mode) {
@@ -75,51 +76,59 @@ export default {
     },
     closeCreated() {
       this.$emit("closeCreated");
-      !browser.hasURLParam("pose")
+      !browser.hasURLParam("pose");
     },
     createdConfirm() {
       if (this.userName == "") {
-        Dialog.toast({ content: '請輸入您的昵稱', type: 'error' })
+        Dialog.toast({ content: "請輸入您的昵稱", type: "error" });
         return;
       }
       let name = encodeURIComponent(this.userName);
-      let hh = window.location.href
-
+      let hh = window.location.href;
 
       if (this.role == "customer") {
-        let tempUrl = this.getUrl(hh, [{
-          key:'mode',
-          val:this.mode
-        },{
-          key:'name',
-          val:name
-        },{
-          key:'role',
-          val:'customer'
-        },{
-          key:'roomId',
-          val:this.roomId
-        }])
+        let tempUrl = this.getUrl(hh, [
+          {
+            key: "mode",
+            val: this.mode,
+          },
+          {
+            key: "name",
+            val: name,
+          },
+          {
+            key: "role",
+            val: "customer",
+          },
+          {
+            key: "roomId",
+            val: this.roomId,
+          },
+        ]);
         // history.replaceState(null, null, hh + "&mode=" + this.mode + "&name=" + name + "&role=customer&roomId=" + this.roomId);
         history.replaceState(null, null, tempUrl);
       } else {
-
-        let tempUrl = this.getUrl(hh, [{
-          key:'mode',
-          val:this.mode
-        },{
-          key:'name',
-          val:name
-        },{
-          key:'role',
-          val:'leader'
-        }])
+        let tempUrl = this.getUrl(hh, [
+          {
+            key: "mode",
+            val: this.mode,
+          },
+          {
+            key: "name",
+            val: name,
+          },
+          {
+            key: "role",
+            val: "leader",
+          },
+        ]);
 
         // history.replaceState(null, null,hh + "&mode=" + this.mode + "&name=" + name + "&role=leader");
         history.replaceState(null, null, tempUrl);
         console.log(tempUrl);
-
       }
+      this.store.commit("rtc/setRole", this.role);
+
       this.$nextTick(() => {
         this.$emit("createdConfirm");
       });

+ 1 - 0
src/components/RTC/index.vue

@@ -59,6 +59,7 @@ const confirmDialog = async () => {
     tempUrl = browser.replaceQueryString(tempUrl, item, "");
   });
   history.replaceState(null, null, tempUrl);
+  store.commit("rtc/setRole", '')
 
   store.commit("showShoppingguide", false);
   dialog.value = "";

+ 5 - 0
src/store/modules/rtc.js

@@ -10,6 +10,7 @@ export default {
             sdkAppId: 1400709402,
             userId: '',
             roomId: '',
+            role:'',
             secretKey: 'ef391b02e6423a6db15eea3d9a0c131f2abac921204246bbe3f36fcea7d111d',
             userSig: 'eJw1jlELgjAURv-LnkPunXNToZceosB6SPsBwVbelrLpFCH675XW43c*Dpwnq4oyMpOjzrBcgkgBVjMbTcdyxiNgy*61vThHmuUoABRkAvjykDZtoCvNAsbAUaWA8u-R7YttFno-JNPou7LBuH0MQR6t2tp6cz-5sy75zrXV3heH9U8M1HySUCapirnC7PUGl3Ix6g__',
             audioDeviceId: '',
@@ -32,6 +33,7 @@ export default {
             return state.showdaogou
         },
         sdkAppId: state => state.sdkAppId,
+        role: state => state.role,
         userId: state => state.userId,
         roomId: state => state.roomId,
         secretKey: state => state.secretKey,
@@ -64,6 +66,9 @@ export default {
         setRoomId(state, payload) {
             state.roomId=payload
         },
+        setRole(state, payload) {
+            state.role=payload
+        },
 
         setDeviceList(state, payload) {
             state.cameraList=payload.cameraItems

+ 278 - 0
src/utils/wxshare.js

@@ -0,0 +1,278 @@
+import browser from '@/utils/browser'
+import { http } from './request'
+import jsonp from 'jsonp'
+function toConfigure() {
+    return new Promise((resolve, reject) => {
+        let name = '厦门四维时代微信公众号'
+        name = encodeURIComponent(name)
+        let uri = encodeURIComponent(location.href.split('#')[0])
+        jsonp(
+            '//www.4dage.com/wechat/jssdk/share?name=' + name + '&uri=' + uri,
+            {
+                param: 'callback',
+            },
+            function (err, data) {
+                console.log(data)
+                wx.config({
+                    debug: false,
+                    appId: data.appId,
+                    timestamp: data.timestamp,
+                    nonceStr: data.nonceStr,
+                    signature: data.signature,
+                    jsApiList: [
+                        'checkJsApi',
+                        'onMenuShareTimeline',
+                        'onMenuShareAppMessage',
+                        'updateTimelineShareData',
+                        'updateAppMessageShareData',
+                        'onMenuShareQQ',
+                        'onMenuShareWeibo',
+                        'hideMenuItems',
+                        'showMenuItems',
+                        'hideAllNonBaseMenuItem',
+                        'showAllNonBaseMenuItem',
+                        'translateVoice',
+                        'startRecord',
+                        'stopRecord',
+                        'onRecordEnd',
+                        'playVoice',
+                        'pauseVoice',
+                        'stopVoice',
+                        'uploadVoice',
+                        'downloadVoice',
+                        'chooseImage',
+                        'previewImage',
+                        'uploadImage',
+                        'downloadImage',
+                        'getNetworkType',
+                        'openLocation',
+                        'getLocation',
+                        'hideOptionMenu',
+                        'showOptionMenu',
+                        'closeWindow',
+                        'scanQRCode',
+                        'chooseWXPay',
+                        'openProductSpecificView',
+                        'addCard',
+                        'chooseCard',
+                        'openCard',
+                    ],
+                })
+                resolve()
+            }
+        )
+
+        // jsonp({
+        //     url: '//www.4dage.com/wechat/jssdk/share',
+        //     data: {
+        //         name: name,
+        //         uri: location.href.split('#')[0],
+        //     },
+        //     // 把前端方法作为参数传递给服务器
+        //     success: function (data) {
+        //         console.log(data)
+        //         wx.config({
+        //             debug: false,
+        //             appId: data.appId,
+        //             timestamp: data.timestamp,
+        //             nonceStr: data.nonceStr,
+        //             signature: data.signature,
+        //             jsApiList: [
+        //                 'checkJsApi',
+        //                 'onMenuShareTimeline',
+        //                 'onMenuShareAppMessage',
+        //                 'updateTimelineShareData',
+        //                 'updateAppMessageShareData',
+        //                 'onMenuShareQQ',
+        //                 'onMenuShareWeibo',
+        //                 'hideMenuItems',
+        //                 'showMenuItems',
+        //                 'hideAllNonBaseMenuItem',
+        //                 'showAllNonBaseMenuItem',
+        //                 'translateVoice',
+        //                 'startRecord',
+        //                 'stopRecord',
+        //                 'onRecordEnd',
+        //                 'playVoice',
+        //                 'pauseVoice',
+        //                 'stopVoice',
+        //                 'uploadVoice',
+        //                 'downloadVoice',
+        //                 'chooseImage',
+        //                 'previewImage',
+        //                 'uploadImage',
+        //                 'downloadImage',
+        //                 'getNetworkType',
+        //                 'openLocation',
+        //                 'getLocation',
+        //                 'hideOptionMenu',
+        //                 'showOptionMenu',
+        //                 'closeWindow',
+        //                 'scanQRCode',
+        //                 'chooseWXPay',
+        //                 'openProductSpecificView',
+        //                 'addCard',
+        //                 'chooseCard',
+        //                 'openCard',
+        //             ],
+        //         })
+        //         resolve()
+        //     },
+        // })
+
+        // $.ajax({
+        //     url: '//www.4dage.com/wechat/jssdk/share',
+        //     type: 'get',
+        //     data: {
+        //         uri: location.href.split('#')[0],
+        //         name: '厦门四维时代微信公众号',
+        //     },
+        //     dataType: 'jsonp',
+        //     //jsonpCallback: "success_jsonp",
+        //     success: function (data, textStatus) {
+        //       console.log(data)
+        //         wx.config({
+        //             debug: false,
+        //             appId: data.appId,
+        //             timestamp: data.timestamp,
+        //             nonceStr: data.nonceStr,
+        //             signature: data.signature,
+        //             jsApiList: [
+        //                 'checkJsApi',
+        //                 'onMenuShareTimeline',
+        //                 'onMenuShareAppMessage',
+        //                 'onMenuShareQQ',
+        //                 'onMenuShareWeibo',
+        //                 'hideMenuItems',
+        //                 'showMenuItems',
+        //                 'hideAllNonBaseMenuItem',
+        //                 'showAllNonBaseMenuItem',
+        //                 'translateVoice',
+        //                 'startRecord',
+        //                 'stopRecord',
+        //                 'onRecordEnd',
+        //                 'playVoice',
+        //                 'pauseVoice',
+        //                 'stopVoice',
+        //                 'uploadVoice',
+        //                 'downloadVoice',
+        //                 'chooseImage',
+        //                 'previewImage',
+        //                 'uploadImage',
+        //                 'downloadImage',
+        //                 'getNetworkType',
+        //                 'openLocation',
+        //                 'getLocation',
+        //                 'hideOptionMenu',
+        //                 'showOptionMenu',
+        //                 'closeWindow',
+        //                 'scanQRCode',
+        //                 'chooseWXPay',
+        //                 'openProductSpecificView',
+        //                 'addCard',
+        //                 'chooseCard',
+        //                 'openCard',
+        //             ],
+        //         })
+        //         resolve()
+        //     },
+        //     error: function (XMLHttpRequest, textStatus, errorThrown) {
+        //         reject('jsonp.error:' + textStatus)
+        //     },
+        // })
+    })
+}
+
+function strToJSON(search) {
+    let args = search.substr(1).split('&')
+    let obj = {}
+    args.forEach(arg => {
+        let index = arg.indexOf('=')
+        if (!~index) {
+            obj[arg] = null
+        } else {
+            obj[arg.substr(0, index)] = arg.substr(index + 1)
+        }
+    })
+
+    return obj
+}
+
+function jsonToStr(data) {
+    let strs = []
+    Object.keys(data).forEach(k => {
+        if (data[k] !== null) {
+            strs.push(`${k}=${data[k]}`)
+        }
+    })
+    return '?' + strs.join('&')
+}
+
+function setup({ title, link, imgUrl, desc }) {
+    let defaultFn = () => {}
+    let defaultChar = ''
+    let search = link.substr(link.indexOf('?'))
+    let path = link.substr(0, link.indexOf('?'))
+    let data = strToJSON(search)
+    wx.ready(function () {
+        // 微信朋友圈
+        data.open = 'wx_friends'
+        wx.onMenuShareTimeline({ title, link: path + jsonToStr(data), imgUrl, desc })
+        // 微信好友
+        data.open = 'wx_friend'
+        wx.onMenuShareAppMessage({ title, desc, link: path + jsonToStr(data), imgUrl, type: defaultChar, dataUrl: defaultChar })
+        // 微博
+        data.open = 'weibo'
+        wx.onMenuShareWeibo({ title, desc, link: path + jsonToStr(data), imgUrl, success: defaultFn, cancel: defaultFn })
+        // 空间
+        data.open = 'qq_zone'
+        wx.onMenuShareQZone({ title, desc, link: path + jsonToStr(data), imgUrl, success: defaultFn, cancel: defaultFn })
+        // QQ好友
+        data.open = 'qq'
+        wx.onMenuShareQQ({ title, desc, link: path + jsonToStr(data), imgUrl, success: defaultFn, cancel: defaultFn })
+        wx.error(function (e) {
+            console.log(e)
+        })
+    })
+}
+// // 封装JSONP方法
+// function jsonp(options) {
+//     // 创建一个script标签
+//     var script = document.createElement('script')
+
+//     // 随机生成一个函数名
+//     /*   Math.random() 随机生成小数 0.123
+//       toString() 转换为字符串
+//       replace('.','') 把点替换 0123
+//       最后随机生成的funName是 myJSONP0123 这种格式 */
+//     var funName = 'myJSONP' + Math.random().toString().replace('.', '')
+
+//     // 多个参数进行拼接
+//     var param = ''
+//     for (var arr in options.data) {
+//         param += '&' + arr + '=' + options.data[arr]
+//     }
+
+//     // 把这个客户传过来的函数设置为全局函数
+//     // . 后面不能跟变量,所以只能用[]
+//     window[funName] = options.success
+
+//     // 给script中的src属性赋值
+//     script.src = options.url + '?callback=' + funName + param
+//     // 放到body容器里面
+//     document.body.appendChild(script)
+
+//     // 等script标签加载完之后,清除标签
+//     script.onload = function () {
+//         document.body.removeChild(script)
+//     }
+// }
+
+export default async args => {
+    if (typeof wx != 'undefined' && browser.detectWeixin()) {
+        // if (typeof wx != 'undefined') {
+        //需要引入 https://res.wx.qq.com/open/js/jweixin-1.2.0.js
+        await toConfigure()
+        setup(args)
+    }
+}