mineCollNew.vue 13 KB

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