index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view>
  3. <view class="video_list">
  4. <view class="video_item" v-for="(item, index) in videoList">
  5. <view class="video_info">
  6. <image class="thumb_img" :src="item.thumb" mode="aspectFit"></image>
  7. <view>
  8. <view class="video_type">
  9. <text class="type_name">{{ item.type_name }}</text>
  10. </view>
  11. <view class="video_title">{{ item.name }}</view>
  12. <view class="video_time">
  13. <text class="time_info">{{ item.end_time }} </text>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="video_btn">
  18. <button class="after_exam" @click="goExam(item.id, item.report_id, item.learn_status)">
  19. {{ item.report_id > 0 ? "查看报告" : "课后评测" }}
  20. </button>
  21. <button class="to_learn" @click.stop="goDetail(item.id)">开始学习</button>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="to_bottom" v-if="!videoList.length"> -----您还没有可学习课程-----</view>
  26. <view class="contact_follow">
  27. <button class="contact_btn" @click.stop="openCustomer()">
  28. <uni-icons type="headphones" size="30" color="#FFFFFF"></uni-icons>
  29. </button>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. // 产品列表
  38. videoList: [],
  39. // 请求参数
  40. requestParam: {
  41. page: 1,
  42. status: 0,
  43. },
  44. // 是否最后一页
  45. isLast: false,
  46. // 是否请求中
  47. isReqing: false,
  48. };
  49. },
  50. onLoad() {},
  51. onShow() {
  52. // 没有数据的话,或者请求中,不允许刷新
  53. if (this.isReqing) return;
  54. // 初始化页码为1
  55. this.requestParam.page = 1;
  56. // 是否是最后一页
  57. this.isLast = false;
  58. // 设置请求中
  59. this.isReqing = true;
  60. // 请求列表
  61. this.$http.request("api/video_course/get_list", this.requestParam).then((re) => {
  62. // 设置非请求中
  63. this.isReqing = false;
  64. // 成功结果
  65. if (re.code == "success") {
  66. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  67. this.videoList = re.data.data;
  68. }
  69. });
  70. },
  71. onPullDownRefresh() {
  72. // 如果请求中,不允许请求,
  73. if (this.isReqing) return false;
  74. // 初始化页码为1
  75. this.requestParam.page = 1;
  76. // 是否是最后一页
  77. this.isLast = false;
  78. // 设置请求中
  79. this.isReqing = true;
  80. // 请求列表
  81. this.$http.request("api/video_course/get_list", this.requestParam).then((re) => {
  82. // 设置非请求中
  83. this.isReqing = false;
  84. // 成功结果
  85. if (re.code == "success") {
  86. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  87. this.videoList = re.data.data;
  88. }
  89. });
  90. uni.stopPullDownRefresh();
  91. },
  92. onReachBottom() {
  93. // 如果页码是0,避免第一页重复
  94. if (this.requestParam.page < 1) return;
  95. // 最后一页不请求
  96. if (this.isLast) return;
  97. // 请求中,不再请求
  98. if (this.isReqing) return;
  99. // 增加一页
  100. this.requestParam.page = this.requestParam.page + 1;
  101. // 设置请求中
  102. this.isReqing = true;
  103. // 请求列表
  104. this.$http.request("api/video_course/get_list", this.requestParam).then((re) => {
  105. // 设置非请求中
  106. this.isReqing = false;
  107. // 成功结果
  108. if (re.code == "success") {
  109. // 数据
  110. if (re.data.last_page <= this.requestParam.page) this.isLast = true;
  111. // 追加数据
  112. this.videoList.push(...re.data.data);
  113. }
  114. });
  115. },
  116. methods: {
  117. goDetail(id) {
  118. uni.navigateTo({
  119. url: "/pages/video/detail?id=" + id,
  120. });
  121. },
  122. openCustomer(){
  123. // #ifdef MP-WEIXIN
  124. console.log(1);
  125. wx.openCustomerServiceChat({
  126. extInfo: {url: 'https://work.weixin.qq.com/kfid/kfc5de89f024f0b8678'},
  127. corpId: 'wwcdbc686326b51a89',
  128. success(res) {}
  129. })
  130. // #endif
  131. },
  132. goExam(id, report_id, status) {
  133. if (status < 0) {
  134. uni.showToast({
  135. title: "请先完成课程再来答题吧",
  136. icon: "none",
  137. duration: 2000,
  138. });
  139. return;
  140. }
  141. if (report_id > 0) {
  142. uni.navigateTo({
  143. url: "/pages/video/record?type=exam&record_id=" + report_id,
  144. });
  145. return;
  146. }
  147. uni.navigateTo({
  148. url: "/pages/video/exam?id=" + id,
  149. });
  150. },
  151. },
  152. };
  153. </script>
  154. <style lang="less">
  155. .video_list {
  156. float: left;
  157. width: 750rpx;
  158. display: block;
  159. overflow: hidden;
  160. .video_item {
  161. display: block;
  162. width: 700rpx;
  163. overflow: hidden;
  164. margin-bottom: 10rpx;
  165. padding: 20rpx 25rpx;
  166. border-radius: 10rpx;
  167. background-color: #ffffff;
  168. .video_btn {
  169. display: flex;
  170. align-items: center;
  171. justify-content: flex-end;
  172. gap: 20rpx;
  173. margin-top: 10rpx;
  174. .to_learn {
  175. margin: 0;
  176. color: #fff;
  177. border: none;
  178. width: 140rpx;
  179. height: 50rpx;
  180. font-size: 26rpx;
  181. line-height: 50rpx;
  182. padding: 0rpx 0rpx;
  183. text-align: center;
  184. border-radius: 10rpx;
  185. background-color: #5045e6;
  186. }
  187. .to_learn::after {
  188. border: none;
  189. }
  190. .after_exam {
  191. margin: 0;
  192. color: #5045e6;
  193. border: none;
  194. width: 140rpx;
  195. height: 50rpx;
  196. font-size: 26rpx;
  197. line-height: 50rpx;
  198. padding: 0rpx 0rpx;
  199. text-align: center;
  200. border-radius: 10rpx;
  201. background-color: #fff;
  202. border: 1px solid #5045e6;
  203. }
  204. }
  205. .video_info {
  206. width: 100%;
  207. display: flex;
  208. .thumb_img {
  209. width: 200rpx;
  210. height: 200rpx;
  211. border-radius: 10rpx;
  212. margin-right: 20rpx;
  213. }
  214. .video_type {
  215. color: #999999;
  216. width: 480rpx;
  217. display: block;
  218. height: 60rpx;
  219. font-size: 26rpx;
  220. line-height: 60rpx;
  221. }
  222. .video_title {
  223. width: 480rpx;
  224. display: block;
  225. height: 80rpx;
  226. font-size: 32rpx;
  227. overflow: hidden;
  228. font-weight: bold;
  229. line-height: 40rpx;
  230. text-overflow: ellipsis;
  231. }
  232. .video_time {
  233. color: #999999;
  234. width: 480rpx;
  235. display: block;
  236. height: 60rpx;
  237. font-size: 26rpx;
  238. line-height: 60rpx;
  239. }
  240. }
  241. }
  242. }
  243. .contact_follow {
  244. bottom: 30%;
  245. right: 20rpx;
  246. width: 100rpx;
  247. height: 100rpx;
  248. display: block;
  249. position: fixed;
  250. border-radius: 50%;
  251. background-color: #1296db;
  252. .contact_btn {
  253. border: none;
  254. width: 100rpx;
  255. color: #ffffff;
  256. height: 100rpx;
  257. padding: 0rpx 0rpx;
  258. line-height: 100rpx;
  259. text-align: center;
  260. border-radius: 50%;
  261. background-color: #1296db;
  262. }
  263. .contact_btn::after {
  264. border: none;
  265. }
  266. }
  267. </style>