index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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" 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. getActivityList({
  80. shopId: this.shopId,
  81. ...this.query,
  82. }).then(res => {
  83. this.list = res.content.records || [];
  84. this.loading = false;
  85. this.list = res.content.records;
  86. let total = this.list.length
  87. if (total >= res.content.total) {
  88. this.listStatus = "noMore";
  89. } else {
  90. this.listStatus = "more";
  91. this.query.currentPage++;
  92. }
  93. })
  94. },
  95. onClickStatus(item) {
  96. this.query.state = item.value;
  97. this.getList();
  98. },
  99. onClick(row) {
  100. // options.scene
  101. if (uni.getStorageSync("token")) {
  102. uni.navigateTo({
  103. url: "/signUp/index?scene=" + row.id,
  104. });
  105. } else {
  106. uni.showModal({
  107. title: "请登录",
  108. confirmText: "去登录",
  109. success(res) {
  110. console.log(res);
  111. if (res.confirm) {
  112. uni.navigateTo({
  113. url: "../../login/login/login?redirect=/pages/activity/index",
  114. });
  115. }
  116. },
  117. });
  118. }
  119. },
  120. onRefresh() {
  121. console.log("下拉刷新了", this.triggered);
  122. this.triggered = true
  123. setTimeout(() => {
  124. this.triggered = false;
  125. }, 1000)
  126. },
  127. loadMore() {
  128. this.getList();
  129. },
  130. },
  131. };
  132. </script>
  133. <style>
  134. page {
  135. background-color: #fafafa;
  136. }
  137. </style>
  138. <style lang="scss" scoped>
  139. .navBarBox .navBar .logo {
  140. width: 0rpx;
  141. height: 82rpx;
  142. // margin-right: 10rpx;
  143. }
  144. .navBarBox .navBar {
  145. font-size: 35rpx;
  146. font-weight: bold;
  147. padding: 3rpx 50rpx;
  148. padding-bottom: 8rpx;
  149. display: flex;
  150. flex-direction: row;
  151. justify-content: center;
  152. align-items: center;
  153. }
  154. .content {
  155. // padding-top: 24%;
  156. }
  157. // .view-content {
  158. // height: 600px;
  159. // background-color: red;
  160. // }
  161. .nvBarBox {
  162. display: flex;
  163. flex-direction: row;
  164. justify-content: space-around;
  165. align-items: center;
  166. // background-color: #fff;
  167. padding: 10rpx 0;
  168. font-size: 30rpx;
  169. color: #999999;
  170. .active {
  171. color: #333333;
  172. font-weight: bold;
  173. }
  174. }
  175. .img-veiew {
  176. position: relative;
  177. overflow: hidden;
  178. .badge {
  179. position: absolute;
  180. top: 0;
  181. right: 0;
  182. width: 120rpx;
  183. text-align: center;
  184. background-color: #DBDBDB;
  185. color: #7A7A7A;
  186. font-size: 24rpx;
  187. padding: 5rpx 10rpx;
  188. }
  189. }
  190. .cover {
  191. width: 100%;
  192. height: 320rpx;
  193. }
  194. .content-box {
  195. padding: 10rpx 20rpx;
  196. // height: 150rpx;
  197. .title {
  198. font-weight: bold;
  199. color: black;
  200. font-size: 32rpx;
  201. // 超出文本使用...
  202. overflow: hidden;
  203. text-overflow: ellipsis;
  204. white-space: nowrap;
  205. }
  206. .sub-title {
  207. font-size: 30rpx;
  208. margin: 15rpx 0 30rpx 0;
  209. overflow: hidden;
  210. text-overflow: ellipsis;
  211. white-space: nowrap;
  212. }
  213. .actionBox {
  214. display: flex;
  215. flex-direction: row;
  216. justify-content: space-around;
  217. margin-top: 10rpx;
  218. .actionItem {
  219. width: 100%;
  220. height: 100%;
  221. display: flex;
  222. justify-content: center;
  223. font-size: 24rpx;
  224. color: #212222;
  225. }
  226. // 前2个后面加线
  227. .actionItem:nth-child(1),
  228. .actionItem:nth-child(2) {
  229. border-right: 1px solid #ccc;
  230. }
  231. }
  232. }
  233. </style>