123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432 |
- <template>
- <view class="resource">
- <statusBar :item="navBarData"></statusBar>
- <!-- 消息提示 -->
- <msgPop :goNum='1'></msgPop>
- <view class="search">
- <uni-search-bar v-model.trim="searchText" bgColor="#f0f2f5" class="btntop" placeholder="搜索"
- cancelButton="none" clearButton="none"></uni-search-bar>
- </view>
- <view class="top">
- <view class="left" @click="phoneLogin" :class="current == 0 ? info1 : info2">
- <text class="">资源库</text>
- <view v-if="current == 0" class="yun">
- <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 10.png"
- mode="aspectFill"></image>
- </view>
- </view>
- <view class="right" @click="accountLogin" :class="current == 1 ? info1 : info2">
- <text class="">精品慕课</text>
- <view v-if="current == 1" class="yun">
- <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 10.png"
- mode="aspectFill"></image>
- </view>
- </view>
- <!-- <view class="right" @click="costClass" :class="current == 2 ? info1 : info2">
- <text class="">付费课程</text>
- <view v-if="current == 2" class="yun">
- <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 10.png"
- mode="aspectFill"></image>
- </view>
- </view> -->
- </view>
- <!-- <swiper class="scroll-view-height" @change="swipeIndex" @transition='cutS' @animationfinish='ani' -->
- <swiper class="scroll-view-height" @change="swipeIndex" :current="current" :duration="300">
- <swiper-item>
- <scroll-view scroll-y="true" :refresher-enabled='refevent' :refresher-triggered="trigger"
- @refresherrefresh='repulling' @scrolltolower="relower" style="height: 100%;">
- <view class="searchPagedata" v-if="!classList.length">暂无数据</view>
- <view class="">
- <teaching-case ref="reso" :acList='classList'></teaching-case>
- </view>
- <view class="loading" v-show="!searchText">
- <view v-if="reLoading==1">数据加载中...</view>
- <view v-if="reLoading==2">没有更多了~~</view>
- </view>
- </scroll-view>
- </swiper-item>
- <swiper-item>
- <scroll-view scroll-y="true" :refresher-enabled='refevent' :refresher-triggered="putrigger"
- @refresherrefresh='purepulling' @scrolltolower="tealower" style="height: 100%;">
- <view class="searchPagedata" v-if="!classList2.length">暂无数据</view>
- <view class="">
- <teaching-case ref="tech" :acList='classList2'></teaching-case>
- </view>
- <view class="loading" v-show="!searchText">
- <view v-if="teaLoading==1">数据加载中...</view>
- <view v-if="teaLoading==2">没有更多了~~</view>
- </view>
- </scroll-view>
- </swiper-item>
- <!-- <swiper-item>
- <scroll-view scroll-y="true" style="height: 100%;">
- <view class=""
- style="height: 100%; width: 750rpx;display: flex;justify-content: center;align-items: center;">
- <image src="../../static/Frame.png" style="width: 400rpx;height: 400rpx;" mode=""></image>
- </view>
- </scroll-view>
- </swiper-item> -->
- </swiper>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- navBarData: {
- title: "课程",
- btn: 0,
- },
- indexId: 1,
- current: 0, //页面切换
- info1: "info1", //类名
- info2: "info2",
- // swiper: 0,
- searchText: "", // 搜索文本
- pic_coll: 'https://teacherapi.cocorobo.cn/teaching-file/static/Stara.png',
- pic_coll2: 'https://teacherapi.cocorobo.cn/teaching-file/static/mine/Collect_yellow.png',
- // 资源库
- classList: [],
- // 精品课程
- classList2: [],
- refevent: true,
- reLoading: 0, //0默认值 1加载中 2没有更多了
- recurrentPage: 1, //页数
- teaLoading: 0, //0默认值 1加载中 2没有更多了
- teacurrentPage: 1,
- // 设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
- trigger: false, //专题
- putrigger: false, //常规
- // 在搜索框有文字的时候下拉刷新禁止触发watch,防止数据叠加
- bansearchData: false
- };
- },
- onShareTimeline() {
- uni.share({
- provider: "weixin",
- scene: "WXSceneTimeline",
- type: 0,
- href: "http://uniapp.dcloud.io/",
- title: "uni-app分享",
- summary: "我正在使用丽湖双创小程序,赶紧跟我一起来体验!",
- imageUrl: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png",
- success: function(res) {
- console.log("success:" + JSON.stringify(res));
- },
- fail: function(err) {
- console.log("fail:" + JSON.stringify(err));
- }
- });
- },
- // 分享
- onShareAppMessage() {
- uni.share({
- provider: "weixin",
- scene: "WXSceneSession",
- type: 1,
- summary: "我正在使用丽湖双创小程序,赶紧跟我一起来体验!",
- success: function(res) {
- console.log("success:" + JSON.stringify(res));
- },
- fail: function(err) {
- console.log("fail:" + JSON.stringify(err));
- }
- });
- },
- watch: {
- searchText(val) {
- if (this.bansearchData) return
-
- if (val === '') {
-
- this.classList = []
- this.reLoading = 0 //0默认值 1加载中 2没有更多了
- this.recurrentPage = 1 //页数
- this.getreList()
-
- this.classList2 = []
- this.teaLoading = 0 //0默认值 1加载中 2没有更多了
- this.teacurrentPage = 1
- this.getteaList()
- return
- }
-
- this.selectSearchdata()
- }
- },
- methods: {
- selectSearchdata() {
- if (this.current === 2) return
- let data = {
- openid: uni.getStorageSync('oId'),
- txt: encodeURIComponent(this.searchText),
- ty: this.current,
- }
- this.$request('/selectActSearch', "get", data).then(res => {
- if (this.current == 0) {
- this.classList = res[0]
- } else if (this.current == 1) {
- this.classList2 = res[0]
- }
- })
- },
- // 资源库下拉刷新
- repulling() {
- this.bansearchData = true
- this.trigger = true
- // this.isrepulling = true
- // setTimeout(() => {
- // this.trigger = false;
- // }, 1000);
- // 资源库
- // this.classList = []
- this.reLoading = 0 //0默认值 1加载中 2没有更多了
- this.recurrentPage = 1 //页数
- if (this.searchText !== '') {
- this.classList2 = []
- this.teaLoading = 0 //0默认值 1加载中 2没有更多了
- this.teacurrentPage = 1
- this.searchText = ''
- this.getteaList()
- }
- this.getreList()
- },
- // 精品慕课下拉刷新
- purepulling() {
- this.bansearchData = true
- this.putrigger = true
- // this.isrepulling = true
- // setTimeout(() => {
- // this.putrigger = false;
- // }, 1000);
- // 精品课程
- // this.classList2 = []
- this.teaLoading = 0 //0默认值 1加载中 2没有更多了
- this.teacurrentPage = 1
- if (this.searchText !== '') {
- this.classList = []
- this.reLoading = 0 //0默认值 1加载中 2没有更多了
- this.recurrentPage = 1 //页数
- this.searchText = ''
- this.getreList()
- }
- this.getteaList()
- },
- // 获取资源库
- getreList() {
- let data = {
- openid: uni.getStorageSync('oId'),
- ty: 0,
- page: this.recurrentPage,
- lim: 30
- }
- this.$request('/selectResource', "POST", data).then(res => {
- // console.log('获取资源库', res);
- if (!res[0].length) {
- this.reLoading = 2
- } else {
- this.reLoading = 0
- }
- if(this.recurrentPage==1){
- this.classList=[]
- }
- this.classList = [...this.classList, ...res[0]]
- this.bansearchData = false
- setTimeout(() => {
- this.trigger = false;
- }, 1000);
-
- })
- },
- // 获取精品慕课
- getteaList() {
- let data = {
- openid: uni.getStorageSync('oId'),
- ty: 1,
- page: this.teacurrentPage,
- lim: 30
- }
- this.$request('/selectResource', "POST", data).then(res => {
- // console.log('获取精品慕课', res);
- if (!res[0].length) {
- this.teaLoading = 2
- } else {
- this.teaLoading = 0
- }
- if(this.teacurrentPage==1){
- this.classList2=[]
- }
- this.classList2 = [...this.classList2, ...res[0]]
- this.bansearchData = false
- setTimeout(() => {
- this.putrigger = false;
- }, 1000);
- })
- },
- // 资源库触底
- relower() {
- if (this.searchText !== '') return console.log('禁止触底');
- console.log('没触底?');
- if (this.reLoading == 2) return
- this.reLoading = 1
- this.recurrentPage++
- setTimeout(this.getreList, 1000)
- },
- // 精品慕课触底
- tealower() {
- if (this.searchText !== '') return console.log('禁止触底');
- console.log('没触底?');
- if (this.teaLoading == 2) return
- this.teaLoading = 1
- this.teacurrentPage++
- setTimeout(this.getteaList, 1000)
- },
- swipeIndex(index) {
- this.current = index.detail.current;
- if (this.searchText !== '') {
- this.selectSearchdata()
- }
- },
- // 区域滑动
- phoneLogin() {
- this.current = 0;
- },
- accountLogin() {
- this.current = 1;
- },
- costClass() {
- this.current = 2;
- }
- },
- onLoad() {
-
- },
- onShow() {
- this.recurrentPage=1
- this.teacurrentPage=1
- if (this.searchText !== '') {
- this.selectSearchdata()
- }else{
- this.getreList()
- this.getteaList()
- }
- this.getAllMessage() // 调用app.js中的方法
- // 获取收藏
- this.$refs.reso.getdata()
- this.$refs.tech.getdata()
- }
- };
- </script>
- <style lang="scss" scoped>
- .btntop {
- width: 100%;
- }
- .searchPagedata {
- width: 750rpx;
- height: 40%;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .resource {
- display: flex;
- flex-direction: column;
- height: 100vh;
- .search {
- background-color: #ffffff;
- position: relative;
- display: flex;
- width: 750rpx;
- height: 88rpx;
- justify-content: center;
- align-items: center;
- }
- .top {
- width: 100%;
- display: flex;
- justify-content: space-around;
- margin: auto;
- background-color: #ffffff;
- padding: 10px 60rpx;
- height: 98rpx;
- .info1 {
- font-weight: bold !important;
- position: relative;
- color: rgba(0, 0, 0, 0.8);
- font-size: 34rpx;
- line-height: 48rpx;
- width: 136rpx;
- height: 48rpx;
- text-align: center;
- .yun {
- width: 134rpx;
- height: 32rpx;
- position: absolute;
- left: 0;
- bottom: -10rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- }
- .info2 {
- color: rgba(0, 0, 0, 0.6);
- font-size: 34rpx;
- font-weight: 400;
- line-height: 48rpx;
- width: 136rpx;
- height: 48rpx;
- text-align: center;
- // font-family: 微软雅黑;
- }
- }
- .scroll-view-height {
- flex: 1;
- width: 100%;
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- }
- }
- </style>
|