skillsTraining.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <!-- 技能培训 -->
  2. <template>
  3. <view class="training">
  4. <u-navbar back-text="" title="" back-icon-color="#FFFFFF" :background="{ background: '#3D5D4C' }"
  5. :border-bottom="false"></u-navbar>
  6. <!-- banner -->
  7. <view class="training-banner">
  8. <u-swiper v-if="bannerList.length" :list="bannerList" name="bannerUrl" border-radius="0" mode="round"
  9. height="380" img-mode="scaleToFill" :mode="bannerList.length > 1 ? 'round' : 'none'"></u-swiper>
  10. <image v-else src="../../static/img/banner-skillsTraining.png" mode="aspectFill"></image>
  11. </view>
  12. <view class="training-total" @click="jumpPage('/pages/mine/skillsTraining/skillsTraining')" v-if="isAddClass">
  13. <view class="training-total-left">
  14. <view>我的技能培训</view>
  15. <view>学习时长:{{ skillTotal.learnTime ? (Number(skillTotal.learnTime) / 3600).toFixed(2) : 0 }}小时</view>
  16. </view>
  17. <view class="training-total-right">
  18. <u-icon name="arrow-right" size="44" color="#666"></u-icon>
  19. </view>
  20. </view>
  21. <view class="training-total" v-else>
  22. <view class="training-total-left">
  23. <view>您还未报班</view>
  24. </view>
  25. </view>
  26. <!-- 报班通知 -->
  27. <view class="training-notice">
  28. <template v-if="enrollList.length">
  29. <view class="training-notice-title">
  30. <view>报班通知</view>
  31. <view @click="jumpPage('pages/skillsTraining/registrationNotice/registrationNotice')">
  32. <text>更多</text>
  33. <u-icon name="arrow-right"></u-icon>
  34. </view>
  35. </view>
  36. <view class="training-notice-content">
  37. <swiper class="swiper" :indicator-dots="true" :autoplay="false" :interval="1000" :duration="500"
  38. indicator-color="#D8D8D8" indicator-active-color="#D8D8D8">
  39. <swiper-item v-for="(item, index) in enrollList" :key="index">
  40. <view class="swiper-item">
  41. <view class="left">
  42. <u-image :src="item.img" mode="aspectFill" border-radius="10" height="220"
  43. width="204">
  44. <view slot="error">
  45. <u-image src="../../static/img/no-image.png" width="204" height="220"
  46. border-radius="10" mode="aspectFill" />
  47. </view>
  48. </u-image>
  49. </view>
  50. <view class="right">
  51. <view class="item">{{ item.name }}</view>
  52. <view class="item">{{ item.schoolName }}</view>
  53. <view class="item">
  54. <u-parse :html="item.description"></u-parse>
  55. </view>
  56. <view class="btn" @click="signUp(item)">报名</view>
  57. </view>
  58. </view>
  59. </swiper-item>
  60. </swiper>
  61. </view>
  62. </template>
  63. </view>
  64. <!-- 技能包 -->
  65. <view class="training-package">
  66. <view class="training-package-title">
  67. <view>技能包</view>
  68. <!-- <view>
  69. <text>更多</text>
  70. <u-icon name="arrow-right"></u-icon>
  71. </view> -->
  72. </view>
  73. <view class="training-package-list">
  74. <view class="training-package-list-item" v-for="(item, index) in packageList" :key="index"
  75. @click="recordBrowseTotal(item)">
  76. <view class="border-1">
  77. <u-image :src="item.img" mode="aspectFill" border-radius="10" height="180" width="294">
  78. <view slot="error">
  79. <u-image src="../../static/img/no-image.png" height="190" width="300" border-radius="10"
  80. mode="aspectFill" />
  81. </view>
  82. </u-image>
  83. </view>
  84. <view>{{ item.name }}</view>
  85. <view>{{ item.schoolName }}</view>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- 问题咨询 -->
  90. <view class="training-bottom" @click="questionAsk">问题咨询</view>
  91. <u-toast ref="uToast" />
  92. <judge-auth ref="judgeAuth" @adoptAuth="adoptAuth" />
  93. </view>
  94. </template>
  95. <script>
  96. export default {
  97. data() {
  98. return {
  99. enrollList: [],
  100. packageList: [],
  101. skillTotal: {},
  102. isAddClass: false,
  103. bannerList: []
  104. }
  105. },
  106. onShow() {
  107. this.getPackageList();
  108. this.getClassNoticeList();
  109. this.getTrainingTotal();
  110. this.queryIsAttendedClass();
  111. this.getBannerList();
  112. },
  113. methods: {
  114. getBannerList() {
  115. this.$u.api.indexApi.indexBannerListApi({
  116. type: 4
  117. }).then(res => {
  118. if (res?.code === 200) {
  119. this.bannerList = res.data;
  120. }
  121. })
  122. },
  123. /**
  124. * 查询是否报过班
  125. */
  126. queryIsAttendedClass() {
  127. this.$u.api.skillTraining.queryIsAttendedClassApi().then(res => {
  128. if (res.code === 200) {
  129. console.log(res)
  130. if (res.data > 0) {
  131. this.isAddClass = true
  132. }
  133. }
  134. })
  135. },
  136. /**
  137. * 获取技能包列表
  138. */
  139. getPackageList() {
  140. this.$u.api.skillTraining.getSkillPackageListApi().then(res => {
  141. if (res.code === 200) {
  142. this.packageList = res.rows
  143. }
  144. })
  145. },
  146. /**
  147. * 获取报班通知列表
  148. */
  149. getClassNoticeList() {
  150. this.$u.api.skillTraining.getClassNoticeApi({
  151. pageNum: 1,
  152. pageSize: 5
  153. }).then(res => {
  154. if (res.code === 200) {
  155. this.enrollList = res.rows;
  156. }
  157. })
  158. },
  159. /**
  160. * 获取个人技能培训统计
  161. */
  162. getTrainingTotal() {
  163. this.$u.api.skillTraining.getTrainingTotalApi().then(res => {
  164. if (res.code === 200) {
  165. this.skillTotal = res.data
  166. }
  167. })
  168. },
  169. /**
  170. * 适应性培训关注度统计
  171. * @param {Object} item
  172. */
  173. recordBrowseTotal(item) {
  174. const query = {
  175. platform: '1', // 平台:1-H5 2-APP 3-小程序 4-PC端
  176. pages: location.href, // 页面路径
  177. btnName: '查看技能包详情', // 按钮名称
  178. btnEvent: '1', //按钮事件: 1-点击 2-长按 3-滑动
  179. ipAddress: '', //IP地址
  180. typeName: '技能培训关注度', //类型名称 例:学校关注度 、适应性考试等
  181. typeCode: 'JNPXGZD', // 类型编码 例:类型名称首字母缩写(XXGZD)
  182. categoryName: item.name, //类别名称 例:XX学校,SS考试
  183. }
  184. this.$u.api.postAnalysis(query).then(res => {
  185. this.jumpPage('/pages/skillsTraining/skillsPackage/skillsPackage', {
  186. id: item.id,
  187. schoolName: item.schoolName
  188. })
  189. })
  190. },
  191. /**
  192. * 跳转到指定页面
  193. * @param { String } url
  194. * @param {Object} parmas
  195. */
  196. jumpPage(url, params) {
  197. this.$u.route({
  198. url,
  199. params
  200. })
  201. },
  202. /**
  203. * 报名
  204. * @param {Object} item
  205. */
  206. signUp(item) {
  207. this.$refs['judgeAuth'].modalShow(item)
  208. },
  209. adoptAuth(item) {
  210. this.$u.api.skillTraining.signUpClassApi({
  211. packageId: item.id
  212. }).then(res => {
  213. if (res.code === 200) {
  214. this.jumpPage('/pages/skillsTraining/submitSuccess/submitSuccess');
  215. } else {
  216. this.$refs.uToast.show({
  217. title: res.msg,
  218. type: 'error'
  219. })
  220. }
  221. })
  222. },
  223. /**
  224. * 问题咨询
  225. */
  226. questionAsk() {
  227. let url =
  228. `${this.config.timChatUrl}?userID=${this.vuex_user.userId}&title=问题咨询&permission=2&type=retire`
  229. this.$u.route({
  230. url: '/pages/webView/webView',
  231. params: {
  232. url: encodeURIComponent(url)
  233. }
  234. })
  235. }
  236. }
  237. }
  238. </script>
  239. <style lang="scss" scoped>
  240. @import './skillsTraining.scss';
  241. </style>