activityPageNew.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <view class="activityPageNew">
  3. <statusBar :item="navBarData"></statusBar>
  4. <!-- 消息提示 -->
  5. <msgPop></msgPop>
  6. <view class="search">
  7. <uni-search-bar v-model.trim="searchText" bgColor="#f0f2f5" class="btntop" placeholder="搜索"
  8. cancelButton="none" clearButton="none"></uni-search-bar>
  9. </view>
  10. <view class="top">
  11. <view class="right" @click="accountLogin" :class="current == 0 ? info1 : info2">
  12. <text class="">常规教研</text>
  13. <view v-if="current == 0" class="yun">
  14. <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 10.png"
  15. mode="aspectFill"></image>
  16. </view>
  17. </view>
  18. <view class="left" @click="phoneLogin" :class="current == 1 ? info1 : info2">
  19. <text class="">专题教研</text>
  20. <view v-if="current == 1" class="yun">
  21. <image src="https://teacherapi.cocorobo.cn/teaching-file/static/yym/Ellipse 10.png"
  22. mode="aspectFill"></image>
  23. </view>
  24. </view>
  25. <!-- <view class="right" @click="costClass" :class="current == 2 ? info1 : info2">
  26. <text class="">付费教研</text>
  27. <view v-if="current == 2" class="yun">
  28. <image src="https://teacherapi.cocorobo.cn/teaching-file/static/yym/Ellipse 10.png"
  29. mode="aspectFill"></image>
  30. </view>
  31. </view> -->
  32. </view>
  33. <!-- <swiper class="scroll-view-height" @change="swipeIndex" @transition='cutS' @animationfinish='ani' -->
  34. <swiper class="scroll-view-height" @change="swipeIndex" :current="current" :duration="300">
  35. <!-- 常规教研 -->
  36. <swiper-item>
  37. <scroll-view scroll-y="true" :refresher-enabled='refevent' :refresher-triggered="putrigger"
  38. @refresherrefresh='purepulling' @scrolltolower="pulower" style="height: 100%;">
  39. <view class="searchPagedata" v-if="!pulist.length">暂无数据</view>
  40. <view>
  41. <listBlock1 ref="listBlock2" :classList="pulist"></listBlock1>
  42. </view>
  43. <view class="loading">
  44. <view v-if="puLoading==1">数据加载中...</view>
  45. <view v-if="puLoading==2">没有更多了~~</view>
  46. </view>
  47. </scroll-view>
  48. </swiper-item>
  49. <!-- 专题教研 -->
  50. <swiper-item>
  51. <scroll-view scroll-y="true" :refresher-enabled='refevent' :refresher-triggered="trigger"
  52. @refresherrefresh='repulling' @scrolltolower="aclower" style="height: 100%;">
  53. <view class="searchPagedata" v-if="!teclist.length">暂无数据</view>
  54. <view class="">
  55. <listBlock1 ref="listBlock1" :classList="teclist"></listBlock1>
  56. </view>
  57. <view class="loading">
  58. <view v-if="acLoading==1">数据加载中...</view>
  59. <view v-if="acLoading==2">没有更多了~~</view>
  60. </view>
  61. </scroll-view>
  62. </swiper-item>
  63. <!-- 付费教研 -->
  64. <!-- <swiper-item>
  65. <scroll-view scroll-y="true" style="height: 100%;">
  66. <view class=""
  67. style="height: 100%; width: 750rpx;display: flex;justify-content: center;align-items: center;">
  68. <image src="../../static/Frame.png" style="width: 400rpx;height: 400rpx;" mode=""></image>
  69. </view>
  70. </scroll-view>
  71. </swiper-item> -->
  72. </swiper>
  73. </view>
  74. </template>
  75. <script>
  76. export default {
  77. data() {
  78. return {
  79. navBarData: {
  80. title: "活动",
  81. btn: 0,
  82. },
  83. refevent: true,
  84. indexId: 1,
  85. current: 0, //控制展示哪一个
  86. info1: "info1", //类名
  87. info2: "info2",
  88. // swiper: 0,
  89. searchText: "", // 搜索文本
  90. // 必须要两个,因为常规与专题的是分两次进行的
  91. isone1: true, // 常规判断是否第一次进入页面
  92. isone2: true, // 教研判断是否第一次进入页面
  93. acLoading: 0, //0默认值 1加载中 2没有更多了
  94. accurrentPage: 1, //页数
  95. puLoading: 0, //0默认值 1加载中 2没有更多了
  96. pucurrentPage: 1,
  97. // 教研
  98. teclist: [],
  99. // 常规
  100. pulist: [],
  101. // 设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
  102. trigger: false, //专题
  103. putrigger: false, //常规
  104. // 触底
  105. // SearchLoading: 0, //0默认值 1加载中 2没有更多了
  106. // 搜索页数
  107. Searchpage: 1,
  108. // 在搜索框有文字的时候下拉刷新禁止触发watch,防止数据叠加
  109. bansearchData: false
  110. };
  111. },
  112. onShareTimeline() {
  113. uni.share({
  114. provider: "weixin",
  115. scene: "WXSceneTimeline",
  116. type: 0,
  117. href: "http://uniapp.dcloud.io/",
  118. title: "uni-app分享",
  119. summary: "我正在使用丽湖双创小程序,赶紧跟我一起来体验!",
  120. imageUrl: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png",
  121. success: function(res) {
  122. console.log("success:" + JSON.stringify(res));
  123. },
  124. fail: function(err) {
  125. console.log("fail:" + JSON.stringify(err));
  126. }
  127. });
  128. },
  129. // 分享
  130. onShareAppMessage() {
  131. uni.share({
  132. provider: "weixin",
  133. scene: "WXSceneSession",
  134. type: 1,
  135. summary: "我正在使用丽湖双创小程序,赶紧跟我一起来体验!",
  136. success: function(res) {
  137. console.log("success:" + JSON.stringify(res));
  138. },
  139. fail: function(err) {
  140. console.log("fail:" + JSON.stringify(err));
  141. }
  142. });
  143. },
  144. watch: {
  145. searchText(val) {
  146. // console.log(val);
  147. if (this.bansearchData) return
  148. if (val === '') {
  149. this.acLoading = 0 //0默认值 1加载中 2没有更多了
  150. this.accurrentPage = 1 //页数
  151. this.teclist = [] // 教研
  152. this.getTecData()
  153. this.puLoading = 0 //0默认值 1加载中 2没有更多了
  154. this.pucurrentPage = 1
  155. this.pulist = [] // 常规
  156. this.getpuData()
  157. return
  158. }
  159. this.selectSearchdata()
  160. }
  161. },
  162. // onUnload() {
  163. // this.$store.dispatch('asyncDelAll')
  164. // },
  165. methods: {
  166. ani() {
  167. this.refevent = true
  168. },
  169. cutS(event) {
  170. // console.log(event.detail);
  171. this.refevent = false
  172. },
  173. // 搜索
  174. selectSearchdata() {
  175. if (this.current === 2) return
  176. let type = null
  177. if (this.current == 0) {
  178. type = 2
  179. } else if (this.current == 1) {
  180. type = 1
  181. } else {
  182. return
  183. }
  184. // console.log(111);
  185. let data = {
  186. openid: uni.getStorageSync('oId'),
  187. txt: this.searchText,
  188. ty: type,
  189. // page: this.Searchpage,
  190. // lim: 15
  191. }
  192. // return console.log(data);
  193. this.$request('/selectSearchdata', "get", data).then(res => {
  194. // console.log('常规', res);
  195. if (this.current == 0) {
  196. this.pulist = res[0]
  197. } else if (this.current == 1) {
  198. this.teclist = res[0]
  199. }
  200. // if (!res[0].length) {
  201. // this.puLoading = 2
  202. // } else {
  203. // this.puLoading = 0
  204. // }
  205. // this.pulist = [...this.pulist, ...res[0]]
  206. })
  207. },
  208. // 专题教研下拉刷新
  209. repulling() {
  210. this.bansearchData = true
  211. this.trigger = true
  212. // this.isrepulling = true
  213. setTimeout(() => {
  214. this.trigger = false;
  215. }, 1000);
  216. this.acLoading = 0 //0默认值 1加载中 2没有更多了
  217. this.accurrentPage = 1 //页数
  218. this.teclist = [] // 教研
  219. if (this.searchText !== '') {
  220. this.puLoading = 0 //0默认值 1加载中 2没有更多了
  221. this.pucurrentPage = 1
  222. this.pulist = [] // 常规
  223. this.getpuData()
  224. }
  225. this.searchText = ''
  226. this.getTecData()
  227. // console.log(111);
  228. },
  229. // 常规教研下拉刷新
  230. purepulling() {
  231. this.bansearchData = true
  232. this.putrigger = true
  233. // this.isrepulling = true
  234. setTimeout(() => {
  235. this.putrigger = false;
  236. }, 1000);
  237. this.puLoading = 0 //0默认值 1加载中 2没有更多了
  238. this.pucurrentPage = 1
  239. this.pulist = [] // 常规
  240. if (this.searchText !== '') {
  241. this.acLoading = 0 //0默认值 1加载中 2没有更多了
  242. this.accurrentPage = 1 //页数
  243. this.teclist = [] // 教研
  244. this.getTecData()
  245. }
  246. this.searchText = ''
  247. this.getpuData()
  248. // console.log(111);
  249. },
  250. // 专题教研触底
  251. aclower() {
  252. if (this.searchText !== '') return console.log('禁止触底');
  253. console.log('没触底?');
  254. if (this.acLoading == 2) return
  255. this.acLoading = 1
  256. this.accurrentPage++
  257. setTimeout(this.getTecData, 1000)
  258. },
  259. // 常规教研触底
  260. pulower() {
  261. if (this.searchText !== '') return console.log('禁止触底');
  262. console.log('没触底?');
  263. if (this.puLoading == 2) return
  264. this.puLoading = 1
  265. this.pucurrentPage++
  266. setTimeout(this.getpuData(), 1000)
  267. },
  268. // 获取专题
  269. getTecData() {
  270. let data = {
  271. openid: uni.getStorageSync('oId'),
  272. ty: 1,
  273. page: this.accurrentPage, //下拉获取更多的备用字段
  274. lim: 30 //一次获取多少数据
  275. }
  276. this.$request('/selectActivity', "POST", data).then(res => {
  277. // console.log('专题', res[0]);
  278. // this.teclist = res[0]
  279. if (this.isone1) {
  280. this.teclist = []
  281. this.isone1 = false
  282. }
  283. if (!res[0].length) {
  284. this.acLoading = 2
  285. } else {
  286. this.acLoading = 0
  287. }
  288. this.teclist = [...this.teclist, ...res[0]]
  289. this.bansearchData = false
  290. })
  291. },
  292. secherData() {
  293. },
  294. // 获取常规
  295. getpuData() {
  296. let data = {
  297. openid: uni.getStorageSync('oId'),
  298. ty: 2,
  299. // txt: (e ? e : ''),
  300. page: this.pucurrentPage, //下拉获取更多的备用字段
  301. lim: 30 //一次获取多少数据
  302. }
  303. // return console.log('获取常规', data);
  304. this.$request('/selectActivity', "POST", data).then(res => {
  305. // console.log('常规', res[0]);
  306. // this.pulist = res[0]
  307. if (this.isone2) {
  308. this.pulist = []
  309. this.isone2 = false
  310. }
  311. if (!res[0].length) {
  312. this.puLoading = 2
  313. } else {
  314. this.puLoading = 0
  315. }
  316. this.pulist = [...this.pulist, ...res[0]]
  317. this.bansearchData = false
  318. })
  319. },
  320. // 区域滑动变换头部
  321. swipeIndex(index) {
  322. // console.log(111);
  323. this.current = index.detail.current;
  324. if (this.searchText !== '') {
  325. this.selectSearchdata()
  326. }
  327. // this.selectSearchdata()
  328. // this.$refs.listBlock1.getdata()
  329. },
  330. // 区域滑动
  331. accountLogin() {
  332. this.current = 0;
  333. },
  334. // 点击专题教研
  335. phoneLogin() {
  336. this.current = 1;
  337. },
  338. // 点击常规教研
  339. costClass() {
  340. this.current = 2;
  341. }
  342. },
  343. onLoad() {
  344. },
  345. onShow() {
  346. // 必须要两个,因为常规与专题的是分两次进行的
  347. this.isone1 = true
  348. this.isone2 = true
  349. this.getpuData() //获取常规列表
  350. this.getTecData() //获取专题列表
  351. this.getAllMessage() // 调用app.js中的方法
  352. // 获取收藏事件
  353. this.$refs.listBlock1.getdata() //专题
  354. this.$refs.listBlock2.getdata() //常规
  355. }
  356. };
  357. </script>
  358. <style lang="scss" scoped>
  359. .btntop {
  360. width: 100%;
  361. }
  362. .searchPagedata {
  363. width: 750rpx;
  364. height: 40%;
  365. display: flex;
  366. justify-content: center;
  367. align-items: center;
  368. }
  369. .activityPageNew {
  370. display: flex;
  371. flex-direction: column;
  372. height: 100vh;
  373. .search {
  374. background-color: #ffffff;
  375. position: relative;
  376. display: flex;
  377. width: 750rpx;
  378. height: 88rpx;
  379. justify-content: center;
  380. align-items: center;
  381. .inpSer {
  382. width: 690rpx;
  383. height: 65rpx;
  384. margin: auto;
  385. background-color: rgba(240, 242, 245, 1);
  386. border-radius: 5rpx;
  387. color: rgba(0, 0, 0, 0.26);
  388. position: relative;
  389. .inpTxt {
  390. color: #000;
  391. height: 100%;
  392. width: 100%;
  393. }
  394. input::placeholder {
  395. color: #000;
  396. }
  397. .ico {
  398. position: absolute;
  399. top: 50%;
  400. left: 20rpx;
  401. transform: translate(0, -50%);
  402. display: flex;
  403. align-items: center;
  404. image {
  405. margin-right: 10rpx;
  406. }
  407. }
  408. }
  409. }
  410. .top {
  411. width: 100%;
  412. display: flex;
  413. justify-content: space-around;
  414. margin: auto;
  415. background-color: #ffffff;
  416. padding: 10px 60rpx;
  417. height: 98rpx;
  418. .info1 {
  419. font-weight: bold !important;
  420. position: relative;
  421. color: rgba(0, 0, 0, 0.8);
  422. font-size: 34rpx;
  423. line-height: 48rpx;
  424. width: 136rpx;
  425. height: 48rpx;
  426. text-align: center;
  427. // font-family: PingFang SC;
  428. // font-family: \9ed1\4f53;
  429. .yun {
  430. width: 134rpx;
  431. height: 32rpx;
  432. position: absolute;
  433. left: 0;
  434. bottom: -10rpx;
  435. // transform: translate(-50%,0%);
  436. // box-shadow: 0px 10rpx 30rpx 6rpx #4a97f2;
  437. image {
  438. width: 100%;
  439. height: 100%;
  440. }
  441. }
  442. }
  443. .info2 {
  444. color: rgba(0, 0, 0, 0.6);
  445. font-size: 34rpx;
  446. font-weight: 400;
  447. line-height: 48rpx;
  448. width: 136rpx;
  449. height: 48rpx;
  450. text-align: center;
  451. // font-family: 微软雅黑;
  452. }
  453. }
  454. .scroll-view-height {
  455. flex: 1;
  456. width: 100%;
  457. display: flex;
  458. flex-wrap: wrap;
  459. justify-content: space-between;
  460. .cont {
  461. background-color: #ffffff;
  462. width: 332rpx;
  463. padding: 20rpx 15rpx;
  464. border-radius: 10px;
  465. margin-bottom: 20rpx;
  466. image {
  467. width: 300rpx;
  468. height: 170rpx;
  469. border-radius: 10rpx;
  470. }
  471. .tit {
  472. width: 257rpx;
  473. margin: 10rpx 0;
  474. // height: 80rpx;
  475. font-weight: bold;
  476. white-space: normal;
  477. display: -webkit-box;
  478. word-break: break-all;
  479. text-overflow: ellipsis;
  480. overflow: hidden;
  481. -webkit-box-orient: vertical;
  482. -webkit-line-clamp: 2;
  483. /*设置 需要显示的行数*/
  484. }
  485. .teacher {
  486. color: #999999;
  487. }
  488. }
  489. }
  490. }
  491. </style>