mineCollNew.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  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. 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?url=" + encodeURIComponent(acid),
  175. });
  176. },
  177. // 取消活动收藏事件
  178. coll(event) {
  179. let aId = event.currentTarget.dataset.e.acId
  180. let data = {
  181. acid: aId,
  182. oid: this.$store.state.user.openid, //用户id
  183. ty: 0
  184. }
  185. this.$request('/deleteOperator', 'POST', data).then(res => {
  186. console.log(res);
  187. this.aclist = this.aclist.filter(e => {
  188. return e.acId != aId
  189. })
  190. // 防止一直取消收藏导致触发不了触底刷新
  191. if (this.aclist.length < 15) {
  192. this.lower()
  193. }
  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. this.clcurrentPage = 1;
  260. this.currentPage = 1;
  261. // 获取数据
  262. this.getData()
  263. this.getTeachData()
  264. }
  265. }
  266. </script>
  267. <style lang="scss" scoped>
  268. .mineCollNew {
  269. display: flex;
  270. flex-direction: column;
  271. height: 100vh;
  272. .classListFlex {
  273. display: flex;
  274. justify-content: space-between;
  275. flex-wrap: wrap;
  276. padding: 30rpx;
  277. }
  278. .cont {
  279. background-color: #ffffff;
  280. width: 332rpx;
  281. padding: 20rpx 15rpx;
  282. border-radius: 10px;
  283. margin-bottom: 20rpx;
  284. position: relative;
  285. .star {
  286. position: absolute;
  287. right: 30rpx;
  288. top: 30rpx;
  289. width: 30rpx;
  290. height: 30rpx;
  291. }
  292. .img {
  293. width: 300rpx;
  294. height: 170rpx;
  295. border-radius: 10rpx;
  296. }
  297. .tit {
  298. width: 257rpx;
  299. margin: 10rpx 0;
  300. font-weight: bold;
  301. white-space: normal;
  302. display: -webkit-box;
  303. word-break: break-all;
  304. text-overflow: ellipsis;
  305. overflow: hidden;
  306. -webkit-box-orient: vertical;
  307. -webkit-line-clamp: 2;
  308. /*设置 需要显示的行数*/
  309. }
  310. .teacher {
  311. color: #999999;
  312. }
  313. .mon {
  314. font-size: 34rpx;
  315. color: rgba(246, 135, 23, 1);
  316. font-weight: 34rpx;
  317. margin-top: 10rpx;
  318. .cost {
  319. font-weight: 40rpx;
  320. }
  321. }
  322. }
  323. .loading {
  324. height: 30rpx;
  325. text-align: center;
  326. padding-top: 20rpx;
  327. padding-bottom: 100rpx;
  328. font-size: 26rpx;
  329. color: #888;
  330. line-height: 2em;
  331. }
  332. .top {
  333. width: 100%;
  334. display: flex;
  335. justify-content: space-between;
  336. margin: 0;
  337. background-color: #ffffff;
  338. padding: 10px 150rpx;
  339. height: 98rpx;
  340. .info1 {
  341. font-weight: bold !important;
  342. position: relative;
  343. color: rgba(0, 0, 0, 0.8);
  344. font-size: 34rpx;
  345. line-height: 48rpx;
  346. width: 136rpx;
  347. height: 48rpx;
  348. text-align: center;
  349. .yun {
  350. width: 134rpx;
  351. height: 32rpx;
  352. position: absolute;
  353. left: 0;
  354. bottom: -10rpx;
  355. image {
  356. width: 100%;
  357. height: 100%;
  358. }
  359. }
  360. }
  361. .info2 {
  362. color: rgba(0, 0, 0, 0.6);
  363. font-size: 34rpx;
  364. font-weight: 400;
  365. line-height: 48rpx;
  366. width: 136rpx;
  367. height: 48rpx;
  368. text-align: center;
  369. font-family: 微软雅黑;
  370. }
  371. }
  372. .scroll-view-height {
  373. flex: 1;
  374. }
  375. .listBlock1 {
  376. display: flex;
  377. justify-content: space-between;
  378. background-color: #ffffff;
  379. padding: 20rpx 30rpx;
  380. width: 100%;
  381. .img {
  382. width: 160rpx;
  383. height: 160rpx;
  384. flex-shrink: 0;
  385. position: relative;
  386. .star {
  387. position: absolute;
  388. right: 10rpx;
  389. top: 10rpx;
  390. width: 30rpx;
  391. height: 30rpx;
  392. }
  393. image {
  394. width: 100%;
  395. height: 100%;
  396. border-radius: 10rpx;
  397. }
  398. }
  399. .right {
  400. padding-left: 20rpx;
  401. flex: 1;
  402. display: flex;
  403. flex-direction: column;
  404. justify-content: space-between;
  405. .title {
  406. display: flex;
  407. width: 500rpx;
  408. justify-content: flex-start;
  409. align-items: center;
  410. .titTxt{
  411. flex: 1;
  412. font-weight: bold;
  413. overflow: hidden;
  414. text-overflow: ellipsis;
  415. white-space: nowrap;
  416. }
  417. text {
  418. font-weight: bold;
  419. overflow: hidden;
  420. text-overflow: ellipsis;
  421. white-space: nowrap;
  422. }
  423. }
  424. .introduce {
  425. font-size: 24rpx;
  426. display: flex;
  427. justify-content: space-between;
  428. .bri {
  429. width: 250rpx;
  430. color: #a7a7a7;
  431. overflow: hidden;
  432. text-overflow: ellipsis;
  433. white-space: nowrap;
  434. }
  435. .tim {
  436. color: #a7a7a7;
  437. }
  438. }
  439. .operate {
  440. display: flex;
  441. justify-content: space-between;
  442. .left {
  443. display: flex;
  444. align-items: baseline;
  445. position: relative;
  446. width: 60%;
  447. .add {
  448. position: absolute;
  449. bottom: 0;
  450. left: 0;
  451. width: 100%;
  452. padding-left: 3rpx;
  453. color: rgba(0, 0, 0, 0.6) !important;
  454. }
  455. }
  456. .Oright {
  457. // width: 80px;
  458. display: flex;
  459. justify-content: flex-end;
  460. align-items: center;
  461. .text {
  462. font-size: 24rpx;
  463. color: #3081E8;
  464. }
  465. .arrow {
  466. display: flex;
  467. justify-content: center;
  468. margin-top: 5rpx;
  469. image {
  470. width: 32rpx;
  471. height: 32rpx;
  472. }
  473. }
  474. }
  475. }
  476. }
  477. .tag {
  478. border: 1px #00b2b6 solid;
  479. flex-shrink: 0;
  480. letter-spacing: 2rpx;
  481. width: 104rpx;
  482. height: 32rpx;
  483. display: flex;
  484. white-space: nowrap;
  485. justify-content: center;
  486. align-items: center;
  487. border-radius: 4rpx;
  488. margin-right: 10rpx;
  489. color: #00b2b6;
  490. line-height: 32rpx;
  491. }
  492. .tag1 {
  493. border: 1px rgba(0, 86, 168, 1) solid;
  494. flex-shrink: 0;
  495. letter-spacing: 2rpx;
  496. width: 104rpx;
  497. height: 32rpx;
  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, 86, 168, 1);
  505. line-height: 32rpx;
  506. }
  507. }
  508. }
  509. </style>