作者 徐浩

合并代码

@@ -37,10 +37,10 @@ @@ -37,10 +37,10 @@
37 }) 37 })
38 }else{ 38 }else{
39 var identity=uni.getStorageSync('identity') 39 var identity=uni.getStorageSync('identity')
40 - uni.reLaunch({  
41 - url:'/new_tec/homePage/homePage'  
42 - })  
43 - return 40 + // uni.reLaunch({
  41 + // url:'/new_tec/homePage/homePage'
  42 + // })
  43 + // return
44 if(identity==2){ 44 if(identity==2){
45 uni.reLaunch({ 45 uni.reLaunch({
46 url:'/pages/tch_index/tch_index' 46 url:'/pages/tch_index/tch_index'
@@ -6,37 +6,50 @@ @@ -6,37 +6,50 @@
6 <view @tap="tabsClick(BIGSHOTS.AUDIOLESSONS)" :class="{'bigShots-1-1-i': true, 'bigShots-1-1-is': type === BIGSHOTS.AUDIOLESSONS}">音频课程</view> 6 <view @tap="tabsClick(BIGSHOTS.AUDIOLESSONS)" :class="{'bigShots-1-1-i': true, 'bigShots-1-1-is': type === BIGSHOTS.AUDIOLESSONS}">音频课程</view>
7 </view> 7 </view>
8 <view class="bigShots-1-2"> 8 <view class="bigShots-1-2">
  9 + <picker @change="bindpickerChange" :value="index" :range="subjectList" range-key="title">
9 <view class="bigShots-1-2-i"> 10 <view class="bigShots-1-2-i">
10 - 视频专辑 <u-icon size="12" name="arrow-down-fill" color="#646464"></u-icon> 11 + <text class="bigShots-1-2-i-t">{{ selectType.name || '请选择分类' }} </text>
  12 + <u-icon size="10" name="arrow-down-fill" color="#646464"></u-icon>
11 </view> 13 </view>
12 - <view class="bigShots-1-2-i">  
13 - 评论量 <u-icon size="12" name="arrow-down-fill" color="#646464"></u-icon> 14 + </picker>
  15 + <view class="bigShots-1-2-i" @click="setSorting(SORTINGTYPE.COMMENT)">
  16 + <text class="bigShots-1-2-i-t" v-if="currentSorting !== SORTINGTYPE.COMMENT">评论量</text>
  17 + <text class="bigShots-1-2-i-t" v-else style="color: #2d81ff;">评论量</text>
  18 +
  19 + <u-icon size="10" v-if="sortLog[SORTINGTYPE.COMMENT] !== SORTORDER.DESC" name="arrow-down-fill" :color="currentSorting !== SORTINGTYPE.COMMENT ? '#646464' : '#2d81ff'"></u-icon>
  20 + <u-icon size="10" v-else name="arrow-up-fill" :color="currentSorting !== SORTINGTYPE.COMMENT ? '#646464' : '#2d81ff'"></u-icon>
14 </view> 21 </view>
15 - <view class="bigShots-1-2-i">  
16 - 点赞量 <u-icon size="12" name="arrow-down-fill" color="#646464"></u-icon> 22 + <view class="bigShots-1-2-i" @click="setSorting(SORTINGTYPE.LIKECOUNT)">
  23 + <text class="bigShots-1-2-i-t" v-if="currentSorting !== SORTINGTYPE.LIKECOUNT">点赞量</text>
  24 + <text class="bigShots-1-2-i-t" v-else style="color: #2d81ff;">点赞量</text>
  25 +
  26 + <u-icon size="10" v-if="sortLog[SORTINGTYPE.LIKECOUNT] !== SORTORDER.DESC" name="arrow-down-fill" :color="currentSorting !== SORTINGTYPE.LIKECOUNT ? '#646464' : '#2d81ff'"></u-icon>
  27 + <u-icon size="10" v-else name="arrow-up-fill" :color="currentSorting !== SORTINGTYPE.LIKECOUNT ? '#646464' : '#2d81ff'"></u-icon>
17 </view> 28 </view>
18 </view> 29 </view>
19 </view> 30 </view>
20 <view class="bigShots-2"> 31 <view class="bigShots-2">
21 - <view class="bigShots-2-i" @click="toBigShotsDetails"> 32 + <view class="bigShots-2-i" v-for="item in list" :key="item.id" @click="toBigShotsDetails(item)">
22 <view class="bigShots-2-i-l"> 33 <view class="bigShots-2-i-l">
23 - <image class="bigShots-2-i-l-i" src="@/static/images/ewm.png"></image> 34 + <image class="bigShots-2-i-l-i" :src="item.cover"></image>
24 </view> 35 </view>
25 <view class="bigShots-2-i-r"> 36 <view class="bigShots-2-i-r">
26 - <view class="bigShots-2-i-r-1">5000题申论100题国考省考公务员考试</view> 37 + <view class="bigShots-2-i-r-1">{{ item.name }}</view>
27 <view class="bigShots-2-i-r-2"> 38 <view class="bigShots-2-i-r-2">
28 <view class="bigShots-2-i-r-2-i"> 39 <view class="bigShots-2-i-r-2-i">
29 <image class="bigShots-2-i-r-2-i-l" src="@/static/imagesV2/icon44.png" mode="widthFix"></image> 40 <image class="bigShots-2-i-r-2-i-l" src="@/static/imagesV2/icon44.png" mode="widthFix"></image>
30 - <text class="bigShots-2-i-r-2-i-t">0</text> 41 + <text class="bigShots-2-i-r-2-i-t">{{ item.comment_count }}</text>
31 </view> 42 </view>
32 <view class="bigShots-2-i-r-2-i"> 43 <view class="bigShots-2-i-r-2-i">
33 <image class="bigShots-2-i-r-2-i-l" src="@/static/imagesV2/icon45.png" mode="widthFix"></image> 44 <image class="bigShots-2-i-r-2-i-l" src="@/static/imagesV2/icon45.png" mode="widthFix"></image>
34 - <text class="bigShots-2-i-r-2-i-t">0</text> 45 + <text class="bigShots-2-i-r-2-i-t">{{ item.up_count }}</text>
35 </view> 46 </view>
36 </view> 47 </view>
37 </view> 48 </view>
38 </view> 49 </view>
  50 + <u-loadmore :status="status" v-if="!notData"/>
39 <u-empty 51 <u-empty
  52 + v-if="notData"
40 mode="data" 53 mode="data"
41 text="暂无数据" 54 text="暂无数据"
42 icon="/static/imagesV2/icon24.png" 55 icon="/static/imagesV2/icon24.png"
@@ -48,20 +61,145 @@ @@ -48,20 +61,145 @@
48 61
49 <script> 62 <script>
50 import { BIGSHOTS } from '@/emit/index.js' 63 import { BIGSHOTS } from '@/emit/index.js'
  64 + /**
  65 + * 排序方式
  66 + */
  67 + const SORTORDER = {
  68 + /**
  69 + * 升序
  70 + * @value asc
  71 + */
  72 + 'ASC': 'asc',
  73 + /**
  74 + * 降序
  75 + * @value desc
  76 + */
  77 + 'DESC': 'desc'
  78 + }
  79 + /**
  80 + * 排序类型
  81 + */
  82 + const SORTINGTYPE = {
  83 + /**
  84 + * 评论量
  85 + * @value 1
  86 + */
  87 + 'COMMENT': 'comment_count',
  88 + /**
  89 + * 点赞量
  90 + * @value 2
  91 + */
  92 + 'LIKECOUNT': 'up_count'
  93 + }
51 export default { 94 export default {
52 data() { 95 data() {
53 return { 96 return {
  97 + SORTINGTYPE,
54 BIGSHOTS, 98 BIGSHOTS,
55 - type: BIGSHOTS.VIDEOLESSONS 99 + SORTORDER,
  100 + page: 1,
  101 + sortLog: {
  102 + comment_count: SORTORDER.ASC,
  103 + up_count: SORTORDER.ASC
  104 + },
  105 + currentSorting: '',
  106 + list: [],
  107 + // 加载前值为loadmore,加载中为loading,没有数据为nomore
  108 + status: 'loadmore',
  109 + type: BIGSHOTS.VIDEOLESSONS,
  110 + subjectList: [],
  111 + selectType: {}
56 } 112 }
57 }, 113 },
  114 + computed: {
  115 + notData() {
  116 + return this.status === 'nomore' && !this.list.length
  117 + }
  118 + },
  119 + onReachBottom() {
  120 + this.getData()
  121 + },
  122 + onShow() {
  123 + this.onRetry()
  124 + this.getClass()
  125 + },
58 methods: { 126 methods: {
  127 + bindpickerChange(e) {
  128 + this.selectType = this.subjectList[e.detail.value]
  129 + this.onRetry()
  130 + },
  131 + setSorting(type) {
  132 + let result = this.sortLog[type]
  133 + if(result === SORTORDER.ASC) {
  134 + result = SORTORDER.DESC
  135 + } else {
  136 + result = SORTORDER.ASC
  137 + }
  138 + this.sortLog[type] = result
  139 + this.currentSorting = type
  140 + this.onRetry()
  141 + },
  142 + onRetry(){
  143 + this.page=1
  144 + this.list = []
  145 + this.status = 'loadmore'
  146 + this.getData()
  147 + },
  148 + getClass() {
  149 + this.$service.P_get('/course/cate', {}).then(res => {
  150 + console.log(res)
  151 + this.subjectList = res.data.map(item => {
  152 + return {
  153 + title: item.name,
  154 + id: item.id,
  155 + ...item
  156 + }
  157 + })
  158 + })
  159 + },
  160 + getData() {
  161 + if(this.status === 'loading' || this.status === 'nomore') return;
  162 + this.status = 'loading';
  163 + uni.showLoading({
  164 + title: '加载中',
  165 + mask: true
  166 + })
  167 + this.$service.P_get('/course', {
  168 + page: this.page,
  169 + order_field: this.currentSorting,
  170 + order_sort: this.currentSorting ? this.sortLog[this.currentSorting] : '',
  171 + cate_id: this.selectType.id || ''
  172 + }).then(res => {
  173 + uni.hideLoading();
  174 + if (res.code == 1) {
  175 + this.page++;
  176 + this.list = [
  177 + ...this.list,
  178 + ...res.data.data
  179 + ];
  180 + this.status = res.data.data.length < res.data.per_page ? 'nomore' : 'loadmore'
  181 + } else {
  182 + this.status = 'loadmore';
  183 + if (res.msg) {
  184 + uni.showToast({
  185 + icon: 'none',
  186 + title: res.msg
  187 + })
  188 + } else {
  189 + uni.showToast({
  190 + icon: 'none',
  191 + title: '获取数据失败'
  192 + })
  193 + }
  194 + }
  195 + })
  196 + },
59 tabsClick(type) { 197 tabsClick(type) {
60 this.type = type 198 this.type = type
61 }, 199 },
62 - toBigShotsDetails() { 200 + toBigShotsDetails(item) {
63 uni.navigateTo({ 201 uni.navigateTo({
64 - url: '/pagesStu/bigShotsDetails/bigShotsDetails' 202 + url: '/pagesStu/bigShotsDetails/bigShotsDetails?id=' + item.id
65 }) 203 })
66 // uni.navigateTo({ 204 // uni.navigateTo({
67 // url: '/pagesStu/audioFrequency/audioFrequency' 205 // url: '/pagesStu/audioFrequency/audioFrequency'
@@ -114,10 +252,14 @@ @@ -114,10 +252,14 @@
114 height: 85rpx; 252 height: 85rpx;
115 align-items: center; 253 align-items: center;
116 padding: 0 25rpx; 254 padding: 0 25rpx;
  255 + background-color: #f8f8f8;
117 .bigShots-1-2-i{ 256 .bigShots-1-2-i{
118 padding-right: 25rpx; 257 padding-right: 25rpx;
119 display: flex; 258 display: flex;
120 align-items: center; 259 align-items: center;
  260 + .bigShots-1-2-i-t{
  261 + margin-right: 10rpx;
  262 + }
121 } 263 }
122 } 264 }
123 } 265 }