MrShi
4 天以前 47d56a8b0f22fb15a46b69dfd46fac23560ad2cd
mini-program/pages/article-details/article-details.vue
@@ -11,11 +11,11 @@
         <view class="pl-wu" v-if="commentList.length === 0">
            <image src="/static/images/default_nocomment@2x.png" mode="widthFix"></image>
         </view>
         <view class="pl-item" v-for="(item, index) in commentList" :key="item.id" v-else>
         <view class="pl-item" v-for="(item, index) in commentList" :key="item.id" v-else @longpress="openDele(item, index)">
            <view class="pl-item-tx">
               <image :src="item.memberImgUrl" mode="widthFix"></image>
               <image :src="item.memberImgUrl || '/static/icon/default.png'" mode="widthFix"></image>
            </view>
            <view class="pl-item-info">
            <view class="pl-item-info" @click.stop="openTwo(item.id, item, item.nikeName)">
               <view class="pl-item-info-name">{{item.nikeName}}</view>
               <view class="pl-item-info-content" v-if="item.content">
                  {{item.content}}
@@ -31,33 +31,24 @@
                  <view class="pl-item-info-data-time">{{item.createDate  }}</view>
                  <view class="pl-item-info-data-list">
                     <view class="pl-item-info-data-list-item"  >
                        <button open-type="getPhoneNumber" style="border:none;" plain="true" @getphonenumber="getphonenumber" v-if="!userInfo ||!userInfo.id">
                            <image  v-if="!userInfo ||!userInfo.id" src="/static/icon/ic_reply2@2x.png" mode="widthFix" ></image>
                        </button>
                        <image v-if="userInfo && userInfo.id" src="/static/icon/ic_reply2@2x.png" mode="widthFix"  @click="openTwo(item.id, item)"></image>
                          <!-- @click.stop="openTwo(item.id, item)" -->
                        <image  src="/static/icon/ic_reply2@2x.png" mode="widthFix"></image>
                     </view>
                     <view class="pl-item-info-data-list-item" >
                        <template  v-if="userInfo && userInfo.id" >
                           <image src="/static/icon/dianzan.png" mode="widthFix" v-if="!item.zanStatus || item.zanStatus == 0"  @click.stop="dianzanpl(item)"></image>
                           <image src="/static/icon/detail_ic_zan_sel@2x.png" mode="widthFix" v-else  @click.stop="dianzanpl(item)"></image>
                           <text :style="{color: (!item.zanStatus || item.zanStatus == 0) ? '#AAAAAA' : '#004096'}"  @click.stop="dianzanpl(item)">{{item.zanCount}}</text>
                        </template>
                        <template  v-else>
                           <button open-type="getPhoneNumber" style="border:none;" plain="true" @getphonenumber="getphonenumber" v-if="!userInfo ||!userInfo.id">
                              <image src="/static/icon/dianzan.png" mode="widthFix"  ></image>
                              <text :style="{color: (!item.zanStatus || item.zanStatus == 0) ? '#AAAAAA' : '#004096'}"  >{{item.zanCount}}</text>
                           </button>
                        </template>
                     </view>
                  </view>
               </view>
               <view class="pl-item" style="border: none;" v-for="(child, a) in item.childern" :key="child.id" >
               <view class="pl-item" style="border: none;" v-for="(child, a) in item.childern" :key="child.id" @click.stop="openTwo(item.id, child, child.nikeName)" @longpress.stop="openDele(child, index, a)">
                  <view class="pl-item-tx">
                     <image :src="child.memberImgUrl" mode="widthFix"></image>
                     <image :src="child.memberImgUrl || '/static/icon/default.png'" mode="widthFix"></image>
                  </view>
                  <view class="pl-item-info">
                     <view class="pl-item-info-name">{{child.nikeName}}</view>
                     <view class="pl-item-info-content" v-if="child.content">
                        <text v-if="child.replyMemberNikeName"> 回复<text  style="color: #AAAAAA;margin-left: 6rpx;margin-right: 6rpx;">{{child.replyMemberNikeName}}</text>: </text>
                        {{child.content}}
                     </view>
                     <view class="pl-item-info-list" v-if="child.multifileList && child.multifileList.length > 0">
