Lou
2024-01-06 d8cb7a8f82e370ed0220490f9b3ec40b30af7621
subPackage/article/detail.vue
@@ -1,141 +1,144 @@
<template>
   <view class="">
      <view class="wrap">
      <view class="container">
         <view class="f-32 fw">{{detailInfo.title}}</view>
         <view class="row flex j-c-s-b a-i-c c-99">
            <view class="flex">
               <!-- <view class="flex a-i-c mr-40">
         <view class="container">
            <view class="f-32 fw">{{detailInfo.title}}</view>
            <view class="row flex j-c-s-b a-i-c c-99">
               <view class="flex">
                  <!-- <view class="flex a-i-c mr-40">
               <u-icon name="thumb-up-fill" color="#CECECE"></u-icon>
               <text class="f-22 ml-10">120</text>
                 </view> -->
               <view class="flex a-i-c">
                  <tag-cell  v-if="detailInfo.dictValue" :text="detailInfo.dictValue"></tag-cell>
                  <view class="flex a-i-c ml-20">
                     <u-icon name="eye-fill" color="#CECECE"></u-icon>
                     <text class="f-22 ml-10">{{detailInfo.viewNumber}}</text>
                  <view class="flex a-i-c">
                     <tag-cell v-if="detailInfo.dictValue" :text="detailInfo.dictValue"></tag-cell>
                     <view class="flex a-i-c ml-20">
                        <u-icon name="eye-fill" color="#CECECE"></u-icon>
                        <text class="f-22 ml-10">{{detailInfo.viewNumber}}</text>
                     </view>
                  </view>
               </view>
               <text class="f-24">{{detailInfo.createTime}}</text>
            </view>
            <text class="f-24">{{detailInfo.createTime}}</text>
         </view>
         <view class="content f-28">
            <u-parse :content="detailInfo.content" :tagStyle="UParseStyle"></u-parse>
         </view>
      </view>
      <view class="" v-if="isLoad">
         <view class="" v-if="eventType == 0 && applyInfo.openFlag == 0">
            <!-- <view class="explain-row c-main  f-28">
               报名和投票先指定好房屋
            </view> -->
            <view class="select-row flex j-c-s-b a-i-c">
               <text class="f-28">房屋</text>
               <view class="select-row-content flex a-i-c">
                  <text class="f-26 c-99 mr-20">{{curSite.name}}</text>
                  <!-- <u-icon name="arrow-right" color="#999"></u-icon> -->
               </view>
            </view>
            <view class="apply">
               <view class="flex f-d-c a-i-c" v-if="applyList.length">
                  <view class="flex mb-20">
                     <image v-for="i in applyList" class="apply-user" src="/static/icon/user-01.png"
                        mode="aspectFill">
                     </image>
                  </view>
                  <text class="f-28 c-99">共{{applyList.length}}人</text>
               </view>
               <button v-if="computeEndTime > 0 && !applyInfo.userId" class="apply-btn bgc-main c-ff "
                  @click="handleApply()">报名</button>
               <button v-if="applyInfo.userId && computeEndTime > 0" class="apply-btn bgc-lightblue c-main  border-current">已报名</button>
               <button v-if="computeEndTime <= 0"
                  class="apply-btn bgc-lightblue c-main border-current">已结束</button>
            <view class="content f-28">
               <u-parse :content="detailInfo.content" :tagStyle="UParseStyle"></u-parse>
            </view>
         </view>
         <view class="mt-20" v-if="eventType == 1 && voteTopicList.length">
            <view class="select-row flex j-c-s-b a-i-c mb-20">
               <text class="f-28">房屋</text>
               <view class="select-row-content flex a-i-c">
                  <text class="f-26 c-99 mr-20">{{curSite.name}}</text>
                  <!-- <u-icon name="arrow-right" color="#999"></u-icon> -->
         <view class="" v-if="isLoad">
            <view class="" v-if="applyInfo.eventType == 0 && applyInfo.openFlag == 0">
               <view class="select-row flex j-c-s-b a-i-c">
                  <text class="f-28">房屋</text>
                  <view class="select-row-content flex a-i-c">
                     <text class="f-26 c-99 mr-20">{{curSite.name}}</text>
                     <!-- <u-icon name="arrow-right" color="#999"></u-icon> -->
                  </view>
               </view>
               <view class="apply">
                  <view class="flex f-d-c a-i-c" v-if="applyList.length">
                     <view class="flex mb-20">
                        <image v-for="i in applyList" class="apply-user" src="/static/icon/user-01.png"
                           mode="aspectFill">
                        </image>
                     </view>
                     <text class="f-28 c-99">共{{applyList.length}}人</text>
                  </view>
                  <button v-if="computeEndTime > 0 && !applyInfo.userId" class="apply-btn bgc-main c-ff "
                     @click="handleApply()">报名</button>
                  <button v-if="applyInfo.userId && computeEndTime > 0"
                     class="apply-btn bgc-lightblue c-main  border-current">已报名</button>
                  <button v-if="computeEndTime <= 0"
                     class="apply-btn bgc-lightblue c-main border-current">已结束</button>
               </view>
            </view>
            <view class="explain-row c-main  f-28">
               投票{{!isEnd && !isComplete?"进行中":"已结束"}}
            </view>
            <view class="vote bgc-ff">
               <view class="mb-20" v-for="(item,index) in voteTopicList" :key="index">
                  <view class="vote-title">
                     <text class="f-30 fw">{{item.discussContent}}</text>
                     <text class="f-26 ml-10">{{item.optionRange == 0?"(单选)":"(多选)"}}</text>
            <view class="mt-20" v-if="this.type == 4 && voteTopicList.length">
               <view class="select-row flex j-c-s-b a-i-c mb-20">
                  <text class="f-28">房屋</text>
                  <view class="select-row-content flex a-i-c">
                     <text class="f-26 c-99 mr-20">{{curSite.name}}</text>
                     <!-- <u-icon name="arrow-right" color="#999"></u-icon> -->
                  </view>
                  <view class="" v-if="item.optionRange == 0">
                     <u-radio-group size="22" iconPlacement="right" activeColor="#017BFC" placement="column"
                        v-model="item.selected" @change="selectOption($event,index)"
                        :disabled="item.isSubmit || isEnd">
                        <view class="mb-30" v-for="(i,k) in item.children">
                           <u-radio :label="i.optionContent" :name="i.id"></u-radio>
                           <view class="flex j-c-s-b a-i-c mt-10">
                              <view class="mt-10" style="width:80%;">
                                 <uv-line-progress v-if="item.selected" height="6" :showText="false"
                                    :percentage="getRatio(i.number)"
                                    activeColor="#017BFC"></uv-line-progress>
                                 <uv-line-progress v-else height="6" :showText="false"></uv-line-progress>
               </view>
               <view class="explain-row c-main  f-28">
                  投票{{!isEnd && !isComplete?"进行中":"已结束"}}
               </view>
               <view class="vote bgc-ff">
                  <view class="mb-20" v-for="(item,index) in voteTopicList" :key="index">
                     <view class="vote-title">
                        <text class="f-30 fw">{{item.discussContent}}</text>
                        <text class="f-26 ml-10">{{item.optionRange == 0?"(单选)":"(多选)"}}</text>
                     </view>
                     <view class="" v-if="item.optionRange == 0">
                        <u-radio-group size="22" iconPlacement="right" activeColor="#017BFC" placement="column"
                           v-model="item.selected" @change="selectOption($event,index)"
                           :disabled="item.isSubmit || isEnd">
                           <view class="mb-30" v-for="(i,k) in item.children">
                              <u-radio :label="i.optionContent" :name="i.id"></u-radio>
                              <view class="flex j-c-s-b a-i-c mt-10">
                                 <view class="mt-10" style="width:80%;">
                                    <uv-line-progress v-if="item.selected" height="6" :showText="false"
                                       :percentage="getRatio(i.number)"
                                       activeColor="#017BFC"></uv-line-progress>
                                    <uv-line-progress v-else height="6"
                                       :showText="false"></uv-line-progress>
                                 </view>
                                 <text class="c-33 f-28"
                                    v-if="i.number && item.isSubmit">{{i.number}}人</text>
                              </view>
                              <text class="c-33 f-28" v-if="i.number && item.isSubmit">{{i.number}}人</text>
                           </view>
                        </view>
                     </u-radio-group>
                  </view>
                  <view class="" v-if="item.optionRange == 1">
                     <u-checkbox-group size="22" iconPlacement="right" activeColor="#017BFC" placement="column"
                        v-model="item.selected" :disabled="isSubmit" @change="selectOption($event,index)"
                        shape="circle" labelColor="#333">
                        <view class="mb-30" v-for="(i,k) in item.children" :key="k">
                           <u-checkbox :label="i.optionContent" :name="i.id"></u-checkbox>
                           <view class="flex j-c-s-b a-i-c mt-10">
                              <view class="mt-10" style="width:80%;">
                                 <uv-line-progress v-if="item.selected" height="6" :showText="false"
                                    :percentage="getRatio(i.number)"
                                    activeColor="#017BFC"></uv-line-progress>
                                 <uv-line-progress v-else height="6" :showText="false"></uv-line-progress>
                        </u-radio-group>
                     </view>
                     <view class="" v-if="item.optionRange == 1">
                        <u-checkbox-group size="22" iconPlacement="right" activeColor="#017BFC"
                           placement="column" v-model="item.selected" :disabled="isSubmit"
                           @change="selectOption($event,index)" shape="circle" labelColor="#333">
                           <view class="mb-30" v-for="(i,k) in item.children" :key="k">
                              <u-checkbox :label="i.optionContent" :name="i.id"></u-checkbox>
                              <view class="flex j-c-s-b a-i-c mt-10">
                                 <view class="mt-10" style="width:80%;">
                                    <uv-line-progress v-if="item.selected" height="6" :showText="false"
                                       :percentage="getRatio(i.number)"
                                       activeColor="#017BFC"></uv-line-progress>
                                    <uv-line-progress v-else height="6"
                                       :showText="false"></uv-line-progress>
                                 </view>
                                 <text class="c-33 f-28" v-if="i.number">{{i.number}}人</text>
                              </view>
                              <text class="c-33 f-28" v-if="i.number">{{i.number}}人</text>
                           </view>
                        </view>
                     </u-checkbox-group>
                        </u-checkbox-group>
                     </view>
                  </view>
                  <button class="apply-btn bgc-main c-ff" v-if="!isEnd  && !isComplete"
                     @click="submitVote()">提交</button>
                  <button class="apply-btn bgc-gray c-d1" v-if="isComplete && !isEnd">已提交</button>
                  <button class="apply-btn bgc-gray c-d1" v-if="isEnd">已结束</button>
               </view>
            </view>
         </view>
         <view class="comment bgc-ff  mt-20" v-if="commentList.length">
            <caption-row title="用户评论" />
            <view class="comment-list ">
               <view class="comment-item flex " v-for="(item,index) in commentList" :key="index">
                  <u-avatar size="45" src="/static/icon/user-01.png"></u-avatar>
                  <view class="comment-item-content">
                     <view class="flex j-c-s-b a-i-c mb-20">
                        <text class="f-28 c-99">{{item.name}}</text>
                        <text class="c-99 f-24">{{item.createTime}}</text>
                     </view>
                     <view class="f-30">
                        {{item.content}}
                     </view>
                  </view>
               </view>
               <button class="apply-btn bgc-main c-ff" v-if="!isEnd  && !isComplete"
                  @click="submitVote()">提交</button>
               <button class="apply-btn bgc-gray c-d1" v-if="isComplete && !isEnd">已提交</button>
               <button class="apply-btn bgc-gray c-d1" v-if="isEnd">已结束</button>
            </view>
         </view>
      </view>
      <view class="comment bgc-ff  mt-20" v-if="commentList.length">
         <caption-row title="用户评论" />
         <view class="comment-list ">
            <view class="comment-item flex " v-for="(item,index) in commentList" :key="index">
               <u-avatar size="45" src="/static/icon/user-01.png"></u-avatar>
               <view class="comment-item-content">
                  <view class="flex j-c-s-b a-i-c mb-20">
                     <text class="f-28 c-99">{{item.name}}</text>
                     <text class="c-99 f-24">{{item.createTime}}</text>
                  </view>
                  <view class="f-30">
                     {{item.content}}
                  </view>
               </view>
            </view>
         </view>
      </view>
      </view>
      <view class="footer">
         <u-search searchIcon='edit-pen' :animation="true" placeholder="写评论" disabled
            @click="navToComment"></u-search>
