activityPageNew.vue 11 KB

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