hengmei-two/pagesB/shopDetail/shopDetail.vue

944 lines
36 KiB
Vue
Raw Normal View History

2021-10-11 10:21:06 +00:00
<template>
<view>
<!-- 状态栏 -->
<status-nav v-if="invite_code==''" :titleVal="'商品详情'" :statusTitle="true"></status-nav>
<!-- 列表 -->
2021-10-22 03:07:32 +00:00
<view :style="{top: statusHNH+'px'}" v-if="isNei!=3" class="posiszy" style="height: 50px;">
2021-10-11 10:21:06 +00:00
<view class="bacf pad-zy32 pad-sx20">
<cate-pu @choosecateEv="choosecateEv" :activeb="invite_code!=''?'#3875F6':publicColor" :newCurrent="cateCurrent*1" :newbmo="'#F2F2F2'" :isCenter="false" :newcateList="cateList"></cate-pu>
</view>
</view>
2021-10-22 03:07:32 +00:00
<view :style="{top: statusHNH+'px'}" v-else class="posiszy" style="height: 50px;"></view>
<view class="pad-x180" :style="{paddingTop: isNei!=3?(statusHNH+60)+'px':statusHNH+'px'}">
2021-10-11 10:21:06 +00:00
<!-- 自定义轮播 -->
<view v-if="isLoading">
<swiper-pu v-if="cateCurrent==0" :isplay="isAutoPlay" :browseP="true" :bannerList="bannerList" :newHeight="'450'" :newRadius="'0'" :newBottom="'5'"></swiper-pu>
2021-11-02 10:23:53 +00:00
<!-- <view v-if="isNei==3" class="score-box">{{detailObj.score}}</view> -->
2021-10-11 10:21:06 +00:00
<view v-show="cateCurrent==isNum">
<view class="pad20 bacf mar-zy20 radius20 mar-s20">
<!-- 标题 -->
2021-10-22 03:07:32 +00:00
<view class="mar-x20 fon36 col3 bold clips3 shop-title-box line-h50">
<view style="margin-top: -8rpx;margin-right: 10rpx;">
<span v-if="isNei!=3" class="radius15 colf fon20" :style="{background:publicColor}">{{detailObj.disease_name}}</span>
<span v-if="isNei==0" class="radius15 colf fon20 mar-z10"></span>
<span v-if="isNei==1" class="radius15 colf fon20 mar-z10"></span>
<span v-if="isNei==2" class="radius15 colf fon20 mar-z10"></span>
</view>
<span>{{detailObj.name}}</span>
2021-10-11 10:21:06 +00:00
</view>
2021-10-22 03:07:32 +00:00
<view class="fon24 col7D">无任何额外消费</view>
2021-10-11 10:21:06 +00:00
<!-- 团购商品详情时显示 -->
2021-10-22 03:07:32 +00:00
<view v-if="isNei==0" class="disjbac fon24 mar-s20 col7D">
2021-11-16 09:48:58 +00:00
<view>团购累计参与人员{{detailObj.activity_order_num}}</view>
<view>还剩余{{detailObj.group_surplus_num}}</view>
2021-10-11 10:21:06 +00:00
</view>
2021-10-22 03:07:32 +00:00
<view class="mar-s20 shop-price" v-if="isNei!=3"><span v-if="isNei==0">:</span><span v-if="isNei==1">:</span>{{detailObj.price/100}} <span v-if="isNei!=10">{{detailObj.original_price/100}}</span></view>
<view class="mar-s20 shop-price" v-else>{{detailObj.score}}</view>
<view class="disjbac shar-box" style="align-items: flex-end;">
<view>
<view class="disac" v-if="detailObj.level_text!=''">
<image class="flexs" src="/static/public/huiy.png" mode="aspectFill"></image>
<view class="fon24 col9">{{detailObj.level_text}}</view>
</view>
2021-11-02 10:23:53 +00:00
<view v-else class="fon24 col9">全部人员可买</view>
2021-10-11 10:21:06 +00:00
</view>
<view class="disac flexs">
<view @tap="shareEv" class="disac fc mar-zy36 posir">
2021-10-22 03:07:32 +00:00
<image src="/static/public/weix.png" class="wh42" mode=""></image>
2021-10-11 10:21:06 +00:00
<view class="fon24 col9">分享</view>
2021-10-22 03:07:32 +00:00
<button class="posia-op" open-type="share">分享</button>
2021-10-11 10:21:06 +00:00
</view>
<view class="disac fc" @tap="tapConllection">
2021-10-22 03:07:32 +00:00
<image v-if="isDetailConllection" src="/static/public/yconllection.png" class="wh44" mode=""></image>
<image v-else src="/static/public/conllection.png" class="wh44" mode=""></image>
2021-10-11 10:21:06 +00:00
<view class="fon24 col9">收藏</view>
</view>
</view>
</view>
2021-11-02 10:23:53 +00:00
<view class="pad-x30 pad-s10 borbot" v-if="isNei==0 || isNei==1 ||isNei==2">
<view class="fon36 colf bold pbackc tc pad-sx20 radius45" v-if="daoTime!='活动已结束'">{{daoTime}}</view>
<view class="fon36 colf bold pbackc tc pad-sx20 radius45" v-else>{{daoTime}}</view>
2021-10-11 10:21:06 +00:00
</view>
<!-- 规格 -->
2021-11-02 10:23:53 +00:00
<view class="dis tc mar-s20 fon28">
<view class="col3 flexs" style="margin-top: 6rpx;">类型</view>
<view class="width100 disac fw" style="justify-content: flex-end;">
<view class="col6 mar-z30 mar-x20 molei" style="background: #F2F2F2;" v-for="(item,index) in skuCate" :key="index">{{item.title}}</view>
</view>
<!-- <view>
2021-10-11 10:21:06 +00:00
<view class="fon26 col3 mar-x20">上市时间</view>
2021-11-02 10:23:53 +00:00
<view class="fon24 colB3">{{detailObj.param_maket_time||'今年'}}</view>
2021-10-11 10:21:06 +00:00
</view>
<view>
<view class="fon26 col3 mar-x20">有效期</view>
2021-11-02 10:23:53 +00:00
<view class="fon24 colB3">{{detailObj.param_validity_time||'永久'}}</view>
2021-10-11 10:21:06 +00:00
</view>
<view>
<view class="fon26 col3 mar-x20">可用时间</view>
2021-11-02 10:23:53 +00:00
<view class="fon24 colB3">{{detailObj.param_use_time||'长期'}}</view>
2021-10-11 10:21:06 +00:00
</view>
<view>
<view class="fon26 col3 mar-x20">术前须知</view>
2021-11-02 10:23:53 +00:00
<view class="fon24 colB3">{{detailObj.param_notice||'无'}}</view>
</view> -->
2021-10-11 10:21:06 +00:00
</view>
</view>
<!-- 销量库存 -->
<view class="pad20 bacf mar-zy20 radius20 mar-s20">
<view class="fon28 disjbac">
<view class="col3">销量</view>
2021-10-22 03:07:32 +00:00
<view class="colB3">已售{{detailObj.amount}}</view>
2021-10-11 10:21:06 +00:00
</view>
<view class="fon28 disjbac mar-s40">
<view class="col3">库存</view>
2021-10-22 03:07:32 +00:00
<view class="colB3">剩余{{detailObj.stock}}</view>
2021-10-11 10:21:06 +00:00
</view>
</view>
<!-- 拼团 -->
2021-11-02 10:23:53 +00:00
<view v-if="isNei==1 && len!=0" class="pad20 bacf mar-zy20 radius20 mar-s20">
2021-10-22 03:07:32 +00:00
<view class="fon28 col3">{{len}}人正在拼团可以直接参与</view>
2021-11-02 10:23:53 +00:00
<swiper :autoplay="true" :interval="3000" :duration="1000" circular="true" class="shop-swiper" :style="{height: (len==1 && pingArr[0].length==1)?'110rpx':'280rpx'}" vertical="true">
<swiper-item v-if="pingArr[index].length!=0" v-for="(item,index) in pingArr" :key="index">
2021-10-22 03:07:32 +00:00
<view class="disjbac posir pad-x20" v-for="(itemt,indext) in item" :key="indext">
<image :src="itemt.imgSrc" mode="aspectFill" class="flexs big-img"></image>
2021-10-11 10:21:06 +00:00
<view class="disjbac width100 mar-z20 pad-sx20">
2021-10-22 03:07:32 +00:00
<view class="fon28 col3 width45">{{itemt.name}}</view>
<view class="fon28 disjbac width100 col7D">
<view class="flexs">
2021-11-02 10:23:53 +00:00
<view>还差{{itemt.num}}人拼成</view>
2021-10-22 03:07:32 +00:00
<view style="margin-top: 7rpx;">{{itemt.time_text}}</view>
2021-10-11 10:21:06 +00:00
</view>
2021-10-22 03:07:32 +00:00
<view @tap="comeTuan(itemt.id,index,indext)" class="colf bold flexs">去拼单</view>
2021-10-11 10:21:06 +00:00
</view>
</view>
2021-10-22 03:07:32 +00:00
<!-- 短线 -->
<view class="duan-xian"></view>
2021-10-11 10:21:06 +00:00
</view>
</swiper-item>
</swiper>
</view>
2021-11-04 07:41:53 +00:00
<!-- 去拼单弹框 -->
<!-- <view v-if="showPD" class="pd-tk-box" @tap.stop="showPD=false"> -->
<view v-if="showPD" class="pd-tk-box">
<view class="bacf radius20 width100 posir">
<view class="fon28 col3">参与{{pinInfo.name}}的拼单</view>
<view class="fon24 col3">仅剩{{pinInfo.num}}个名额{{pinDao}}后结束</view>
<view class="disjcac">
<image :src="pinInfo.imgSrc" mode="aspectFill"></image>
<image src="/static/public/pin-jie.png" mode=""></image>
<image src="/static/public/weiz.png" mode=""></image>
</view>
<view @tap="atOnceSpellOrder(1)"></view>
<image @tap="atOnceSpellOrder(0)" src="/static/public/pin-close.png" class="posia" mode=""></image>
</view>
</view>
2021-10-11 10:21:06 +00:00
<!-- 详情 -->
<view class="pad20 bacf mar-zy20 radius20 mar-s20">
<view class="fon28 col3 bold">产品详情</view>
<view class="fon28 mar-s20" style="color: #1A1A1A; line-height: 40rpx;">
<rich-text :nodes="detailInfo"></rich-text>
</view>
</view>
<!-- 医生 -->
2021-11-02 10:23:53 +00:00
<view v-if="doctorList.length!=0" class="pad20 bacf mar-zy20 radius20 mar-s20">
2021-10-11 10:21:06 +00:00
<view class="fon28 col3 bold">医生</view>
2021-11-02 10:23:53 +00:00
<view @tap="goDoctor(item.id)" v-for="(item,index) in doctorList" :key="index" class="disjbac posir pad-sx20">
<image :src="item.imgSrc" mode="aspectFill" class="flexs big-img"></image>
2021-10-11 10:21:06 +00:00
<view class="disjbac width100 mar-z20 pad-sx20">
2021-11-02 10:23:53 +00:00
<view class="fon28 col3 width50">{{item.name}}</view>
<view class="fon24 width50 col7D">擅长{{item.goodAt}}</view>
2021-10-11 10:21:06 +00:00
</view>
2021-11-02 10:23:53 +00:00
<view v-if="(doctorList.length-1)!=index" class="duan-xian"></view>
2021-10-11 10:21:06 +00:00
</view>
</view>
<!-- 产品推荐 -->
2021-11-02 10:23:53 +00:00
<view v-if="dataList.length!=0" class="fon30 bold mar-s40 mar-x10 pad-zy50 pcol"></view>
2021-10-22 03:07:32 +00:00
<shopList :dataList="dataList" v-if="dataList.length!=0"></shopList>
2021-10-11 10:21:06 +00:00
</view>
2021-11-02 10:23:53 +00:00
<!-- 案例日记 -->
<view v-show="cateCurrent==1" class="pad-zy20">
<view v-if="listArrone.length!=0">
<list-pu @chooseLike="chooseLike" @comfirmev="comfirmev" :list="listArrone"></list-pu>
2021-11-08 07:50:30 +00:00
<view class="fon24 col3 tc">暂无更多内容</view>
2021-11-02 10:23:53 +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 v-show="cateCurrent==2" class="pad-zy20">
<view v-if="listArrtwo.length!=0">
<list-pu @chooseLike="chooseLike" @comfirmev="comfirmev" :list="listArrtwo"></list-pu>
2021-11-08 07:50:30 +00:00
<view class="fon24 col3 tc">暂无更多内容</view>
2021-11-02 10:23:53 +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 v-show="cateCurrent==3" class="pad-zy20">
<view v-if="listArrthree.length!=0">
<list-pu @chooseLike="chooseLike" @comfirmev="comfirmev" :list="listArrthree"></list-pu>
2021-11-08 07:50:30 +00:00
<view class="fon24 col3 tc">暂无更多内容</view>
2021-11-02 10:23:53 +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 v-show="cateCurrent==4" class="pad-zy20">
<view v-if="listArrfour.length!=0">
<list-pu @chooseLike="chooseLike" @comfirmev="comfirmev" :list="listArrfour"></list-pu>
2021-11-08 07:50:30 +00:00
<view class="fon24 col3 tc">暂无更多内容</view>
2021-11-02 10:23:53 +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>
2021-10-11 10:21:06 +00:00
</view>
<!-- 底部导航 -->
<view class="posixzy disjbac bacf pad-zy32 btnBKS">
<view class="posir">
<image @tap="backHome" class="posia backH" src="/static/public/back-home.png" mode="aspectFill"></image>
</view>
<view class="disac fon26 colf">
2021-11-02 10:23:53 +00:00
<view @tap="showTK = true" class="disjcac lianShare addCart-btn"><span v-if="isNei!=1"></span><span v-else></span></view>
<view @tap="showTK = true" class="disjcac lianShare mai-btn"><span v-if="isNei!=1"></span><span v-else></span></view>
2021-10-11 10:21:06 +00:00
</view>
</view>
<!-- 购物车 -->
2021-10-22 03:07:32 +00:00
<view @tap="goShopCart" class="detail-cart-box">
<view class="posir">
<image src="/static/public/cart.png" mode="aspectFill"></image>
2021-11-02 10:23:53 +00:00
<view class="posia" v-if="cartNum!=0"><view>{{cartNum}}</view></view>
2021-10-11 10:21:06 +00:00
</view>
2021-10-22 03:07:32 +00:00
</view>
2021-10-11 10:21:06 +00:00
<!-- 客服 -->
2021-11-02 10:23:53 +00:00
<view @tap="lianK" style="position: fixed;right: 16rpx;bottom: 140rpx;">
2021-10-11 10:21:06 +00:00
<view class="posir" style="width: 142rpx;height: 142rpx;">
<image src="/static/public/kf-logo.png" mode="aspectFill" style="width: 142rpx;height: 142rpx;"></image>
2021-11-02 10:23:53 +00:00
<button v-if="haveImg" open-type="contact" class="posia-op"></button>
2021-10-11 10:21:06 +00:00
</view>
</view>
<!-- 立即购买加入购物车弹框 -->
<view v-if="showTK" class="posAll" @tap="showTK=false">
2021-10-22 03:07:32 +00:00
<view class="bacf posixzy bottom-popu" @tap.stop="showTK=true">
2021-10-11 10:21:06 +00:00
<view class="disjb pad-zy50">
2021-10-22 03:07:32 +00:00
<image :src="zhuImg" mode="aspectFill"></image>
<view class="disjbac width100">
<view v-if="isNei!=3">
<view class="fon40 mar-sx10 colf8">{{skuDetail.price/100}}</view>
<view v-if="isNei!=10"><span class="yuan-price">{{skuDetail.original_price/100}}</span></view>
2021-10-11 10:21:06 +00:00
</view>
2021-10-22 03:07:32 +00:00
<view v-else><view class="fon40 mar-sx10 colf8">积分{{skuDetail.score}}</view></view>
<image @tap.stop="showTK=false" src="/static/public/cha-close.png" style="margin-right: 0rpx;" mode=""></image>
2021-10-11 10:21:06 +00:00
</view>
</view>
<!-- 标题 -->
2021-10-22 03:07:32 +00:00
<view class="fon36 col3 bold clips3 pad-zy30 mar-s20 shop-title-box line-h50">
<view style="margin-top: -8rpx;margin-right: 10rpx;">
<span class="radius15 colf fon20" :style="{background:publicColor}">{{detailObj.disease_name}}</span>
<span class="radius15 colf fon20 mar-z10" v-if="isNei==0"></span>
<span class="radius15 colf fon20 mar-z10" v-if="isNei==1"></span>
<span class="radius15 colf fon20 mar-z10" v-if="isNei==2"></span>
</view>
2021-11-02 10:23:53 +00:00
<span>{{detailObj.name}}</span>
2021-10-11 10:21:06 +00:00
</view>
2021-11-02 10:23:53 +00:00
<view class="dis mar-sx40 pad-zy30 col3">
<view class="fon28 flexs" style="margin-top: 6rpx;">类型</view>
<view class="fon26 disac fw width100" style="justify-content: flex-end;">
<view @tap="chooselei(indexl)" class="mar-x20" v-for="(item,indexl) in allRes.sku" :key="indexl" :class="leiIndex==indexl?'activelei':'molei'" :style="{background:leiIndex==indexl?publicColor:'#F2F2F2'}">{{item.title}}</view>
2021-10-11 10:21:06 +00:00
</view>
</view>
<view class="disjbac mar-sx40 pad-zy30 fon28">
<view class="col3">库存</view>
2021-10-22 03:07:32 +00:00
<view class="fon26 col3" style="color: #5B5B5B;">{{skuDetail.stock}}</view>
2021-10-11 10:21:06 +00:00
</view>
<view class="disjbac mar-sx40 pad-zy30 fon28">
<view class="col3">购买数量</view>
<view class="fon26 col3 disac bold">
2021-10-22 03:07:32 +00:00
<image @tap="buyNum!=1?buyNum--:''" src="/static/public/del.png" class="del-btn" mode=""></image>
<input type="text" v-model="buyNum" class="num-input"/>
<image @tap="buyNum++" src="/static/public/add.png" class="add-btn" mode=""></image>
2021-10-11 10:21:06 +00:00
</view>
</view>
<!-- 加入购物车立即购买 -->
2021-11-02 10:23:53 +00:00
<view v-if="isNei!=1" class="disjbac pad-zy30 colf fon32 mar-x50">
2021-10-22 03:07:32 +00:00
<view @tap="addCart" class="ev-btn pbackc">加入购物车</view>
2021-11-02 10:23:53 +00:00
<view v-if="isNei!=3" @tap.stop="goGetReadyDan(0)" class="ev-btn bcf8"></view>
<view v-else @tap.stop="goGetReadyDan(0)" class="ev-btn bcf8">立即兑换</view>
2021-10-11 10:21:06 +00:00
</view>
<!-- 单独购买立即拼团 -->
2021-11-02 10:23:53 +00:00
<view v-else class="disjbac pad-zy30 colf fon32 mar-x50">
<view @tap.stop="goGetReadyDan(2)" class="ev-btn" style="background: #C8C8C8;">单独购买</view>
<view @tap.stop="goGetReadyDan(0)" class="ev-btn bcf8">发起拼团</view>
2021-10-11 10:21:06 +00:00
</view>
</view>
</view>
<!-- 返回顶部 -->
<!-- <back-top :showTop="showTop" @backTop="backTop"></back-top> -->
<!-- 弹框授权 -->
<empower @buttonH="buttonH" :vision="vision" :isWhere="2" @cancleEv="cancleEv"></empower>
<!-- 弹框 -->
<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>
</view>
</view>
</template>
<script>
import listDoctor from '@/components/list-doctor.vue';
import swiperPu from '@/components/swiper-pu.vue';
2021-10-22 03:07:32 +00:00
import {cancleCollectionShopEV,collectionShopEV} from '@/jsFile/publicAPI.js';
2021-10-11 10:21:06 +00:00
import empower from '@/components/empower.vue';
import shopList from '@/components/shop-list.vue';
export default {
components:{
listDoctor,
swiperPu,
empower,
shopList
},
data() {
return {
statusBarHeight:uni.getSystemInfoSync().statusBarHeight,
2021-10-22 03:07:32 +00:00
isLoading:false,
2021-10-11 10:21:06 +00:00
vision:false,
statusHNH:uni.getStorageSync('statusHNH'),
publicColor:uni.getStorageSync('publicColor') || '#3875F6',//主题颜色
cateCurrent:0,
haveImg:true,
2021-10-22 03:07:32 +00:00
cateList:[{
id:1,
title:'商品详情',
pid:11,
sort:4
}],
bannerList:[],//轮播
//相关推荐
xgList:[],
//产品推荐
dataList:[],
2021-10-11 10:21:06 +00:00
showTop:false,
isDetailConllection:false,//是否已收藏
isNum:0,
listArrone:[],//问题
2021-10-22 03:07:32 +00:00
//案例日记
listArrtwo:[],
//效果模拟
listArrthree:[],
//科普视频
listArrfour:[],
2021-11-02 10:23:53 +00:00
//医生列表
doctorList:[],
2021-10-11 10:21:06 +00:00
detailObj:{},//详情
detailInfo:'',//富文本
category_id:'',//栏目ID
active:'',//是否是详情页
share_id:0,
invite_code:'',
isShowP:false,
showTK:false,
leiIndex:0,
2021-10-22 03:07:32 +00:00
showPD:false,
isNei:'',//什么类型的商品
pingArr:[],//拼团列表
len:0,//正在拼团人数
pinInfo:{},//拼单人信息
allRes:{},//所有订单信息
zhuImg:'',//cover图
skuDetail:{},//sku详情
buyNum:1,//购买数量
2021-11-02 10:23:53 +00:00
daoTime:'',//储存倒计时
csNum:0,//点击次数,
isBuy:0,//
ispt:0,//拼团的方式0默认发起拼团1参与平台 2单独购买
isScore:0,//是否是积分
cartNum:0,
2021-11-04 07:41:53 +00:00
skuCate:[],//类型
pinDao:'',//平团倒计时
serverTime:'',//服务器时间
timerServer:null,
timerp:null,
timera:null,
pinUserId:0,//发起拼单人ID
isAutoPlay:false
2021-10-11 10:21:06 +00:00
}
},
onPageScroll(e) {
e.scrollTop > 360 ? this.showTop = true : this.showTop = false
},
onShareAppMessage(res) {
var ya = this;
2021-11-02 10:23:53 +00:00
this.$requst.post('user/record',{type:'content',action:'share',id:this.detailObj.spu_id}).then(res=>{console.log('分享成功:',res);},error=>{})
2021-10-11 10:21:06 +00:00
let maiOjb = {
e:4,//内容分享
2021-11-02 10:23:53 +00:00
c:this.detailObj.spu_id*1,
2021-10-11 10:21:06 +00:00
t:new Date().getTime()//当前时间戳
}
this.$toolAll.tools.maiDian(maiOjb)
2021-10-22 03:07:32 +00:00
if(ya.detailObj.share_img==null) ya.detailObj.share_img = ya.detailObj.cover;
2021-10-11 10:21:06 +00:00
var shareObj = {
2021-10-22 03:07:32 +00:00
     title: `${ya.detailObj.name}`, // 默认是小程序的名称(可以写slogan等)
2021-11-02 10:23:53 +00:00
     path: `/pagesB/shopDetail/shopDetail?id=${this.detailObj.spu_id}&category_id=${this.category_id}&share_id=${uni.getStorageSync('userId')}&invite_code=${uni.getStorageSync('invite_code')}`, // 默认是当前页面,必须是以‘/’开头的完整路径
2021-10-11 10:21:06 +00:00
     imageUrl: ya.$http + ya.detailObj.share_img//自定义图片路径可以是本地文件路径、代码包文件路径或者网络图片路径支持PNG及JPG不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
  };
  return shareObj;
},
onShow() {
2021-11-02 10:23:53 +00:00
uni.removeStorageSync('chooseAddress');
this.isAutoPlay = true;
},
onHide() {
this.isAutoPlay = false;
2021-10-11 10:21:06 +00:00
},
2021-11-04 07:41:53 +00:00
onUnload() {
clearInterval(this.timera);
clearInterval(this.timerp);
clearInterval(this.timerServer);
this.isAutoPlay = false;
2021-11-04 07:41:53 +00:00
},
2021-10-11 10:21:06 +00:00
onLoad(options) {
if(options.category_id!=undefined) {
this.category_id = options.category_id
this.conid = options.id
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,//用户邀请码
}
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 => {})
}
},
});
} else {
this.$toolAll.tools.overdue()
this.$toolAll.tools.isLogin()
}
}
// this.checkDetail(this.conid)
if(options.share_id!=undefined) this.share_id = options.share_id
let maiOjb = {
e:4,//内容分享
c:this.conid*1,
t:new Date().getTime()//当前时间戳
}
2021-10-22 03:07:32 +00:00
this.$toolAll.tools.maiDian(maiOjb);
2021-11-02 10:23:53 +00:00
if(options.isIntegral=="true"){this.isScore = 3;}
this.checkDetail(options.id,options.is_activity);
this.cartNumEv();
2021-10-11 10:21:06 +00:00
},
methods: {
2021-11-02 10:23:53 +00:00
cartNumEv(){//购物车数量
let ntype = 'spu'
if(this.isScore==3) ntype = 'score';
this.$requst.post('order/shopping-cart-count',{type:ntype}).then(res=>{
if(res.code==0){
this.cartNum = res.data.count;
}
})
},
checkPTList(id){//查询正在拼团的人数
2021-11-04 07:41:53 +00:00
uni.request({
url:'https://hengmei.scdxtc.cn/api/spu/group-list',
data:{id:id},
method:'post',
header:{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer '+uni.getStorageSync('token') || ''
},
success: (res) => {
if(res.data.code==0){
let ntime = new Date(res.header.Date).getTime();//服务器时间
this.timerServer = setInterval(()=>{
ntime = ntime + 1000
this.serverTime = new Date(ntime);
},1000);
if(res.data.data.length!=0){
res.data.data.forEach(item=>{
let pObj = {
id:item.id,
imgSrc:item.cover,
name:item.name,
num:item.num,//剩余拼团数量
time:item.time,//拼团截止时间
time_text:item.time_text//拼团截止时间展示文本
}
this.pingArr.push(pObj);
})
this.len = this.pingArr.length;
let n = 2; //假设每行显示2个
let lineNum = this.len % 2 === 0 ? this.len / 2 : Math.floor( (this.len / 2) + 2 );
let newPArr = [];
for (let i = 0; i < lineNum; i++) {
let temp = this.pingArr.slice(i*n, i*n+n);
newPArr.push(JSON.parse(JSON.stringify(temp)));
2021-11-02 10:23:53 +00:00
}
2021-11-04 07:41:53 +00:00
this.pingArr = newPArr;
2021-11-02 10:23:53 +00:00
}
2021-11-04 07:41:53 +00:00
} else this.$toolAll.tools.showToast(res.msg);
}
2021-11-02 10:23:53 +00:00
})
},
goGetReadyDan(index){//弹框中的立即购买
2021-10-22 03:07:32 +00:00
this.showTK = false;
// {id:1,imgSrc:'/static/tabbar/mya.png',title:'【99皮皮节】【种植发际线】',price:3888,num:1,isActive:false},
let nprice = '';
if(this.isNei==3) {
nprice = this.detailObj.score;
} else nprice = this.skuDetail.price/100;
2021-11-02 10:23:53 +00:00
this.ispt = index;
if(index==2){nprice = this.skuDetail.original_price/100;}
2021-10-22 03:07:32 +00:00
let params = {
2021-11-02 10:23:53 +00:00
id:this.detailObj.spu_id,
2021-10-22 03:07:32 +00:00
imgSrc:this.$http + this.detailObj.cover,
coding:this.skuDetail.coding,
price:nprice,
num:this.buyNum,
title:this.detailObj.name,
2021-11-02 10:23:53 +00:00
sku_name:this.skuDetail.title,
is_score:this.detailObj.is_score,
group_id:this.ispt,//0发起拼团 1参与拼团 2单独购买
2021-11-04 07:41:53 +00:00
is_only:this.ispt,
pin_user_id:this.pinUserId//发起拼单人ID
2021-10-22 03:07:32 +00:00
}
let newList = [params];
uni.setStorageSync('orderList',newList);
uni.navigateTo({
url:`/pagesA/getReadyDan/getReadyDan?isNei=${this.isNei}`
})
},
addCart(){//添加购物车事件
2021-11-02 10:23:53 +00:00
if(this.csNum==0){
this.csNum++;
this.$toolAll.tools.showToast('正在加入购物车...');
this.$requst.post('order/shopping-cart-add',{sku_id:this.skuDetail.id,num:this.buyNum}).then(res=>{
if(res.code==0) {
this.showTK = false;
this.$toolAll.tools.showToast('添加购物车成功(*^▽^*)');
this.cartNumEv();
this.csNum = 0;
}
})
}
2021-10-22 03:07:32 +00:00
},
comeTuan(pinId,index,index2){//去拼单
2021-10-11 10:21:06 +00:00
this.showPD = true;
2021-10-22 03:07:32 +00:00
this.pinInfo = this.pingArr[index][index2];
2021-11-04 07:41:53 +00:00
this.pinDao = this.$toolAll.tools.dayTime(this.pinInfo.time,this.serverTime);
this.timerp = setInterval(()=>{
if((new Date(this.pinInfo.time).getTime()) - (new Date(this.serverTime).getTime())<=0){
this.pinDao = '已结束';
this.checkPTList(this.detailObj.id);
this.showPD = false;
clearInterval(this.timerp);
} else {
this.pinDao = this.$toolAll.tools.dayTime(this.pinInfo.time,this.serverTime);
}
},1000)
},
atOnceSpellOrder(index){//参与拼单
if(index==1){
this.showTK = true;
this.pinUserId = this.pinInfo.id;
}
this.showPD = false;
clearInterval(this.timerp);
this.daoTime = '';
2021-10-11 10:21:06 +00:00
},
chooselei(index){//类型选择
this.leiIndex = index
2021-10-22 03:07:32 +00:00
this.skuDetail = this.allRes.sku[index];
2021-10-11 10:21:06 +00:00
},
moveHandle(){//禁止底层滑动
return false
},
2021-11-02 10:23:53 +00:00
lianK(){//客服
// if(!this.jieDuan){
// let isAuth = this.$toolAll.tools.returnAuth()
// if(!isAuth){
if(this.haveImg == false) {
this.vision = true
} else {
this.$requst.post('user/rand-bind-service').then(res=>{})
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)
}
// } else this.jieDuan = true
// }
},
2021-10-11 10:21:06 +00:00
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
}
},
chooseLike(e){//收藏事件
let cateId = ''
let newArr = []
2021-11-02 10:23:53 +00:00
if(this.cateCurrent==1) {
2021-10-11 10:21:06 +00:00
newArr = this.listArrone
cateId = newArr[e].id
}
2021-11-02 10:23:53 +00:00
if(this.cateCurrent==2) {
2021-10-11 10:21:06 +00:00
newArr = this.listArrtwo
cateId = newArr[e].id
}
2021-11-02 10:23:53 +00:00
if(this.cateCurrent==3) {
2021-10-11 10:21:06 +00:00
newArr = this.listArrthree
cateId = newArr[e].id
}
2021-11-02 10:23:53 +00:00
if(this.cateCurrent==4) {
2021-10-11 10:21:06 +00:00
newArr = this.listArrfour
cateId = newArr[e].id
}
if(newArr[e].is_collected==0){
newArr[e].is_collected = 1
// 调用收藏事件
2021-10-22 03:07:32 +00:00
collectionShopEV({action:'collect',id:cateId})
2021-10-11 10:21:06 +00:00
}
},
comfirmev(e){//确认取消收藏事件
let cateId = ''
2021-11-02 10:23:53 +00:00
if(this.cateCurrent==1) {
2021-10-11 10:21:06 +00:00
this.listArrone[e].is_collected = 0
cateId = this.listArrone[e].id
}
2021-11-02 10:23:53 +00:00
if(this.cateCurrent==2) {
2021-10-11 10:21:06 +00:00
this.listArrtwo[e].is_collected = 0
cateId = this.listArrtwo[e].id
}
2021-11-02 10:23:53 +00:00
if(this.cateCurrent==3) {
2021-10-11 10:21:06 +00:00
this.listArrthree[e].is_collected = 0
cateId = this.listArrthree[e].id
}
2021-11-02 10:23:53 +00:00
if(this.cateCurrent==4) {
2021-10-11 10:21:06 +00:00
this.listArrfour[e].is_collected = 0
cateId = this.listArrfour[e].id
}
this.$toolAll.tools.showToast('正在取消...','loading')
// 调用取消收藏事件
2021-10-22 03:07:32 +00:00
cancleCollectionShopEV({action:'collect',id:cateId})
2021-10-11 10:21:06 +00:00
},
buttonH(e){//授权成功
this.haveImg = e
if(e) {
this.vision = false
this.isShowP = true
}
},
cancleEv(e){//取消授权
2021-11-02 10:23:53 +00:00
// if(e==0) this.vision = false
2021-10-11 10:21:06 +00:00
},
backHome(){
uni.navigateTo({
url:'/pages/tabbar/pagehome/pagehome'
})
},
shareEv(){
if(this.haveImg == false) {
this.vision = true
}
},
2021-11-02 10:23:53 +00:00
checkDetail(newId,is_activity){
uni.request({
url:'https://hengmei.scdxtc.cn/api/spu/detail',
data:{id:newId,is_activity:is_activity},
method:'post',
header:{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer '+uni.getStorageSync('token') || ''
},
success: (res) => {
if(res.data.code==0){
this.allRes = res.data.data;
this.zhuImg = this.$http + res.data.data.detail.cover;
// 默认显示的sku
if(res.data.data.sku.length!=0){
res.data.data.sku.forEach(item=>{
if(item.is_default==1) {
this.skuDetail = item;
}
})
}
this.isLoading = true;
// 栏目类别
if(res.data.data.category.length!=0){
res.data.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
})
}
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()
}
// 详情
this.detailObj = res.data.data.detail;
// 类型
this.skuCate = res.data.data.sku;
if(this.detailObj.activity_type=='group_buy') this.isNei = 0;
if(this.detailObj.activity_type=='group_make') this.isNei = 1;
if(this.detailObj.activity_type=='limit_time') this.isNei = 2;
if(this.detailObj.activity_type=='normal') {
if(this.isScore==3) {
this.isNei = this.isScore;
} else this.isNei = 10;
}
2021-11-08 07:50:30 +00:00
if(res.data.data.detail.activity_end_at!=undefined){
let startTime = new Date(res.header.Date).getTime();
let endTime = new Date(res.data.data.detail.activity_end_at).getTime();
if(startTime - endTime >=0) {//如果开始时间的时间戳 - 结束时间的时间戳 >= 0 活动结束
this.daoTime = "活动已结束";
clearInterval(this.timera);
} else {
this.daoTime = this.$toolAll.tools.dayTime(res.data.data.detail.activity_end_at,startTime);//初始化
this.timera = setInterval(()=>{//倒计时赋值
startTime = startTime + 1000;
this.daoTime = this.$toolAll.tools.dayTime(res.data.data.detail.activity_end_at,startTime);
},1000)
}
2021-11-02 10:23:53 +00:00
}
let maiOjb = {
e:1,//内容访问
c:this.detailObj.spu_id*1,
t:new Date().getTime()//当前时间戳
}
this.$toolAll.tools.maiDian(maiOjb)
// 轮播
// 图片字符串转数组
let arrImg = this.detailObj.images.split(',')
arrImg.forEach(item=>{
let newImgObj = {
imgSrc:this.$http + item,
url:'',
isVideo:false,
poster:'',
2021-10-22 03:07:32 +00:00
}
2021-11-02 10:23:53 +00:00
// 存图片
this.bannerList.push(newImgObj)
2021-10-22 03:07:32 +00:00
})
2021-11-08 07:50:30 +00:00
console.log(this.bannerList);
2021-11-02 10:23:53 +00:00
// 存视频
if(this.detailObj.video!=''){
this.bannerList[0] = {
imgSrc:this.$http + arrImg[0],
url:this.$http + this.detailObj.video,
isVideo:true,
poster:'',
2021-10-22 03:07:32 +00:00
}
}
2021-11-02 10:23:53 +00:00
// 默认显示是否收藏
if(this.detailObj.is_collected==0) this.isDetailConllection = false
if(this.detailObj.is_collected==1) this.isDetailConllection = true
// 富文本
this.detailInfo = this.$toolAll.tools.escape2Html(this.detailObj.content)
// 医生列表
if(res.data.data.doctor.length!=0){
res.data.data.doctor.forEach(item=>{
let docObj = {
id:item.id,
imgSrc:item.headimg,
name:item.name,
goodAt:item.skill
}
this.doctorList.push(docObj);
})
2021-10-22 03:07:32 +00:00
}
2021-11-02 10:23:53 +00:00
// 正在平团人数
if(this.isNei==1 && this.detailObj.activity_going.length!=0) {
this.checkPTList(this.detailObj.id);//查询商品正在拼团列表
2021-10-22 03:07:32 +00:00
}
2021-11-02 10:23:53 +00:00
this.checkShopList();
}
}
})
},
checkShopList(){// 产品推荐
let params = {
keyword:'',//商品关键字 支持模糊搜索
page:1,
size:10,
doctor_role:'',//医生从职位标识 从商品筛选条件接口获取 目前为doctor=医生 design=设计师
doctor_name:'',//医生姓名 模糊搜索
activity:'',//活动类型 不填为普通商品+活动商品 normal=普通商品group_make=拼团group_buy=团购;limit_time=限时促销
disease_id:''//病种ID
}
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){
this.dataList = [];
if(res.data.data.list.length!=0){
res.data.data.list.forEach(item=>{
2021-10-22 03:07:32 +00:00
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;
2021-11-02 10:23:53 +00:00
let group_cover = [];
if(item.activity_group_cover.length!=0) {
item.activity_group_cover.forEach(item=>{
group_cover.push(this.$http + item)
})
}
2021-10-22 03:07:32 +00:00
let obj = {
id:item.id,
imgSrc: this.$http + item.cover,
title: item.name,
zhePrice:item.price/100,
yuanPrice:item.original_price/100,
integral:'',
2021-11-02 10:23:53 +00:00
isTuan:tuan,//是否是团购
isPing:ping,//是否是拼团活动
isXian:xian,//是否是限时活动
isIntegral:integral,//是否是积分
2021-10-22 03:07:32 +00:00
grade:'',
disease_name:item.disease_name,//病种名称
disease_id:item.disease_id,//病种ID
2021-11-02 10:23:53 +00:00
reponseTime:res.header.Date,//接口响应时间
activity_end_at:item.activity_end_at,//限时结束时间
activity_group_cover:group_cover,//参团人的头像
activity_group_num:item.activity_group_num,//已经参团人数
2021-10-22 03:07:32 +00:00
}
this.dataList.push(obj)
})
}
}
}
2021-11-02 10:23:53 +00:00
})
2021-10-22 03:07:32 +00:00
},
goShopCart(){//去购物车事件
2021-11-02 10:23:53 +00:00
let isScore = '';
if(this.isNei==3) isScore = 'score';
uni.navigateTo({
url:`/pagesA/shopCart/shopCart?isScore=${isScore}`
})
},
goDoctor(id){
2021-10-22 03:07:32 +00:00
uni.navigateTo({
2021-11-02 10:23:53 +00:00
url:`/pagesB/doctorDetail/doctorDetail?doctor_id=${id}`
2021-10-22 03:07:32 +00:00
})
},
2021-11-08 07:50:30 +00:00
choosecateEv(e){//分类列表事件
2021-10-11 10:21:06 +00:00
this.cateCurrent = e
2021-11-08 07:50:30 +00:00
this.$requst.post('archives/category',{category_id:this.cateList[e].id,page:1,size:2000}).then(res=>{
2021-10-11 10:21:06 +00:00
// console.log('该分类下的列表:',res);
if(res.code==0){
2021-11-02 10:23:53 +00:00
if(e==1 && this.active!=e) this.listArrone = []
if(e==2 && this.active!=e) this.listArrtwo = []
if(e==3 && this.active!=e) this.listArrthree = []
if(e==4 && this.active!=e) this.listArrfour = []
2021-10-11 10:21:06 +00:00
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!=''){
2021-11-02 10:23:53 +00:00
if(e==1 && this.active!=e) this.listArrone.push(arrObj)
if(e==2 && this.active!=e) this.listArrtwo.push(arrObj)
if(e==3 && this.active!=e) this.listArrthree.push(arrObj)
if(e==4 && this.active!=e) this.listArrfour.push(arrObj)
2021-10-11 10:21:06 +00:00
}
})
}
}
},error=>{})
},
tapConllection(){//收藏、取消收藏事件
2021-11-02 10:23:53 +00:00
let isLikeCon = 'collect';
let nid = '';
if(this.detailObj.is_activity==1) nid=this.detailObj.spu_id;
else nid=this.detailObj.id;
2021-10-22 03:07:32 +00:00
// 调用收藏事件
2021-11-02 10:23:53 +00:00
if(!this.isDetailConllection) collectionShopEV({action:isLikeCon,id:nid})
2021-10-22 03:07:32 +00:00
// 调用取消收藏事件
2021-11-02 10:23:53 +00:00
else cancleCollectionShopEV({action:isLikeCon,id:nid})
2021-10-22 03:07:32 +00:00
this.isDetailConllection = !this.isDetailConllection
2021-10-11 10:21:06 +00:00
},
backTop(){//回到顶部事件
uni.pageScrollTo({
scrollTop: 0,
duration: 300
});
},
}
}
</script>
<style>
</style>