Browse Source

详情页关注研究员弹窗

chenlei 3 months ago
parent
commit
8d822d1de8
2 changed files with 282 additions and 41 deletions
  1. 145 23
      src/views/report/Detail.vue
  2. 137 18
      src/views/report/PDF.vue

+ 145 - 23
src/views/report/Detail.vue

@@ -23,11 +23,13 @@ const reportId = route.query.reportid
 const reportInfo = ref(null)
 const reportContent = ref('')
 const isFollowed = ref(false)
-const authorInfo=ref(null)
+const authorInfoList=ref([])
 const isLogin=ref(true)
 const productId = route.query.productId
 const isSubscribe=ref(true)
 const isFree=ref(true)
+const priceNum=ref('')
+const visible = ref(false);
 const subscribeStatus = ref('')//expired --过期 unSubscribe--未订阅 subscribed--订阅中
 const riskLevelStatus=ref('')//expired过期的 unTest未测评 unMatch风险等级不匹配
 const headImgStyle = ref([])
@@ -61,8 +63,8 @@ async function getReportInfo() {
     productId: productId
   })
   if (res.Ret === 200 && res.ErrCode === 0) {
-    const { detail, authorInfo } = res.data
-    authorInfo.value=authorInfo
+    const { detail, authorInfo, price } = res.data
+    authorInfoList.value=authorInfo
     reportInfo.value = detail
     isLogin.value=res.data.login
     riskLevelStatus.value=res.data.riskLevelStatus
@@ -73,6 +75,7 @@ async function getReportInfo() {
     layoutBaseInfo.value['创建时间'] = reportInfo.value.publishTime
     isSubscribe.value=res.data.isSubscribe
     isFree.value=res.data.isFree
+    priceNum.value=price
     subscribeStatus.value=res.data.subscribeStatus
     getAuthorFollowState()
     nextTick(() => {
@@ -102,22 +105,51 @@ function getAuthorFollowState() {
   })
 }
 function changeFollowState() {
-  apiUser.followAuthor({
-    analystNames: reportInfo.value.author,
-    followType: isFollowed.value ? 'unfollowed' : 'following',
-    mobile: userInfo?.mobile || ''
-  }).then(res => {
-    if (res.Ret === 200 && res.ErrCode === 0) {
-      isFollowed.value = !isFollowed.value
-      Toast({
-        theme: 'success',
-        direction: 'row',
-        message: isFollowed.value ? '关注成功' : '取消关注成功',
-      })
-    }
-  })
+  if (authorInfoList.value.length > 1) {
+    visible.value = true
+  } else {
+    apiUser.followAuthor({
+      analystNames: reportInfo.value.author,
+      followType: isFollowed.value ? 'unfollowed' : 'following',
+      mobile: userInfo?.mobile || ''
+    }).then(res => {
+      if (res.Ret === 200 && res.ErrCode === 0) {
+        isFollowed.value = !isFollowed.value
+        Toast({
+          theme: 'success',
+          direction: 'row',
+          message: isFollowed.value ? '关注成功' : '取消关注成功',
+        })
+      }
+    })
+  }
 }
 
+function onClose() {
+  visible.value = false
+}
+
+// 关注列表
+function changeFollowStateList(item) {
+  console.log(item);
+    apiUser.followAuthor({
+      analystNames: item.name,
+      followType: item.following === 'unfollowed' ? 'following' : 'unfollowed',
+      mobile: userInfo?.mobile || ''
+    }).then(res => {
+      if (res.Ret === 200 && res.ErrCode === 0) {
+        item.following = item.following === 'unfollowed' ? 'following' : 'unfollowed'
+        getAuthorFollowState()
+        Toast({
+          theme: 'success',
+          direction: 'row',
+          message: item.following === 'unfollowed' ? '取消关注成功' : '关注成功',
+        })
+      }
+    })
+}
+
+
 // 显示免责声明
 const isShowMZSM = ref(false)
 
@@ -190,10 +222,17 @@ function goPrimary(){
     url: `/pages-order/payPage/index?id=${productId}`
   })
 }
