activityPageNew.vue 12 KB

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