金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

269 lines
7.7 KiB

  1. <template>
  2. <view>
  3. <lf-nav title="我的报名" :showIcon="true" bgColor="#fff" @changeHeight="e => nav_height = e"></lf-nav>
  4. <view v-if="tab_list.length">
  5. <u-tabs :list="tab_list" active-color="#15716E" inactive-color='#777777' :is-scroll="true" :current="tab_current" @change="tabChange"></u-tabs>
  6. </view>
  7. <swiper :style="{height: autoHeight}" :current="tab_current" @change="swiperChange">
  8. <swiper-item v-for="(tab, tabIndex) in tab_list" :key="tabIndex">
  9. <scroll-view :style="{height: autoHeight}" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="isRefresher"
  10. @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
  11. <view class="scroll-content">
  12. <view class="card" v-for="(item, index) in tab.list" :key="index" @click="$url('/pages/user/my/myregister?activity_id='+item.activity_id)">
  13. <view class="cover">
  14. <image class="img" :src="item.activity.image"></image>
  15. <view class="label" :class="'theme-'+ (index+1)">{{item.state}}</view>
  16. </view>
  17. <view class="info">
  18. <view class="title">{{item.name}}</view>
  19. <view class="date">{{item.created_at}}</view>
  20. </view>
  21. </view>
  22. <!-- 空数据的情况 -->
  23. <view class="loading-more">
  24. <text v-if="tab.list.length"
  25. :class="{'loading-more-text': tab.loadingClass}">{{ tab.loadingText }}</text>
  26. <lf-nocontent v-else></lf-nocontent>
  27. </view>
  28. </view>
  29. <view style="height: 30rpx;"></view>
  30. </scroll-view>
  31. </swiper-item>
  32. </swiper>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data(){
  38. let _public = {
  39. page: 1,
  40. isPage: true,
  41. loadingClass: true,
  42. loadingText: '正在加载中'
  43. }
  44. return {
  45. tab_current: 0,
  46. tab_list: [{
  47. name: '全部',
  48. state: '',
  49. list: [],
  50. ..._public
  51. },{
  52. name: '待参加',
  53. state: '待使用',
  54. list: [],
  55. ..._public
  56. },{
  57. name: '已参加',
  58. state: '已使用',
  59. list: [],
  60. ..._public
  61. },{
  62. name: '已过期',
  63. state: '已过期',
  64. list: [],
  65. ..._public
  66. }],
  67. scrollH: 0,
  68. nav_height: 0,
  69. isRefresher: true,
  70. pageSize: 10
  71. }
  72. },
  73. computed: {
  74. autoHeight(){
  75. return `calc(${this.scrollH}px - ${this.nav_height}px - 86rpx)`;
  76. }
  77. },
  78. onLoad(){
  79. let info = uni.getSystemInfoSync();
  80. this.scrollH = info.screenHeight;
  81. this.getMyActivity()
  82. },
  83. methods: {
  84. // 页面触底,加载下一页
  85. onScrolltolower(){
  86. let tab_item = this.tab_list[this.tab_current];
  87. if(tab_item.isPage){
  88. tab_item.page = tab_item.page + 1;
  89. this.getMyActivity();
  90. }
  91. },
  92. // 下拉刷新处理
  93. refreshFn(options){
  94. let tab_item = this.tab_list[this.tab_current];
  95. tab_item.page = 1;
  96. tab_item.isPage = true;
  97. tab_item.loadingClass = true;
  98. tab_item.list = []
  99. tab_item.loadingText = '正在加载中';
  100. this.getMyActivity(options);
  101. },
  102. // scroll-view 下拉刷新
  103. onRefresherrefresh(){
  104. this.isRefresher = true;
  105. this.refreshFn({type: 'scrollRefresh'});
  106. },
  107. tabChange(event){
  108. this.tab_current = event;
  109. this.getMyActivity();
  110. },
  111. swiperChange(event){
  112. this.tab_current = event.detail.current;
  113. if (event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  114. this.getMyActivity();
  115. },
  116. getMyActivity(options = {}) {
  117. let tab_item = this.tab_list[this.tab_current];
  118. this.$http
  119. .get({
  120. api: 'api/activity/my',
  121. data:{
  122. state: tab_item.state,
  123. page: tab_item.page,
  124. page_size: this.pageSize
  125. },
  126. header: {
  127. Authorization: `Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjczYTViNTA1NDNlYmNmMjFkNmZiMGJlNzc0NmJmMDE4MDc3MTRkY2Y1MjBiMjM3MGQyZDAyYzQxMTlmMDU4ZTkwMTUxNDQwOTk4MjJhODFhIn0.eyJhdWQiOiIzIiwianRpIjoiNzNhNWI1MDU0M2ViY2YyMWQ2ZmIwYmU3NzQ2YmYwMTgwNzcxNGRjZjUyMGIyMzcwZDJkMDJjNDExOWYwNThlOTAxNTE0NDA5OTgyMmE4MWEiLCJpYXQiOjE2MzExNjk1MDIsIm5iZiI6MTYzMTE2OTUwMiwiZXhwIjoxNjYyNzA1NTAyLCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.p0YoIC_bhOxIOugYxDQTOFIK9t2ORiHQq9H6JWzdByBJKWkFDBisKaXZJvzn1HdU5cjNQnHaBfWpG1Ed15cQlB2LdpXxxc38iaaGW2J6WhlLhVkehloii-TtlZTOeqNrpAHbSe5DRrmm_L07Llm9wr1T1A6pP3MhzdHiZ9d6748j3_cJjK4CJUl3WfYRTaozLFlI00OCW4zzGfgivSighjSFyhqMoHnQ2iSoeWdcJnYpXzXQdc5AXvXOt6eIIa7o2F6Ma1tUseTYVijEVfngdfd21JI1eH6tHrSqUItkQHAart9o74dJn9micI3WrN5yEBXgzemqWkQGV4QzFHLyd3wk-XvP1s2GhCeWlJZOQADzgzhLoxzFUbgM5xULWHp3yfpePGISlM4ZpBwTHcqQt1i_UkNX_zCxa3RYQbZFDfWW0-UPbvHw40t5BY6X7nTPMhPjPGnnPq18jyYBrWBbC9vBWs2o2IHAe5VlkHtmy_v5fymFJLfFzS784Nxp2qPJFWxI7IfrpNckHxohhs5LoieQivw2MyU2shFOUjgwe0xQgyg6UBg5PwNknGTTmzYdavCM4BiQ7moqOuoI15ccIEmc_uMiuLVEfDPlzejP9PQv6mj6IlkJ8HSu4KZU-LxKmtLnGeEwMjVAZBIhsOwzMkaMF1nZ70pgv2YYwBQyVVs`
  128. },
  129. })
  130. .then(res => {
  131. if (res.data.code == 200) {
  132. if (res.data.status) {
  133. let isPage = res.data.next_page_url == null?false:true;
  134. tab_item.isPage = isPage;
  135. if(!isPage) {
  136. tab_item.loadingClass = false;
  137. tab_item.loadingText = '没有更多数据啦~';
  138. }
  139. if(options.type == 'pageRefresh') {
  140. uni.stopPullDownRefresh();
  141. }else if(options.type == 'scrollRefresh') {
  142. this.isRefresher = false;
  143. }
  144. if(tab_item.page == 1) {
  145. tab_item.list = res.data.data.data;
  146. }else {
  147. tab_item.list.push(...res.data.data.data);
  148. }
  149. console.log('数组列表',tab_item.list)
  150. } else {
  151. wx.showModal({
  152. content: res.data.message || '请下拉页面刷新重试',
  153. showCancel: false
  154. });
  155. }
  156. } else {
  157. wx.showModal({
  158. content: res.data.message || '请下拉页面刷新重试',
  159. showCancel: false
  160. });
  161. }
  162. wx.hideLoading();
  163. })
  164. .catch(() => {
  165. wx.hideLoading();
  166. wx.showModal({
  167. content: '请求失败',
  168. showCancel: false
  169. });
  170. });
  171. }
  172. }
  173. }
  174. </script>
  175. <style lang="scss" scoped="scoped">
  176. .scroll-content{
  177. width: 100%;
  178. display: flex;
  179. flex-wrap: wrap;
  180. justify-content: center;
  181. .card{
  182. width: 686rpx;
  183. height: max-content;
  184. background-color: #FFFFFF;
  185. box-shadow: 1rpx 1rpx 6rpx 3rpx #e5e5e5;
  186. margin-top: 30rpx;
  187. border-radius: 20rpx;
  188. overflow: hidden;
  189. .cover{
  190. width: 686rpx;
  191. height: 300rpx;
  192. position: relative;
  193. .img{
  194. width: 100%;
  195. height: 100%;
  196. background-color: #EEEEEE;
  197. }
  198. .label{
  199. position: absolute;
  200. top: 0;
  201. left: 0;
  202. width: 118rpx;
  203. height: 57rpx;
  204. border-radius: 20rpx 0rpx 20rpx 0rpx;
  205. text-align: center;
  206. line-height: 57rpx;
  207. color: #FFFFFF;
  208. font-size: 26rpx;
  209. }
  210. }
  211. .info{
  212. width: 686rpx;
  213. height: max-content;
  214. padding: 20rpx 30rpx;
  215. box-sizing: border-box;
  216. .title{
  217. font-size: 28rpx;
  218. color: #222222;
  219. font-weight: bold;
  220. }
  221. .date{
  222. margin-top: 20rpx;
  223. font-size: 24rpx;
  224. color: #555555;
  225. }
  226. }
  227. }
  228. }
  229. .theme-1{
  230. background-color: #15716E;
  231. }
  232. .theme-2{
  233. background-color: #1789E4;
  234. }
  235. .theme-3{
  236. background-color: #777777;
  237. }
  238. // tabs 样式修改
  239. /deep/.u-scroll-box {
  240. display: flex;
  241. justify-content: center;
  242. align-items: center;
  243. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  244. }
  245. /deep/.u-scroll-box .u-tab-bar {
  246. background-color: #15716E!important;
  247. width: 80rpx!important;
  248. position: absolute;
  249. left: 0;
  250. bottom: -12rpx;
  251. }
  252. /deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
  253. background-color: #15716E!important;
  254. width: 56rpx!important;
  255. position: absolute;
  256. height: 5rpx!important;
  257. left: 8rpx;
  258. bottom: -4rpx;
  259. }
  260. /deep/ .u-tab-item {
  261. font-size: 28rpx!important;
  262. }
  263. </style>