index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="activity">
  3. <u-navbar leftIconSize="0" :placeholder="true" bgColor="#ffffff">
  4. <view slot="left" style="font-size: 32rpx;">免费抽奖</view>
  5. </u-navbar>
  6. <view class="status">
  7. <u-tabs @change="changeTab" :scrollable="false" :list="statusArr" lineWidth="30" lineHeight="3"
  8. lineColor="#E96737" :activeStyle="{
  9. color: '#E96737',
  10. transform: 'scale(1)',
  11. width: '150rpx',
  12. }" :inactiveStyle="{
  13. color: '#999999',
  14. transform: 'scale(1)',
  15. width: '150rpx'
  16. }" itemStyle="padding-left: 11px; padding-right: 11px; height: 44px;text-align: center; ">
  17. </u-tabs>
  18. </view>
  19. <view class="list">
  20. <view v-for="(item,index) in list" :key="index" class="list-view">
  21. <view class="list-view-slot">
  22. <view @click="toRecord(item)">
  23. <view style="position: relative;">
  24. <image :src="item.picUrl" mode="" class="list-view-slot-img"></image>
  25. <span v-if="item.status.value == 3" style="position: absolute; right: 30rpx; top: 300rpx; border-radius: 6rpx; font-size: 24rpx; padding: 10rpx; color: #333333; background-color: rgba(255, 255, 255, 0.5);">{{item.fakeNum}}人已参与</span>
  26. </view>
  27. <view class="list-view-slot-bor">
  28. <view class="list-view-slot-bor-title">
  29. <view class="time bor-title">{{item.title}}</view>
  30. <!-- <view v-if="item.status.value == 2" class="time">
  31. 开始时间:{{ $parseTime(item.startTime, '{y}-{m}-{d} {h}:{i}:{s}')}}</view> -->
  32. <!-- <view v-else class="time">开奖时间:{{ $parseTime(item.endTime, '{y}-{m}-{d} {h}:{i}:{s}')}} -->
  33. <view v-if="item.status.value == 3" class="timetwo">开奖时间:{{ $parseTime(item.endTime, '{y}-{m}-{d} {h}:{i}:{s}')}}</view>
  34. <view v-else class="time">开奖时间:{{ $parseTime(item.endTime, '{y}-{m}-{d} {h}:{i}:{s}')}}</view>
  35. </view>
  36. <view class="details">
  37. <button class="details-button" v-if="item.status.value == 3">免费参与</button>
  38. <button class="details-buttonTwo" v-else-if="item.isHit == 0">未中奖</button>
  39. <button class="details-button" v-else-if="item.isHit == 1">已中奖</button>
  40. <!-- <button class="details-buttonTwo" v-else>即将开始</button> -->
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="flex empty" v-if="!list.length && !loading && triggerStatus == 0">
  47. <view class="center">
  48. <image class="center-img"
  49. src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_3.png" mode=""></image>
  50. <view class="center-font">新的活动正在准备中...</view>
  51. </view>
  52. <!-- <u-empty text="活动为空" mode="order" /> -->
  53. </view>
  54. <view class="flex empty" v-if="!list.length && !loading && triggerStatus != 0">
  55. <view class="center">
  56. <image class="center-img"
  57. src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_3.png" mode=""></image>
  58. <view class="center-font">还没有已开奖活动</view>
  59. </view>
  60. <!-- <u-empty text="活动为空" mode="order" /> -->
  61. </view>
  62. </view>
  63. <custom-tab-bar :activeValue="'activity'" />
  64. </view>
  65. </template>
  66. <script>
  67. import env from '../../config/env.js'
  68. import $http from '@/utils/request.js'
  69. export default {
  70. data() {
  71. return {
  72. list: [],
  73. statusArr: [{
  74. name: '参与抽奖'
  75. }, {
  76. name: '已开奖',
  77. }, {
  78. disabled: true
  79. }, {
  80. disabled: true
  81. }, {
  82. disabled: true
  83. }],
  84. triggerStatus: 0,
  85. }
  86. },
  87. onLoad(opthios) {
  88. if (opthios.triggerStatus) {
  89. this.triggerStatus = opthios.triggerStatus
  90. }
  91. },
  92. onShow() {
  93. this.pageList()
  94. },
  95. methods: {
  96. toRecord(item) {
  97. if (!uni.getStorageSync('token')) {
  98. uni.navigateTo({
  99. url: '/pages/login/index'
  100. })
  101. return
  102. }
  103. uni.navigateTo({
  104. url: item.status.value == 4 ? `/packageOperate/activity/record?id=${ item.id }` :
  105. `/packageOperate/activity/index?id=${ item.id }`
  106. })
  107. },
  108. changeTab(e) {
  109. if (e.index == 0) {
  110. this.triggerStatus = 0
  111. } else if (e.index == 1) {
  112. this.triggerStatus = 1
  113. }
  114. this.pageList()
  115. },
  116. pageList() {
  117. this.list = []
  118. this.getList()
  119. },
  120. getList() {
  121. uni.showLoading({
  122. title: '加载中'
  123. });
  124. this.loading = true
  125. $http.post(`/api/v1/mp/user/marketing/list?pageNum=1&pageSize=30`, {
  126. triggerStatus: this.triggerStatus,
  127. }).then(res => {
  128. uni.hideLoading();
  129. this.loading = false
  130. if (res.code == 0) {
  131. res.rows.forEach(item => {
  132. let picUrlArr = item.picUrl.split(',')
  133. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/750'
  134. item.status = JSON.parse(item.status)
  135. })
  136. this.total = res.total
  137. this.list = this.list.concat(res.rows)
  138. }
  139. }).catch(() => {
  140. uni.hideLoading();
  141. this.loading = false
  142. })
  143. },
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. .activity {
  149. width: 100%;
  150. height: 100%;
  151. // 设置ios刘海屏底部横线安全区域
  152. padding-bottom: constant(safe-area-inset-bottom);
  153. padding-bottom: env(safe-area-inset-bottom);
  154. }
  155. .status {
  156. width: 100%;
  157. position: fixed;
  158. z-index: 100;
  159. background-color: #FFFFFF;
  160. box-shadow: 0 5rpx 5rpx #ececec;
  161. }
  162. .list {
  163. padding: 120rpx 20rpx 100rpx;
  164. &-view {
  165. text-align: center;
  166. height: 560rpx;
  167. &-slot {
  168. background-color: #FFFFFF;
  169. // margin-bottom: 20rpx;
  170. border-radius: 22rpx;
  171. &-img {
  172. width: 100%;
  173. height: 370rpx;
  174. border-radius: 22rpx 22rpx 0 0;
  175. }
  176. &-bor {
  177. line-height: 50rpx;
  178. width: 700rpx;
  179. height: 140rpx;
  180. margin: 0 auto;
  181. padding: 10rpx 20rpx 0 20rpx;
  182. border-radius: 0 0 22rpx 22rpx;
  183. &-title {
  184. text-align: left;
  185. float: left;
  186. .time {
  187. color: #333333;
  188. }
  189. .bor-title {
  190. font-size: 32rpx;
  191. }
  192. .timetwo {
  193. background: rgba(249, 130, 44, 0.08);
  194. margin-top: 10rpx;
  195. border: 2rpx solid #F9822C;
  196. font-size: 26rpx;
  197. border-radius: 6rpx;
  198. color: #F9822C;
  199. padding: 0 15rpx;
  200. line-height: 40rpx;
  201. }
  202. }
  203. .details {
  204. float: right;
  205. .details-button {
  206. width: 200rpx;
  207. height: 72rpx;
  208. line-height: 72rpx;
  209. background-color: #F9822C;
  210. color: #fff;
  211. margin-top: 30rpx;
  212. font-size: 30rpx;
  213. border-radius: 20rpx;
  214. }
  215. .details-buttonTwo {
  216. width: 200rpx;
  217. height: 72rpx;
  218. line-height: 72rpx;
  219. background-color: #BBBBBB;
  220. color: #fff;
  221. margin-top: 30rpx;
  222. font-size: 30rpx;
  223. border-radius: 20rpx;
  224. }
  225. }
  226. }
  227. }
  228. }
  229. }
  230. .empty {
  231. height: 60vh;
  232. .center {
  233. text-align: center;
  234. &-img {
  235. width: 228rpx;
  236. height: 320rpx;
  237. }
  238. &-font {
  239. font-size: 30rpx;
  240. font-weight: 400;
  241. color: #999999;
  242. margin-bottom: 250rpx;
  243. }
  244. }
  245. }
  246. </style>