zhaoxiaohai 2 years ago
parent
commit
8d5bef0fd8

+ 30 - 70
pages/annunciate/details.js

@@ -1,12 +1,15 @@
 const _Http = getApp().globalData.http,
     MFT = require("../../utils/matchingFeilType"),
     deleteMark = require("../../utils/deleteMark");
-
+import {
+    weAtob
+} from "../../utils/weapp-jwt.js";
 Page({
     /**
      * 页面的初始数据
      */
     data: {
+        tabsTitle: "详情",
         rate: {
             nubmer: 5,
             text: "非常满意"
@@ -15,58 +18,57 @@ Page({
         loading: false,
         isEvaluate: false
     },
-    /**
-     * 生命周期函数--监听页面加载
-     */
     onLoad(options) {
+        console.log(options)
         let dataAuth = '';
         if (options.auth.includes('团队内部数据分析') && options.auth.includes('经销商数据分析')) {
             dataAuth = 'all';
         } else {
             dataAuth = options.auth.includes('团队内部数据分析') ? '内部' : '经销商'
-        }
+        };
+        let viewData = options.auth.includes('团队内部数据分析') || options.auth.includes('经销商数据分析');
         this.setData({
-            viewData: options.auth.includes('团队内部数据分析') || options.auth.includes('经销商数据分析'),
+            viewData,
             dataAuth,
-            feedback: options.feedback,
             sat_noticeid: options.id
         });
-        /* 详情 */
+        this.queryNoticeMain(); //获取详情
+        if (viewData) this.queryReadRecord(); //查询数据
+    },
+    /* 通告详情 */
+    queryNoticeMain() {
         _Http.basic({
             "classname": "saletool.notice.notice",
             "method": "queryNoticeMain",
             "content": {
-                "sat_noticeid": options.id
+                "sat_noticeid": this.data.sat_noticeid
             }
         }).then(res => {
-            console.log('详情', res)
             if (res.msg != '成功') return wx.showToast({
                 title: res.msg,
                 icon: "none"
             });
-            let list = MFT.fileList(res.data.attinfos.filter(v => v.usetype != 'cover')),
-                videoList = [],
-                attinfos = [];
-            if (list.length > 0) {
-                for (let i = 0; i < list.length; i++) {
-                    list[i].fileType == 'video' ? videoList.push(list[i]) : attinfos.push(list[i]);
-                }
-                res.data.attinfos = attinfos;
-            }
-            if (res.data.content.length) res.data.content = decodeURIComponent(res.data.content);
+            let list = MFT.fileList(res.data.attinfos.filter(v => v.usetype != 'cover')), //过滤封面文件
+                videoList = [], //视频附件列表
+                attinfos = []; //其他附件
+            list.forEach(v => v.fileType == 'video' ? videoList.push(v) : attinfos.push(v));
+            res.data.attinfos = attinfos;
+            if (res.data.content.length) res.data.content = weAtob(res.data.content); //解码富文本
             this.setData({
                 detailsData: res.data,
                 videoList
             });
         });
+    },
+    /* 查询数据 */
+    queryReadRecord() {
         _Http.basic({
             "classname": "saletool.notice.notice",
             "method": "queryReadRecord",
             "content": {
-                "sat_noticeid": options.id
+                "sat_noticeid": this.data.sat_noticeid
             }
         }).then(res => {
-            console.log(321654,res)
             if (res.msg != '成功') return wx.showToast({
                 title: res.msg,
                 icon: "none"
@@ -88,11 +90,10 @@ Page({
     rateChange({
         detail
     }) {
-        console.log(detail)
         let rate = {
             nubmer: detail,
             text: ""
-        }
+        };
         switch (detail) {
             case 1:
                 rate.text = '很不满意'
@@ -110,7 +111,6 @@ Page({
                 rate.text = '非常满意'
                 break;
         }
-        console.log(rate)
         this.setData({
             rate
         })
@@ -169,50 +169,10 @@ Page({
             })
         })
     },
-
-    /**
-     * 生命周期函数--监听页面初次渲染完成
-     */
-    onReady() {},
-    /**
-     * 生命周期函数--监听页面显示
-     */
-    onShow() {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面隐藏
-     */
-    onHide() {
-
-    },
-
-    /**
-     * 生命周期函数--监听页面卸载
-     */
-    onUnload() {
-
-    },
-
-    /**
-     * 页面相关事件处理函数--监听用户下拉动作
-     */
-    onPullDownRefresh() {
-
-    },
-
-    /**
-     * 页面上拉触底事件的处理函数
-     */
-    onReachBottom() {
-
+    /* tabs切换 */
+    tabChange(e) {
+        this.setData({
+            tabsTitle: e.detail.title
+        })
     },
-
-    /**
-     * 用户点击右上角分享
-     */
-    onShareAppMessage() {
-
-    }
 })

+ 1 - 1
pages/annunciate/details.json

@@ -1,7 +1,7 @@
 {
     "navigationBarTitleText": "通告详情",
     "usingComponents": {
-        "DispalyData": "./modules/displayData",
+        "DispalyData": "/components/My_displayData/displayData",
         "van-rate": "@vant/weapp/rate/index",
         "mp-html": "/components/mp-html/index",
         "My_accessory": "/components/My_accessory/index"

+ 1 - 4
pages/annunciate/details.scss

@@ -94,11 +94,8 @@ textarea {
     margin: 50rpx 0;
 }
 
-
-
-
 .tag {
-    max-width: 100rpx !important;
+    max-width: 200rpx !important;
     height: 36rpx;
     line-height: 36rpx;
     padding: 0 10rpx;

+ 10 - 58
pages/annunciate/details.wxml

@@ -1,62 +1,14 @@
-<!-- swipeable -->
-<van-tabs wx:if="{{viewData}}" sticky color='var(--assist)' title-active-color='var(--assist)'>
-    <van-tab title="详情">
-        <view class="main">
-            <view class="title multi-line">{{detailsData.title}}</view>
-            <view class="incidental">
-                <view class="incidental_l">
-                    <van-tag wx:if="{{detailsData.classname}}" custom-class='tag line-1' color="#FF3B30" plain>{{detailsData.classname}}</van-tag>
-                    <view class="time">发布于:{{detailsData.createdate}}</view>
-                </view>
-                <view class="incidental_r">
-                    <view class="incidental_r_item">
-                        <text class="iconfont icon-a-tonggaoliulanliang" />
-                        {{detailsData.readcount}}
-                    </view>
-                </view>
-            </view>
-            <block wx:if="{{detailsData.content.length}}">
-                <view class="cut-off-rule" />
-                <mp-html content="{{detailsData.content}}" />
-            </block>
-        </view>
-        <view class="box" wx:if="{{detailsData.attinfos[0]}}">
-            <view class="label">附件</view>
-            <My_accessory list="{{detailsData.attinfos}}" />
-        </view>
-        <view class="box" wx:if="{{videoList[0]}}">
-            <view class="label">视频</view>
-            <video wx:for="{{videoList}}" src="{{item.url}}" />
-        </view>
-        <My_card wx:if="{{feedback!='false'}}" custom-class="evaluate" title="通告评价" hover>
-            <view slot='title-r' class="title-r">{{evaluate.evaluatecount}}人评分</view>
-            <view class="score">
-                <text>总体</text>
-                <van-rate custom-class='rate' readonly='{{isEvaluate}}' value="{{ rate.nubmer }}" size="{{ 25 }}" color="#ffd21e" void-icon="star" void-color="#eee" bind:change="rateChange" />
-                <text>{{rate.text}}</text>
-            </view>
-            <view class="evaluation-title">建议与反馈</view>
-            <view style="width: 100%; text-align: center;">
-                <textarea value="{{evaluate.leavemessage}}" disabled='{{isEvaluate}}' bind:input='textInput' placeholder="请输入您的建议与反馈" />
-                <view class="but-box">
-                    <van-button bindtap="submit" disabled='{{isEvaluate}}' loading='{{loading}}' loading-text="提交中..." custom-class='submit' color="var(--assist)">提交</van-button>
-                </view>
-            </view>
-        </My_card>
-        <view style="height: 30px;" />
-    </van-tab>
-
-    <van-tab title="数据">
-        <DispalyData dataId="{{sat_noticeid}}" dataAuth="{{dataAuth}}" />
-    </van-tab>
+<van-tabs wx:if="{{viewData}}" sticky color='var(--assist)' title-active-color='var(--assist)' bind:change='tabChange'>
+    <van-tab title="详情" />
+    <van-tab title="数据" />
 </van-tabs>
-
-<block wx:else>
+<DispalyData wx:if="{{tabsTitle=='数据'}}" dataId="{{sat_noticeid}}" dataAuth="{{dataAuth}}" />
+<view hidden="{{tabsTitle!='详情'}}">
     <view class="main">
         <view class="title multi-line">{{detailsData.title}}</view>
         <view class="incidental">
             <view class="incidental_l">
-                <van-tag custom-class='tag line-1' color="#FF3B30" plain>{{detailsData.classname}}</van-tag>
+                <van-tag wx:if="{{detailsData.classname}}" custom-class='tag line-1' color="#FF3B30" plain>{{detailsData.classname}}</van-tag>
                 <view class="time">发布于:{{detailsData.createdate}}</view>
             </view>
             <view class="incidental_r">
@@ -79,20 +31,20 @@
         <view class="label">视频</view>
         <video wx:for="{{videoList}}" src="{{item.url}}" />
     </view>
-    <My_card wx:if="{{feedback!='false'}}" custom-class="evaluate" title="通告评价" hover>
+    <My_card custom-class="evaluate" title="通告评价" hover>
         <view slot='title-r' class="title-r">{{evaluate.evaluatecount}}人评分</view>
         <view class="score">
             <text>总体</text>
-            <van-rate custom-class='rate' value="{{ rate.nubmer }}" size="{{ 25 }}" color="#ffd21e" void-icon="star" void-color="#eee" bind:change="rateChange" />
+            <van-rate custom-class='rate' readonly='{{isEvaluate}}' value="{{ rate.nubmer }}" size="{{ 25 }}" color="#ffd21e" void-icon="star" void-color="#eee" bind:change="rateChange" />
             <text>{{rate.text}}</text>
         </view>
         <view class="evaluation-title">建议与反馈</view>
         <view style="width: 100%; text-align: center;">
-            <textarea value="{{evaluate.leavemessage}}" bind:input='textInput' placeholder="请输入您的建议与反馈" />
+            <textarea value="{{evaluate.leavemessage}}" disabled='{{isEvaluate}}' bind:input='textInput' placeholder="请输入您的建议与反馈" />
             <view class="but-box">
                 <van-button bindtap="submit" disabled='{{isEvaluate}}' loading='{{loading}}' loading-text="提交中..." custom-class='submit' color="var(--assist)">提交</van-button>
             </view>
         </view>
     </My_card>
     <view style="height: 30px;" />
-</block>
+</view>

+ 9 - 10
pages/annunciate/index.js

@@ -25,14 +25,14 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad(options) {
-        console.log(options.auth)
-        let auth = JSON.parse(options.auth)[0].meta.auth;
-        let authList = [];
-        auth.forEach(v => authList.push(v.optionname));
-        console.log(authList)
-        this.setData({
-            authList
-        })
+        if (options.auth) {
+            let authList = [];
+            JSON.parse(options.auth)[0].meta.auth.forEach(v => authList.push(v.optionname));
+            this.setData({
+                authList
+            })
+        }
+
         this.getList();
     },
 
@@ -66,8 +66,7 @@ Page({
     toDetails(e) {
         const {
             item
-        } = e.currentTarget.dataset;
-        let authList = this.data.authList;
+        } = e.currentTarget.dataset, authList = this.data.authList;
         wx.navigateTo({
             url: `./details?id=${item.sat_noticeid}&feedback=${authList.includes('反馈')}&auth=${authList}`
         })