mineCollNew.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. <template>
  2. <view class="mineCollNew">
  3. <statusBar :item="navBarData"></statusBar>
  4. <!-- 消息提示 -->
  5. <msgPop></msgPop>
  6. <view class="top">
  7. <view class="left" @click="acpag" :class="current == 0 ? info1 : info2">
  8. <text class="">活动</text>
  9. <view v-if="current == 0" class="yun">
  10. <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 10.png"
  11. mode="aspectFill"></image>
  12. </view>
  13. </view>
  14. <view class="right" @click="clapag" :class="current == 1 ? info1 : info2">
  15. <text class="">课程</text>
  16. <view v-if="current == 1" class="yun">
  17. <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 10.png"
  18. mode="aspectFill"></image>
  19. </view>
  20. </view>
  21. </view>
  22. <swiper class="scroll-view-height" @change="swipeIndex" :current="current" :duration="300">
  23. <swiper-item>
  24. <scroll-view scroll-y="true" @scrolltolower="lower" style="height: 100%;">
  25. <view class="">
  26. <view class="classListFlex" v-if="aclist.length==0">
  27. </view>
  28. <view class="listBlock1" v-for="(i,index) in aclist" :key="i.acId" @click="gotoDetail"
  29. :data-aid="i.acId">
  30. <view class="img cell-img">
  31. <image :src="i.pic" mode="aspectFill"></image>
  32. <image class="star" @click.stop="coll" :data-e="i" :src="pic_coll2" mode=""></image>
  33. </view>
  34. <view class="right">
  35. <view class="title">
  36. <view class="bqZ-font" style="font-size: 20rpx;"
  37. :class="i.acshape=='线下活动'?'tag':'tag1'"> {{i.acshape}}</view>
  38. <view class="titTxt btn-font " style="font-size:34rpx ;">
  39. {{i.acName}}
  40. </view>
  41. </view>
  42. <view class="introduce">
  43. <view class="bri">
  44. 深圳职业技术大学
  45. <!-- {{ i.address }} -->
  46. </view>
  47. <view class="tim">
  48. {{ i.create_at }}
  49. </view>
  50. </view>
  51. <view class="operate">
  52. <view class="left">
  53. <view class="add fz-font">已报名{{i.bnum}}人</view>
  54. </view>
  55. <view class="Oright">
  56. <view class="text">{{ i.signNum?'已报名':'报名' }}</view>
  57. <view class="arrow">
  58. <image
  59. src="https://teacherapi.cocorobo.cn/teaching-file/static/mine/arrow-right-blue.png"
  60. mode="aspectFill"></image>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="loading">
  68. <view v-if="newsLoading==1">数据加载中...</view>
  69. <view v-if="newsLoading==2">没有更多了~~</view>
  70. </view>
  71. </scroll-view>
  72. </swiper-item>
  73. <swiper-item>
  74. <scroll-view scroll-y="true" @scrolltolower="cllower" style="height: 100%;">
  75. <view class="classListFlex">
  76. <view class="cont" @click="gotoWeb" v-for="(item, index) in classlist" :index="index"
  77. :key="i.cid" :data-kid="item.href">
  78. <image class="star" :src="pic_coll2" @click.stop="collcl" :data-e="item" mode="aspectFill">
  79. </image>
  80. <image class="img" :src="item.img" mode="aspectFill" />
  81. <view class="tit btn-font">{{ item.ctit }}</view>
  82. <!-- <view class="teacher fz-font">{{ item.school }}</view> -->
  83. </view>
  84. </view>
  85. <view class="loading">
  86. <view v-if="clLoading==1">数据加载中...</view>
  87. <view v-if="clLoading==2">没有更多了~~</view>
  88. </view>
  89. </scroll-view>
  90. </swiper-item>
  91. </swiper>
  92. <!-- <view class="" style="height: 68rpx;width: 750rpx;">
  93. </view> -->
  94. </view>
  95. </template>
  96. <script>
  97. export default {
  98. data() {
  99. return {
  100. navBarData: {
  101. title: '我的收藏',
  102. btn: 1
  103. },
  104. current: 0, //课程活动切换
  105. info1: "info1", //类名
  106. info2: "info2",
  107. aclist: [], //活动数据list
  108. classlist: [], //课程数据list
  109. // // 收藏活动list
  110. // collArr: [],
  111. // // 收藏课程list
  112. // collArrcl: [],
  113. // 触底加载动画提示
  114. newsLoading: 0, //0默认值 1加载中 2没有更多了
  115. currentPage: 1,
  116. clLoading: 0, //0默认值 1加载中 2没有更多了
  117. clcurrentPage: 1,
  118. pic_coll: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/Vstar21707269669382.png',
  119. pic_coll2: 'https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/VStar1707269577778.png',
  120. };
  121. },
  122. methods: {
  123. // 获取活动数据
  124. getData() {
  125. let data = {
  126. oid: this.$store.state.user.openid, //用户id
  127. type: 0,
  128. page: this.currentPage, //下拉获取更多的备用字段
  129. lim: 30 //一次获取多少数据
  130. }
  131. console.log('data', data);
  132. this.$request('/selectCollAcList', 'POST', data).then(res => {
  133. console.log('获取活动数据', res);
  134. if (this.currentPage == 1) {
  135. this.aclist = [] //活动数据list
  136. }
  137. if (!res[0].length) {
  138. this.newsLoading = 2
  139. } else {
  140. this.newsLoading = 0
  141. }
  142. this.aclist = [...this.aclist, ...res[0]]
  143. })
  144. },
  145. // 获取课程数据
  146. getTeachData() {
  147. // console.log('触发课程收藏事件');
  148. let data = {
  149. oid: this.$store.state.user.openid, //用户id
  150. type: 1,
  151. page: this.clcurrentPage, //下拉获取更多的备用字段
  152. lim: 30 //一次获取多少数据
  153. }
  154. this.$request('/selectOperatorTech', 'POST', data).then(res => {
  155. console.log('获取课程数据', res);
  156. // 每次调用前清零,防止push叠加错误
  157. // this.classlist = []
  158. if (this.clcurrentPage == 1) {
  159. this.classlist = [] //课程数据list
  160. }
  161. if (!res[0].length) {
  162. this.clLoading = 2
  163. } else {
  164. this.clLoading = 0
  165. }
  166. this.classlist = [...this.classlist, ...res[0]]
  167. // this.classlist = res[0]
  168. })
  169. },
  170. // 跳转活动详情页
  171. gotoDetail(e) {
  172. let aid = e.currentTarget.dataset.aid;
  173. uni.navigateTo({
  174. url: `/pages/activityDetailNew/activityDetailNew?acId=${aid}`
  175. });
  176. },
  177. // 查看课程外部链接
  178. gotoWeb(e) {
  179. // return console.log('aaaaaa', e.currentTarget.dataset);
  180. let acid = e.currentTarget.dataset.kid
  181. uni.navigateTo({
  182. url: "/pages/skipone/skipone?item=" + encodeURIComponent(JSON.stringify(acid))
  183. // url: "/pages/skipone/skipone?url=" + encodeURIComponent(acid),
  184. });
  185. },
  186. // 取消活动收藏事件
  187. coll(event) {
  188. let aId = event.currentTarget.dataset.e.acId
  189. let data = {
  190. acid: aId,
  191. oid: this.$store.state.user.openid, //用户id
  192. ty: 0
  193. }
  194. this.$store.dispatch('asyncUpdatemsg', {
  195. collAoff: 0
  196. })
  197. this.$request('/deleteOperator', 'POST', data).then(res => {
  198. // console.log(res);
  199. setTimeout(() => {
  200. this.$store.dispatch('asyncDelMsg')
  201. }, 1500)
  202. this.aclist = this.aclist.filter(e => {
  203. return e.acId != aId
  204. })
  205. // 防止一直取消收藏导致触发不了触底刷新
  206. if (this.aclist.length < 15) {
  207. this.lower()
  208. }
  209. })
  210. },
  211. // 取消课程收藏事件
  212. collcl(event) {
  213. let cId = event.currentTarget.dataset.e.cid
  214. let data = {
  215. cid: cId,
  216. oid: this.$store.state.user.openid, //用户id
  217. ty: 1
  218. }
  219. this.$store.dispatch('asyncUpdatemsg', {
  220. collAoff: 0
  221. })
  222. this.$request('/deleteOperator', 'POST', data).then(res => {
  223. // console.log('取消课程收藏', res);
  224. setTimeout(() => {
  225. this.$store.dispatch('asyncDelMsg')
  226. }, 1500)
  227. this.classlist = this.classlist.filter(e => {
  228. return e.cid != cId
  229. })
  230. // 防止一直取消收藏导致触发不了触底刷新
  231. if (this.classlist.length < 15) {
  232. this.cllower()
  233. }
  234. })
  235. },
  236. // 活动触底加载更多
  237. lower() {
  238. console.log('活动没触底?');
  239. if (this.newsLoading == 2) return
  240. this.newsLoading = 1
  241. this.currentPage++
  242. setTimeout(this.getData, 1000)
  243. },
  244. // 课程触底加载更多
  245. cllower() {
  246. console.log('课程没触底?');
  247. if (this.clLoading == 2) return
  248. this.clLoading = 1
  249. this.clcurrentPage++
  250. setTimeout(this.getTeachData, 1000)
  251. },
  252. //跳转到第三方链接
  253. gotoLink(e) {
  254. let link = e.currentTarget.dataset.link;
  255. uni.navigateTo({
  256. url: "/pages/skipone/skipone?url=" + encodeURIComponent(link),
  257. });
  258. },
  259. swipeIndex(index) {
  260. this.current = index.detail.current;
  261. },
  262. // 区域滑动
  263. acpag() {
  264. this.current = 0;
  265. },
  266. clapag() {
  267. this.current = 1;
  268. },
  269. },
  270. onLoad(e) {
  271. console.log('e', e);
  272. if (Object.keys(e).length != 0) {
  273. this.current = e.ty * 1
  274. // console.log(99999);
  275. }
  276. },
  277. onShow() {
  278. this.clcurrentPage = 1;
  279. this.currentPage = 1;
  280. // 获取数据
  281. this.getData()
  282. this.getTeachData()
  283. }
  284. }
  285. </script>
  286. <style lang="scss" scoped>
  287. .mineCollNew {
  288. display: flex;
  289. flex-direction: column;
  290. height: 100vh;
  291. .classListFlex {
  292. display: flex;
  293. justify-content: space-between;
  294. flex-wrap: wrap;
  295. padding: 30rpx;
  296. }
  297. .cont {
  298. background-color: #ffffff;
  299. width: 332rpx;
  300. padding: 20rpx 15rpx;
  301. border-radius: 10px;
  302. margin-bottom: 20rpx;
  303. position: relative;
  304. .star {
  305. position: absolute;
  306. right: 30rpx;
  307. top: 30rpx;
  308. width: 30rpx;
  309. height: 30rpx;
  310. }
  311. .img {
  312. width: 300rpx;
  313. height: 170rpx;
  314. border-radius: 10rpx;
  315. }
  316. .tit {
  317. width: 257rpx;
  318. margin: 10rpx 0;
  319. font-weight: bold;
  320. white-space: normal;
  321. display: -webkit-box;
  322. word-break: break-all;
  323. text-overflow: ellipsis;
  324. overflow: hidden;
  325. -webkit-box-orient: vertical;
  326. -webkit-line-clamp: 2;
  327. /*设置 需要显示的行数*/
  328. }
  329. .teacher {
  330. color: #999999;
  331. }
  332. .mon {
  333. font-size: 34rpx;
  334. color: rgba(246, 135, 23, 1);
  335. font-weight: 34rpx;
  336. margin-top: 10rpx;
  337. .cost {
  338. font-weight: 40rpx;
  339. }
  340. }
  341. }
  342. .loading {
  343. height: 30rpx;
  344. text-align: center;
  345. padding-top: 20rpx;
  346. padding-bottom: 100rpx;
  347. font-size: 26rpx;
  348. color: #888;
  349. line-height: 2em;
  350. }
  351. .top {
  352. width: 100%;
  353. display: flex;
  354. justify-content: space-between;
  355. margin: 0;
  356. background-color: #ffffff;
  357. padding: 10px 150rpx;
  358. height: 98rpx;
  359. .info1 {
  360. font-weight: bold !important;
  361. position: relative;
  362. color: rgba(0, 0, 0, 0.8);
  363. font-size: 34rpx;
  364. line-height: 48rpx;
  365. width: 136rpx;
  366. height: 48rpx;
  367. text-align: center;
  368. .yun {
  369. width: 134rpx;
  370. height: 32rpx;
  371. position: absolute;
  372. left: 0;
  373. bottom: -10rpx;
  374. image {
  375. width: 100%;
  376. height: 100%;
  377. }
  378. }
  379. }
  380. .info2 {
  381. color: rgba(0, 0, 0, 0.6);
  382. font-size: 34rpx;
  383. font-weight: 400;
  384. line-height: 48rpx;
  385. width: 136rpx;
  386. height: 48rpx;
  387. text-align: center;
  388. // font-family: 微软雅黑;
  389. }
  390. }
  391. .scroll-view-height {
  392. flex: 1;
  393. }
  394. .listBlock1 {
  395. display: flex;
  396. justify-content: space-between;
  397. background-color: #ffffff;
  398. padding: 20rpx 30rpx;
  399. width: 100%;
  400. .img {
  401. width: 160rpx;
  402. height: 160rpx;
  403. flex-shrink: 0;
  404. position: relative;
  405. .star {
  406. position: absolute;
  407. right: 10rpx;
  408. top: 10rpx;
  409. width: 30rpx;
  410. height: 30rpx;
  411. }
  412. image {
  413. width: 100%;
  414. height: 100%;
  415. border-radius: 10rpx;
  416. }
  417. }
  418. .right {
  419. padding-left: 20rpx;
  420. flex: 1;
  421. display: flex;
  422. flex-direction: column;
  423. justify-content: space-between;
  424. .title {
  425. display: flex;
  426. width: 500rpx;
  427. justify-content: flex-start;
  428. align-items: center;
  429. .titTxt {
  430. flex: 1;
  431. color: rgba(0, 0, 0, 0.8);
  432. font-weight: bold;
  433. overflow: hidden;
  434. text-overflow: ellipsis;
  435. white-space: nowrap;
  436. }
  437. text {
  438. font-weight: bold;
  439. overflow: hidden;
  440. text-overflow: ellipsis;
  441. white-space: nowrap;
  442. }
  443. }
  444. .introduce {
  445. font-size: 24rpx;
  446. display: flex;
  447. justify-content: space-between;
  448. .bri {
  449. width: 250rpx;
  450. color: #a7a7a7;
  451. overflow: hidden;
  452. text-overflow: ellipsis;
  453. white-space: nowrap;
  454. }
  455. .tim {
  456. color: #a7a7a7;
  457. }
  458. }
  459. .operate {
  460. display: flex;
  461. justify-content: space-between;
  462. .left {
  463. display: flex;
  464. align-items: baseline;
  465. position: relative;
  466. width: 60%;
  467. .add {
  468. position: absolute;
  469. bottom: 0;
  470. left: 0;
  471. width: 100%;
  472. padding-left: 3rpx;
  473. color: rgba(0, 0, 0, 0.6) !important;
  474. }
  475. }
  476. .Oright {
  477. // width: 80px;
  478. display: flex;
  479. justify-content: flex-end;
  480. align-items: center;
  481. .text {
  482. font-size: 24rpx;
  483. color: #3081E8;
  484. }
  485. .arrow {
  486. display: flex;
  487. justify-content: center;
  488. margin-top: 5rpx;
  489. image {
  490. width: 32rpx;
  491. height: 32rpx;
  492. }
  493. }
  494. }
  495. }
  496. }
  497. .tag {
  498. border: 1px rgba(0, 178, 182, 1) solid;
  499. flex-shrink: 0;
  500. letter-spacing: 2rpx;
  501. // min-width: 104rpx;
  502. // height: 36rpx;
  503. padding: 2rpx 4rpx;
  504. display: flex;
  505. white-space: nowrap;
  506. justify-content: center;
  507. align-items: center;
  508. border-radius: 4rpx;
  509. margin-right: 10rpx;
  510. color: rgba(0, 178, 182, 1);
  511. line-height: 32rpx;
  512. // border: 1px #00b2b6 solid;
  513. // flex-shrink: 0;
  514. // letter-spacing: 2rpx;
  515. // width: 104rpx;
  516. // height: 32rpx;
  517. // display: flex;
  518. // white-space: nowrap;
  519. // justify-content: center;
  520. // align-items: center;
  521. // border-radius: 4rpx;
  522. // margin-right: 10rpx;
  523. // color: #00b2b6;
  524. // line-height: 32rpx;
  525. }
  526. .tag1 {
  527. flex-shrink: 0;
  528. letter-spacing: 2rpx;
  529. // min-width: 104rpx;
  530. // height: 36rpx;
  531. padding: 2rpx 4rpx;
  532. display: flex;
  533. white-space: nowrap;
  534. justify-content: center;
  535. align-items: center;
  536. border-radius: 4rpx;
  537. margin-right: 10rpx;
  538. line-height: 32rpx;
  539. border: 1px rgba(0, 86, 168, 1) solid;
  540. color: rgba(0, 86, 168, 1);
  541. // border: 1px rgba(0, 86, 168, 1) solid;
  542. // flex-shrink: 0;
  543. // letter-spacing: 2rpx;
  544. // width: 104rpx;
  545. // height: 32rpx;
  546. // display: flex;
  547. // white-space: nowrap;
  548. // justify-content: center;
  549. // align-items: center;
  550. // border-radius: 4rpx;
  551. // margin-right: 10rpx;
  552. // color: rgba(0, 86, 168, 1);
  553. // line-height: 32rpx;
  554. }
  555. }
  556. }
  557. </style>