+
+// 跳转研究员详情页
+function goDetails(item){
+  wx.miniProgram.reLaunch({
+    url:'/pages-user/authordetail/index?id='+item.id
+  })
+}
 </script>
 
 <template>
-  <div class="report-detail-page" v-if="reportInfo">
+  <div :class="!isLogin||['expired','unTest','unMatch'].includes(riskLevelStatus) || (!isSubscribe && !isFree)? 'no-auth-box report-detail-page' : 'report-detail-page'" v-if="reportInfo">
     <!-- 智能研报有版头版尾 -->
     <div class="html-head-img-box" v-if="reportInfo.headResource.imgUrl">
       <img
@@ -236,13 +275,15 @@ function goPrimary(){
       <div class="author-box">
         <div class="img-box">
           <img
-            :src="authorInfo?.[0].headImgUrl|| defaultImg"
+            :src="authorInfoList?.[0].headImgUrl|| defaultImg"
           />
         </div>
         <div class="author-info">
-          <span class="name">{{
-            reportInfo.author.split(",").join("、")
-          }}</span>
+          <span class="name">
+            <template  v-for="(item, index) in authorInfoList" :key="index">
+              {{ item.name }} {{ index === authorInfoList.length - 1 ? "" : "、" }}
+            </template>
+          </span>
           <span class="time">{{ reportInfo.publishTime }}&nbsp;{{reportInfo.riskLevel}}</span>
         </div>
         <div
@@ -376,7 +417,7 @@ function goPrimary(){
           <div class="pay-btn-confirm">
               <div class="pay-btn-money">
                   <span>合计</span>
-                  <span class="pay">¥{{ reportInfo.price }}</span>
+                  <span class="pay">¥{{ priceNum }}</span>
               </div>
               <t-button
                 class="btn"
@@ -391,6 +432,30 @@ function goPrimary(){
   </div>
   <!-- 免责声明 -->
   <disclaimers-wrap v-model:show="isShowMZSM" />
+  <!-- 关注弹窗 -->
+  <t-popup v-model="visible" placement="center" style="width: 350px">
+    <t-icon class="close-btn" name="close-circle" size="32" color="#fff" @click="onClose" />
+    <div class="author-popup">
+      <div class="title">作者详情</div>
+      <div class="authorList-box" v-for="(item, index) in authorInfoList" :key="index">
+        <div class="img-list-box" @click="goDetails(item)">
+          <img
+            :src="authorInfoList?.[0].headImgUrl|| defaultImg"
+          />
+        </div>
+        <div class="name-list-box" @click="goDetails(item)">
+          {{ item.name }}
+        </div>
+        <div
+          @click="changeFollowStateList(item)"
+          :class="['opt-btn', item.following === 'following' ? 'following' : '']"
+          v-if="isLogin"
+        >
+          {{ item.following === 'following' ? "取消关注" : "关注" }}
+        </div>
+      </div>
+    </div>
+  </t-popup>
 </template>
 
 <style lang="scss" scoped>
@@ -428,6 +493,7 @@ function goPrimary(){
         -webkit-box-orient: vertical;
       }
       .time {
+        display: block;
         margin-top: 10px;
         font-size: var(--font-size-small);
         color: var(--text-color-grey);
@@ -564,6 +630,10 @@ function goPrimary(){
     }
   }
 }
+.no-auth-box {
+  height: 100vh;
+  overflow: hidden;
+}
 .no-auth-wrap {
   position: fixed;
   left: 0;
@@ -642,4 +712,56 @@ function goPrimary(){
     }
   }
 }
+.close-btn {
+  position: absolute;
+  left: 100%;
+  margin-left: -16px;
+  top: calc(-1 * (24px  + 32px));
+}
+.title {
+  padding: 30rpx;
+  font-size: 32px;
+  color: #323233;
+  text-align: center;
+}
+.author-popup {
+  padding: 30px;
+  .authorList-box {
+    margin: 20px 0;
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    .img-list-box {
+      width: 78px;
+      height: 78px;
+      border-radius: 50%;
+      overflow: hidden;
+      img {
+        width: 100%;
+        height: 100%;
+      }
+    }
+    .name-list-box {
+      display: -webkit-box;
+      -webkit-box-orient: vertical;
+      overflow: hidden;
+      text-overflow: ellipsis;
+      -webkit-line-clamp: 2; /* 限制为2行 */
+    }
+    .opt-btn {
+      margin-left: 40%;
+      min-width: 140px;
+      height: 40px;
+      padding: 5px 10px;
+      border-radius: 8px;
+      background-color: var(--primary-color);
+      color: var(--text-color-inverse);
+      text-align: center;
+      &.following {
+        background-color: var(--bg-disabled-color);
+        color: var(--text-color-grey);
+      }
+    }
+  }
+}
 </style>

+ 137 - 18
src/views/report/PDF.vue

@@ -27,6 +27,8 @@ const isLogin=ref(true)
 const productId = route.query.productId
 const isSubscribe=ref(true)
 const isFree=ref(true)
+const authorInfoList=ref([])
+const visible = ref(false);
 const subscribeStatus = ref('')//expired --过期 unSubscribe--未订阅 subscribed--订阅中
 const riskLevelStatus=ref('')//expired过期的 unTest未测评 unMatch风险等级不匹配
 async function getReportInfo() {
@@ -43,6 +45,7 @@ async function getReportInfo() {
     isSubscribe.value=res.data.isSubscribe
     isFree.value=res.data.isFree
     subscribeStatus.value=res.data.subscribeStatus
+    authorInfoList.value= res.data.authorInfo
     getAuthorFollowState()
 
     // 设置分享文案
@@ -64,20 +67,48 @@ function getAuthorFollowState() {
   })
 }
 function changeFollowState() {
-  apiUser.followAuthor({
-    analystNames: reportInfo.value.author,
-    followType: isFollowed.value ? 'unfollowed' : 'following',
-    mobile: userInfo?.mobile || ''
-  }).then(res => {
-    if (res.Ret === 200 && res.ErrCode === 0) {
-      isFollowed.value = !isFollowed.value
-      Toast({
-        theme: 'success',
-        direction: 'row',
-        message: isFollowed.value ? '关注成功' : '取消关注成功',
-      })
-    }
-  })
+  if (authorInfoList.value.length > 1) {
+    visible.value = true
+  } else {
+    apiUser.followAuthor({
+      analystNames: reportInfo.value.author,
+      followType: isFollowed.value ? 'unfollowed' : 'following',
+      mobile: userInfo?.mobile || ''
+    }).then(res => {
+      if (res.Ret === 200 && res.ErrCode === 0) {
+        isFollowed.value = !isFollowed.value
+        Toast({
+          theme: 'success',
+          direction: 'row',
+          message: isFollowed.value ? '关注成功' : '取消关注成功',
+        })
+      }
+    })
+  }
+}
+
+function onClose() {
+  visible.value = false
+}
+
+// 关注列表
+function changeFollowStateList(item) {
+  console.log(item);
+    apiUser.followAuthor({
+      analystNames: item.name,
+      followType: item.following === 'unfollowed' ? 'following' : 'unfollowed',
+      mobile: userInfo?.mobile || ''
+    }).then(res => {
+      if (res.Ret === 200 && res.ErrCode === 0) {
+        item.following = item.following === 'unfollowed' ? 'following' : 'unfollowed'
+        getAuthorFollowState()
+        Toast({
+          theme: 'success',
+          direction: 'row',
+          message: item.following === 'unfollowed' ? '取消关注成功' : '关注成功',
+        })
+      }
+    })
 }
 
 // 显示免责声明
@@ -123,10 +154,17 @@ function goPrimary(){
     url: `/pages-order/payPage/index?id=${productId}`
   })
 }
