281 lines
8.5 KiB
Vue
281 lines
8.5 KiB
Vue
<template>
|
||
<view>
|
||
<status-container :ifReturn="false" titlet="传武佳小程序">
|
||
<view slot="content">
|
||
<view class="" style="margin-top: -20rpx;">
|
||
<swiper-pu :bannerList="bannerList" newBottom="20rpx" newHeight="460rpx"></swiper-pu>
|
||
</view>
|
||
<view class="posi-sticky" :style="{top:newtop+'px'}">
|
||
<swiper-tab id="tab" :list="dataList" v-model="current" @changeEv="clickTab" :itemColor="'#e42417'" :lineColor="'#e42417'"></swiper-tab>
|
||
</view>
|
||
<view class="pad-zy20 pad-s25" v-if="ifLoading">
|
||
<view class="" v-if="bigCourse.length">
|
||
<view @tap="goBigCourse(item.id,dataList[current].id,item.is_buy)" class="radius8 bacf pad10 boxshow1" v-for="(item,index) in bigCourse" :key="index">
|
||
<view class="posir">
|
||
<image :src="item.cover" style="height: 518rpx;" mode="aspectFill" class="width100" lazy-load></image>
|
||
<view class="posia-xzy bac5 fon24 colf pad18">
|
||
<view class="clips1">{{item.name}}</view>
|
||
<view class="disjbac ae">
|
||
<view class="">
|
||
<span class="bold">¥{{item.price}}</span>
|
||
<span class="fon20 colf8 mar-z20 tline-through">¥{{item.original_price}}</span>
|
||
</view>
|
||
<view class="radius18 pad-zy12 pad-sx4 borbot-f disjcac">{{item.is_buy?'去学习':'购买'}}</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="" v-else>
|
||
<pitera textStr="查询课程列表无果o(╥﹏╥)o" textColor="#b0aaa9" paddingStr="40rpx 0 20rpx 0"></pitera>
|
||
</view>
|
||
<!-- 两列列表 start -->
|
||
<list ref="refcourse" @goDetail="goCourseDetail"></list>
|
||
<!-- 两列列表 end -->
|
||
<!-- 推荐视频 start -->
|
||
<view class="disjb ae mar-s40 mar-x20">
|
||
<view class="fon32 bold colb">推荐视频</view>
|
||
<view class="fon20" style="color: #bbb4b3;" @tap="goMore(0)">更多+</view>
|
||
</view>
|
||
<view class="radius8 bacf pad10 boxshow1 mar-x30" v-for="(item,index) in videoList" :key="index">
|
||
<view class="posir disjcac">
|
||
<image :src="item.cover" style="height: 388rpx;" mode="aspectFill" class="width100" lazy-load></image>
|
||
<image v-if="item.src.includes('.mp4')" @tap="palyVideo(index)" class="posia" src="/static/tabbar/icon-play.png" mode="" style="width: 70rpx;height: 70rpx;" lazy-load></image>
|
||
</view>
|
||
<view class="fon24 pad-sx16 disjcac" style="color: #262626;">
|
||
<view class="clips2">{{item.title}}</view>
|
||
</view>
|
||
</view>
|
||
<!-- 推荐视频 end -->
|
||
<!-- 推荐商品 start -->
|
||
<view class="disjb ae mar-s40">
|
||
<view class="fon32 bold colb">推荐商品</view>
|
||
<view class="fon20" style="color: #bbb4b3;" @tap="goMore(1)">更多+</view>
|
||
</view>
|
||
<list ref="refshop" @goDetail="goShopDetail"></list>
|
||
<!-- 推荐商品 end -->
|
||
</view>
|
||
</view>
|
||
</status-container>
|
||
<!-- 底部tab -->
|
||
<foot-tab></foot-tab>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import swiperPu from '@/components/swipers/swiper-pu.vue';
|
||
import swiperTab from '@/components/swiper-tab/swiper-tab.vue';
|
||
import footTab from '@/components/foot-tabs/foot-tab.vue';
|
||
import list from '@/components/list.vue';
|
||
import pitera from '@/components/nothing/pitera.vue';
|
||
import {reportRecord} from '@/jsFile/public-api.js';
|
||
export default {
|
||
components:{
|
||
'foot-tab' :footTab,
|
||
swiperTab,
|
||
swiperPu,
|
||
list,
|
||
pitera
|
||
},
|
||
data() {
|
||
return {
|
||
newtop:uni.getSystemInfoSync().statusBarHeight + 40,
|
||
bannerList:[],//轮播图
|
||
current:0,
|
||
dataList:[],//分类列表
|
||
classId:'',//分类id
|
||
bigCourse:[],
|
||
videoList:[],//推荐视频
|
||
ifLoading:false,
|
||
ifCount:0,
|
||
}
|
||
},
|
||
onShow() {
|
||
// 开启banner图自动轮播
|
||
this.$store.commit('setAutoplay',true);
|
||
},
|
||
onHide() {
|
||
// 关闭banner图自动轮播
|
||
this.$store.commit('setAutoplay',false);
|
||
},
|
||
onShareAppMessage(res) {
|
||
var shareObj = {
|
||
title: ``, // 默认是小程序的名称(可以写slogan等)
|
||
path: `/pages/tabbar/pagehome/pagehome?invite_code=${uni.getStorageSync('invite_code')}`, // 默认是当前页面,必须是以‘/’开头的完整路径
|
||
imageUrl: ``//自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
|
||
};
|
||
return shareObj;
|
||
},
|
||
onLoad(op) {
|
||
// 解码一:unescape("http%3A//www.baidu.com%3Fname%3Dzhang@xiao@jie%26order%3D1");
|
||
// 解码二:decodeURIComponent("http%3A%2F%2Fwww.baidu.com%3Fname%3Dzhang%40xiao%40jie%26order%3D1")
|
||
if(op.q!=undefined){
|
||
this.$toolAll.tools.analysis(op.q);
|
||
}
|
||
// 调用获取分类列表
|
||
this.getCourseCate();
|
||
// 调用获取首页banner图
|
||
this.getBanner();
|
||
},
|
||
methods: {
|
||
// 获取首页banner图
|
||
getBanner(){
|
||
this.$requst.get('/api/common/slides',{position:'home-banner'}).then(res=>{
|
||
if(res.code==0){
|
||
if(res.data.length){
|
||
res.data.forEach(item=>{
|
||
let obj = {
|
||
imgSrc:item.src,
|
||
url:item.url,
|
||
isVideo:false,
|
||
poster:''
|
||
}
|
||
this.bannerList.push(obj);
|
||
})
|
||
}
|
||
}
|
||
})
|
||
},
|
||
// tab点击事件
|
||
clickTab(index){
|
||
this.current = index;
|
||
// 设置分类id
|
||
this.classId = this.dataList[index].id;
|
||
this.bigCourse = [];
|
||
this.$refs.refcourse.list = [];
|
||
this.ifCount++;
|
||
// 调用获取课程列表
|
||
this.getCourseList();
|
||
},
|
||
// 获取分类列表
|
||
getCourseCate(){
|
||
this.$requst.get('/api/spu/category',{type:'course'}).then(res=>{
|
||
// 设置分类列表
|
||
this.dataList = res.data;
|
||
// 如果分类列表不为空
|
||
if(this.dataList.length){
|
||
// 设置分类id
|
||
this.classId = this.dataList[0].id;
|
||
// 调用获取课程列表
|
||
this.getCourseList();
|
||
}
|
||
})
|
||
},
|
||
// 大图点击事件
|
||
goBigCourse(id,category_id,is_buy){
|
||
if(this.$toolAll.tools.judgeAuth()) {
|
||
this.$toolAll.tools.goPage(`/pagesB/course-detail/course-detail?id=${id}&category_id=${category_id}`);
|
||
}
|
||
},
|
||
// 获取课程列表
|
||
getCourseList(){
|
||
let params = {
|
||
category_id:this.classId,
|
||
is_home:1
|
||
}
|
||
this.$requst.post('/api/spu/course',params).then(res=>{
|
||
if(res.code==0){
|
||
this.ifLoading = true;
|
||
if(!this.ifCount){
|
||
// 调用获取推荐视频列表
|
||
this.getVideoList();
|
||
// 调用获取推荐视频列表
|
||
this.getShopList();
|
||
}
|
||
let dataList = res.data.list;
|
||
if(dataList.length){
|
||
this.bigCourse.push(dataList[0]);
|
||
dataList.splice(0,1);
|
||
if(dataList.length){
|
||
setTimeout(()=>{
|
||
// 设置课程列表
|
||
this.$refs.refcourse.list = dataList;
|
||
},200)
|
||
}
|
||
}
|
||
}
|
||
})
|
||
},
|
||
// 获取推荐视频列表
|
||
getVideoList(){
|
||
let params = {
|
||
page:1,
|
||
size:50,
|
||
is_home:1
|
||
}
|
||
this.$requst.post('/api/spu/video',params).then(res=>{
|
||
if(res.code==0){
|
||
// 设置推荐视频列表
|
||
this.videoList = res.data.list;
|
||
}
|
||
})
|
||
},
|
||
// 获取推荐商品
|
||
getShopList(){
|
||
let params = {
|
||
page:1,
|
||
size:50,
|
||
is_home:1
|
||
}
|
||
this.$requst.post('/api/spu/list',params).then(res=>{
|
||
if(res.code==0){
|
||
this.$refs.refshop.list = res.data.list;
|
||
}
|
||
})
|
||
},
|
||
// 播放视频
|
||
palyVideo(index){
|
||
if(this.$toolAll.tools.judgeAuth()) {
|
||
if(this.videoList[index].type=="video_number"){
|
||
// #ifdef MP-WEIXIN
|
||
wx.openChannelsActivity({
|
||
finderUserName:this.videoList[index].video_number,
|
||
feedId:this.videoList[index].video_id,
|
||
success:(res)=>{
|
||
reportRecord({id:this.videoList[index].id}).then(result=>{})
|
||
},fail:()=>{
|
||
// this.$toolAll.tools.showToast('视频已丢失或已删除')
|
||
}
|
||
})
|
||
// #endif
|
||
} else {
|
||
let newArr = [];
|
||
newArr.push(this.videoList[index])
|
||
uni.setStorageSync('videoList',newArr);
|
||
uni.navigateTo({
|
||
url:`/pagesB/play-video/play-video?current=${index}`
|
||
})
|
||
reportRecord({id:this.videoList[index].id}).then(result=>{})
|
||
}
|
||
}
|
||
},
|
||
// 更多
|
||
goMore(index){
|
||
uni.reLaunch({
|
||
url:['/pages/tabbar/video/video','/pages/tabbar/shop/shop'][index]
|
||
})
|
||
},
|
||
// 去课程详情
|
||
goCourseDetail(id){
|
||
if(this.$toolAll.tools.judgeAuth()) {
|
||
uni.navigateTo({
|
||
url:`/pagesB/course-detail/course-detail?id=${id}`
|
||
})
|
||
}
|
||
},
|
||
// 去商品详情
|
||
goShopDetail(id){
|
||
if(this.$toolAll.tools.judgeAuth()) {
|
||
uni.navigateTo({
|
||
url:`/pagesB/shop-detail/shop-detail?id=${id}`
|
||
})
|
||
}
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style>
|
||
|
||
</style>
|