@@ -70,7 +61,7 @@
                     <view class="pl-item-info-data">
                        <view class="pl-item-info-data-time">{{child.createDate}}</view>
                        <view class="pl-item-info-data-list">
                           <view class="pl-item-info-data-list-item" @click="openTwo(item.id, child)">
                           <view class="pl-item-info-data-list-item">
                              <image src="/static/icon/ic_reply2@2x.png" mode="widthFix"></image>
                           </view>
                           <view class="pl-item-info-data-list-item" @click.stop="dianzanpl(child)">
@@ -105,10 +96,10 @@
         <view style="width: 100%; height: env(safe-area-inset-bottom);"></view>
      </view>
      <!-- 删除评论 -->
      <u-popup :show="show" round="5" mode="bottom">
      <u-popup :show="show" round="5" mode="bottom" @close="show = false">
         <view class="dele">
            <view class="dele-title">删除我的评论</view>
            <view class="dele-item" style="color: #E4001D;">删除</view>
            <view class="dele-item" style="color: #E4001D;" @click="deleOne">删除</view>
            <view class="dele-item" @click="show = false">取消</view>
         </view>
      </u-popup>
@@ -116,7 +107,7 @@
      <u-popup :show="show1" round="5" mode="bottom" @close="closePush">
         <view class="pus">
            <view class="pus-content">
               <textarea placeholder="说点什么吧~" v-model="value"></textarea>
               <textarea :placeholder="nikeName ? `回复${nikeName}的评论` : '说点什么吧~'" v-model="value"></textarea>
               <view class="pus-content-list" v-if="multifileList.length > 0">
                  <view class="pus-content-list-item" v-for="(item, index) in multifileList" :key="index">
                     <view class="shanchu" @click.stop="deleImg(index)">
@@ -160,10 +151,14 @@
            page: 1,
            next: true,
            value: '',
            nikeName: '',
            multifileList: [],
            
            commentId: null,
            item: null
            pl: null,
            item: null,
            one: null,
            two: null
         }
      },
      onLoad(option) {
@@ -179,23 +174,34 @@
         }
      },
      methods: {
         // 授权手机号
         getphonenumber(e) {
            if (e.detail.errMsg === 'getPhoneNumber:ok') {
               this.$u.api.wxPhone({
                  code: e.detail.code,
                  shopId:this.recshopid,
                  recId:this.recuserid,
                  openid: this.openid
               }).then(res => {
         openDele(item, one, two) {
            this.one = one
            this.two = two
            this.pl = item
            if ((item.memberId === this.userInfo.id) && item.isdeleted !== 1) {
               this.show = true
            }
         },
         deleOne() {
            this.$u.api.deleteComment(this.pl.id)
               .then(res => {
                  if (res.code === 200) {
                     this.$store.commit('setUserInfo', res.data.member)
                     this.$store.commit('setToken', res.data.token)
                      this.$store.commit('setRecShopId','')
                      this.$store.commit('setRecUserId','')
                     this.pl.content = '该评论已被原作者删除'
                     this.pl.isdeleted = 1
                     // if (this.one && !this.two) {
                     //    this.commentList[this.one].content = '该评论已被原作者删除'
                     //    this.commentList[this.one].isdeleted = 1
                     // } else if (this.one && this.two) {
                     //    this.commentList[this.one].childern[this.two].content = '该评论已被原作者删除'
                     //    this.commentList[this.one].childern[this.two].isdeleted = 1
                     // }
                     // this.one = null
                     // this.two = null
                     this.pl = null
                     this.show = false
                  }
               })
            }
         },
         // 点赞
         dianzanpl(item) {
@@ -226,9 +232,14 @@
            }
         },
         // 二级评论
         openTwo(commentId, item) {
         openTwo(commentId, item, nikeName) {
            if (!this.userInfo) {
               this.$refs.login.open()
               return;
            }
            this.item = item
            this.commentId = commentId
            this.nikeName = nikeName
            this.show1 = true
         },
         // 删除图片
@@ -281,6 +292,7 @@
         closePush() {
            this.item = null
            this.commentId = null
            this.nikeName = ''
            this.value = ''
            this.multifileList = []
            this.show1 = false
@@ -329,7 +341,7 @@
               activityId: this.info.id,
               content: this.value,
               multifileList: this.multifileList,
               // commentId: this.commentId,
               commentId: this.commentId,
               replyId: this.item ? this.item.id : null
            }).then(res => {
               if (res.code === 200) {
@@ -689,6 +701,7 @@
                     height: 132rpx;
                     border-radius: 16rpx;
                     overflow: hidden;
                     margin-bottom: 15rpx;
                     image {
                        width: 100%;
                     }