activityPageNew.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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. watch: {
  113. searchText(val) {
  114. // console.log(val);
  115. if (this.bansearchData) return
  116. if (val === '') {
  117. this.acLoading = 0 //0默认值 1加载中 2没有更多了
  118. this.accurrentPage = 1 //页数
  119. this.teclist = [] // 教研
  120. this.getTecData()
  121. this.puLoading = 0 //0默认值 1加载中 2没有更多了
  122. this.pucurrentPage = 1
  123. this.pulist = [] // 常规
  124. this.getpuData()
  125. return
  126. }
  127. this.selectSearchdata()
  128. }
  129. },
  130. // onUnload() {
  131. // this.$store.dispatch('asyncDelAll')
  132. // },
  133. methods: {
  134. ani() {
  135. this.refevent = true
  136. },
  137. cutS(event) {
  138. // console.log(event.detail);
  139. this.refevent = false
  140. },
  141. // 搜索
  142. selectSearchdata() {
  143. if (this.current === 2) return
  144. let type = null
  145. if (this.current == 0) {
  146. type = 2
  147. } else if (this.current == 1) {
  148. type = 1
  149. } else {
  150. return
  151. }
  152. // console.log(111);
  153. let data = {
  154. openid: uni.getStorageSync('oId'),
  155. txt: this.searchText,
  156. ty: type,
  157. // page: this.Searchpage,
  158. // lim: 15
  159. }
  160. // return console.log(data);
  161. this.$request('/selectSearchdata', "get", data).then(res => {
  162. // console.log('常规', res);
  163. if (this.current == 0) {
  164. this.pulist = res[0]
  165. } else if (this.current == 1) {
  166. this.teclist = res[0]
  167. }
  168. // if (!res[0].length) {
  169. // this.puLoading = 2
  170. // } else {
  171. // this.puLoading = 0
  172. // }
  173. // this.pulist = [...this.pulist, ...res[0]]
  174. })
  175. },
  176. // 专题教研下拉刷新
  177. repulling() {
  178. this.bansearchData = true
  179. this.trigger = true
  180. // this.isrepulling = true
  181. setTimeout(() => {
  182. this.trigger = false;
  183. }, 1000);
  184. this.acLoading = 0 //0默认值 1加载中 2没有更多了
  185. this.accurrentPage = 1 //页数
  186. this.teclist = [] // 教研
  187. if (this.searchText !== '') {
  188. this.puLoading = 0 //0默认值 1加载中 2没有更多了
  189. this.pucurrentPage = 1
  190. this.pulist = [] // 常规
  191. this.getpuData()
  192. }
  193. this.searchText = ''
  194. this.getTecData()
  195. // console.log(111);
  196. },
  197. // 常规教研下拉刷新
  198. purepulling() {
  199. this.bansearchData = true
  200. this.putrigger = true
  201. // this.isrepulling = true
  202. setTimeout(() => {
  203. this.putrigger = false;
  204. }, 1000);
  205. this.puLoading = 0 //0默认值 1加载中 2没有更多了
  206. this.pucurrentPage = 1
  207. this.pulist = [] // 常规
  208. if (this.searchText !== '') {
  209. this.acLoading = 0 //0默认值 1加载中 2没有更多了
  210. this.accurrentPage = 1 //页数
  211. this.teclist = [] // 教研
  212. this.getTecData()
  213. }
  214. this.searchText = ''
  215. this.getpuData()
  216. // console.log(111);
  217. },
  218. // 专题教研触底
  219. aclower() {
  220. if (this.searchText !== '') return console.log('禁止触底');
  221. console.log('没触底?');
  222. if (this.acLoading == 2) return
  223. this.acLoading = 1
  224. this.accurrentPage++
  225. setTimeout(this.getTecData, 1000)
  226. },
  227. // 常规教研触底
  228. pulower() {
  229. if (this.searchText !== '') return console.log('禁止触底');
  230. console.log('没触底?');
  231. if (this.puLoading == 2) return
  232. this.puLoading = 1
  233. this.pucurrentPage++
  234. setTimeout(this.getpuData(), 1000)
  235. },
  236. // 获取专题
  237. getTecData() {
  238. let data = {
  239. openid: uni.getStorageSync('oId'),
  240. ty: 1,
  241. page: this.accurrentPage, //下拉获取更多的备用字段
  242. lim: 30 //一次获取多少数据
  243. }
  244. this.$request('/selectActivity', "POST", data).then(res => {
  245. // console.log('专题', res[0]);
  246. // this.teclist = res[0]
  247. if (this.isone1) {
  248. this.teclist = []
  249. this.isone1 = false
  250. }
  251. if (!res[0].length) {
  252. this.acLoading = 2
  253. } else {
  254. this.acLoading = 0
  255. }
  256. this.teclist = [...this.teclist, ...res[0]]
  257. this.bansearchData = false
  258. })
  259. },
  260. secherData() {
  261. },
  262. // 获取常规
  263. getpuData() {
  264. let data = {
  265. openid: uni.getStorageSync('oId'),
  266. ty: 2,
  267. // txt: (e ? e : ''),
  268. page: this.pucurrentPage, //下拉获取更多的备用字段
  269. lim: 30 //一次获取多少数据
  270. }
  271. // return console.log('获取常规', data);
  272. this.$request('/selectActivity', "POST", data).then(res => {
  273. // console.log('常规', res[0]);
  274. // this.pulist = res[0]
  275. if (this.isone2) {
  276. this.pulist = []
  277. this.isone2 = false
  278. }
  279. if (!res[0].length) {
  280. this.puLoading = 2
  281. } else {
  282. this.puLoading = 0
  283. }
  284. this.pulist = [...this.pulist, ...res[0]]
  285. this.bansearchData = false
  286. })
  287. },
  288. // 区域滑动变换头部
  289. swipeIndex(index) {
  290. // console.log(111);
  291. this.current = index.detail.current;
  292. if (this.searchText !== '') {
  293. this.selectSearchdata()
  294. }
  295. // this.selectSearchdata()
  296. // this.$refs.listBlock1.getdata()
  297. },
  298. // 区域滑动
  299. accountLogin() {
  300. this.current = 0;
  301. },
  302. // 点击专题教研
  303. phoneLogin() {
  304. this.current = 1;
  305. },
  306. // 点击常规教研
  307. costClass() {
  308. this.current = 2;
  309. }
  310. },
  311. // 分享
  312. onShareAppMessage() {
  313. uni.share({
  314. provider: "weixin",
  315. scene: "WXSceneSession",
  316. type: 1,
  317. summary: "我正在使用丽湖双创小程序,赶紧跟我一起来体验!",
  318. success: function(res) {
  319. console.log("success:" + JSON.stringify(res));
  320. },
  321. fail: function(err) {
  322. console.log("fail:" + JSON.stringify(err));
  323. }
  324. });
  325. },
  326. onLoad() {
  327. },
  328. onShow() {
  329. // 必须要两个,因为常规与专题的是分两次进行的
  330. this.isone1 = true
  331. this.isone2 = true
  332. this.getpuData() //获取常规列表
  333. this.getTecData() //获取专题列表
  334. this.getAllMessage() // 调用app.js中的方法
  335. // 获取收藏事件
  336. this.$refs.listBlock1.getdata() //专题
  337. this.$refs.listBlock2.getdata() //常规
  338. }
  339. };
  340. </script>
  341. <style lang="scss" scoped>
  342. .btntop {
  343. width: 100%;
  344. }
  345. .searchPagedata {
  346. width: 750rpx;
  347. height: 40%;
  348. display: flex;
  349. justify-content: center;
  350. align-items: center;
  351. }
  352. .activityPageNew {
  353. display: flex;
  354. flex-direction: column;
  355. height: 100vh;
  356. .search {
  357. background-color: #ffffff;
  358. position: relative;
  359. display: flex;
  360. width: 750rpx;
  361. height: 88rpx;
  362. justify-content: center;
  363. align-items: center;
  364. .inpSer {
  365. width: 690rpx;
  366. height: 65rpx;
  367. margin: auto;
  368. background-color: rgba(240, 242, 245, 1);
  369. border-radius: 5rpx;
  370. color: rgba(0, 0, 0, 0.26);
  371. position: relative;
  372. .inpTxt {
  373. color: #000;
  374. height: 100%;
  375. width: 100%;
  376. }
  377. input::placeholder {
  378. color: #000;
  379. }
  380. .ico {
  381. position: absolute;
  382. top: 50%;
  383. left: 20rpx;
  384. transform: translate(0, -50%);
  385. display: flex;
  386. align-items: center;
  387. image {
  388. margin-right: 10rpx;
  389. }
  390. }
  391. }
  392. }
  393. .top {
  394. width: 100%;
  395. display: flex;
  396. justify-content: space-around;
  397. margin: auto;
  398. background-color: #ffffff;
  399. padding: 10px 60rpx;
  400. height: 98rpx;
  401. .info1 {
  402. font-weight: bold !important;
  403. position: relative;
  404. color: rgba(0, 0, 0, 0.8);
  405. font-size: 34rpx;
  406. line-height: 48rpx;
  407. width: 136rpx;
  408. height: 48rpx;
  409. text-align: center;
  410. // font-family: PingFang SC;
  411. // font-family: \9ed1\4f53;
  412. .yun {
  413. width: 134rpx;
  414. height: 32rpx;
  415. position: absolute;
  416. left: 0;
  417. bottom: -10rpx;
  418. // transform: translate(-50%,0%);
  419. // box-shadow: 0px 10rpx 30rpx 6rpx #4a97f2;
  420. image {
  421. width: 100%;
  422. height: 100%;
  423. }
  424. }
  425. }
  426. .info2 {
  427. color: rgba(0, 0, 0, 0.6);
  428. font-size: 34rpx;
  429. font-weight: 400;
  430. line-height: 48rpx;
  431. width: 136rpx;
  432. height: 48rpx;
  433. text-align: center;
  434. // font-family: 微软雅黑;
  435. }
  436. }
  437. .scroll-view-height {
  438. flex: 1;
  439. width: 100%;
  440. display: flex;
  441. flex-wrap: wrap;
  442. justify-content: space-between;
  443. .cont {
  444. background-color: #ffffff;
  445. width: 332rpx;
  446. padding: 20rpx 15rpx;
  447. border-radius: 10px;
  448. margin-bottom: 20rpx;
  449. image {
  450. width: 300rpx;
  451. height: 170rpx;
  452. border-radius: 10rpx;
  453. }
  454. .tit {
  455. width: 257rpx;
  456. margin: 10rpx 0;
  457. // height: 80rpx;
  458. font-weight: bold;
  459. white-space: normal;
  460. display: -webkit-box;
  461. word-break: break-all;
  462. text-overflow: ellipsis;
  463. overflow: hidden;
  464. -webkit-box-orient: vertical;
  465. -webkit-line-clamp: 2;
  466. /*设置 需要显示的行数*/
  467. }
  468. .teacher {
  469. color: #999999;
  470. }
  471. }
  472. }
  473. }
  474. </style>