basicTraining.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="training">
  3. <u-navbar back-text="" title="" back-icon-color="#FFFFFF" :background="{ background: '#3D5D4C' }" :border-bottom="false"></u-navbar>
  4. <image class="bg" src="../../static/img/basic-training-bg.png" mode="widthFix"></image>
  5. <view class="tab">
  6. <view class="tab-bg">
  7. <view class="tab-list">
  8. <view class="tab-item" v-for="(item, index) in tabs" :key="index" :class="{ active: tabIndex === index }" @click="tabChange(index)">{{
  9. item.name
  10. }}</view>
  11. </view>
  12. <view class="training-data" v-if="tabIndex === 0">
  13. <view class="training-data-item">
  14. <view>已看课程</view>
  15. <view
  16. ><text>{{ online.play }}</text
  17. >个</view
  18. >
  19. </view>
  20. <view class="training-data-item">
  21. <view>还需观看</view>
  22. <view
  23. ><text style="color: #ff7e00">{{ online.playNot }}</text
  24. >个</view
  25. >
  26. </view>
  27. </view>
  28. <view class="training-offline" v-if="tabIndex === 1">
  29. <view>未参加线下培训</view>
  30. <view>(注:必须参加线下培训才能通过适应性培训)</view>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 适应性培训 -->
  35. <view class="training-adaptability mt26" v-if="tabIndex === 0">
  36. <view class="training-adaptability-title">线上课程</view>
  37. </view>
  38. <view class="training-adaptability" v-if="tabIndex === 0">
  39. <view class="training-adaptability-list" v-if="list.length">
  40. <view class="training-adaptability-list-item" v-for="(item, index) in list" :key="index" @click="recordBrowseTotal(item)">
  41. <view class="left">
  42. <u-image :src="item.titleImg" width="198" height="144" border-radius="10"></u-image>
  43. </view>
  44. <view class="right">
  45. <view>{{ item.adaptName }}</view>
  46. <view>共{{ item.amount }}节课,已学完{{ item.finishCount }}节课,学习进度{{ item.finishPercent ? item.finishPercent : 0 }}%</view>
  47. </view>
  48. </view>
  49. </view>
  50. <view v-else>
  51. <u-empty text="暂无线上课程" mode="list"></u-empty>
  52. </view>
  53. </view>
  54. <!-- 线下培训 -->
  55. <view class="training-offline1" v-if="tabIndex === 1">
  56. <view class="training-offline1-title"> 线下培训 </view>
  57. <view class="training-offline1-list" v-if="offLineList.length">
  58. <view class="training-offline1-list-item" v-for="(item, index) in offLineList" :key="index" @click="recordBrowseTotal(item, 1)">
  59. <view class="bottom">
  60. <view>{{ item.adaptName }}</view>
  61. </view>
  62. <view class="top">
  63. <view>{{ item.adaptAddress }}</view>
  64. <view>{{ item.createTime }}</view>
  65. </view>
  66. </view>
  67. </view>
  68. <view v-else>
  69. <u-empty text="暂无线下培训" mode="list"></u-empty>
  70. </view>
  71. </view>
  72. <view class="study-status" v-if="tabIndex === 0">学习状态:{{ online.status === 0 ? '未完成' : '已完成' }}</view>
  73. <view class="study-status" v-if="tabIndex === 1">学习状态:{{ offlineStatus === 0 ? '未完成' : '已完成' }}</view>
  74. <u-toast ref="uToast" />
  75. <judge-auth ref="judgeAuth" @adoptAuth="adoptAuth" />
  76. </view>
  77. </template>
  78. <script>
  79. export default {
  80. data() {
  81. return {
  82. tabs: [{ name: '适应性培训' }, { name: '线下培训' }],
  83. tabIndex: 0,
  84. list: [],
  85. online: {
  86. status: 0,
  87. play: 0,
  88. playNot: 0
  89. },
  90. offlineStatus: 0,
  91. offLineList: []
  92. };
  93. },
  94. onShow() {
  95. this.getOnlineList(1, 200000);
  96. this.getOnlineStatus();
  97. this.getOfflineList();
  98. },
  99. methods: {
  100. // 切换菜单
  101. tabChange(index) {
  102. this.tabIndex = index;
  103. },
  104. /**
  105. * 获取在线课程
  106. * @param {Object} pageNum
  107. * @param {Object} pageSize
  108. */
  109. getOnlineList(pageNum, pageSize) {
  110. this.$u.api.training.getOnlineListApi({ pageNum, pageSize }).then((res) => {
  111. if (res.code === 200) {
  112. this.list = res.rows;
  113. } else {
  114. this.$refs.uToast.show({
  115. title: res.msg,
  116. type: 'error'
  117. });
  118. }
  119. });
  120. },
  121. /**
  122. * 获取在线课程学习状态
  123. */
  124. getOnlineStatus() {
  125. this.$u.api.training.getOnlineStatusApi().then((res) => {
  126. if (res.code === 200) {
  127. this.online.status = res.data.status;
  128. this.online.play = res.data.play;
  129. this.online.playNot = res.data.playNot;
  130. } else {
  131. this.$refs.uToast.show({
  132. title: res.msg,
  133. type: 'error'
  134. });
  135. }
  136. });
  137. },
  138. getOfflineList() {
  139. this.$u.api.training
  140. .getOfflineListApi({
  141. pageNum: 1,
  142. paheSize: 3000
  143. })
  144. .then((res) => {
  145. console.log(res);
  146. if (res.code === 200) {
  147. this.offLineList = res.rows;
  148. } else {
  149. this.$refs.uToast.show({
  150. title: res.msg,
  151. type: 'error'
  152. });
  153. }
  154. });
  155. },
  156. jumpPage(url, params) {
  157. this.$u.route({
  158. url: url,
  159. params: params
  160. });
  161. },
  162. adoptAuth(item) {
  163. this.jumpPage('/pages/basicTraining/onlineTrainingDetails/onlineTrainingDetails', { id: item.id });
  164. },
  165. /**
  166. * 适应性培训关注度统计
  167. * @param {Object} item
  168. */
  169. recordBrowseTotal(item, type) {
  170. const query = {
  171. platform: '1', // 平台:1-H5 2-APP 3-小程序 4-PC端
  172. pages: location.href, //页面路径
  173. btnName: '查看课程详情', //按钮名称
  174. btnEvent: '1', //按钮事件: 1-点击 2-长按 3-滑动
  175. ipAddress: '', //IP地址
  176. typeName: '适应性培训关注度', //类型名称 例:学校关注度 、适应性考试等
  177. typeCode: 'SYXPXGZD', // 类型编码 例:类型名称首字母缩写(XXGZD)
  178. categoryName: item.adaptName //类别名称 例:XX学校,SS考试
  179. };
  180. this.$u.api.postAnalysis(query).then((res) => {
  181. if (type === 1) {
  182. this.jumpPage('pages/basicTraining/offlineTrainingDetails/offlineTrainingDetails', { id: item.id });
  183. } else {
  184. this.$refs['judgeAuth'].modalShow(item);
  185. }
  186. });
  187. }
  188. }
  189. };
  190. </script>
  191. <style lang="scss" scoped>
  192. @import './basicTraining.scss';
  193. </style>