linwe
2024-08-08 3c738f4fe2762bba8087e5a22fc0dc06560eab0e
subPackage/article/detail.vue
@@ -42,10 +42,10 @@
                     </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 "
                  <button v-if="computeEndTime > 0 && !applyInfo.householdId" class="apply-btn bgc-main c-ff "
                     @click="handleApply()">报名</button>
                  <button v-if="applyInfo.userId && computeEndTime > 0"
                  <button v-if="applyInfo.householdId && computeEndTime > 0"
                     class="apply-btn bgc-lightblue c-main  border-current">已报名</button>
                  <button v-if="computeEndTime <= 0"
@@ -61,19 +61,44 @@
                     <!-- <u-icon name="arrow-right" color="#999"></u-icon> -->
                  </view>
               </view>
               <view class="explain-row c-main  f-28">
                  投票{{!isEnd && !isComplete?"进行中":"已结束"}}
               <view class="explain-row ">
                  <text class="f-28 c-main" v-if="!isEnd && !isComplete && isStart">投票进行中</text>
                  <text class="f-28 c-main" v-if="isComplete && !isEnd">投票已提交</text>
                  <text class="f-28 c-main" v-if="isEnd">投票已结束</text>
                  <text class="f-28 c-main" v-if="!isStart">投票未开始</text>
                  <text class="ml-20 f-26 " v-if="applyInfo.voteRestrictions == 1">(该议题为一户一票)</text>
                  <view class="f-26 mt-20 fw" v-if="!isStart">
                     {{applyInfo.startTime }} -
                     {{applyInfo.endTime}}
                  </view>
               </view>
               <view class="vote bgc-ff">
                  <view class="mb-20" v-for="(item,index) in voteTopicList" :key="index">
                     <view class="vote-title">
                        <text v-if="item.mandatoryFlag == 2" class="vote-sign">*</text>
                        <text class="f-30 fw">{{item.discussContent}}</text>
                        <text class="f-26 ml-10">{{item.optionRange == 0?"(单选)":"(多选)"}}</text>
                        <text class="f-26 ml-10" v-if="item.optionRange == 0">(单选)</text>
                        <text class="f-26 ml-10" v-if="item.optionRange == 1 && !item.optionNumber">(多选)</text>
                        <text class="f-26 ml-10"
                           v-if="item.optionRange == 1 && item.optionNumber>0  && !item.optionNumberMin">
                           (多选{{`最多可选${item.optionNumber}项`}})
                        </text>
                        <text class="f-26 ml-10"
                           v-if="item.optionRange == 1 && item.optionNumber>0  && item.optionNumberMin > 0">
                           (多选 {{`最少需选${item.optionNumberMin}项`}},{{`最多可选${item.optionNumber}项`}})
                        </text>
                     </view>
                     <view class="file-btn  f-26  " v-if="item.attachment"
                        @click="navToDocument(item.attachment)">
                        {{item.discussContent}}附件
                     </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">
                           :disabled="item.isSubmit || isEnd  || isComplete  || !isStart">
                           <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">
