mineCollNew.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  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.stop="gotoLink"
  29. :data-link="i.link">
  30. <view class="img cell-img">
  31. <image :src="i.pic" mode="aspectFill"></image>
  32. <image class="star" @click.stop="coll" :data-e="i" :src="pic_coll2" mode=""></image>
  33. </view>
  34. <view class="right">
  35. <view class="title">
  36. <!-- <view class="tag bqZ-font">{{i.acshape}}</view> -->
  37. <view class="bqZ-font" :class="i.acshape=='线下活动'?'tag':'tag1'"> {{i.acshape}}</view>
  38. <view class="titTxt btn-font" style="">
  39. {{i.acName}}
  40. </view>
  41. </view>
  42. <view class="introduce">
  43. <view class="bri">
  44. {{ i.brief }}
  45. </view>
  46. <view class="tim">
  47. {{ i.create_at }}
  48. </view>
  49. </view>
  50. <view class="operate">
  51. <view class="left">
  52. <view class="add fz-font">已报名{{i.bnum}}人</view>
  53. </view>
  54. <view class="Oright" @click="gotoDetail" :data-aid="i.acId">
  55. <view class="text">报名</view>
  56. <view class="arrow">
  57. <image
  58. src="https://teacherapi.cocorobo.cn/teaching-file/static/mine/arrow-right-blue.png"
  59. mode="aspectFill"></image>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="loading">
  67. <view v-if="newsLoading==1">数据加载中...</view>
  68. <view v-if="newsLoading==2">没有更多了~~</view>
  69. </view>
  70. </scroll-view>
  71. </swiper-item>
  72. <swiper-item>
  73. <scroll-view scroll-y="true" @scrolltolower="cllower" style="height: 100%;">
  74. <view class="classListFlex">
  75. <view class="cont" @click="gotoWeb" v-for="(item, index) in classlist" :index="index"
  76. :key="index" :data-kid="item.href">
  77. <image class="star" :src="pic_coll2" @click.stop="collcl" :data-e="item" mode="aspectFill">
  78. </image>
  79. <image class="img" :src="item.img" mode="aspectFill" />
  80. <view class="tit btn-font">{{ item.ctit }}</view>
  81. <!-- <view class="teacher fz-font">{{ item.school }}</view> -->
  82. </view>
  83. </view>
  84. <view class="loading">
  85. <view v-if="clLoading==1">数据加载中...</view>
  86. <view v-if="clLoading==2">没有更多了~~</view>
  87. </view>
  88. </scroll-view>
  89. </swiper-item>
  90. </swiper>
  91. <!-- <view class="" style="height: 68rpx;width: 750rpx;">
  92. </view> -->
  93. </view>
  94. </template>
  95. <script>
  96. export default {
  97. data() {
  98. return {
  99. navBarData: {
  100. title: '我的收藏',
  101. btn: 1
  102. },
  103. current: 0, //课程活动切换
  104. info1: "info1", //类名
  105. info2: "info2",
  106. aclist: [], //活动数据list
  107. classlist: [], //课程数据list
  108. // // 收藏活动list
  109. // collArr: [],
  110. // // 收藏课程list
  111. // collArrcl: [],
  112. // 触底加载动画提示
  113. newsLoading: 0, //0默认值 1加载中 2没有更多了
  114. currentPage: 1,
  115. clLoading: 0, //0默认值 1加载中 2没有更多了
  116. clcurrentPage: 1,
  117. pic_coll: 'https://teacherapi.cocorobo.cn/teaching-file/static/Stara.png',
  118. pic_coll2: 'https://teacherapi.cocorobo.cn/teaching-file/static/mine/Collect_yellow.png',
  119. };
  120. },
  121. methods: {
  122. // 获取活动数据
  123. getData() {
  124. let data = {
  125. oid: this.$store.state.user.openid, //用户id
  126. type: 0,
  127. page: this.currentPage, //下拉获取更多的备用字段
  128. lim: 15 //一次获取多少数据
  129. }
  130. console.log('data', data);
  131. this.$request('/selectCollAcList', 'POST', data).then(res => {
  132. console.log('获取活动数据', res);
  133. if (!res[0].length) {
  134. this.newsLoading = 2
  135. } else {
  136. this.newsLoading = 0
  137. }
  138. this.aclist = [...this.aclist, ...res[0]]
  139. })
  140. },
  141. // 获取课程数据
  142. getTeachData() {
  143. // console.log('触发课程收藏事件');
  144. let data = {
  145. oid: this.$store.state.user.openid, //用户id
  146. type: 1,
  147. page: this.clcurrentPage, //下拉获取更多的备用字段
  148. lim: 15 //一次获取多少数据
  149. }
  150. this.$request('/selectOperatorTech', 'POST', data).then(res => {
  151. console.log('获取课程数据', res);
  152. // 每次调用前清零,防止push叠加错误
  153. // this.classlist = []
  154. if (!res[0].length) {
  155. this.clLoading = 2
  156. } else {
  157. this.clLoading = 0
  158. }
  159. this.classlist = [...this.classlist, ...res[0]]
  160. // this.classlist = res[0]
  161. })
  162. },
  163. // 跳转活动详情页
  164. gotoDetail(e) {
  165. let aid = e.currentTarget.dataset.aid;
  166. uni.navigateTo({
  167. url: `/pages/activityDetailNew/activityDetailNew?acId=${aid}`
  168. });
  169. },
  170. // 查看课程外部链接
  171. gotoWeb(e) {
  172. // return console.log('aaaaaa', e.currentTarget.dataset);
  173. let acid = e.currentTarget.dataset.kid
  174. uni.navigateTo({
  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. font-weight: bold;
  426. overflow: hidden;
  427. text-overflow: ellipsis;
  428. white-space: nowrap;
  429. }
  430. text {
  431. font-weight: bold;
  432. overflow: hidden;
  433. text-overflow: ellipsis;
  434. white-space: nowrap;
  435. }
  436. }
  437. .introduce {
  438. font-size: 24rpx;
  439. display: flex;
  440. justify-content: space-between;
  441. .bri {
  442. width: 250rpx;
  443. color: #a7a7a7;
  444. overflow: hidden;
  445. text-overflow: ellipsis;
  446. white-space: nowrap;
  447. }
  448. .tim {
  449. color: #a7a7a7;
  450. }
  451. }
  452. .operate {
  453. display: flex;
  454. justify-content: space-between;
  455. .left {
  456. display: flex;
  457. align-items: baseline;
  458. position: relative;
  459. width: 60%;
  460. .add {
  461. position: absolute;
  462. bottom: 0;
  463. left: 0;
  464. width: 100%;
  465. padding-left: 3rpx;
  466. color: rgba(0, 0, 0, 0.6) !important;
  467. }
  468. }
  469. .Oright {
  470. // width: 80px;
  471. display: flex;
  472. justify-content: flex-end;
  473. align-items: center;
  474. .text {
  475. font-size: 24rpx;
  476. color: #3081E8;
  477. }
  478. .arrow {
  479. display: flex;
  480. justify-content: center;
  481. margin-top: 5rpx;
  482. image {
  483. width: 32rpx;
  484. height: 32rpx;
  485. }
  486. }
  487. }
  488. }
  489. }
  490. .tag {
  491. border: 1px #00b2b6 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: #00b2b6;
  503. line-height: 32rpx;
  504. }
  505. .tag1 {
  506. border: 1px rgba(0, 86, 168, 1) 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: rgba(0, 86, 168, 1);
  518. line-height: 32rpx;
  519. }
  520. }
  521. }
  522. </style>