activityPageNew.vue 13 KB

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