调取课程列表分类接口、课程列表接口、商品详情接口

master
chen 2022-08-05 11:05:55 +08:00
parent a1a3edb942
commit 2b2afbb814
5 changed files with 107 additions and 27 deletions

View File

@ -1,7 +1,7 @@
<template>
<view class="disjbac fw">
<view @tap="goDetail(item.id)" class="radius8 bacf pad12 boxshow1 width48_6 mar-s20 flexs " v-for="(item,index) in list" :key="index">
<image :src="item.cover" style="height: 226rpx;" mode="aspectFill" class="width100" lazy-load></image>
<image :src="item.cover" style="height: 226rpx;" mode="aspectFill" class="width100 animated fadeIn" lazy-load></image>
<view class="fon24 pad-zy8 disjb fc" style="color: #262626;">
<view class="clips2 mar-sx10" style="height: 64rpx;">{{item.name}}</view>
<view class="disjbac ae pad-x10">

View File

@ -12,7 +12,7 @@ const refreshTokenPage = () => {
provider: 'weixin',
success: (result)=> {
uni.request({
url: `${getApp().globalData.hostapi}user/login`,
url: `${getApp().globalData.hostapi}/api/user/login`,
method: 'post',
data: {code:result.code},
success: res => {

View File

@ -5,21 +5,21 @@
<view class="posi-sticky" :style="{top:newtop+'px'}">
<view class="pad-sx26 pad-zy20" style="border-bottom: 2rpx solid #fcede8;">
<view class="radius40 pad-sx2 disjbac pad-zy20" style="background-color: #fff6f5;border: 2rpx solid #ece6e6;">
<input type="text" class="fon24 width100 pad-sx6" placeholder="关键字搜索" placeholder-style="color:#aaa4a3">
<input v-model="keyword" @confirm="getCourseList" type="text" class="fon24 width100 pad-sx6" placeholder="关键字搜索" placeholder-style="color:#aaa4a3">
<view class="disjcac pad-sx6 pad-zy10" @tap="getCourseList">
<image class="flexs" src="/static/tabbar/icon-search.png" mode="" style="width: 28rpx;height: 28rpx;" lazy-load></image>
</view>
</view>
</view>
<swiper-tab id="tab" :list="dataList" v-model="current" @changeEv="clickTab" :itemColor="'#e42417'" :lineColor="'#e42417'"></swiper-tab>
</view>
<view class="pad-zy20">
<list @goDetail="goDetail"></list>
<list @goDetail="goDetail"></list>
<list @goDetail="goDetail"></list>
<list @goDetail="goDetail"></list>
<list @goDetail="goDetail"></list>
<list ref="refcourse" @goDetail="goDetail"></list>
<view class="" v-if="noMore">
<pitera textStr="上滑加载更多/到底了~~" textColor="#b0aaa9" paddingStr="40rpx 0 20rpx 0"></pitera>
</view>
</view>
</view>
</status-container>
<!-- 底部tab -->
<foot-tab current='0'></foot-tab>
@ -39,21 +39,71 @@
newtop:uni.getSystemInfoSync().statusBarHeight + 42,
// newtop:uni.getSystemInfoSync().statusBarHeight + (140 / 750 * uni.getSystemInfoSync().windowWidth),
current:0,
dataList:[
{title:'课堂讲解'},
{title:'武德教育'},
{title:'爱国主义教育'},
{title:'示范动作讲解'},
],
dataList:[],//
classId:'',//id
keyword:'',//
page:1,
size:10,
total:0,
noMore:false,//
}
},
onLoad() {
//
this.getCourseCate();
},
onReachBottom() {
if(this.total!=this.$refs.refcourse.list.length){
this.page++;
//
this.getCourseList();
}
},
methods: {
// tab
clickTab(index){
this.current = index;
this.page = 1;
this.noMore = false;
// id
this.classId = this.dataList[index].id;
//
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();
}
})
},
//
getCourseList(){
let params = {
category_id:this.classId,
page:this.page,
size:this.size,
keyword:this.keyword
}
this.$requst.post('/api/spu/course',params).then(res=>{
if(res.code==0){
//
this.total = res.data.total;
if(this.page==1){this.$refs.refcourse.list=[];}
//
this.$refs.refcourse.list = [...this.$refs.refcourse.list,...res.data.list];
if(this.total==this.$refs.refcourse.list.length && this.page!=1){
this.noMore = true;
}
}
})
},
//
goDetail(id){

View File

@ -7,9 +7,11 @@
</view>
<view class="pad-zy20">
<list ref="refproduct" @goDetail="goDetail"></list>
<view class="" v-if="noMore">
<pitera textStr="上滑加载更多/到底了~~" textColor="#b0aaa9" paddingStr="40rpx 0 20rpx 0"></pitera>
</view>
</view>
</view>
</status-container>
<!-- 底部tab -->
<foot-tab current="1"></foot-tab>
@ -36,26 +38,36 @@
dataList:[],//
classId:'',//id
page:1,
size:20,
size:10,
total:0,
noMore:false,//
}
},
onLoad() {
//
this.getHomeCate();
},
onReachBottom() {
if(this.total!=this.$refs.refproduct.list.length){
this.page++;
//
this.getProductList();
}
},
methods: {
// tab
clickTab(index){
this.current = index;
this.page = 1;
this.noMore = false;
// id
this.classId = this.dataList[index].id;
//
this.getProductList();
},
//
//
getHomeCate(){
this.$requst.get('/api/spu/category').then(res=>{
this.$requst.get('/api/spu/category',{type:'normal',need_all:1}).then(res=>{
//
this.dataList = res.data;
//
@ -81,6 +93,9 @@
if(this.page==1){this.$refs.refproduct.list=[];}
//
this.$refs.refproduct.list = [...this.$refs.refproduct.list,...res.data.list];
if(this.total==this.$refs.refproduct.list.length && this.page!=1){
this.noMore = true;
}
}
})
},

View File

@ -5,10 +5,10 @@
<view class="bacf boxshowb">
<swiper-pu newBottom="20rpx" newHeight="520rpx"></swiper-pu>
<view class="pad-zy30 pad-sx24">
<view class="fon26 col26">止戈为武思通造化随通而 行为术基础动作教学</view>
<view class="fon26 col26">{{shopInfo.name}}</view>
<view class="col-e42417 dis ae fon24 mar-s20">
<view class="bold">199.00</view>
<view class="tline-through fon20 col-969696 mar-z10">220.00</view>
<view class="bold">{{shopInfo.price}}</view>
<view class="tline-through fon20 col-969696 mar-z10">{{shopInfo.original_price}}</view>
</view>
</view>
</view>
@ -47,6 +47,8 @@
data() {
return {
richText:'',
shopId:'',//id
shopInfo:'',//
}
},
onShow() {
@ -57,10 +59,23 @@
// banner
this.$store.commit('setAutoplay',false);
},
onLoad() {
onLoad(op) {
this.shopId = op.id;
//
this.getDetail();
},
methods: {
//
getDetail(){
this.$requst.post('/api/spu/detail',{id:this.shopId}).then(res=>{
if(res.code==0){
//
this.shopInfo = res.data.detail;
//
this.richText = this.$toolAll.tools.escape2Html(this.shopInfo.content);
}
})
},
//
goConfirmOrder(){
uni.navigateTo({