index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <div class="announcement">
  3. <div class="tap-part">
  4. <van-tabs
  5. v-model="active"
  6. color="#2A3980"
  7. line-width="175px"
  8. title-active-color="#2A3980"
  9. >
  10. <van-tab title="最新培训">
  11. <div class="tips-list">
  12. <div
  13. v-for="item in tipList"
  14. :class="['tip-item', item.active && 'active']"
  15. @click="selectChange(item.value)"
  16. >
  17. {{ item.label }}
  18. </div>
  19. </div>
  20. <div class="card-news-list">
  21. <div
  22. v-for="item in list"
  23. class="detail-card shadow-radius news-card"
  24. @click="getDetail(item)"
  25. >
  26. <div class="image">
  27. <img :src="item.annexArray[0]" alt=""/>
  28. </div>
  29. <div class="info-part">
  30. <div class="top">
  31. <p class="text">{{ item.trainTitle }}</p>
  32. <span
  33. v-if="item.onlineOfflineStatus === '线下'"
  34. class="tip-grid-bg"
  35. >线下</span
  36. >
  37. <span v-else class="tip-grid-bg red">线上</span>
  38. </div>
  39. <div class="bottom">
  40. <div
  41. v-if="
  42. item.onlineOfflineStatus === '线下' &&
  43. item.registrationStatus === '1'
  44. "
  45. class="left"
  46. >
  47. <span class="normal-tip by y-bg" style="text-align: center"
  48. >报名中</span
  49. >
  50. </div>
  51. <div
  52. v-if="
  53. item.onlineOfflineStatus === '线下' &&
  54. item.registrationStatus === '2'
  55. "
  56. class="left"
  57. >
  58. <span class="normal-tip by h-bg" style="text-align: center"
  59. >报名已结束</span
  60. >
  61. </div>
  62. <div
  63. v-if="
  64. item.onlineOfflineStatus === '线上' &&
  65. item.trainStatus === '2'
  66. "
  67. class="left"
  68. >
  69. <span class="normal-tip by z-bg" style="text-align: center"
  70. >可观看</span
  71. >
  72. </div>
  73. <div class="right">
  74. <div class="num">{{ item.partakeNumber }}人参与</div>
  75. <div
  76. class="icon-collect"
  77. @click.stop="changeCollectorsStatus(item)"
  78. >
  79. <i
  80. v-if="item.collectorsStatus === '2'"
  81. class="iconfont icon-wujiaoxingxingxingshoucangdianji blue"
  82. ></i>
  83. <i
  84. v-else
  85. class="iconfont icon-wujiaoxingxingxingshoucangdianji"
  86. ></i>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </van-tab>
  94. <van-tab title="报名记录">
  95. <div class="card-news-list">
  96. <div
  97. v-for="item1 in regisSignList"
  98. class="record-card shadow-radius"
  99. >
  100. <div class="left">
  101. <img :src="item1.annexArray[0]" alt=""/>
  102. <p class="text">请出示二维码签到</p>
  103. </div>
  104. <div class="right">
  105. <div class="title">{{ item1.trainTitle }}</div>
  106. <div class="time">时间:{{ item1.trainStartTime }}开始</div>
  107. <div class="add">
  108. <p>地址:{{ item1.trainAddress }}</p>
  109. </div>
  110. <div class="bottom">
  111. <p
  112. v-if="item1.registrationStatus === '1'"
  113. class="normal-tip by y-bg"
  114. style="text-align: center"
  115. >
  116. 报名中
  117. </p>
  118. <p
  119. v-else
  120. class="normal-tip by h-bg"
  121. style="text-align: center"
  122. >
  123. 已结束
  124. </p>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. </van-tab>
  130. </van-tabs>
  131. </div>
  132. </div>
  133. </template>
  134. <script>
  135. import Base from '@/pages/base/base'
  136. import auth from '@/service/auth'
  137. import { clickCollect, list, listRegisSignInfo } from '@/service/api_train'
  138. export default {
  139. name: 'ParkTraining',
  140. mixins: [Base],
  141. data() {
  142. return {
  143. url: process.env.VUE_APP_API_URL,
  144. active: 0,
  145. dc_key: ['trainType'],
  146. userId: '',
  147. tipList: [],
  148. search: {
  149. trainType: '',
  150. userId: '',
  151. publishStatus: '2'
  152. },
  153. list: [],
  154. regisSignList: []
  155. }
  156. },
  157. mounted() {
  158. this.userId = auth.uid()
  159. this.initDict(this.dc_key).then((res) => {
  160. this.tipList = this.dc_data.trainType
  161. this.getData()
  162. this.getRegisSignInfo()
  163. })
  164. },
  165. methods: {
  166. getData() {
  167. const _this = this
  168. this.search.userId = this.userId
  169. list(this.search).then((res) => {
  170. _this.list = res
  171. _this.list.forEach((e) => {
  172. e.annexArray[0] = e.annexArray[0].replace(
  173. '/webServer/FileController/download/',
  174. process.env.VUE_APP_API_URL + '/FileController/download/'
  175. )
  176. })
  177. })
  178. },
  179. getRegisSignInfo() {
  180. const _this = this
  181. listRegisSignInfo({ userId: this.userId, referenceType: '2' })
  182. .then((res) => {
  183. _this.regisSignList = res
  184. _this.regisSignList.forEach((item) => {
  185. console.log(this.url)
  186. item.annexArray[0] = item.annexArray[0].replace(
  187. '/server/FileController/download/',
  188. process.env.VUE_APP_API_URL + '/FileController/download/'
  189. )
  190. item.trainStartTime = this.$common.transBaseDateTime(
  191. item.trainStartTime
  192. )
  193. })
  194. console.log(_this.regisSignList)
  195. })
  196. .catch(() => {
  197. })
  198. },
  199. selectChange(value) {
  200. let tel = true
  201. this.tipList.forEach((i) => {
  202. if (i.value === value) {
  203. if (i.active) {
  204. tel = false
  205. } else {
  206. i.active = true
  207. }
  208. } else {
  209. i.active = false
  210. }
  211. })
  212. if (tel) {
  213. this.search.trainType = value
  214. this.getData()
  215. }
  216. },
  217. getDetail(val) {
  218. if (val.onlineOfflineStatus === '线下') {
  219. this.$router.push({
  220. path: '/parkTraining/detail',
  221. query: {
  222. // 这里面是写需要传送的值
  223. id: val.id
  224. }
  225. })
  226. } else {
  227. this.$router.push({
  228. path: '/parkTraining/onlineDetail',
  229. query: {
  230. // 这里面是写需要传送的值
  231. id: val.id
  232. }
  233. })
  234. }
  235. },
  236. changeCollectorsStatus(val) {
  237. if (val.collectorsStatus === '2') {
  238. const _this = this
  239. clickCollect({
  240. id: val.id,
  241. userId: auth.currUser().id,
  242. collectorsStatus: '1'
  243. }).then((res) => {
  244. _this.getData()
  245. _this.getRegisSignInfo()
  246. })
  247. } else {
  248. const _this = this
  249. clickCollect({
  250. id: val.id,
  251. userId: auth.currUser().id,
  252. collectorsStatus: '2'
  253. }).then((res) => {
  254. _this.getData()
  255. _this.getRegisSignInfo()
  256. })
  257. }
  258. }
  259. }
  260. }
  261. </script>
  262. <style lang="scss" scoped type="text/scss">
  263. .announcement {
  264. box-sizing: border-box;
  265. .tap-part {
  266. margin-top: 10px;
  267. height: calc(100vh - 10px);
  268. .van-tabs {
  269. height: 100%;
  270. }
  271. .info-list {
  272. height: calc(100vh - 92px);
  273. background-color: #fff;
  274. padding: 0 20px;
  275. overflow-y: auto;
  276. }
  277. }
  278. }
  279. //头部标签
  280. .tips-list {
  281. margin-top: 20px;
  282. @include flex;
  283. flex-wrap: wrap;
  284. .tip-item {
  285. width: 120px;
  286. margin: 0 15px 20px;
  287. text-align: center;
  288. line-height: 40px;
  289. font-size: 24px;
  290. color: #fff;
  291. border-radius: 4px;
  292. background-color: rgba(215, 215, 215, 1);
  293. }
  294. .active {
  295. background-color: $main;
  296. }
  297. }
  298. .card-news-list {
  299. box-sizing: border-box;
  300. overflow-y: auto;
  301. height: calc(100vh - 240px);
  302. padding: 20px 20px;
  303. .news-card {
  304. margin-bottom: 10px;
  305. }
  306. .record-card {
  307. margin-bottom: 10px;
  308. height: 346px;
  309. background-color: #fff;
  310. padding: 20px 30px;
  311. box-sizing: border-box;
  312. @include flex;
  313. .left {
  314. display: flex;
  315. flex-direction: column;
  316. justify-content: space-between;
  317. height: 100%;
  318. img {
  319. width: 244px;
  320. }
  321. .text {
  322. margin-bottom: 10px;
  323. text-align: center;
  324. font-size: 16px;
  325. color: $color4;
  326. }
  327. }
  328. .right {
  329. display: flex;
  330. flex-direction: column;
  331. justify-content: space-between;
  332. text-align: center;
  333. font-size: 24px;
  334. height: 100%;
  335. color: $color4;
  336. padding-left: 100px;
  337. .title {
  338. font-weight: 700;
  339. margin-top: 20px;
  340. }
  341. .time {
  342. }
  343. .add {
  344. p {
  345. word-break: break-word;
  346. }
  347. }
  348. .bottom {
  349. text-align: right;
  350. }
  351. }
  352. }
  353. }
  354. </style>