index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <view class="main">
  3. <navbar :config="config" backColor="#666"></navbar>
  4. <swiper class="swiper" circular indicator-dots autoplay>
  5. <swiper-item v-for="(item,index) in bannerList" :key="index">
  6. <image @click="imgLink(item.model_type, item.model_id, item.url, item.shop_id)" class="cover" :src="item.cover"></image>
  7. </swiper-item>
  8. </swiper>
  9. <view class="content">
  10. <view class="history" v-if="recentList.length>0">
  11. <view class="title-box">
  12. <view class="title">最近观看</view>
  13. <view class="right" @click="goMore">
  14. <text>查看更多</text>
  15. <text class="iconfont2">&#xe65f;</text>
  16. </view>
  17. </view>
  18. <scroll-view class="list" scroll-x @scroll="scroll">
  19. <!-- <scroll-view></scroll-view> -->
  20. <view class="item" v-for="(item,index) in recentList" :key="index" @click="goDetail(item)">
  21. <view class="tag" v-if="item.has_vip">会员课程</view>
  22. <image class="cover" :src="item.study_url" mode="aspectFill"></image>
  23. <view class="box">
  24. <view class="desc">{{item.study_name}}</view>
  25. <view class="author"><text class="label">讲师:</text>{{item.study_teacher}}</view>
  26. <view class="count">
  27. <text class="iconfont2">&#xe709;</text>
  28. <text class="num">学习人次:{{item.studying_count}}次</text>
  29. <text style="color: transparent;height: 1px;">{{timeStamp}}</text>
  30. </view>
  31. </view>
  32. </view>
  33. </scroll-view>
  34. </view>
  35. <u-tabs :list="classList" name="study_type_name" :current="classIndex" @change="changeClass"
  36. active-color="#22A834" font-size="30" :style="`top: calc(${statusBarHeight}px + 44px)`"></u-tabs>
  37. <view class="class-list">
  38. <view class="item-box" v-for="(item,index) in list" :key="index">
  39. <view class="item" @click="goDetail(item)">
  40. <view class="tag" v-if="item.has_vip">会员专享</view>
  41. <image class="cover" :src="item.study_url" mode="aspectFill"></image>
  42. <view class="box">
  43. <view class="desc">{{item.study_name}}</view>
  44. <view class="author"><text class="label">讲师:</text>{{item.study_teacher}}</view>
  45. <view class="count">
  46. <text class="iconfont2">&#xe709;</text>
  47. <text class="num">学习人次:{{item.studying_count}}次</text>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view>
  54. <noData v-if="list<=0"></noData>
  55. <u-loadmore v-else :status="status" />
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import noData from "@/components/noData/nodata.vue"
  62. export default {
  63. components:{noData},
  64. data() {
  65. return {
  66. //手机状态栏高度
  67. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  68. config: {
  69. back: true,
  70. title: '公益讲堂',
  71. color: '1a1a1a',
  72. backgroundColor: [1, "#fff"],
  73. statusBarFontColor: 'black'
  74. },
  75. param: {
  76. page: 1,
  77. limit: 10
  78. },
  79. bannerList: [],
  80. classList: [],
  81. classIndex: 0,
  82. recentList: [],
  83. list: [],
  84. totalCount:0,
  85. status:"nomore", //加载前值为loadmore,加载中为loading,没有数据为nomore
  86. timeStamp:null,//时间戳
  87. }
  88. },
  89. onLoad() {
  90. this.getRecentList();
  91. this.getClassList();
  92. this.getBanner();
  93. },
  94. onPullDownRefresh() {
  95. this.param.page = 1;
  96. this.list = [];
  97. this.totalCount = 0;
  98. this.getRecentList();
  99. this.getClassList();
  100. this.getBanner();
  101. uni.stopPullDownRefresh();
  102. },
  103. onReachBottom(){
  104. if(this.status=='loadmore'){
  105. this.param.page++
  106. this.getList()
  107. }
  108. },
  109. methods: {
  110. getBanner(){
  111. this.$http.get('/ad/ad/getByCode/forum-banner',{})
  112. .then(res=>{
  113. if (res.code == 200) {
  114. this.bannerList = res.list;
  115. }
  116. })
  117. },
  118. changeClass(index) {
  119. this.classIndex = index;
  120. this.param.study_type = this.classList[index].id
  121. this.getList('reset')
  122. },
  123. goDetail(item) {
  124. uni.navigateTo({
  125. url: '/pages/learningClassroom/detail?id='+item.id
  126. })
  127. },
  128. // 最近观看列表
  129. getRecentList() {
  130. this.$http.get('/studying/studyingLately/6').then(res => {
  131. if (res && res.code == 200) {
  132. this.recentList = res.list
  133. }
  134. })
  135. },
  136. // 分类列表
  137. getClassList() {
  138. // /studyingtype/getAllStudy
  139. // /studyingtype/getFirstSelect
  140. this.$http.get('/studyingtype/getFirstSelect').then(res => {
  141. if (res && res.code == 200) {
  142. this.classList = res.data;
  143. this.param.study_type = this.classList[0].id
  144. this.getList()
  145. }
  146. })
  147. },
  148. // 获取课程列表
  149. getList(reset) {
  150. if (reset) this.param.page = 1;
  151. this.status='loading';
  152. this.$http.get('/studying/list', this.param).then(res => {
  153. if (res && res.code == 200) {
  154. if (reset) this.list = []
  155. this.list.push(...res.page.list);
  156. this.totalCount=res.page.totalCount;
  157. if(this.list.length<this.totalCount) this.status='loadmore';
  158. else this.status='nomore';
  159. }
  160. })
  161. },
  162. scroll(e){
  163. this.timeStamp=e.timeStamp
  164. },
  165. goMore(){
  166. uni.navigateTo({
  167. url:"/pages/learningClassroom/recentWatching"
  168. })
  169. },
  170. /**轮播图跳转 */
  171. imgLink(type, id, url, shopid) {
  172. if (type == "goods") {
  173. uni.navigateTo({
  174. url: "/pages/product/goods/goods?id=" + id + "&shopid=" + shopid,
  175. });
  176. } else if (type == "service") {
  177. // uni.navigateTo({
  178. // url: "/pages/product/goods/serviceGood?id=" + id
  179. // });
  180. } else if (type == "point_goods") {
  181. // uni.navigateTo({
  182. // url: "/pages/product/goods/IntegralGood?id=" + id
  183. // });
  184. } else if (type == "url") {
  185. if(/^http/.test(url)){
  186. uni.navigateTo({
  187. url: "/pages/index/webView?linkUrl=" + url,
  188. });
  189. }else{
  190. uni.navigateTo({
  191. url
  192. });
  193. }
  194. }
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss" scoped>
  200. .main {
  201. min-height: 100vh;
  202. background-color: #fdfdfd;
  203. .cover {
  204. width: 100%;
  205. height: 340rpx;
  206. background-color: #f2f2f2;
  207. }
  208. .content {
  209. padding: 40rpx 0;
  210. .history {
  211. padding: 0 30rpx;
  212. margin-bottom: 40rpx;
  213. .title-box {
  214. display: flex;
  215. justify-content: space-between;
  216. align-items: center;
  217. margin-bottom: 27rpx;
  218. .title {
  219. font-size: 36rpx;
  220. font-family: PingFang SC, PingFang SC-Bold;
  221. font-weight: 700;
  222. text-align: left;
  223. color: #1a1a1a;
  224. }
  225. .right {
  226. .more-text {
  227. font-size: 24rpx;
  228. font-family: PingFang SC, PingFang SC-Regular;
  229. font-weight: 400;
  230. text-align: right;
  231. color: #333333;
  232. }
  233. .iconfont2 {
  234. font-size: 27rpx;
  235. }
  236. }
  237. }
  238. .list {
  239. // overflow-x: auto;
  240. overflow-y: hidden;
  241. white-space: nowrap;
  242. padding-bottom: 4rpx;
  243. .item {
  244. display: inline-block;
  245. width: 317rpx;
  246. border-radius: 16rpx;
  247. overflow: hidden;
  248. margin-right: 20rpx;
  249. background-color: white;
  250. filter: drop-shadow(2rpx 4rpx 8rpx rgba(26, 58, 70, 0.1));
  251. box-shadow: 0rpx 4rpx 8rpx 0rpx #f1f1f1;
  252. position: relative;
  253. .tag {
  254. background: #138e46;
  255. color: white;
  256. border-radius: 0px 16rpx 0px 16rpx;
  257. padding: 0 10rpx;
  258. height: 41rpx;
  259. width: fit-content;
  260. line-height: 41rpx;
  261. font-size: 24rpx;
  262. position: absolute;
  263. top: 0;
  264. right: 0;
  265. z-index: 1;
  266. }
  267. .cover {
  268. width: 317rpx;
  269. height: 292rpx;
  270. background-color: #f2f2f2;
  271. }
  272. .box {
  273. padding: 5rpx 26rpx 38rpx 26rpx;
  274. .desc {
  275. font-size: 24rpx;
  276. font-family: PingFang SC, PingFang SC-Regular;
  277. font-weight: 400;
  278. text-align: left;
  279. color: #333333;
  280. line-height: 36rpx;
  281. height: 72rpx;
  282. margin-bottom: 5rpx;
  283. white-space: normal;
  284. overflow: hidden;
  285. text-overflow: ellipsis;
  286. display: -webkit-box;
  287. -webkit-line-clamp: 2;
  288. -webkit-box-orient: vertical;
  289. }
  290. .author {
  291. font-size: 24rpx;
  292. font-family: PingFang SC, PingFang SC-Regular;
  293. font-weight: 400;
  294. color: #808080;
  295. line-height: 34rpx;
  296. .label {
  297. color: #1a1a1a;
  298. }
  299. }
  300. .count {
  301. .iconfont2 {
  302. font-size: 35rpx;
  303. color: #2DB62B;
  304. vertical-align: middle;
  305. }
  306. .num {
  307. font-size: 24rpx;
  308. font-family: PingFang SC, PingFang SC-Regular;
  309. font-weight: 400;
  310. text-align: left;
  311. color: #999999;
  312. line-height: 24rpx;
  313. vertical-align: middle;
  314. }
  315. }
  316. }
  317. }
  318. }
  319. }
  320. }
  321. .u-tabs {
  322. position: sticky;
  323. top: 0;
  324. z-index: 50;
  325. }
  326. .class-list {
  327. display: flex;
  328. justify-content: space-between;
  329. padding: 27rpx 30rpx 30rpx 30rpx;
  330. flex-wrap: wrap;
  331. .item-box {
  332. width: 336rpx;
  333. }
  334. .item {
  335. display: block;
  336. width: 100%;
  337. border-radius: 16rpx;
  338. overflow: hidden;
  339. margin: 0 20rpx 35rpx 0;
  340. background-color: white;
  341. filter: drop-shadow(1px 2px 4px rgba(26, 58, 70, 0.1));
  342. box-shadow: 0rpx 4rpx 8rpx 0rpx #f1f1f1;
  343. position: relative;
  344. .tag {
  345. background: #138e46;
  346. color: white;
  347. border-radius: 0px 16rpx 0px 16rpx;
  348. padding: 0 10rpx;
  349. height: 41rpx;
  350. width: fit-content;
  351. line-height: 41rpx;
  352. font-size: 24rpx;
  353. position: absolute;
  354. top: 0;
  355. right: 0;
  356. z-index: 1;
  357. }
  358. .cover {
  359. width: 100%;
  360. height: 240rpx;
  361. background-color: #f2f2f2;
  362. }
  363. .box {
  364. padding: 5rpx 26rpx 38rpx 26rpx;
  365. .desc {
  366. font-size: 24rpx;
  367. font-family: PingFang SC, PingFang SC-Regular;
  368. font-weight: 400;
  369. text-align: left;
  370. color: #333333;
  371. line-height: 36rpx;
  372. height: 72rpx;
  373. margin-bottom: 5rpx;
  374. white-space: normal;
  375. }
  376. .author {
  377. font-size: 24rpx;
  378. font-family: PingFang SC, PingFang SC-Regular;
  379. font-weight: 400;
  380. color: #808080;
  381. line-height: 34rpx;
  382. .label {
  383. color: #1a1a1a;
  384. }
  385. }
  386. .count {
  387. .iconfont2 {
  388. font-size: 35rpx;
  389. color: #2DB62B;
  390. vertical-align: middle;
  391. }
  392. .num {
  393. font-size: 24rpx;
  394. font-family: PingFang SC, PingFang SC-Regular;
  395. font-weight: 400;
  396. text-align: left;
  397. color: #999999;
  398. line-height: 24rpx;
  399. vertical-align: middle;
  400. }
  401. }
  402. }
  403. }
  404. }
  405. }
  406. .no-data-view{
  407. margin-top:20rpx !important;
  408. }
  409. /deep/ .u-scroll-box >view{
  410. border-bottom: 1rpx solid #e6e6e6;
  411. }
  412. </style>