hengmei-two/pagesB/problemDetail/problemDetail.vue

677 lines
24 KiB
Vue
Raw Normal View History

2021-08-19 06:40:59 +00:00
<template>
<view>
<!-- 状态栏 -->
2021-08-26 01:50:19 +00:00
<status-nav v-if="invite_code==''" :titleVal="'分类'" :statusTitle="true"></status-nav>
<view v-if="invite_code!=''" class="status-box statusHNH" style="background-color: #FFFFFF;">
2021-12-20 08:02:27 +00:00
<view :style="{height:statusBarHeight+'px'}"></view>
<view class="status-nav">
<!-- 标题 -->
2021-08-26 01:50:19 +00:00
<view class="tab-title tcenter" style="color: #000000;">分类</view>
2021-12-20 08:02:27 +00:00
</view>
2021-08-26 01:50:19 +00:00
</view>
2021-08-19 06:40:59 +00:00
<!-- 列表 -->
<view :style="{top: statusHeight+'px'}" class="posiszy" style="height: 50px;">
2021-08-19 06:40:59 +00:00
<view class="bacf pad-zy32 pad-sx20">
2021-12-20 08:02:27 +00:00
<cate-pu @choosecateEv="choosecateEv" :activeb="invite_code!=''?'#3875F6':publicColor"
:newCurrent="cateCurrent*1" :newbmo="'#F2F2F2'" :isCenter="false" :newcateList="cateList"></cate-pu>
2021-08-19 06:40:59 +00:00
</view>
</view>
<view class="pad-x180" :style="{paddingTop: (statusHeight+50)+'px'}">
2021-08-19 06:40:59 +00:00
<view v-if="isLoading" class="pad-s30">
<view v-show="cateCurrent==isNum">
<view class="pad-zy32">
<!-- 自定义轮播 -->
2022-04-21 06:13:17 +00:00
<swiper-pu v-if="ifSwiper" :browseP="true" :isplay="isAutoPlay" :bannerList="bannerList" :newHeight="newHeight"
2021-12-20 08:02:27 +00:00
:newRadius="'10'" :newBottom="'5'"></swiper-pu>
2021-08-19 06:40:59 +00:00
<!-- 标题 -->
2022-04-21 06:13:17 +00:00
<view class="fon36 col3 bold mar-sx20 clips2" style="line-height: 50rpx;">{{detailObj.title}}</view>
2021-08-19 06:40:59 +00:00
<view class="disjbac">
<view class="disac">
<!-- 发布者头像 -->
<image lazy-load class="flexs" :src="fabImg || '/static/public/logo.png'"
2021-12-20 08:02:27 +00:00
style="width: 60rpx;height: 60rpx;border-radius: 100%;" mode="aspectFill"></image>
2021-08-19 06:40:59 +00:00
<view class="mar-z10">
<!-- 发布者昵称 -->
2021-11-18 09:34:08 +00:00
<view class="fon28 col3 clips1">{{detailObj.published_by || '恒美植发'}}</view>
2021-08-19 06:40:59 +00:00
<!-- 发布时间 -->
2021-12-20 08:02:27 +00:00
<view class="fon20 col9" style="margin-top: 6rpx;">{{detailObj.published_at}}发布
</view>
2021-08-19 06:40:59 +00:00
</view>
</view>
<view class="disac flexs">
<view class="disac fc" @tap="tapLike" style="width: 60rpx;">
<image src="/static/public/looks.png"
style="width: 42rpx;height: 42rpx;" mode=""></image>
<view class="fon24 col9 tc">{{detailObj.views}}</view>
</view>
<view class="disac fc mar-zy36" @tap="tapLike" style="width: 60rpx;">
2021-12-20 08:02:27 +00:00
<image v-if="isDetailLike" src="/static/public/detail-like.png"
style="width: 42rpx;height: 42rpx;" mode=""></image>
<image v-else src="/static/public/detail-nlike.png"
style="width: 42rpx;height: 42rpx;" mode=""></image>
<view class="fon24 col9 tc">{{detailObj.likes}}</view>
2021-08-19 06:40:59 +00:00
</view>
<!-- <view class="disac fc mar-zy36 posir">
2021-08-19 06:40:59 +00:00
<image src="/static/public/weix.png" style="width: 42rpx;height: 42rpx;" mode=""></image>
<view class="fon24 col9">分享</view>
2021-12-20 08:02:27 +00:00
<button class="posia" open-type="share"
style="top: 0;right: 0;left: 0;bottom: 0;opacity: 0;">分享</button>
</view> -->
2021-08-19 06:40:59 +00:00
<view class="disac fc" @tap="tapConllection">
2021-12-20 08:02:27 +00:00
<image v-if="isDetailConllection" src="/static/public/yconllection.png"
style="width: 44rpx;height: 44rpx;" mode=""></image>
<image v-else src="/static/public/conllection.png"
style="width: 44rpx;height: 44rpx;" mode=""></image>
<view class="fon24 col9">{{detailObj.collects>1000?'999+':detailObj.collects}}</view>
2021-08-19 06:40:59 +00:00
</view>
</view>
</view>
<!-- 内容详情 -->
<view class="fon28 mar-s20" style="color: #1A1A1A; line-height: 40rpx;">
<rich-text :nodes="detailInfo"></rich-text>
</view>
</view>
2021-12-20 08:02:27 +00:00
<view class="pad-zy20">
2022-07-12 07:17:50 +00:00
<view class="fon30 bold tc mar-sx40" :style="{color:publicColor}" v-if="detailObj.diary_id>0"></view>
<view class="fon30 bold tc mar-sx40" :style="{color:publicColor}" v-else></view>
<!-- 相关推荐||日记合集列表 -->
2022-03-04 08:48:40 +00:00
<list-pu @chooseLike="chooseLikex" @praise="praisexgEv" @comfirmev="comfirmevx" :list="xgList"></list-pu>
2021-08-19 06:40:59 +00:00
</view>
<view class="tc fon28 bold" style="color: #fff;background-color: #3875f6;padding: 20rpx;" @tap="gopage(cateCurrent)">{{contentVal}}>></view>
2021-08-19 06:40:59 +00:00
<view class="pad-zy20">
<view class="fon30 bold tc mar-sx40" :style="{color:publicColor}">推荐医生</view>
<!-- 推荐医生列表 -->
<list-doctor v-if="dataList.length!=0" :list="dataList"></list-doctor>
<view v-if="dataList.length==0" class="disjcac fc" style="margin-top: 10%;">
<image class="zanw-img" src="/static/public/nothing.png" mode="aspectFill"></image>
</view>
</view>
</view>
2021-12-20 08:02:27 +00:00
<view v-if="cateCurrent!=isNum">
<view v-if="allList.length!=0" class="pad-zy20">
2022-03-04 08:48:40 +00:00
<list-pu @chooseLike="chooseLike" @praise="praiseEv" @comfirmev="comfirmev" :list="allList"></list-pu>
2021-08-19 06:40:59 +00:00
</view>
<view v-else class="disjcac fc" style="margin-top: 40%;">
<image class="zanw-img" src="/static/public/nothing.png" mode="aspectFill"></image>
<view class="fon24 col3">暂无内容</view>
</view>
</view>
</view>
<!-- 分享 -->
<view @tap="shareImgEv" class="detail-cart-box" style="display: flex;justify-content: center;align-items: center;width: 112rpx;height: 112rpx;border-radius: 100%;background-color: #0fac29;bottom: 160rpx;color: #FFFFFF;">
<image class="zanw-img" src="/static/public/share-pyq.png" mode="aspectFill" style="width: 64rpx;height: 81rpx;"></image>
</view>
2021-08-19 06:40:59 +00:00
<!-- 返回顶部 -->
<!-- <back-top :showTop="showTop" @backTop="backTop"></back-top> -->
2022-03-04 08:48:40 +00:00
<!-- 用户信息授权手机号授权 -->
2022-07-22 10:39:41 +00:00
<view v-if="ifNeedAuth">
<auth-userInfo-mobileInfo></auth-userInfo-mobileInfo>
</view>
2022-02-15 08:02:16 +00:00
<!-- 底部导航 -->
<view class="posixzy">
<bottom-tab></bottom-tab>
</view>
2021-08-19 06:40:59 +00:00
</view>
</view>
</template>
<script>
import listDoctor from '@/components/list-doctor.vue';
import swiperPu from '@/components/swiper-pu.vue';
2022-02-15 08:02:16 +00:00
import bottomTab from '@/components/bottom-tab.vue';
2021-12-20 08:02:27 +00:00
import {
collectionEV,
cancleCollectionEV
} from '@/jsFile/publicAPI.js';
import { base64ToPath } from '@/jsFile/base64-src.js';
2021-08-19 06:40:59 +00:00
export default {
2021-12-20 08:02:27 +00:00
components: {
2021-08-19 06:40:59 +00:00
listDoctor,
swiperPu,
2022-03-04 08:48:40 +00:00
bottomTab,
2021-08-19 06:40:59 +00:00
},
data() {
return {
2021-12-20 08:02:27 +00:00
statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
isLoading: false,
cateCurrent: 0,
cateList: [],
bannerList: [], //轮播
xgList: [ //相关推荐
2021-08-19 06:40:59 +00:00
],
2021-12-20 08:02:27 +00:00
dataList: [ //推荐医生
2021-08-19 06:40:59 +00:00
],
2021-12-20 08:02:27 +00:00
showTop: false,
isDetailLike: false, //是否喜欢
likeCon: '点赞',
isDetailConllection: false, //是否已收藏
isNum: 0,
listArrone: [], //问题
listArrtwo: [ //案例日记
2021-08-19 06:40:59 +00:00
],
2021-12-20 08:02:27 +00:00
listArrthree: [ //效果模拟
2021-08-19 06:40:59 +00:00
],
2021-12-20 08:02:27 +00:00
listArrfour: [ //科普视频
2021-08-19 06:40:59 +00:00
],
2021-12-20 08:02:27 +00:00
detailObj: {}, //详情
detailInfo: '', //富文本
category_id: '', //栏目ID
active: '', //是否是详情页
share_id: 0,
invite_code: '',
isAutoPlay: false,
fabImg: '' ,//发布者头像
allArr:[],
page:1,
size:20,
total:0,
isZanw:true,
allList:[],
contentVal:'',
2022-02-17 03:49:34 +00:00
newHeight:'450',
2022-04-21 06:13:17 +00:00
ifSwiper:0,//是否显示swiper
shareFlag:true,
2022-07-22 10:39:41 +00:00
ifNeedAuth:false,//是否需要授权
shareImg:''
2021-08-19 06:40:59 +00:00
}
},
computed: {
// 主题颜色
publicColor() {
return this.$store.state.publicColor
},
statusHeight() {
return this.$store.state.statusHeight
}
},
2021-08-19 06:40:59 +00:00
onPageScroll(e) {
2021-12-20 08:02:27 +00:00
e.scrollTop > 360 ? this.showTop = true : this.showTop = false
2021-08-19 06:40:59 +00:00
},
2021-12-20 08:02:27 +00:00
onReachBottom() { //触底事件
if(this.cateCurrent!=this.isNum){
if(this.total!=this.allList.length){
this.page++
this.checkList(this.cateCurrent)//调用自主预约列表事件
} else {
if(this.isZanw) this.$toolAll.tools.showToast('暂无更多列表','none',1000)
this.isZanw = false
}
}
2021-08-19 06:40:59 +00:00
},
2021-08-26 01:50:19 +00:00
onShareAppMessage(res) {
2021-12-20 08:02:27 +00:00
var ya = this;
this.$requst.post('user/record', {
type: 'content',
action: 'share',
id: this.detailObj.id
}).then(res => {
console.log('分享成功:', res);
}, error => {})
2022-07-12 07:17:50 +00:00
2022-03-04 08:48:40 +00:00
// 调用tools.js中的种植埋点事件
this.$toolAll.tools.plantPoint(4,this.detailObj.id);
2021-08-19 06:40:59 +00:00
var shareObj = {
2021-12-20 08:02:27 +00:00
title: `${ya.detailObj.title}`, // 默认是小程序的名称(可以写slogan等)
path: `/pagesB/problemDetail/problemDetail?id=${this.detailObj.id}&category_id=${this.category_id}&share_id=${uni.getStorageSync('userId')}&invite_code=${uni.getStorageSync('invite_code')}`, // 默认是当前页面,必须是以‘/’开头的完整路径
// imageUrl: `${ya.$http}${ya.detailObj.share_img || ya.detailObj.cover}` //自定义图片路径可以是本地文件路径、代码包文件路径或者网络图片路径支持PNG及JPG不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
imageUrl: this.shareImg //自定义图片路径可以是本地文件路径、代码包文件路径或者网络图片路径支持PNG及JPG不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
2021-12-20 08:02:27 +00:00
};
return shareObj;
2021-08-19 06:40:59 +00:00
},
2021-08-22 08:53:12 +00:00
onShow() {
this.isAutoPlay = true;
},
2021-12-20 08:02:27 +00:00
onHide() {
this.isAutoPlay = false;
},
2021-12-20 08:02:27 +00:00
onUnload() {
this.isAutoPlay = false;
2021-08-22 08:53:12 +00:00
},
2021-08-19 06:40:59 +00:00
onLoad(options) {
2022-08-12 07:36:39 +00:00
console.log(uni.getStorageSync('phone_active'),uni.getStorageSync('is_active'));
2022-03-21 01:44:07 +00:00
if(uni.getStorageSync('phone_active')!=0 && uni.getStorageSync('is_active')!=0){
2022-03-04 08:48:40 +00:00
if (options.category_id != undefined) {
this.category_id = options.category_id
if(options.invite_code!=undefined){this.invite_code = options.invite_code;}
if (options.share_id != undefined){this.share_id = options.share_id;}
this.checkDetail(options.id);
// 调用tools.js中的种植埋点事件
this.$toolAll.tools.plantPoint(1,options.id);
2021-08-26 01:50:19 +00:00
}
2022-07-22 10:39:41 +00:00
} else {
2022-08-12 07:36:39 +00:00
let pages = getCurrentPages(); //获取加载的页面
let currentPage = pages[pages.length - 1]; //获取当前页面的对象
let data = currentPage.options;
2022-07-22 10:39:41 +00:00
if (options.category_id != undefined) {
this.category_id = options.category_id
2022-08-12 07:36:39 +00:00
this.timer = setInterval(()=>{
if(uni.getStorageSync('userId')){
}
},200)
uni.login({
provider: 'weixin',
success: (res)=> {
if (res.code) {
var params = {
code: res.code,
invite_code: data.invite_code || '', // 用户邀请码
source_code: data.source_code || '', // 渠道
channel: data.channel || ''
}
uni.request({
url: `${uni.getStorageSync('hostapi')}user/login`,
method: 'GET',
data: params,
success: result => {
if(result.data.data.token!=''){
uni.setStorageSync('token',result.data.data.token); // 缓存token
uni.setStorageSync('userId',result.data.data.account_id)//缓存用户id
uni.setStorageSync('expire',result.data.data.expire); // 缓存失效时间(时间戳格式)
uni.setStorageSync('phone_active',result.data.data.phone_active); // 是否绑定手机号
uni.setStorageSync('is_active',result.data.data.is_active)//是否第一次授权
this.share_id = result.data.data.account_id;
this.checkDetail(options.id);
}
},
})
}
},
});
2022-07-22 10:39:41 +00:00
// 调用tools.js中的种植埋点事件
this.$toolAll.tools.plantPoint(1,options.id);
}
2021-08-19 06:40:59 +00:00
}
},
methods: {
// 获取文章分享图
getShareImg(id){
this.$requst.get('archives/detail-share',{id}).then(res=>{
if(res.code==0){
// this.shareImg = res.data.src;
base64ToPath(res.data.share_img).then(path=>{
this.shareImg = path;
})
}
})
},
// 分享图分享
shareImgEv(){
this.$toolAll.tools.showToast('分享图生成中...','none',10000);
if(this.shareFlag){
this.shareFlag = false;
this.$requst.post('archives/share',{id:this.detailObj.id}).then(res=>{
base64ToPath(res.data.share_img).then(path=>{
uni.hideToast();
this.$toolAll.tools.showToast('正在调起分享...');
wx.showShareImageMenu({
path: path,
success:(res=>{
this.shareFlag = true;
this.$requst.post('user/record', {
type: 'content',
action: 'share',
id: this.detailObj.id
}).then(res => {
console.log('分享成功:', res);
}, error => {})
// 调用tools.js中的种植埋点事件
this.$toolAll.tools.plantPoint(4);
}),
fail:(err=>{
this.shareFlag = true;
})
})
})
})
} else {this.$toolAll.tools.showToast('请勿重复点击');}
},
// 去更多列表页
gopage(index){
uni.navigateTo({
url:`/pagesB/problemList/problemList?title=${this.cateList[index].title}&category_id=${this.cateList[index].id}`
})
},
2021-12-20 08:02:27 +00:00
chooseLike(e) { //收藏事件
2021-08-19 06:40:59 +00:00
// console.log(this.dataList[e].is_collected);
2021-12-20 08:02:27 +00:00
if (this.allList[e].is_collected == 0) {
this.allList[e].is_collected = 1
2021-08-19 06:40:59 +00:00
// 调用收藏事件
2021-12-20 08:02:27 +00:00
collectionEV({
action: 'collect',
archive_id: this.allList[e].id
})
2021-08-19 06:40:59 +00:00
}
},
2021-12-20 08:02:27 +00:00
comfirmev(e) { //确认取消收藏事件
this.allList[e].is_collected = 0;
this.$toolAll.tools.showToast('正在取消...', 'loading')
2021-08-19 06:40:59 +00:00
// 调用取消收藏事件
2021-12-20 08:02:27 +00:00
cancleCollectionEV({
action: 'collect',
archive_id: this.allList[e].id
})
2021-08-19 06:40:59 +00:00
},
2021-12-20 08:02:27 +00:00
chooseLikex(e) { //收藏事件
if (this.xgList[e].is_collected == 0) {
2021-08-19 06:40:59 +00:00
this.xgList[e].is_collected = 1
// 调用收藏事件
2021-12-20 08:02:27 +00:00
collectionEV({
action: 'collect',
archive_id: this.xgList[e].id
})
2021-08-19 06:40:59 +00:00
}
},
2021-12-20 08:02:27 +00:00
comfirmevx(e) { //确认取消收藏事件
2021-08-19 06:40:59 +00:00
this.xgList[e].is_collected = 0
2021-12-20 08:02:27 +00:00
this.$toolAll.tools.showToast('正在取消...', 'loading')
2021-08-19 06:40:59 +00:00
// 调用取消收藏事件
2021-12-20 08:02:27 +00:00
cancleCollectionEV({
action: 'collect',
archive_id: this.xgList[e].id
})
},
checkDetail(newId) {
this.getShareImg(newId);
2021-12-20 08:02:27 +00:00
this.$requst.post('archives/detail', {
id: newId,
share_id: this.share_id
}).then(res => {
2021-08-19 06:40:59 +00:00
// console.log('详情数据:',res);
2021-12-20 08:02:27 +00:00
if (res.code == 0) {
2021-08-19 06:40:59 +00:00
// 栏目类别
2021-12-20 08:02:27 +00:00
if (res.data.category.length != 0) {
res.data.category.forEach((item, index) => {
2021-08-19 06:40:59 +00:00
let cateObj = {
2021-12-20 08:02:27 +00:00
id: item.id, //栏目ID
title: item.title, //栏目名称
active: item.active, //是否选中
model_id: item.model_id, //模型ID
model_name: item.model_name, //模型标识
2022-07-12 07:17:50 +00:00
sort: item.sort,
2021-08-19 06:40:59 +00:00
}
this.cateList.push(cateObj)
2021-12-20 08:02:27 +00:00
this.allArr.push([]);
2021-08-19 06:40:59 +00:00
// 默认选中的栏目
2021-12-20 08:02:27 +00:00
if (item.active == 1) this.active = this.cateCurrent = index
2021-08-19 06:40:59 +00:00
// 默认展示栏目详情
2021-12-20 08:02:27 +00:00
if (this.category_id == item.id) this.isNum = index
2021-08-19 06:40:59 +00:00
})
2021-12-20 08:02:27 +00:00
this.contentVal = this.cateList[this.cateCurrent].title.slice(2);
if(this.cateList[this.cateCurrent].title== '毛发百科' || this.cateList[this.cateCurrent].title== '科普视频') {
this.newHeight = '200';
}
2021-08-19 06:40:59 +00:00
}
// 详情
2021-11-18 09:34:08 +00:00
this.detailObj = res.data.detail;
2022-07-22 10:39:41 +00:00
if(uni.getStorageSync('phone_active')!=1){
this.ifNeedAuth = this.detailObj.need_permission ? true : false;
2022-08-12 07:36:39 +00:00
this.isLoading = this.detailObj.need_permission ? false : true;
} else {
this.isLoading = true;
2022-07-22 10:39:41 +00:00
}
2022-04-21 06:13:17 +00:00
// 是否显示swiper
this.ifSwiper = this.detailObj.images_show;
2021-12-20 08:02:27 +00:00
if (this.detailObj.published_headimgurl != '') {
2021-11-18 09:34:08 +00:00
this.fabImg = this.$http + this.detailObj.published_headimgurl;
}
2021-12-20 08:02:27 +00:00
if (this.detailObj.is_liked == 1) {
if (this.detailObj.likes >= 1000) this.likeCon = '999+'
2021-08-19 06:40:59 +00:00
else this.likeCon = this.detailObj.likes
}
// 轮播
// 图片字符串转数组
let arrImg = this.detailObj.images.split(',')
2021-12-20 08:02:27 +00:00
arrImg.forEach(item => {
2021-08-19 06:40:59 +00:00
let newImgObj = {
2021-12-20 08:02:27 +00:00
imgSrc: this.$http + item,
url: '',
isVideo: false,
poster: '',
2021-08-19 06:40:59 +00:00
}
// 存图片
this.bannerList.push(newImgObj)
})
2021-08-22 08:53:12 +00:00
// 存视频
2021-12-20 08:02:27 +00:00
if (this.detailObj.video != '') {
2021-08-22 08:53:12 +00:00
this.bannerList[0] = {
2021-12-20 08:02:27 +00:00
imgSrc: this.$http + arrImg[0],
url: this.$http + this.detailObj.video,
isVideo: true,
poster: '',
2021-08-22 08:53:12 +00:00
}
}
2021-08-19 06:40:59 +00:00
// 默认显示是否收藏
2021-12-20 08:02:27 +00:00
if (this.detailObj.is_collected == 0) this.isDetailConllection = false
if (this.detailObj.is_collected == 1) this.isDetailConllection = true
if (this.detailObj.is_liked == 0) this.isDetailLike = false
if (this.detailObj.is_liked == 1) this.isDetailLike = true
2021-08-19 06:40:59 +00:00
// 富文本
this.detailInfo = this.$toolAll.tools.escape2Html(this.detailObj.content)
// 相关推荐xgList
2021-12-20 08:02:27 +00:00
if(this.cateList[this.cateCurrent].title=='日记分享') {
if (res.data.diary.length != 0) {
res.data.diary.forEach(item => {
let fabImg = '';
2022-01-24 05:53:00 +00:00
if (item.published_headimgurl != '' && item.published_headimgurl != null) {
2021-12-20 08:02:27 +00:00
fabImg = this.$http + item.published_headimgurl
2022-01-24 05:53:00 +00:00
}
2021-12-20 08:02:27 +00:00
let tObj = {
category_id: item.category_id, //栏目ID
id: item.id,
is_collected: item.is_collected, //是否已收藏
collects: item.collects, //收藏量
views: item.views, //查看量
main_img: this.$http + item.cover, //封面图
video: this.$http + item.video, //视频地址
title: item.title, //标题
content: item.subtitle, //副标题
head_img: fabImg || '/static/public/logo.png', //发布者头像
name: item.published_by || '恒美植发', //发布者昵称
2022-03-04 08:48:40 +00:00
isVideo: item.video.includes(".mp4"), //是否是视频
likes:item.likes,//点赞数量
2022-07-14 09:43:56 +00:00
is_liked:item.is_liked,//是否已点赞
tag_text:item.tag_text,
2021-12-20 08:02:27 +00:00
}
if (item.cover != '' && item.video == '') {
this.xgList.push(tObj)
}
})
}
} else {
this.relevant();
2021-08-19 06:40:59 +00:00
}
// 推荐医生
2021-12-20 08:02:27 +00:00
if (res.data.doctor.length != 0) {
res.data.doctor.forEach(item => {
2021-08-19 06:40:59 +00:00
let doObj = {
2021-12-20 08:02:27 +00:00
id: item.id,
imgSrc: item.headimg != null ? item.headimg : '',
name: item.name,
cyear: parseFloat(item.work_time),
bmen: item.dept_name,
zcheng: '主任医师',
goodAt: item.diseases,
show_detail: item.show_detail
2021-08-19 06:40:59 +00:00
}
this.dataList.push(doObj)
})
}
2021-08-26 01:50:19 +00:00
this.choosecateEv(this.cateCurrent)
2022-03-04 08:48:40 +00:00
} else this.$toolAll.tools.showToast(res.msg);
}, error => {this.$toolAll.tools.showToast(error.msg);})
2021-08-19 06:40:59 +00:00
},
2021-12-20 08:02:27 +00:00
relevant(){
this.$requst.post('archives/category', {
category_id: this.cateList[this.cateCurrent].id,
keyword: '',
page:this.page,
size:this.size
}).then(res => {
if(res.code==0){
if (res.data.list.list.length != 0) {
res.data.list.list.forEach(item => {
let fabImg = '';
if (item.published_headimgurl != '' && item.published_headimgurl != null)
fabImg = this.$http + item.published_headimgurl
let tObj = {
category_id: item.category_id, //栏目ID
id: item.id,
is_collected: item.is_collected, //是否已收藏
collects: item.collects, //收藏量
views: item.views, //查看量
main_img: this.$http + item.cover, //封面图
video: this.$http + item.video, //视频地址
title: item.title, //标题
content: item.subtitle, //副标题
head_img: fabImg || '/static/public/logo.png', //发布者头像
name: item.published_by || '恒美植发', //发布者昵称
2022-03-04 08:48:40 +00:00
isVideo: item.video.includes(".mp4"), //是否是视频
likes:item.likes,//点赞数量
2022-07-14 09:43:56 +00:00
is_liked:item.is_liked,//是否已点赞
tag_text:item.tag_text,
2021-12-20 08:02:27 +00:00
}
if (item.cover != '' && item.video == '') {
this.xgList.push(tObj)
}
})
2021-08-19 06:40:59 +00:00
}
2022-03-04 08:48:40 +00:00
} else this.$toolAll.tools.showToast(res.msg);
}).catch(err=>{this.$toolAll.tools.showToast(err.msg);})
2021-08-19 06:40:59 +00:00
},
2021-12-20 08:02:27 +00:00
choosecateEv(e) {
this.page = 1;
this.isZanw = true;
this.checkList(e);
},
checkList(e){
this.$requst.post('archives/category', {
category_id: this.cateList[e].id,
keyword: '',
page:this.page,
size:this.size
}).then(res => {
// console.log('该分类下的列表:',res);
if (res.code == 0) {
if(this.page==1) {
if(this.active != e) this.allList = [];
uni.pageScrollTo({
scrollTop:0,
duration:0
})
}
this.total = res.data.list.total;
if (res.data.list.list.length != 0) {
res.data.list.list.forEach(item => {
let num = item.video.search(".mp4")
let isVideo = false
if (num != '-1') isVideo = true
2022-01-24 05:53:00 +00:00
let fabImg = '';
if (item.published_headimgurl != '' && item.published_headimgurl != null)
fabImg = this.$http + item.published_headimgurl
2021-12-20 08:02:27 +00:00
let arrObj = {
category_id: item.category_id, //栏目ID
id: item.id,
is_collected: item.is_collected, //是否已收藏
collects: item.collects, //收藏量
views: item.views, //查看量
main_img: this.$http + item.cover, //封面图
video: this.$http + item.video, //视频地址
title: item.title, //标题
content: item.subtitle, //副标题
2022-01-24 05:53:00 +00:00
head_img: fabImg || '/static/public/logo.png', //发布者头像
name: item.published_by || '恒美植发', //发布者昵称
2022-03-04 08:48:40 +00:00
isVideo: isVideo ,//是否是视频
likes:item.likes,//点赞数量
2022-07-14 09:43:56 +00:00
is_liked:item.is_liked ,// 是否已点赞
tag_text:item.tag_text,
2021-12-20 08:02:27 +00:00
}
if (item.cover != '') {
this.allList.push(arrObj);
}
})
}
this.cateCurrent = e;
2022-03-04 08:48:40 +00:00
} else this.$toolAll.tools.showToast(res.msg);
}, error => {this.$toolAll.tools.showToast(error.msg);})
},
praiseEv(e){ // 点赞事件
2022-07-22 10:39:41 +00:00
// if(this.allList[e].is_liked==0){
2022-03-04 08:48:40 +00:00
this.allList[e].is_liked = 1;
this.allList[e].likes++;
2022-07-22 10:39:41 +00:00
// if(this.allList[e].likes>1000) this.allList[e].likes = '999+'
2022-03-04 08:48:40 +00:00
// 调用收藏事件
collectionEV({action:'like',archive_id:this.allList[e].id})
2022-07-22 10:39:41 +00:00
// }
2022-03-04 08:48:40 +00:00
},
// 相关列表的点赞事件
praisexgEv(e){
2022-07-22 10:39:41 +00:00
// if(this.xgList[e].is_liked==0){
2022-03-04 08:48:40 +00:00
this.xgList[e].is_liked = 1;
this.xgList[e].likes++;
2022-07-22 10:39:41 +00:00
// if(this.xgList[e].likes>1000) this.xgList[e].likes = '999+'
2022-03-04 08:48:40 +00:00
// 调用收藏事件
collectionEV({action:'like',archive_id:this.xgList[e].id})
2022-07-22 10:39:41 +00:00
// }
2021-12-20 08:02:27 +00:00
},
tapLike() { //喜欢、不喜欢事件
2022-07-22 10:39:41 +00:00
// this.isDetailLike = !this.isDetailLike
this.isDetailLike = true;
2022-03-04 08:48:40 +00:00
if (this.isDetailLike) {
this.detailObj.likes++
this.likeCon = this.detailObj.likes
if (this.likeCon >= 1000) this.likeCon = '999+'
2021-12-20 08:02:27 +00:00
} else {
2022-03-04 08:48:40 +00:00
this.detailObj.likes--
this.likeCon = '喜欢'
2021-12-20 08:02:27 +00:00
}
2022-03-04 08:48:40 +00:00
let isLikeCon = 'like'
//调用点赞事件
2022-07-22 10:39:41 +00:00
// if (this.isDetailLike)
collectionEV({
2022-03-04 08:48:40 +00:00
action: isLikeCon,
archive_id: this.detailObj.id
})
//调用取消点赞事件
2022-07-22 10:39:41 +00:00
// else cancleCollectionEV({
// action: isLikeCon,
// archive_id: this.detailObj.id
// })
2021-08-19 06:40:59 +00:00
},
2021-12-20 08:02:27 +00:00
tapConllection() { //收藏、取消收藏事件
2021-08-19 06:40:59 +00:00
let isLikeCon = 'collect'
2022-03-04 08:48:40 +00:00
// 调用收藏事件
if (!this.isDetailConllection) collectionEV({
action: isLikeCon,
archive_id: this.detailObj.id
})
// 调用取消收藏事件
else cancleCollectionEV({
action: isLikeCon,
archive_id: this.detailObj.id
})
if(!this.isDetailConllection){
this.detailObj.collects++
} else {
this.detailObj.collects--
}
2022-03-04 08:48:40 +00:00
this.isDetailConllection = !this.isDetailConllection
2021-11-08 07:50:30 +00:00
},
2021-12-20 08:02:27 +00:00
backTop() { //回到顶部事件
uni.pageScrollTo({
scrollTop: 0,
duration: 300
});
2021-08-19 06:40:59 +00:00
},
2021-12-20 08:02:27 +00:00
backEv(){
uni.navigateBack({delta:1})
}
2021-08-19 06:40:59 +00:00
}
}
</script>
<style>
2021-12-20 08:02:27 +00:00
2021-08-19 06:40:59 +00:00
</style>