@@ -86,17 +111,18 @@
                                 </view>
                                 <text class="c-33 f-28"
                                    v-if="i.number && item.isSubmit">{{i.number}}人</text>
                                    v-if="i.number && item.isSubmit  && item.voteNumberPublic == 1">{{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"
                           placement="column" v-model="item.selected" :disabled="item.isSubmit || isEnd"
                           @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>
                              <u-checkbox :label="i.optionContent" :name="i.id"
                                 :disabled="i.disabled"></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"
@@ -105,16 +131,18 @@
                                    <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>
                                 <text class="c-33 f-28"
                                    v-if="i.number && item.voteNumberPublic == 1">{{i.number}}人</text>
                              </view>
                           </view>
                        </u-checkbox-group>
                     </view>
                  </view>
                  <button class="apply-btn bgc-main c-ff" v-if="!isEnd  && !isComplete"
                  <button class="apply-btn bgc-main c-ff" v-if="!isEnd  && !isComplete  && isStart"
                     @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>
                  <button class="apply-btn bgc-gray c-dd" v-if="isComplete && !isEnd">已提交</button>
                  <button class="apply-btn bgc-gray c-dd" v-if="isEnd">已结束</button>
                  <button class="apply-btn bgc-gray c-dd" v-if="!isStart">未开始</button>
               </view>
            </view>
         </view>
@@ -154,7 +182,6 @@
         </view>
      </view> -->
      <u-popup :show="isShowPopup" @close="isShowPopup = false" mode="center" :round="10" :closeable="true">
         <view class='login-mode'>
            <view class="f-30 fw">
@@ -166,7 +193,8 @@
            <view class='flex a-i-c login-input'>
               <input class='f-30 c-33' type='number' placeholder='请输入验证码' v-model="validationCode"
                  placeholder-class='c-aa f-28'></input>
               <button class='login-input-btn f-24 c-33' @click='getValidationCode'>{{text}}</button>
               <button class='login-input-btn f-24 c-33' :disabled="validationCode?true:false"
                  @click='getValidationCode'>{{text}}</button>
            </view>
            <!--    <button class='login-btn c-ff f-30' :class='validationCode?"bgc-main":""'
               :disabled="validationCode?false:true">确定</button> -->
@@ -180,11 +208,20 @@
<script>
   import {
      getDetail,
      getCommentList
      getCommentList,
      addPointsNumber
   } from '@/api/article/article.js'
   import * as communityModel from "@/api/community/community.js"
   import tagCell from '@/components/noticeList/tagCell.vue'
   import captionRow from "@/components/caption/caption.vue"
   import {
      minioBaseUrl
   } from "@/common/setting.js"
   import {
      sendCode
   } from "@/api/system/index.js"
   export default {
      components: {
         tagCell,
@@ -213,10 +250,13 @@
            isShowPopup: false,
            validationCode: "",
            phone: "",
            text: "获取验证码"
            text: "获取验证码",
            isSendCode: false,
            isStart: false //投票是否开始
         }
      },
      onLoad(option) {
         console.log(option)
         this.$set(this.params, "id", option.id);
         if (option.type) {
            // this.$set(this.params, "eventType", option.type);
@@ -224,8 +264,17 @@
            // this.pdId = option.pdId;
            this.$set(this.params, "type", option.type);
            this.curSite = uni.getStorageSync("siteInfo")
            if (option.type == 6) {
               console.log(222)
               this.addNumber(option.id);
            }
         }
         this.getDetailInfo()
         if (this.curSite.relationship == 18) { //租客隐藏投票、报名信息
            this.isLoad = false;
         }
         this.getAritcleComment();
         uni.$on('refreshComment', () => {
            this.getAritcleComment()
@@ -242,12 +291,34 @@
            let endTimestamp = new Date(this.applyInfo.endTime).getTime();
            if (Number(endTimestamp) - Number(curTimestamp) <= 0) {
               this.isEnd = true;
               this.setOptionDisable() //时间结束,所有多项按钮禁用
            }
            return Number(endTimestamp) - Number(curTimestamp)
         },
         computeStartTime() {
            let curTimestamp = new Date().getTime();
            let startTimestamp = new Date(this.applyInfo.startTime).getTime();
            if (Number(curTimestamp) - Number(startTimestamp) >= 0) {
               this.isStart = true;
            } else {
               this.setOptionDisable()
               this.isStart = false;
               //时间没到,所有多项按钮禁用
            }
            // return Number(endTimestamp) - Number(curTimestamp)
         }
      },
      methods: {
         addNumber(id) {
            addPointsNumber({
               houseCode: this.curSite.houseCode,
               id
            }).then(res => {
               console.log(res)
            })
         },
         toNumber(val) {
            return Number(val)
@@ -258,6 +329,7 @@
         },
         getDetailInfo() {
            this.params.houseCode = uni.getStorageSync("curHouseCode")
            getDetail(this.params).then(res => {
               this.detailInfo = res.data;
               this.type = res.data.type
@@ -290,7 +362,8 @@
         //报名列表
         getApplyList() {
            communityModel.getApplyList({
               articleId: this.params.id
               articleId: this.params.id,
               houseCode: uni.getStorageSync("curHouseCode")
            }).then(res => {
               // console.log(res)
               if (res.code == 200) {
@@ -302,11 +375,16 @@
         //报名、投票详情
         getApplyDetail() {
            communityModel.getApplyDetail({
               articleId: this.params.id
               articleId: this.params.id,
               houseCode: uni.getStorageSync("curHouseCode")
            }).then(res => {
               // console.log(res)
               if (res.code == 200) {
                  this.applyInfo = res.data;
                  if (res.data.voteRestrictions == 1 && res.data.disabled) {
                     this.isComplete = true; //一户一票
                     this.setOptionDisable()
                  }
               }
            })
         },
@@ -314,21 +392,26 @@
         //获取投票议题
         getVoteList() {
            communityModel.getVoteTopics({
               articleId: this.params.id
               articleId: this.params.id,
               houseCode: uni.getStorageSync("curHouseCode")
            }).then(res => {
               if (res.code == 200) {
                  let data = res.data;
                  let tempArr = [];
                  let count = 0;
                  if (data.length) {
                     for (let i of data) {
                        if (i.selected) {
                           this.isComplete = true;
                           tempArr.push(i);
                           if (typeof i.selected == "string" && i.optionRange == 0) {
                           if (typeof(i.selected) == "string" && i.optionRange == 0) {
                              this.isSubmit = true;
                              i.isSubmit = true;
                              i.selected = Number(i.selected)
                           }
                           if (typeof i.selected == "string" && i.optionRange == 1) {
                           if (typeof(i.selected) == "string" && i.optionRange == 1) {
                              this.isSubmit = true;
                              i.isSubmit = true;
                              i.selected = JSON.parse(i.selected)
@@ -337,9 +420,15 @@
                     }
                  }
                  this.voteTopicList = data;
                  if (data.length == tempArr.length) {
                     this.isComplete = true;
                  // if (data.length == tempArr.length) {
                  //    this.isComplete = true;
                  //    this.setOptionDisable()
                  // }
                  if (this.isComplete) {
                     this.setOptionDisable();
                  }
               }
            })
         },
@@ -396,9 +485,35 @@
         selectOption(id, index) {
            let item = this.voteTopicList[index];
            item.selected = id;
            if (id.length <= item.optionNumber) {
               item.selected = id;
            }
            for (let i = 0, ii = item.children.length; i < ii; i++) {
               item.children[i].selected = false;
               for (let k = 0, kk = item.selected.length; k < kk; k++) {
                  if (item.children[i].id === item.selected[k]) {
                     item.children[i].selected = true;
                  }
                  item.children[i].disabled = false;
                  if (item.selected.length == item.optionNumber) {
                     if (!item.children[i].selected) {
                        item.children[i].disabled = true;
                     }
                  }
               }
            }
            this.$set(this.voteTopicList, index, item);
         },
         setOptionDisable() {
            for (let i = 0, ii = this.voteTopicList.length; i < ii; i++) {
               for (let k = 0, kk = this.voteTopicList[i].children.length; k < kk; k++) {
                  this.voteTopicList[i].children[k].disabled = true;
               }
            }
         },
         getParams(signPath) {
            let list = JSON.parse(JSON.stringify(this.voteTopicList));
@@ -412,23 +527,71 @@
                  i.signaturePath = signPath ? signPath : ""
                  arr.push(i)
               }
               // else if (!i.selected && i.mandatoryFlag == 2) {
               //    this.$showTips('必填议题请选择选项')
               //    return;
               // }
            }
            return arr;
         },
         checkOption() {
            let list = this.voteTopicList;
            for (let i = 0, ii = list.length; i < ii; i++) {
               if (list[i].optionRange == 0) {
                  if (!list[i].selected && list[i].mandatoryFlag == 2) {
                     this.$showTips('必填议题请选择选项')
                     return false;
                  }
               } else {
                  if (list[i].mandatoryFlag == 2) {
                     if (list[i].selected) {
                        if (list[i].optionNumberMin && (list[i].optionNumberMin > list[i].selected
                              .length)) { //判断最少需选
                           this.$showTips(`第${i+1}个议题最少需选${list[i].optionNumberMin}项`)
                           return false;
                        }
                     } else {
                        this.$showTips('必填议题请选择选项')
                        return false;
                     }
                  }
               }
            }
         },
         confirmValidationCode() {
            if (!this.validationCode) {
               this.$showTips("请输入验证码");
               return
            }
            this.voteRequest()
         },
         //提交投票
         submitVote() {
            if (this.applyInfo.signatureFlag == 1) {
               if (this.voteTopicList.length == 1 && (this.voteTopicList[0].mandatoryFlag == 1 || !this.voteTopicList[
                     0].mandatoryFlag) && !this.voteTopicList[0].selected) {
                  this.$showTips("请选择议题选项");
                  return
               } else {
                  if (this.checkOption() === false) return;
               }
               uni.navigateTo({
                  url: `signature?type=2`
               })
            } else {
               if (this.voteTopicList.length == 1 && (this.voteTopicList[0].mandatoryFlag == 1 || !this.voteTopicList[
                     0].mandatoryFlag) && !this.voteTopicList[0].selected) {
                  this.$showTips("请选择议题选项");
                  return
               } else {
                  if (this.checkOption() === false) return;
               }
               this.isShowPopup = true;
               // this.voteRequest()
            }
@@ -450,12 +613,16 @@
            // }
         },
         voteRequest(signPath) {
         voteRequest(signPath, code) {
            let data = this.getParams(signPath)
            uni.showLoading({
               title: "加载中..."
            });
            communityModel.addVoteOperate(data).then(res => {
            communityModel.addVoteOperate({
               phone: uni.getStorageSync("userInfo").phone,
               code: code ? code : this.validationCode,
               children: data
            }).then(res => {
               uni.hideLoading()
               if (res.code == 200) {
                  uni.showToast({
@@ -485,24 +652,58 @@
            //    return false;
            // }
            // this.sendValidationCode();
            if (this.isSendCode) return;
            let second = 60;
            let time = setInterval(() => {
               second--
               this.text = `${second}秒后获取`
               if (second == 0 || this.data.isLogin) {
                  clearInterval(time);
                  this.text = "获取验证码";
            this.isSendCode = true;
            sendCode({
               phone: uni.getStorageSync("userInfo").phone,
            }).then(res => {
               if (res.code == 200) {
                  let time = setInterval(() => {
                     second--
                     this.text = `${second}秒后获取`
                     if (second == 0 || !this.isLogin) {
                        clearInterval(time);
                        this.isSendCode = false
                        this.text = "获取验证码";
                     }
                  }, 1000)
               } else {
                  this.isSendCode = false;
               }
            }, 1000)
            })
         },
         navToDocument(url) {
         sendValidationCode() {
         },
            wx.showLoading({
               title: "加载中...",
            });
            wx.downloadFile({
               url: `${minioBaseUrl}${url}`,
               success: function(res) {
                  const filePath = res.tempFilePath;
                  wx.openDocument({
                     filePath: filePath,
                     fileType: 'pdf',
                     showMenu: true,
                     success: function(res) {
                        wx.hideLoading();
                     },
                     complete: function(err) {
                        console.log("complete===>", err);
                     },
                     fail: function(res) {
                        console.log("打开失败");
                     },
                  });
               },
            });
            // uni.navigateTo({
            //    url: `document?url=${url}`
            // })
         }
      }
   }
</script>
@@ -591,8 +792,8 @@
      border: 1px solid currentColor
   }
   .c-d1 {
      color: #d1d1d1;
   .c-dd {
      color: #ddd
   }
   .c-33 {
@@ -604,6 +805,10 @@
      .vote-title {
         padding: 30rpx 0;
      }
      .vote-sign {
         color: red;
      }
   }
@@ -737,4 +942,14 @@
   .mt-30 {
      margin-top: 30rpx;
   }
   .file-btn {
      display: inline-block;
      padding: 10rpx 20rpx;
      border-radius: 6rpx;
      color: #fff;
      margin-bottom: 20rpx;
      text-align: center;
      background-color: #999;
   }
</style>