hengmei-two/pagesB/problemDetail/problemDetail.vue

803 lines
32 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;">
<view :style="{height:statusBarHeight+'px'}"></view>
<view class="status-nav">
<!-- 标题 -->
<view class="tab-title tcenter" style="color: #000000;">分类</view>
</view>
</view>
2021-08-19 06:40:59 +00:00
<!-- 列表 -->
<view :style="{top: statusHNH+'px'}" class="posiszy" style="height: 50px;">
<view class="bacf pad-zy32 pad-sx20">
2021-08-26 01:50:19 +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>
2021-08-26 09:57:04 +00:00
<view class="pad-x180" :style="{paddingTop: (statusHNH+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">
<!-- 自定义轮播 -->
<swiper-pu :browseP="true" :isplay="isAutoPlay" :bannerList="bannerList" :newHeight="'450'" :newRadius="'10'" :newBottom="'5'"></swiper-pu>
2021-08-19 06:40:59 +00:00
<!-- 标题 -->
<view class="fon36 col3 bold mar-sx20 clips2" style="line-height: 50rpx;">{{detailObj.title}}</view>
<view class="disjbac">
<view class="disac">
<!-- 发布者头像 -->
<image class="flexs" src="/static/public/logo.png" style="width: 60rpx;height: 60rpx;border-radius: 100%;" mode="aspectFill"></image>
<view class="mar-z10">
<!-- 发布者昵称 -->
<view class="fon28 col3 clips1">恒美植发</view>
<!-- 发布时间 -->
<view class="fon20 col9" style="margin-top: 6rpx;">{{detailObj.published_at}}发布</view>
</view>
</view>
<view class="disac flexs">
<view class="disac fc" @tap="tapLike" style="width: 60rpx;">
<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">{{likeCon}}</view>
</view>
<view @tap="shareEv" class="disac fc mar-zy36 posir">
<image src="/static/public/weix.png" style="width: 42rpx;height: 42rpx;" mode=""></image>
<view class="fon24 col9">分享</view>
2021-11-02 10:23:53 +00:00
<button class="posia-op" open-type="share">分享</button>
2021-08-26 09:57:04 +00:00
<!-- <button v-if="haveImg" class="posia" open-type="share" style="top: 0;right: 0;left: 0;bottom: 0;opacity: 0;"></button> -->
2021-08-19 06:40:59 +00:00
</view>
<view class="disac fc" @tap="tapConllection">
<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">收藏</view>
</view>
</view>
</view>
<!-- 内容详情 -->
<view class="fon28 mar-s20" style="color: #1A1A1A; line-height: 40rpx;">
<rich-text :nodes="detailInfo"></rich-text>
</view>
</view>
<view class="pad-zy20" v-show="cateCurrent==1">
<view class="fon30 bold tc mar-sx40" :style="{color:publicColor}">相关推荐</view>
<!-- 相关推荐列表 -->
<list-pu @chooseLike="chooseLikex" @comfirmev="comfirmevx" :list="xgList"></list-pu>
</view>
<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 class="fon24 col3">暂无推荐医生</view>
</view>
</view>
</view>
<!-- 案例日记 -->
<view v-show="cateCurrent==0 && isNum!=0" class="pad-zy20">
<view v-if="listArrone.length!=0">
<list-pu @chooseLike="chooseLike" @comfirmev="comfirmev" :list="listArrone"></list-pu>
</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 v-show="cateCurrent==1 && isNum!=1" class="pad-zy20">
<view v-if="listArrtwo.length!=0">
<list-pu @chooseLike="chooseLike" @comfirmev="comfirmev" :list="listArrtwo"></list-pu>
</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 v-show="cateCurrent==2 && isNum!=2" class="pad-zy20">
<view v-if="listArrthree.length!=0">
<list-pu @chooseLike="chooseLike" @comfirmev="comfirmev" :list="listArrthree"></list-pu>
</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 v-show="cateCurrent==3 && isNum!=3" class="pad-zy20">
<view v-if="listArrfour.length!=0">
<list-pu @chooseLike="chooseLike" @comfirmev="comfirmev" :list="listArrfour"></list-pu>
</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>
2021-11-08 07:50:30 +00:00
<block v-if="isHot">
<view v-if="dataShopList.length!=0" style="margin-top: -20rpx;">
<view class="pad20">
<view style="width: 48.6%;float: left;">
<view v-if="index1%2==0" v-for="(item1,index1) in dataShopList" :key="index1" class="bacf radius15 mar-x20 animated fadeIn posir" @tap="goPage(item1.id,index1)">
<image :src="item1.imgSrc" mode="aspectFill" style="width: 100%;border-top-left-radius: 15rpx;border-top-right-radius: 15rpx;height: 325rpx;"></image>
<view class="pad-zy20 pad-s10 pad-x30">
<view class="fon28 bold col3 clips2">{{item1.title}}</view>
<view class="disac fon20 mar-sx20" v-if="!item1.isIntegral">
<view class="radius10 colf mar-y10" style="padding: 6rpx 10rpx;" :style="{background:publicColor}">{{item1.disease_name}}</view>
<view class="radius10 colf" v-if="item1.isTuan" style="padding: 6rpx 10rpx;background: #F85050;"></view>
<view class="radius10 colf" v-if="item1.isPing" style="padding: 6rpx 10rpx;background: #F85050;"></view>
<view class="radius10 colf" v-if="item1.isXian" style="padding: 6rpx 10rpx;background: #F85050;"></view>
</view>
<view class="disac">
<view class="fon28 bold" style="color: #F85050;margin-right: 8rpx;">
<view v-if="item1.isIntegral" class="mar-s20">
<view>积分:{{item1.integral}}</view>
<view class="disac mar-s20" v-if="item1.grade!=0">
<image src="/static/public/huiy.png" style="width: 40rpx;height: 33rpx;" mode=""></image>
<view class="fon24 col3 mar-z10">{{item1.level_text}}</view>
</view>
</view>
<view v-else>
<span v-if="item1.isPing"></span>
<span v-if="item1.isXian"></span>
{{item1.zhePrice}}
</view>
</view>
<view v-if="item1.isXian || item1.isPing || item1.isTuan" class="fon24" style="text-decoration: line-through;color: #C7C7C7;">{{item1.yuanPrice}}</view>
</view>
<view v-if="item1.isPing" class="disjbac mar-s20">
<view class="fon24 col80">已拼团{{item1.activity_group_num}}</view>
<view class="disac">
<image v-for="(itemm,indexm) in item1.activity_group_cover" :key="indexm" :src="itemm" mode="" style="width: 40rpx;height: 40rpx;border-radius: 100%;margin-left: -20rpx;"></image>
</view>
</view>
<view v-if="item1.isXian || item1.isPing || item1.isTuan" class="fon24 col80 mar-s20">{{item1.activity_end_at}}</view>
</view>
</view>
</view>
<view style="width: 48.6%;float: right;">
<view v-if="index1%2!=0" v-for="(item1,index1) in dataShopList" :key="index1" class="bacf radius15 mar-x20 animated fadeIn posir" @tap="goPage(item1.id,index1)">
<image :src="item1.imgSrc" mode="aspectFill" style="width: 100%;border-top-left-radius: 15rpx;border-top-right-radius: 15rpx;height: 325rpx;"></image>
<view class="pad-zy20 pad-s10 pad-x30">
<view class="fon28 bold col3 clips2">{{item1.title}}</view>
<view class="disac fon20 mar-sx20" v-if="!item1.isIntegral">
<view class="radius10 colf mar-y10" style="padding: 6rpx 10rpx;" :style="{background:publicColor}">{{item1.disease_name}}</view>
<view class="radius10 colf" v-if="item1.isTuan" style="padding: 6rpx 10rpx;background: #F85050;"></view>
<view class="radius10 colf" v-if="item1.isPing" style="padding: 6rpx 10rpx;background: #F85050;"></view>
<view class="radius10 colf" v-if="item1.isXian" style="padding: 6rpx 10rpx;background: #F85050;"></view>
</view>
<view class="disac">
<view class="fon28 bold" style="color: #F85050;margin-right: 8rpx;">
<view v-if="item1.isIntegral" class="mar-s20">
<view>积分:{{item1.integral}}</view>
<view class="disac mar-s20" v-if="item1.grade!=0">
<image src="/static/public/huiy.png" style="width: 40rpx;height: 33rpx;" mode=""></image>
<view class="fon24 col3 mar-z10">{{item1.level_text}}</view>
</view>
</view>
<view v-else>
<span v-if="item1.isPing"></span>
<span v-if="item1.isXian"></span>
{{item1.zhePrice}}
</view>
</view>
<view v-if="item1.isTuan || item1.isPing || item1.isXian" class="fon24" style="text-decoration: line-through;color: #C7C7C7;">{{item1.yuanPrice}}</view>
</view>
<view v-if="item1.isPing" class="disjbac mar-s20">
<view class="fon24 col80">已拼团{{item1.activity_group_num}}</view>
<view class="disac">
<image v-for="(itemm,indexm) in item1.activity_group_cover" :key="indexm" :src="itemm" mode="" style="width: 40rpx;height: 40rpx;border-radius: 100%;margin-left: -20rpx;"></image>
</view>
</view>
<view v-if="item1.isXian || item1.isPing || item1.isTuan" class="fon24 col80 mar-s20">{{item1.activity_end_at}}</view>
</view>
</view>
</view>
</view>
</view>
<!-- <nothing-page v-if="dataShopList.length==0" :content="`暂无更多商品列表`"></nothing-page> -->
</block>
2021-08-19 06:40:59 +00:00
</view>
2021-08-26 09:57:04 +00:00
<view class="posixzy disjbac bacf pad-zy32 btnBKS">
2021-08-19 06:40:59 +00:00
<view class="posir">
2021-08-26 09:57:04 +00:00
<image @tap="backHome" class="posia backH" src="/static/public/back-home.png" mode="aspectFill"></image>
2021-08-19 06:40:59 +00:00
</view>
<view class="disac fon26 colf">
2021-08-26 09:57:04 +00:00
<view @tap="lianK" class="disac posir lianShare" style="background-color: #3875F6; border-top-left-radius: 51rpx;border-bottom-left-radius: 51rpx;">
2021-08-19 06:40:59 +00:00
<image src="/static/public/bottom-customer.png" class="mar-zy20" style="width: 47rpx;height: 47rpx;" mode="aspectFill"></image>
<view>联系客服</view>
<button v-if="haveImg" class="fon24 posia" style="opacity: 0;top: 0;left: 0;right: 0;bottom: 0;" open-type="contact"></button>
</view>
2021-08-26 09:57:04 +00:00
<view @tap="shareEv" class="disac posir lianShare" style="background-color: #38CE51;border-top-right-radius: 51rpx;border-bottom-right-radius: 51rpx;">
2021-08-19 06:40:59 +00:00
<image src="/static/public/bottom-shear.png" style="width: 47rpx;height: 47rpx;margin-left: 15rpx;margin-right: 8rpx;" mode="aspectFill"></image>
<view>分享给好友</view>
2021-11-02 10:23:53 +00:00
<button v-if="haveImg" class="posia-op" open-type="share"></button>
2021-08-19 06:40:59 +00:00
</view>
</view>
</view>
<!-- 返回顶部 -->
<!-- <back-top :showTop="showTop" @backTop="backTop"></back-top> -->
<!-- 弹框授权 -->
<empower @buttonH="buttonH" :vision="vision" :isWhere="2" @cancleEv="cancleEv"></empower>
2021-08-27 03:04:06 +00:00
<!-- 弹框 -->
<view v-if="isShowP" @touchmove.stop.prevent="moveHandle" class="disjcac posAll">
<view class="bacf radius20 width100 tank-box">
<view class="tc tank-box-itemone">请授权绑定手机号</view>
<view class="fon28 colf pad-x30 pad-zy30 tc disjb">
<view @tap="isShowP=false" class="pad-sx10 radius10 tank-btn" style="background-color: rgba(230, 230, 230,1);color: #000000;">暂不绑定</view>
<view class="pad-sx10 radius10 tank-btn posir pbackc">
立即绑定
<button open-type="getPhoneNumber" @getphonenumber="getphonenumber" class="posia syxzo">立即绑定</button>
</view>
</view>
</view>
</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';
import {collectionEV,cancleCollectionEV} from '@/jsFile/publicAPI.js';
import empower from '@/components/empower.vue';
export default {
components:{
listDoctor,
swiperPu,
empower
},
data() {
return {
2021-08-26 01:50:19 +00:00
statusBarHeight:uni.getSystemInfoSync().statusBarHeight,
2021-08-19 06:40:59 +00:00
isLoading:false,
vision:false,
statusHNH:uni.getStorageSync('statusHNH'),
2021-08-26 01:50:19 +00:00
publicColor:uni.getStorageSync('publicColor') || '#3875F6',//主题颜色
2021-08-19 06:40:59 +00:00
cateCurrent:0,
haveImg:true,
cateList:[],
bannerList:[],//轮播
xgList:[//相关推荐
],
dataList:[//推荐医生
],
showTop:false,
isDetailLike:false,//是否喜欢
likeCon:'点赞',
isDetailConllection:false,//是否已收藏
isNum:0,
listArrone:[],//问题
listArrtwo:[//案例日记
],
listArrthree:[//效果模拟
],
listArrfour:[//科普视频
],
detailObj:{},//详情
detailInfo:'',//富文本
category_id:'',//栏目ID
active:'',//是否是详情页
2021-08-26 09:57:04 +00:00
// jieDuan:false,
2021-08-26 01:50:19 +00:00
share_id:0,
2021-08-27 03:04:06 +00:00
invite_code:'',
2021-11-08 07:50:30 +00:00
isShowP:false,
zanArr:[],
dataShopList:[],
timeList:[],
isHot:false,
isAutoPlay:false
2021-08-19 06:40:59 +00:00
}
},
onPageScroll(e) {
e.scrollTop > 360 ? this.showTop = true : this.showTop = false
},
onReachBottom() {//触底事件
// for (let i = 0; i < 4; i++) {
// if(this.cateCurrent==0) {
// let obj = {status:false,main_img:'',title:'恒美小课堂',content:'饺子会吃肉?',head_img:'/static/public/like.png',name:'吃肉的饺子',isCate:0}
// this.listArrone.push(obj)
// }
// if(this.cateCurrent==1) {
// let obj = {status:false,main_img:'',title:'恒美小课堂',content:'饺子会吃肉?',head_img:'/static/public/like.png',name:'吃肉的饺子',isCate:1}
// this.listArrtwo.push(obj)
// }
// if(this.cateCurrent==2) {
// let obj = {status:false,main_img:'',title:'恒美小课堂',content:'饺子会吃肉?',head_img:'/static/public/like.png',name:'吃肉的饺子',isCate:2}
// this.listArrthree.push(obj)
// }
// if(this.cateCurrent==3) {
// let obj = {status:false,main_img:'',title:'恒美小课堂',content:'饺子会吃肉?',head_img:'/static/public/like.png',name:'吃肉的饺子',isCate:3}
// this.listArrfour.push(obj)
// }
// }
},
2021-08-26 01:50:19 +00:00
onShareTimeline() {},
onShareAppMessage(res) {
2021-08-19 06:40:59 +00:00
var ya = this;
2021-08-26 01:50:19 +00:00
this.$requst.post('user/record',{type:'content',action:'share',id:this.detailObj.id}).then(res=>{console.log('分享成功:',res);},error=>{})
let maiOjb = {
e:4,//内容分享
c:this.detailObj.id*1,
t:new Date().getTime()//当前时间戳
}
this.$toolAll.tools.maiDian(maiOjb)
2021-08-19 06:40:59 +00:00
var shareObj = {
2021-08-26 01:50:19 +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')}`, // 默认是当前页面,必须是以‘/’开头的完整路径
2021-08-29 01:36:29 +00:00
     imageUrl: ya.$http + ya.detailObj.share_img//自定义图片路径可以是本地文件路径、代码包文件路径或者网络图片路径支持PNG及JPG不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
2021-08-26 01:50:19 +00:00
  };
2021-08-19 06:40:59 +00:00
  return shareObj;
},
2021-08-22 08:53:12 +00:00
onShow() {
this.isAutoPlay = true;
},
onUnload() {
this.isAutoPlay = false;
},
onHide() {
this.isAutoPlay = false;
2021-08-22 08:53:12 +00:00
},
2021-08-19 06:40:59 +00:00
onLoad(options) {
if(options.category_id!=undefined) {
this.category_id = options.category_id
this.conid = options.id
2021-08-26 01:50:19 +00:00
this.invite_code = options.invite_code
uni.setStorageSync('ninvite_code',this.invite_code)
if(this.invite_code!='' && this.invite_code!=undefined){
uni.login({
provider: 'weixin',
success: (res)=> {
if (res.code) {
var params = {
code:res.code,
invite_code:this.invite_code,//用户邀请码
}
2021-08-26 09:57:04 +00:00
this.$requst.post('user/login',params).then(res => {
if(res.data.token!=''){
if(res.data.is_active==0) {
this.haveImg = false
this.vision = true
}
}
},error => {})
2021-08-26 01:50:19 +00:00
}
},
});
} else {
this.$toolAll.tools.overdue()
this.$toolAll.tools.isLogin()
}
2021-08-19 06:40:59 +00:00
}
2021-08-26 01:50:19 +00:00
this.checkDetail(this.conid)
if(options.share_id!=undefined) this.share_id = options.share_id
2021-09-14 09:53:16 +00:00
let maiOjb = {
e:4,//内容分享
c:this.conid*1,
t:new Date().getTime()//当前时间戳
}
this.$toolAll.tools.maiDian(maiOjb)
2021-08-19 06:40:59 +00:00
},
methods: {
2021-08-27 03:04:06 +00:00
moveHandle(){//禁止底层滑动
return false
},
getphonenumber(e){//授权绑定手机号
if(e.detail.errMsg=="getPhoneNumber:ok"){
this.$requst.post('user/bind-phone',{iv:e.detail.iv,encryptedData:e.detail.encryptedData}).then(res=>{
// console.log('手机号信息:',res);
if(res.code==0){
this.isShowP = false
this.$toolAll.tools.showToast('手机号绑定成功','success')
}
},error=>{})
} else {
this.isShowP = false
}
},
2021-08-19 06:40:59 +00:00
chooseLike(e){//收藏事件
// console.log(this.dataList[e].is_collected);
let cateId = ''
let newArr = []
if(this.cateCurrent==0) {
newArr = this.listArrone
cateId = newArr[e].id
}
if(this.cateCurrent==1) {
newArr = this.listArrtwo
cateId = newArr[e].id
}
if(this.cateCurrent==2) {
newArr = this.listArrthree
cateId = newArr[e].id
}
if(this.cateCurrent==3) {
newArr = this.listArrfour
cateId = newArr[e].id
}
if(newArr[e].is_collected==0){
newArr[e].is_collected = 1
// 调用收藏事件
collectionEV({action:'collect',archive_id:cateId})
}
},
comfirmev(e){//确认取消收藏事件
let cateId = ''
if(this.cateCurrent==0) {
this.listArrone[e].is_collected = 0
cateId = this.listArrone[e].id
}
if(this.cateCurrent==1) {
this.listArrtwo[e].is_collected = 0
cateId = this.listArrtwo[e].id
}
if(this.cateCurrent==2) {
this.listArrthree[e].is_collected = 0
cateId = this.listArrthree[e].id
}
if(this.cateCurrent==3) {
this.listArrfour[e].is_collected = 0
cateId = this.listArrfour[e].id
}
this.$toolAll.tools.showToast('正在取消...','loading')
// 调用取消收藏事件
cancleCollectionEV({action:'collect',archive_id:cateId})
},
chooseLikex(e){//收藏事件
if(this.xgList[e].is_collected==0){
this.xgList[e].is_collected = 1
// 调用收藏事件
collectionEV({action:'collect',archive_id:this.xgList[e].id})
}
},
comfirmevx(e){//确认取消收藏事件
this.xgList[e].is_collected = 0
this.$toolAll.tools.showToast('正在取消...','loading')
// 调用取消收藏事件
cancleCollectionEV({action:'collect',archive_id:this.xgList[e].id})
},
2021-08-27 03:04:06 +00:00
buttonH(e){//授权成功
this.haveImg = e
if(e) {
this.vision = false
this.isShowP = true
}
},
cancleEv(e){//取消授权
2021-08-19 06:40:59 +00:00
if(e==0) this.vision = false
},
backHome(){
uni.navigateTo({
url:'/pages/tabbar/pagehome/pagehome'
})
},
2021-08-22 08:53:12 +00:00
lianK(){//客服
2021-08-26 09:57:04 +00:00
// if(!this.jieDuan){
// let isAuth = this.$toolAll.tools.returnAuth()
// if(!isAuth){
if(this.haveImg == false) {
this.vision = true
} else {
2021-11-02 10:23:53 +00:00
this.$requst.post('user/rand-bind-service').then(res=>{})
2021-08-22 08:53:12 +00:00
this.$toolAll.tools.closeTimer()//清空埋点倒计时
this.$requst.post('user/record',{type:'other',action:'ask',id:0}).then(res=>{},error=>{})
let maiOjb = {
e:5,//内容咨询
t:new Date().getTime()//当前时间戳
}
this.$toolAll.tools.maiDian(maiOjb)
2021-08-26 09:57:04 +00:00
}
// } else this.jieDuan = true
// }
},
shareEv(){
if(this.haveImg == false) {
this.vision = true
2021-08-19 06:40:59 +00:00
}
},
checkDetail(newId){
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);
if(res.code==0){
this.isLoading=true
// 栏目类别
if(res.data.category.length!=0){
res.data.category.forEach((item,index)=>{
let cateObj = {
id:item.id,//栏目ID
title:item.title,//栏目名称
active:item.active,//是否选中
model_id:item.model_id,//模型ID
model_name:item.model_name,//模型标识
sort:item.sort
}
this.cateList.push(cateObj)
// 默认选中的栏目
if(item.active==1) this.active = this.cateCurrent = index
// 默认展示栏目详情
if(this.category_id==item.id) this.isNum = index
})
2021-11-08 07:50:30 +00:00
this.cateList.push({title:'热门商品'})
2021-08-19 06:40:59 +00:00
}
2021-08-26 01:50:19 +00:00
if(this.invite_code!='' && this.invite_code!=undefined){
const query = wx.createSelectorQuery()
query.select('.statusHNH').boundingClientRect((rect) => {
// console.log('状态栏+标题栏:',rect);
this.statusHNH = rect.height
// console.log(this.statusHNH );
}).exec()
}
2021-08-19 06:40:59 +00:00
// 详情
this.detailObj = res.data.detail
2021-08-26 01:50:19 +00:00
let maiOjb = {
e:1,//内容访问
c:this.detailObj.id*1,
t:new Date().getTime()//当前时间戳
}
this.$toolAll.tools.maiDian(maiOjb)
2021-08-19 06:40:59 +00:00
if(this.detailObj.is_liked==1) {
if(this.detailObj.likes >= 1000) this.likeCon = '999+'
else this.likeCon = this.detailObj.likes
}
// 轮播
// 图片字符串转数组
let arrImg = this.detailObj.images.split(',')
arrImg.forEach(item=>{
let newImgObj = {
imgSrc:this.$http + item,
url:'',
isVideo:false,
poster:'',
}
// 存图片
this.bannerList.push(newImgObj)
})
2021-08-22 08:53:12 +00:00
// 存视频
if(this.detailObj.video!=''){
this.bannerList[0] = {
2021-08-26 01:50:19 +00:00
imgSrc:this.$http + arrImg[0],
2021-08-22 08:53:12 +00:00
url:this.$http + this.detailObj.video,
isVideo:true,
poster:'',
}
}
2021-08-19 06:40:59 +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
// 富文本
this.detailInfo = this.$toolAll.tools.escape2Html(this.detailObj.content)
// 相关推荐xgList
if(res.data.diary.length!=0){
res.data.diary.forEach(item=>{
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:'/static/public/logo.png',//发布者头像
name:'恒美植发',//发布者昵称
2021-08-26 01:50:19 +00:00
isVideo:item.video.includes(".mp4")//是否是视频
2021-08-19 06:40:59 +00:00
}
if(item.cover!='' && item.video==''){
this.xgList.push(tObj)
}
})
}
// 推荐医生
if(res.data.doctor.length!=0){
res.data.doctor.forEach(item=>{
let doObj = {
id:item.id,
2021-08-26 01:50:19 +00:00
imgSrc: item.headimg!=null ? item.headimg : '',
2021-08-19 06:40:59 +00:00
name:item.name,
2021-08-27 03:04:06 +00:00
cyear:parseFloat(item.work_time),
2021-08-19 06:40:59 +00:00
bmen:item.dept_name,
zcheng:'主任医师',
goodAt:item.diseases,
show_detail:item.show_detail
}
this.dataList.push(doObj)
})
}
2021-08-26 01:50:19 +00:00
this.choosecateEv(this.cateCurrent)
2021-08-19 06:40:59 +00:00
}
},error=>{})
},
choosecateEv(e){
this.cateCurrent = e
2021-11-08 07:50:30 +00:00
this.isHot = false;
if(this.cateList[e].title=='热门商品'){
this.checkSotList();
} else {
this.$requst.post('archives/category',{category_id:this.cateList[e].id,keyword:''}).then(res=>{
// console.log('该分类下的列表:',res);
if(res.code==0){
if(e==0 && this.active!=e) this.listArrone = []
if(e==1 && this.active!=e) this.listArrtwo = []
if(e==2 && this.active!=e) this.listArrthree = []
if(e==3 && this.active!=e) this.listArrfour = []
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
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,//副标题
head_img:'/static/public/logo.png',//发布者头像
name:'恒美植发',//发布者昵称
isVideo:isVideo//是否是视频
}
if(item.cover!=''){
if(e==0 && this.active!=e) this.listArrone.push(arrObj)
if(e==1 && this.active!=e) this.listArrtwo.push(arrObj)
if(e==2 && this.active!=e) this.listArrthree.push(arrObj)
if(e==3 && this.active!=e) this.listArrfour.push(arrObj)
}
})
}
2021-08-19 06:40:59 +00:00
}
2021-11-08 07:50:30 +00:00
},error=>{})
}
2021-08-19 06:40:59 +00:00
},
tapLike(){//喜欢、不喜欢事件
2021-08-26 09:57:04 +00:00
// if(!this.jieDuan){
// let isAuth = this.$toolAll.tools.returnAuth()
// if(!isAuth){
2021-08-22 08:53:12 +00:00
this.isDetailLike = !this.isDetailLike
if(this.isDetailLike){
this.detailObj.likes++
this.likeCon = this.detailObj.likes
if(this.likeCon >= 1000) this.likeCon = '999+'
}else{
this.detailObj.likes--
this.likeCon = '喜欢'
}
let isLikeCon = 'like'
//调用点赞事件
if(this.isDetailLike) collectionEV({action:isLikeCon,archive_id:this.detailObj.id})
//调用取消点赞事件
else cancleCollectionEV({action:isLikeCon,archive_id:this.detailObj.id})
2021-08-26 09:57:04 +00:00
// } else this.jieDuan = true
// }
2021-08-19 06:40:59 +00:00
},
tapConllection(){//收藏、取消收藏事件
let isLikeCon = 'collect'
2021-08-26 09:57:04 +00:00
// if(!this.jieDuan){
// let isAuth = this.$toolAll.tools.returnAuth()
// if(!isAuth){
2021-08-22 08:53:12 +00:00
// 调用收藏事件
if(!this.isDetailConllection) collectionEV({action:isLikeCon,archive_id:this.detailObj.id})
// 调用取消收藏事件
else cancleCollectionEV({action:isLikeCon,archive_id:this.detailObj.id})
this.isDetailConllection = !this.isDetailConllection
2021-08-26 09:57:04 +00:00
// } else this.jieDuan = true
// }
2021-08-19 06:40:59 +00:00
},
2021-11-08 07:50:30 +00:00
checkSotList(){//查询热门商品
this.isHot = true;
let params = {
page:1,
size:2000,
is_hot:1
}
uni.request({
url:'https://hengmei.scdxtc.cn/api/spu/list',
data:params,
method:'post',
header:{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer '+uni.getStorageSync('token') || ''
},
success: (res) => {
if(res.data.code==0){
clearInterval(this.timer);
// if(this.page==1) {
this.zanArr = [];
this.dataShopList = [];
this.timeList = [];
// }
this.total = res.data.total;
if(res.data.data.list.length!=0){
res.data.data.list.forEach(item=>{
let tuan = false,ping = false,xian = false,integral = false;
if(item.activity_type=='group_make') ping = true;
if(item.activity_type=='group_buy') tuan = true;
if(item.activity_type=='limit_time') xian = true;
let group_cover = [];
if(item.activity_group_cover.length!=0) {
item.activity_group_cover.forEach(item=>{
group_cover.push(this.$http + item)
})
}
let obj = {
id:item.id,
imgSrc: this.$http + item.cover,
title: item.name,
zhePrice:item.price/100,
yuanPrice:item.original_price/100,
integral:'',
isTuan:tuan,//是否是团购
isPing:ping,//是否是拼团活动
isXian:xian,//是否是限时活动
isIntegral:integral,//是否是积分
grade:'',
disease_name:item.disease_name,//病种名称
reponseTime:res.header.Date,//接口响应时间
activity_end_at:item.activity_end_at,//限时结束时间
activity_group_cover:group_cover,//参团人的头像
activity_group_num:item.activity_group_num,//已经参团人数
}
this.zanArr.push(obj)
})
this.zanArr.forEach((item,index)=>{
if(item.activity_end_at!='') {
let obj = {
id:item.id,
reponseTime:item.reponseTime,
time:item.activity_end_at,
nIndex:index
}
this.timeList.push(obj);
}
})
if(this.timeList!=0){
this.$toolAll.tools.showToast('加载中...')
this.timer = setInterval(()=>{//定时器
if(this.timeList.length!=0){
this.timeList.forEach((item,index)=>{
if(item.id==this.zanArr[item.nIndex].id){
let endTime = new Date(this.timeList[index].time).getTime();//把结束时间转时间戳
this.timeList[index].reponseTime = new Date(this.timeList[index].reponseTime).getTime() + 1000;//请求接口的时间递增,即:开始时间
if(this.timeList[index].reponseTime - endTime >=0) {//如果开始时间的时间戳 - 结束时间的时间戳 >= 0 活动结束
this.zanArr[item.nIndex].activity_end_at = "活动已结束";
} else {
// 继续进行倒计时
this.zanArr[item.nIndex].activity_end_at = this.$toolAll.tools.dayTime(this.timeList[index].time,this.timeList[index].reponseTime);
}
}
})
}
},1000)
setTimeout(()=>{
this.dataShopList = this.zanArr;
},1000)
} else {
this.dataShopList = this.zanArr;
}
}
}
}
})
},
goPage(id,index){//进入商品详情事件
uni.navigateTo({
url:`/pagesB/shopDetail/shopDetail?id=${id}&isIntegral=${this.dataShopList[index].isIntegral}`
})
},
2021-08-19 06:40:59 +00:00
backTop(){//回到顶部事件
uni.pageScrollTo({
scrollTop: 0,
duration: 300
});
},
}
}
</script>
<style>
</style>