index.vue 5.9 KB

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