index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <view class="content">
  3. <view class="navBarBox">
  4. <view class="statusBar" :style="{ paddingTop: statusBarHeight + 'px' }"></view>
  5. <view class="navBar">
  6. <view>活动</view>
  7. <image class="logo" mode="scaleToFill"></image>
  8. </view>
  9. </view>
  10. <!-- <view class="nvBarBox">
  11. <view @click="onClickStatus(item)" v-for="item in status" :class="[query.state === item.value ? 'active' : '']">{{
  12. item.name }}</view>
  13. </view> -->
  14. <zs-list mt="0" @load="loadMore" :status="listStatus">
  15. <uni-card v-for="item in list" :key="item.activityCover" padding="0" spacing="0">
  16. <view @click.stop="onClick(item)">
  17. <view class='img-veiew'>
  18. <!-- <view class="badge">{{ item.status }}</view> -->
  19. <image slot="cover" class="cover" :src="item.activityCover">
  20. </image>
  21. </view>
  22. <view class="content-box">
  23. <view class="title">{{ item.activityName }}</view>
  24. <view class="sub-title">
  25. 活动时间: {{ item.activityStartTime }} 至 {{ item.activityEndTime }}
  26. </view>
  27. <!-- <view class="sub-title">
  28. 活动地点:{{ item.address }}
  29. </view> -->
  30. </view>
  31. </view>
  32. </uni-card>
  33. </zs-list>
  34. <zs-tab-bar :value="1"></zs-tab-bar>
  35. </view>
  36. </template>
  37. <script>
  38. import uniCard from "@/uni_modules/uni-card/components/uni-card/uni-card.vue";
  39. import { getActivityList } from "../../api/activity";
  40. export default {
  41. components: {
  42. uniCard,
  43. },
  44. data() {
  45. return {
  46. navBarHeight: 0,
  47. statusBarHeight: 0,
  48. list: [],
  49. triggered: false,
  50. loading: false,
  51. status: [
  52. // wait 未开始 doing 进行中 over 已结束
  53. { name: "全部", value: null },
  54. { name: "未开始", value: 'wait' },
  55. { name: "进行中", value: 'doing' },
  56. { name: "已结束", value: 'over' },
  57. ],
  58. shopId: uni.getStorageSync("gdShopId"),
  59. query: {
  60. currentPage: 1,
  61. pageSize: 3,
  62. activityEnable: 1,
  63. state: null,
  64. },
  65. listStatus: "more", // more noMore loading
  66. };
  67. },
  68. onShow() {
  69. this.getList();
  70. this.query.state = null;
  71. },
  72. created() {
  73. this.navBarHeight = this.$navHight(1);
  74. this.statusBarHeight = uni.getSystemInfoSync()["statusBarHeight"];
  75. this.navBarHeight = this.navBarHeight + 10 + "px";
  76. },
  77. methods: {
  78. getList() {
  79. this.listStatus="loading"
  80. getActivityList({
  81. shopId: this.shopId,
  82. ...this.query,
  83. }).then(res => {
  84. this.list = this.list.concat(res.content.records);
  85. this.loading = false;
  86. // this.list = res.content.records;
  87. let total = this.list.length
  88. if (total >= res.content.total) {
  89. this.listStatus = "noMore";
  90. } else {
  91. this.listStatus = "more";
  92. this.query.currentPage++;
  93. }
  94. })
  95. },
  96. onClickStatus(item) {
  97. this.query.state = item.value;
  98. this.getList();
  99. },
  100. onClick(row) {
  101. // options.scene
  102. if (uni.getStorageSync("token")) {
  103. uni.navigateTo({
  104. url: "/signUp/index?scene=" + row.id,
  105. });
  106. } else {
  107. uni.showModal({
  108. title: "请登录",
  109. confirmText: "去登录",
  110. success(res) {
  111. console.log(res);
  112. if (res.confirm) {
  113. uni.navigateTo({
  114. url: "../../login/login/login?redirect=/pages/activity/index",
  115. });
  116. }
  117. },
  118. });
  119. }
  120. },
  121. onRefresh() {
  122. console.log("下拉刷新了", this.triggered);
  123. this.triggered = true
  124. setTimeout(() => {
  125. this.triggered = false;
  126. }, 1000)
  127. },
  128. loadMore() {
  129. this.getList();
  130. },
  131. },
  132. };
  133. </script>
  134. <style>
  135. page {
  136. background-color: #fafafa;
  137. }
  138. </style>
  139. <style lang="scss" scoped>
  140. ::v-deep .zs-list {
  141. height: 80vh;
  142. overflow-y: scroll;
  143. }
  144. .navBarBox .navBar .logo {
  145. width: 0rpx;
  146. height: 82rpx;
  147. // margin-right: 10rpx;
  148. }
  149. .navBarBox .navBar {
  150. font-size: 35rpx;
  151. font-weight: bold;
  152. padding: 3rpx 50rpx;
  153. padding-bottom: 8rpx;
  154. display: flex;
  155. flex-direction: row;
  156. justify-content: center;
  157. align-items: center;
  158. }
  159. .content {
  160. // padding-top: 24%;
  161. }
  162. // .view-content {
  163. // height: 600px;
  164. // background-color: red;
  165. // }
  166. .nvBarBox {
  167. display: flex;
  168. flex-direction: row;
  169. justify-content: space-around;
  170. align-items: center;
  171. // background-color: #fff;
  172. padding: 10rpx 0;
  173. font-size: 30rpx;
  174. color: #999999;
  175. .active {
  176. color: #333333;
  177. font-weight: bold;
  178. }
  179. }
  180. .img-veiew {
  181. position: relative;
  182. overflow: hidden;
  183. .badge {
  184. position: absolute;
  185. top: 0;
  186. right: 0;
  187. width: 120rpx;
  188. text-align: center;
  189. background-color: #DBDBDB;
  190. color: #7A7A7A;
  191. font-size: 24rpx;
  192. padding: 5rpx 10rpx;
  193. }
  194. }
  195. .cover {
  196. width: 100%;
  197. height: 320rpx;
  198. }
  199. .content-box {
  200. padding: 10rpx 20rpx;
  201. // height: 150rpx;
  202. .title {
  203. font-weight: bold;
  204. color: black;
  205. font-size: 32rpx;
  206. // 超出文本使用...
  207. overflow: hidden;
  208. text-overflow: ellipsis;
  209. white-space: nowrap;
  210. }
  211. .sub-title {
  212. font-size: 30rpx;
  213. margin: 15rpx 0 30rpx 0;
  214. overflow: hidden;
  215. text-overflow: ellipsis;
  216. white-space: nowrap;
  217. }
  218. .actionBox {
  219. display: flex;
  220. flex-direction: row;
  221. justify-content: space-around;
  222. margin-top: 10rpx;
  223. .actionItem {
  224. width: 100%;
  225. height: 100%;
  226. display: flex;
  227. justify-content: center;
  228. font-size: 24rpx;
  229. color: #212222;
  230. }
  231. // 前2个后面加线
  232. .actionItem:nth-child(1),
  233. .actionItem:nth-child(2) {
  234. border-right: 1px solid #ccc;
  235. }
  236. }
  237. }
  238. </style>