+
+// 跳转研究员详情页
+function goDetails(item){
+  wx.miniProgram.reLaunch({
+    url:'/pages-user/authordetail/index?id='+item.id
+  })
+}
 </script>
 
 <template>
-  <div class="report-ht_pdf-wrap" v-if="reportInfo">
+  <div :class="!isLogin||['expired','unTest','unMatch'].includes(riskLevelStatus) || (!isSubscribe && !isFree)? 'no-auth-box report-ht_pdf-wrap' : 'report-ht_pdf-wrap'"  v-if="reportInfo">
     <div class="report-top-box">
       <div class="title-box">{{ reportInfo.title }}</div>
       <div class="author-box">
@@ -140,9 +178,11 @@ function goPrimary(){
           />
         </div>
         <div class="author-info">
-          <span class="name">{{
-            reportInfo.author.split(",").join("、")
-          }}</span>
+          <span class="name">
+            <template  v-for="(item, index) in authorInfoList" :key="index">
+              {{ item.name }} {{ index === authorInfoList.length - 1 ? "" : "、" }}
+            </template>
+          </span>
           <span class="time">
             {{dayjs(reportInfo.publishedTime).format("YYYY-MM-DD HH:mm:ss")}}&nbsp;
             {{reportInfo.riskLevel}}
@@ -237,6 +277,29 @@ function goPrimary(){
   </div>
   <!-- 免责声明 -->
   <disclaimers-wrap v-model:show="isShowMZSM" />
+  <t-popup v-model="visible" placement="center" style="width: 350px">
+    <t-icon class="close-btn" name="close-circle" size="32" color="#fff" @click="onClose" />
+    <div class="author-popup">
+      <div class="title">作者详情</div>
+      <div class="authorList-box" v-for="(item, index) in authorInfoList" :key="index">
+        <div class="img-list-box" @click="goDetails(item)">
+          <img
+            :src="authorInfoList?.[0].headImgUrl|| defaultImg"
+          />
+        </div>
+        <div class="name-list-box" @click="goDetails(item)">
+          {{ item.name }}
+        </div>
+        <div
+          @click="changeFollowStateList(item)"
+          :class="['opt-btn', item.following === 'following' ? 'following' : '']"
+          v-if="isLogin"
+        >
+          {{ item.following === 'following' ? "取消关注" : "关注" }}
+        </div>
+      </div>
+    </div>
+  </t-popup>
 </template>
 
 <style scoped lang="scss">
@@ -342,6 +405,10 @@ function goPrimary(){
     margin-top: 20px;
   }
 }
+.no-auth-box {
+  height: 100vh;
+  overflow: hidden;
+}
 .no-auth-wrap {
   position: fixed;
   left: 0;
@@ -420,4 +487,56 @@ function goPrimary(){
     }
   }
 }
+.close-btn {
+  position: absolute;
+  left: 100%;
+  margin-left: -16px;
+  top: calc(-1 * (24px  + 32px));
+}
+.title {
+  padding: 30rpx;
+  font-size: 32px;
+  color: #323233;
+  text-align: center;
+}
+.author-popup {
+  padding: 30px;
+  .authorList-box {
+    margin: 20px 0;
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    .img-list-box {
+      width: 78px;
+      height: 78px;
+      border-radius: 50%;
+      overflow: hidden;
+      img {
+        width: 100%;
+        height: 100%;
+      }
+    }
+    .name-list-box {
+      display: -webkit-box;
+      -webkit-box-orient: vertical;
+      overflow: hidden;
+      text-overflow: ellipsis;
+      -webkit-line-clamp: 2; /* 限制为2行 */
+    }
+    .opt-btn {
+      margin-left: 40%;
+      min-width: 140px;
+      height: 40px;
+      padding: 5px 10px;
+      border-radius: 8px;
+      background-color: var(--primary-color);
+      color: var(--text-color-inverse);
+      text-align: center;
+      &.following {
+        background-color: var(--bg-disabled-color);
+        color: var(--text-color-grey);
+      }
+    }
+  }
+}
 </style>