@@ -171,7 +174,7 @@
            params: {
               id: ""
            },
            eventType: null,
            type: null,
            detailInfo: {},
            pdId: "",
            curSite: {},
@@ -182,7 +185,7 @@
            isSubmit: false, // 是否已提交投票
            commentList: [],
            isEnd: false, //是否结束
            isComplete: false ,// 是否完成全部投票
            isComplete: false, // 是否完成全部投票
            UParseStyle: {
               img: 'width: 100%; float: left;'
            }
@@ -191,9 +194,9 @@
      onLoad(option) {
         this.$set(this.params, "id", option.id);
         if (option.type) {
            this.$set(this.params, "eventType", option.type);
            this.eventType = option.type;
            this.pdId = option.pdId;
            // this.$set(this.params, "eventType", option.type);
            // this.eventType = option.type;
            // this.pdId = option.pdId;
            this.curSite = uni.getStorageSync("siteInfo")
         }
         this.getDetailInfo()
@@ -226,15 +229,18 @@
         getDetailInfo() {
            getDetail(this.params).then(res => {
               this.isLoad = true;
               this.detailInfo = res.data;
               if (this.pdId) {
               this.type = res.data.type
               if (res.data.type == 3) {
                  this.isLoad = true;
                  this.getApplyDetail()
               }
               if (this.eventType == 0) {
                  this.getApplyList();
                  console.log(this.type)
               }
               if (this.eventType == 1) {
               if (res.data.type == 4) {
                  this.isLoad = true;
                  this.getApplyDetail()
                  this.getVoteList();
               }
            })
@@ -255,9 +261,9 @@
         //报名列表
         getApplyList() {
            communityModel.getApplyList({
               publicDiscussId: this.pdId
               articleId: this.params.id
            }).then(res => {
               console.log(res)
               // console.log(res)
               if (res.code == 200) {
                  this.applyList = res.data.records;
               }
@@ -267,9 +273,9 @@
         //报名、投票详情
         getApplyDetail() {
            communityModel.getApplyDetail({
               id: this.pdId
               articleId: this.params.id
            }).then(res => {
               console.log(res)
               // console.log(res)
               if (res.code == 200) {
                  this.applyInfo = res.data;
               }
@@ -279,7 +285,7 @@
         //获取投票议题
         getVoteList() {
            communityModel.getVoteTopics({
               publicDiscussId: this.pdId
               articleId: this.params.id
            }).then(res => {
               if (res.code == 200) {
                  let data = res.data;
@@ -312,14 +318,18 @@
         //报名
         handleApply() {
            if (this.computeEndTime > 0) {
               communityModel.addApply({
                  publicDiscussId: this.pdId
                  publicDiscussId: this.pdId,
                  articleId: this.params.id,
                  houseCode: uni.getStorageSync("siteInfo").houseCode
               }).then(res => {
                  if (res.code == 200) {
                     uni.showToast({
                        title: "操作成功"
                     })
                     this.getApplyList();
                     this.getApplyDetail()
                  }
               })
            } else {
@@ -343,6 +353,8 @@
               if (i.selected) {
                  delete i.children;
                  i.selected = JSON.stringify(i.selected)
                  i.articleId = this.params.id
                  i.houseCode = uni.getStorageSync("siteInfo").houseCode
                  arr.push(i)
               }
            }
@@ -385,9 +397,11 @@
   page {
      background-color: #f5f5f5;
   }
    .wrap{
      padding:0 0 130rpx;
   .wrap {
      padding: 0 0 130rpx;
   }
   .container {
      padding: 0 30rpx;
      background-color: #fff;