activityPageNew.vue 12 KB

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