zhaoxiaohai 3 anos atrás
pai
commit
d678e3007b

+ 96 - 14
pages/annunciate/details.js

@@ -1,7 +1,7 @@
-const _Http = getApp().globalData.http;
+const _Http = getApp().globalData.http,
+    MFT = require("../../utils/matchingFeilType");
 
 Page({
-
     /**
      * 页面的初始数据
      */
@@ -9,9 +9,11 @@ Page({
         rate: {
             nubmer: 5,
             text: "非常满意"
-        }
+        },
+        videoList: [],
+        loading: false,
+        isEvaluate: false
     },
-
     /**
      * 生命周期函数--监听页面加载
      */
@@ -25,11 +27,26 @@ Page({
             }
         }).then(res => {
             console.log('详情', res)
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            });
+
+            let list = MFT.fileList(res.data[0].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[0].attinfos = attinfos;
+            }
             if (res.data[0].content.length) res.data[0].content = decodeURIComponent(res.data[0].content);
             this.setData({
-                detailsData: res.data[0]
-            })
-        })
+                detailsData: res.data[0],
+                videoList
+            });
+        });
         _Http.basic({
             "classname": "saletool.notice.notice",
             "method": "queryReadRecord",
@@ -37,9 +54,22 @@ Page({
                 "sat_noticeid": options.id
             }
         }).then(res => {
-            console.log("评分", res)
-        })
-
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            });
+            let isEvaluate = false;
+            if (res.data[0].score != 0) {
+                this.rateChange({
+                    detail: res.data[0].score
+                })
+                isEvaluate = true;
+            }
+            this.setData({
+                evaluate: res.data[0],
+                isEvaluate
+            })
+        });
     },
     /* 评分 */
     rateChange({
@@ -70,13 +100,65 @@ Page({
             rate
         })
     },
+    textInput({
+        detail
+    }) {
+        this.setData({
+            "evaluate.leavemessage": detail.value
+        })
+    },
+    submit() {
+        if (this.data.isEvaluate) return wx.showToast({
+            title: '您已提交过建议',
+            icon: "none"
+        })
+        const evaluate = this.data.evaluate,
+            that = this;
+        if (evaluate.leavemessage.length > 0) {
+            that.updateReadRecord()
+        } else {
+            wx.showModal({
+                title: "提示",
+                content: "通告评分(建议与反馈)没有完成,是否确认提交,提交后无法修改",
+                success: res => {
+                    if (res.confirm) that.updateReadRecord()
+                }
+            })
+        }
+    },
+    updateReadRecord() {
+        this.setData({
+            loading: true
+        })
+        _Http.basic({
+            "classname": "saletool.notice.notice",
+            "method": "updateReadRecord",
+            "content": {
+                "sat_noticeid": this.data.detailsData.sat_noticeid,
+                "score": this.data.rate.nubmer,
+                "leavemessage": this.data.evaluate.leavemessage
+            }
+        }).then(res => {
+            this.setData({
+                loading: false
+            });
+            if (res.msg != '成功') return wx.showToast({
+                title: res.data,
+                icon: "none"
+            });
+            wx.showToast({
+                title: '提交成功!',
+            });
+            this.setData({
+                isEvaluate: true
+            })
+        })
+    },
+
     /**
      * 生命周期函数--监听页面初次渲染完成
      */
-    onReady() {
-
-    },
-
+    onReady() {},
     /**
      * 生命周期函数--监听页面显示
      */

+ 2 - 1
pages/annunciate/details.json

@@ -3,6 +3,7 @@
     "usingComponents": {
         "DispalyData": "./modules/displayData",
         "van-rate": "@vant/weapp/rate/index",
-        "mp-html": "/components/mp-html/index"
+        "mp-html": "/components/mp-html/index",
+        "My_accessory": "/components/My_accessory/index"
     }
 }

+ 28 - 0
pages/annunciate/details.scss

@@ -21,6 +21,27 @@
     }
 }
 
+.box {
+    width: 690rpx;
+    margin: 0 auto;
+    margin-top: 30rpx;
+
+    .label {
+        font-size: 28rpx;
+        font-family: PingFang SC-Bold, PingFang SC;
+        font-weight: bold;
+        color: #333333;
+    }
+
+    video {
+        width: 690rpx;
+        height: 360rpx;
+        border-radius: 16rpx;
+        overflow: hidden;
+        margin-top: 20rpx;
+    }
+}
+
 /* 通告评价 */
 .evaluate {
     .title-r {
@@ -87,4 +108,11 @@ textarea {
     font-size: 20rpx;
     font-family: PingFangSC-Regular-, PingFangSC-Regular;
     font-weight: normal;
+}
+
+.evaluation-title {
+    font-size: 28rpx;
+    font-weight: bold;
+    color: #333333;
+    margin-left: 30rpx;
 }

+ 14 - 8
pages/annunciate/details.wxml

@@ -20,26 +20,32 @@
                 <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>
+        <view></view>
         <My_card custom-class="evaluate" title="通告评价" hover>
-            <view slot='title-r' class="title-r">112人评分</view>
+            <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" />
                 <text>{{rate.text}}</text>
             </view>
-            <view class="but-box">
-                <van-button custom-class='submit' color="var(--assist)">提交</van-button>
-            </view>
-        </My_card>
-        <My_card title="建议与反馈">
+            <view class="evaluation-title">建议与反馈</view>
             <view style="width: 100%; text-align: center;">
-                <textarea placeholder="请输入您的建议与反馈"></textarea>
+                <textarea value="{{evaluate.leavemessage}}" bind:input='textInput' placeholder="请输入您的建议与反馈" />
                 <view class="but-box">
-                    <van-button custom-class='submit' color="var(--assist)">提交</van-button>
+                    <van-button bindtap="submit" disabled='{{isEvaluate}}' loading='{{loading}}' loading-text="提交中..." custom-class='submit' color="var(--assist)">提交</van-button>
                 </view>
             </view>
         </My_card>
     </van-tab>
+
     <van-tab title="数据">
         <DispalyData></DispalyData>
     </van-tab>

+ 4 - 0
pages/annunciate/index.js

@@ -44,6 +44,10 @@ Page({
                 title: res.data,
                 icon: "none"
             })
+            for (let i = 0; i < res.data.length; i++) {
+                let obj = res.data[i].attinfos.find(v => v.usetype == 'cover');
+                res.data[i].cover = (obj) ? obj.url : '';
+            }
             this.setData({
                 total: res.total,
                 list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),