Browse Source

二维码

zhaoxiaohai 3 years ago
parent
commit
c0997b04e8

+ 9 - 18
components/My_TwoDimensionalCode/analyze.js

@@ -10,7 +10,7 @@ function showModel(data, content) {
         content: content,
         showCancel: false,
         success: (res => {
-            if (res.confirm) wx.navigateTo({
+            if (res.confirm) wx.reLaunch({
                 url: '/pages/login/index',
             })
         })
@@ -18,7 +18,7 @@ function showModel(data, content) {
 }
 
 //解析二维码链接
-function setDataUrl(url) {
+function setDataUrl(url, login) {
     let q = url;
     console.log("q", q);
     const data = {
@@ -27,23 +27,14 @@ function setDataUrl(url) {
         name: q.slice(q.lastIndexOf('fbrand=') + 7, q.lastIndexOf('&'))
     }
     if (!wx.getStorageSync('userData').token) {
-        return showModel(data, '当前未登录,请登录后进入')
-    } else {
-        _Http.basic({
-            "accesstoken": wx.getStorageSync('userData').token,
-            "classname": "customer.usercenter.usermsg.usermsg",
-            "method": "query_usermsg",
-            "content": {}
-        }).then(res => {
-            if (res.msg != '成功') showModel(data, "登陆状态已过期,请重新登陆!");
-            return data;
-        })
-    }
+        return showModel(data, '当前未登录,请登录后进入!')
+    } else if (login) {
+        return showModel(data, '登录状态已过期,请重新登陆!')
+    };
+    return data;
 }
 
-
-
-
 module.exports = {
-    setDataUrl
+    setDataUrl,
+    showModel
 }

+ 19 - 35
pages/liveStreaming/index.js

@@ -11,7 +11,7 @@ Page({
     tabsList: ["私域直播", "展会直播"], //tabs列表
     tabsIndex: 0, //tabs下标
     accountStatus: -1, //直播账号状态 1-账号正常 2-账号审核中 3-没有账号
-    liveDataCount: {}, //实时数据统计
+    //liveDataCount: {}, 实时数据统计
     liveDataCountForSession: {}, //单场次数据统计
     liveSessionList: [], //直播场次列表
     liveUserList: [], //直播用户观看记录
@@ -32,6 +32,22 @@ Page({
     //获取直播账号
     this.getLiveInfo()
   },
+  /* 实时 */
+  realTime() {
+    const that = this;
+    _Http.basic({
+      "accesstoken": wx.getStorageSync('userData').token,
+      "classname": "customer.live.live",
+      "method": "getRealTimeViewerList",
+      "content": {
+        "pageNumber": 1,
+        "pageSize": 20,
+        "channelid": that.data.accountMsg.channelid
+      }
+    }).then(res => {
+      console.log(res)
+    })
+  },
   /* 自定义model回调 */
   showModelCallBack({
     detail
@@ -96,33 +112,12 @@ Page({
         accountMsg: res.data[0],
         isSy
       })
-      /* 直播数据统计 */
-      this.getLiveDataCount()
+      //获取实时数据
+      this.realTime()
       /* 直播场次列表查询 */
       this.getLiveSessionList()
     })
   },
-  /* 直播数据统计 */
-  getLiveDataCount() {
-    //判断私域还是展会
-    const method = (this.data.tabsIndex == 0) ? 'getSYLiveDataCount' : 'getLiveDataCount'
-    _Http.basic({
-      "accesstoken": wx.getStorageSync('userData').token,
-      "classname": "customer.live.live",
-      "method": method,
-      "content": {
-        "channelid": this.data.accountMsg.channelid
-      }
-    }).then(res => {
-      if (res.msg != '成功') return wx.showToast({
-        title: res.data,
-        icon: "none"
-      });
-      this.setData({
-        liveDataCount: res.data
-      })
-    })
-  },
   /* 直播场次列表查询 */
   getLiveSessionList() {
     const method = (this.data.tabsIndex == 0) ? "getSYLiveSessionList" : "getLiveSessionList"
@@ -213,22 +208,11 @@ Page({
       })
     });
   },
-  /* 返回场次列表 */
-  returnLiveData() {
-    this.setData({
-      dataTypes: 0,
-      userPageNumber: 1,
-      userPageTotal: 1
-    })
-  },
   /* 场次列表选中 */
   optionItemIndex(e) {
     const {
       index
     } = e.currentTarget.dataset;
-    if (index == this.data.optionRow) return this.setData({
-      optionRow: -1
-    });
     this.setData({
       optionRow: index
     })

+ 5 - 60
pages/liveStreaming/index.wxml

@@ -50,66 +50,10 @@
     <view class="msgBox-title-and-but">
         <view wx:if="{{dataTypes==0}}" class="msgBox-title">直播数据</view>
         <view wx:else class="msgBox-title">直播场次:{{showStartTime}}</view>
-        <view wx:if="{{dataTypes==1}}" class="dataReturn" catchtap="returnLiveData">
-            <van-icon style="margin-right: -10rpx;" name="arrow-left" />
-            <van-icon style="margin-right: -5rpx;" name="arrow-left" />
-            返回场次列表
-        </view>
-    </view>
-    <!-- 数据表格 -->
-    <view hidden="{{dataTypes!=0}}">
-        <!-- 数据宫格 -->
-        <view class="data-grid">
-            <view>
-                <view class="title">观看次数(次)</view>
-                <view class="number">{{liveDataCount.viewCounts}}</view>
-            </view>
-            <view>
-                <view class="title">观看人数(人)</view>
-                <view class="number">{{liveDataCount.viewers}}</view>
-            </view>
-            <view>
-                <view class="title">观看时长(分钟)</view>
-                <view class="number">{{liveDataCount.viewDuration}}</view>
-            </view>
-            <view>
-                <view class="title">人均观看次数(次)</view>
-                <view class="number">{{liveDataCount.viewCountsAvg}}</view>
-            </view>
-            <view>
-                <view class="title">人均观看时长(分钟)</view>
-                <view class="number">{{liveDataCount.viewDurationAvg}}</view>
-            </view>
-        </view>
-        <block wx:if="{{liveSessionList.length>=1}}">
-            <scroll-view scroll-x="{{true}}" class="data-formlist">
-                <!-- 表头 -->
-                <view class="data-formlist-header">
-                    <view class="w200rpx">开始时间</view>
-                    <view style="width: 180rpx;">直播id</view>
-                    <view style="width: 160rpx;">观看次数(次)</view>
-                    <view style="width: 200rpx;">观看时长(分钟)</view>
-                    <view style="width: 240rpx;">描述</view>
-                </view>
-                <!-- 表格 -->
-                <view wx:for="{{liveSessionList}}" wx:key="index" class="data-formlist-row {{optionRow==index?'option-row':''}}" data-index="{{index}}" catchtap="optionItemIndex">
-                    <view class="w200rpx u-line-1">{{item.starttime}}</view>
-                    <view class="u-line-1" style="width: 180rpx;">{{item.sessionid}}</view>
-                    <view class="u-line-1" style="width: 160rpx;">{{item.liveuv}}</view>
-                    <view class="u-line-1" style="width: 200rpx;">{{item.duration}}</view>
-                    <view class="u-line-1" style="width: 240rpx; display: flex; align-items: center;">
-                        <input disabled="{{true}}" style="width: 100%; text-align: center;" type="text" value="{{item.description==null?'暂无':item.description}}" />
-                    </view>
-                    <view class="more-but-box" wx:if="{{optionRow==index}}">
-                        <view class="more-but" data-index="{{index}}" catchtap="viewDetails">更多</view>
-                    </view>
-                </view>
-            </scroll-view>
-        </block>
     </view>
     <!-- 数据宫格 -->
-    <view hidden="{{dataTypes!=1}}">
-        <view class="data-grid">
+    <block>
+        <view wx:if="{{false}}" class="data-grid">
             <view>
                 <view class="title">观看次数(次)</view>
                 <view class="number">{{liveDataCountForSession.viewCounts}}</view>
@@ -159,11 +103,12 @@
                 <view class="u-line-1" style="width: 180rpx;">{{item.viewtype=='live'?'直播':'回放'}}</view>
             </view>
         </scroll-view>
-    </view>
+    </block>
+    <!-- 分页 -->
     <My_paging show="{{liveSessionList.length>=1}}" count='{{dataTypes==0?pageNumber:userPageNumber}}' bind:lifeClick='buttonLifeClick' bind:rightClick='buttonRightClick'></My_paging>
 </view>
 <!-- 自定义model -->
-<My_showModel isShow='{{myShowModel}}' content="直播地址:+{{accountMsg.fliveurl_web}}" confirm='一键复制' cancel='知道了' bindcallBack='showModelCallBack' />
+<My_showModel isShow='{{myShowModel}}' content="直播地址:{{accountMsg.fliveurl_web}}" confirm='一键复制' cancel='知道了' bindcallBack='showModelCallBack' />
 
 <!-- 自定义model -->
 <My_showModel isShow='{{myShowModel2}}' content="您的私域直播账号正在申请中" hideCancel />

+ 0 - 20
pages/liveStreaming/index.wxss

@@ -73,26 +73,6 @@
     background-color: #FAFAFA;
 }
 
-.data-formlist-row .more-but-box {
-    position: absolute;
-    width: 100%;
-    height: 30rpx;
-    top: 12rpx;
-}
-
-.more-but-box .more-but {
-    position: fixed;
-    width: 68rpx;
-    height: 30rpx;
-    line-height: 30rpx;
-    background: #4DC2D4;
-    box-shadow: 4rpx 4rpx 4rpx 0px rgba(0, 0, 0, 0.06);
-    border-radius: 15rpx;
-    right: 35rpx;
-    font-size: 20rpx;
-    color: #FFFFFF;
-}
-
 .data-formlist-row>view {
     float: left;
     line-height: 56rpx !important;

+ 25 - 17
pages/tabbar-pages/home/index.js

@@ -79,18 +79,6 @@ Page({
      */
     onLoad: function (query) {
         const that = this;
-        // 获取到二维码原始链接内容
-        if (query.q) {
-            //有登录态直接加入
-            this.ifQrCodeType(analyze.setDataUrl(decodeURIComponent(query.q)));
-        } else if (wx.getStorageSync('qrCodeMsg')) {
-            //无登录态判断缓存中是否存在
-            this.ifQrCodeType(wx.getStorageSync('qrCodeMsg'));
-            //返回数据后清空缓存
-            setTimeout(() => {
-                wx.removeStorageSync('qrCodeMsg');
-            }, 500)
-        };
         /* 获取最新供需列表 */
         _Http.basic({
             "accesstoken": wx.getStorageSync('userData').token,
@@ -106,15 +94,35 @@ Page({
                 }
             }
         }).then(res => {
-            console.log(res)
-            if (res.msg != '成功') return wx.showToast({
-                title: res.data,
-                icon: "none"
-            });
+            if (res.msg != '成功') {
+                wx.showToast({
+                    title: res.data,
+                    icon: "none"
+                });
+                if (query.q) {
+                    //有登录态直接加入
+                    analyze.setDataUrl(decodeURIComponent(query.q), true);
+                    console.log('登录态')
+                }
+                return;
+            }
             const data = handleList.getYTD(res.data);
             this.setData({
                 productList: data
             });
+            // 获取到二维码原始链接内容
+            if (query.q) {
+                //有登录态直接加入
+                this.ifQrCodeType(analyze.setDataUrl(decodeURIComponent(query.q)));
+                console.log('有登录态')
+            } else if (wx.getStorageSync('qrCodeMsg')) {
+                //判断缓存中是否存在
+                this.ifQrCodeType(wx.getStorageSync('qrCodeMsg'));
+                //返回数据后清空缓存
+                setTimeout(() => {
+                    wx.removeStorageSync('qrCodeMsg');
+                }, 500)
+            };
         });
         /* 获取合作商家 */
         _Http.basic({