liyongli 3 سال پیش
والد
کامیت
4c423d4e94

+ 8 - 2
miniprogram/pages/home/index.js

@@ -13,17 +13,23 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    let url = app.base.url + '/t.json?time=' + (new Date());
+    // if(wx.getSystemInfoSync().platform === "devtools") url = app.base.url + '/t_dev.json?time=' + (new Date())
     wx.showLoading()
     const fs = wx.getFileSystemManager();
     wx.downloadFile({
-      url: app.base.url + '/t.json?time=' + (new Date()),
+      url,
       success: r => {
         fs.readFile({
           filePath: r.tempFilePath,
           encoding: 'utf8',
           position: 0,
           success(res) {
-            let data = res.data ? JSON.parse(res.data) : {};
+            let D = res.data;
+            if(/xml/g.test(D)) {
+              D = '{}'
+            }
+            let data = res.data ? JSON.parse(D) : {};
             app.globalData.origin = data;
             wx.hideLoading()
           },

+ 12 - 2
miniprogram/pages/index/index.js

@@ -25,7 +25,9 @@ Page({
     cloud: {
       width: 0,
       height: 0
-    }
+    },
+    detailList: [],
+    diglogTitle: ""
   },
 
   onLoad(option) {
@@ -44,7 +46,9 @@ Page({
           success(map) {
             json = JSON.parse(map.data || "{}").json || {};
             let data = app.globalData.origin;
+            console.log(data.totalDetails)
             that.setData({
+              detailList: data.totalDetails || [],
               getData: {
                 platform: data.platform || [],
                 map: data.map || [],
@@ -412,7 +416,7 @@ Page({
           top: '55%',
           radius: [0, '50%'],
           label: {
-            position: 'inner', 
+            position: 'inner',
             formatter: "{b}\n{d}%",
             fontSize: 12,
           },
@@ -453,4 +457,10 @@ Page({
     chart.setOption(option);
     return chart;
   },
+  showDetail: function (e) {
+    console.log(e.currentTarget.dataset.title)
+    this.setData({
+      diglogTitle: (e.currentTarget.dataset.title || "")
+    })
+  }
 });

+ 1 - 0
miniprogram/pages/index/index.json

@@ -5,6 +5,7 @@
     "van-image": "@vant/weapp/image/index",
     "van-row": "@vant/weapp/row/index",
     "van-divider": "@vant/weapp/divider/index",
+    "van-icon": "@vant/weapp/icon/index",
     "van-col": "@vant/weapp/col/index"
   },
   "navigationBarTitleText": "传播分析"

+ 43 - 7
miniprogram/pages/index/index.wxml

@@ -1,12 +1,27 @@
 <wxs module="format" src="../../wxs/until.wxs"></wxs>
 <view class="browse">
   <van-row>
-    <van-col span="12">传播量:{{format.formatNumber(getData.total.play_count)}}</van-col>
-    <van-col span="12">发稿量:{{format.formatNumber(getData.total.all)}}条</van-col>
+    <van-col span="12" data-title="传播量" bindtap="showDetail">
+      传播量:{{format.formatNumber(getData.total.play_count)}}
+      <van-icon color="#1AB6FF" name="warning-o" />
+    </van-col>
+    <van-col span="12">
+      <!-- <van-col span="12" data-title="发稿量" bindtap="showDetail"> -->
+      发稿量:{{format.formatNumber(getData.total.all)}}条
+      <!-- <van-icon color="#1AB6FF" name="warning-o" /> -->
+    </van-col>
   </van-row>
   <van-row>
-    <van-col span="12">点赞量:{{format.formatNumber(getData.total.digg_count)}}</van-col>
-    <van-col span="12">评论量:{{format.formatNumber(getData.total.comment_count)}}条</van-col>
+    <van-col span="12">
+      <!-- <van-col span="12" data-title="点赞量" bindtap="showDetail"> -->
+      点赞量:{{format.formatNumber(getData.total.digg_count)}}
+      <!-- <van-icon color="#1AB6FF" name="warning-o" /> -->
+    </van-col>
+    <van-col span="12">
+      <!-- <van-col span="12" data-title="评论量" bindtap="showDetail"> -->
+      评论量:{{format.formatNumber(getData.total.comment_count)}}条
+      <!-- <van-icon color="#1AB6FF" name="warning-o" /> -->
+    </van-col>
   </van-row>
 </view>
 <van-cell wx:if="{{eclook.show}}" title="发稿平台" />
@@ -37,6 +52,27 @@
 <view wx:if="{{portrait.show}}" class="f2-chart">
   <ec-canvas id="bar" width="{{width}}" height="{{height[3]}}" canvas-id="mychart-bar" ec="{{ portrait }}"></ec-canvas>
 </view>
-<view wx:if="{{getData.total}}" style="padding: 0 30rpx">
-  <van-divider contentPosition="center" fontSize="10">以上数据每周五17:00更新</van-divider>
-</view>
+
+<cover-view wx:if="{{diglogTitle}}" class="modolBg">
+  <cover-view class="local_dialog">
+    <cover-view class="local_dialog_title">
+      <cover-view class="local_dialog_close" bindtap="showDetail">
+        <cover-view class="local_dialog_close_left"></cover-view>
+        <cover-view class="local_dialog_close_right"></cover-view>
+      </cover-view>
+      <cover-view class="title">
+        {{diglogTitle}}
+      </cover-view>
+    </cover-view>
+    <cover-view class="local_dialog_body">
+      <cover-view style="padding-right:5px;white-space:pre-wrap;line-height: 1.5em;width:490rpx;margin: 0 auto;">
+        <cover-view wx:key="id" wx:for="{{detailList}}">
+          <cover-view style="line-height:1.8em;font-weight: bold;">{{item.platform}}:</cover-view>
+          <cover-view style="line-height:1.8em" wx:key="id" wx:for="{{item.list || []}}" wx:for-item="v"
+            wx:for-index="i">{{v.title}}:{{format.formatNumber(v.play_count)}}</cover-view>
+        </cover-view>
+      </cover-view>
+      <cover-view style="height:25px"></cover-view>
+    </cover-view>
+  </cover-view>
+</cover-view>

+ 69 - 0
miniprogram/pages/index/index.wxss

@@ -53,4 +53,73 @@
 .pro{
   padding: 0 30rpx;
   margin-bottom: 20rpx;
+}
+
+
+
+.modolBg {
+  position: fixed;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  z-index: 1;
+  background-color: rgba(0, 0, 0, .5);
+}
+
+.local_dialog {
+  top: 50%;
+  left: 50%;
+  width: 600rpx;
+  position: absolute;
+  border-radius: 1em;
+  background-color: #eee;
+  transform: translate(-50%, -50%);
+}
+
+.local_dialog_title {
+  position: relative;
+  text-align: right;
+  padding: 8px 15px;
+  margin-bottom: 1rpx;
+  line-height: 1.5em;
+}
+
+.local_dialog_title .title {
+  font-size: 16px;
+  height: 25px;
+  text-align: center;
+  line-height: 25px;
+  color: #121212;
+}
+.local_dialog_close {
+  float: right;
+  position: relative;
+  width: 1.5em;
+  height: 1.5em;
+}
+
+.local_dialog_close_left,
+.local_dialog_close_right {
+  position: absolute;
+  width: 100%;
+  height: 1rpx;
+  background-color: #121212;
+  top: 50%;
+  transform: rotate(45deg);
+}
+
+.local_dialog_close_right {
+  transform: rotate(135deg);
+}
+
+.local_dialog_body {
+  max-height: 60vh;
+  overflow: hidden;
+  overflow-y: scroll;
+  padding: 8px 15px 0 15px;
+  white-space: normal;
+  line-height: 2em;
+  font-size: 14px;
+  color: #222;
 }