mineCollNew.vue 13 KB

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