mineCollNew.vue 14 KB

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