mineCollNew.vue 12 KB

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