index.vue 6.5 KB

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