index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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">
  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>
  55. <custom-tab-bar :activeValue="'activity'" />
  56. </view>
  57. </template>
  58. <script>
  59. import env from '../../config/env.js'
  60. import $http from '@/utils/request.js'
  61. export default {
  62. data() {
  63. return {
  64. list: [],
  65. statusArr: [{
  66. name: '参与抽奖'
  67. }, {
  68. name: '已开奖',
  69. }, {
  70. disabled: true
  71. }, {
  72. disabled: true
  73. }, {
  74. disabled: true
  75. }],
  76. triggerStatus: 0,
  77. }
  78. },
  79. onLoad(opthios) {
  80. if (opthios.triggerStatus) {
  81. this.triggerStatus = opthios.triggerStatus
  82. }
  83. },
  84. onShow() {
  85. this.pageList()
  86. },
  87. methods: {
  88. toRecord(item) {
  89. if (!uni.getStorageSync('token')) {
  90. uni.navigateTo({
  91. url: '/pages/login/index'
  92. })
  93. return
  94. }
  95. uni.navigateTo({
  96. url: item.status.value == 4 ? `/packageOperate/activity/record?id=${ item.id }` :
  97. `/packageOperate/activity/index?id=${ item.id }`
  98. })
  99. },
  100. changeTab(e) {
  101. if (e.index == 0) {
  102. this.triggerStatus = 0
  103. } else if (e.index == 1) {
  104. this.triggerStatus = 1
  105. }
  106. this.pageList()
  107. },
  108. pageList() {
  109. this.list = []
  110. this.getList()
  111. },
  112. getList() {
  113. uni.showLoading({
  114. title: '加载中'
  115. });
  116. this.loading = true
  117. $http.post(`/api/v1/mp/user/marketing/list?pageNum=1&pageSize=30`, {
  118. triggerStatus: this.triggerStatus,
  119. }).then(res => {
  120. uni.hideLoading();
  121. this.loading = false
  122. if (res.code == 0) {
  123. res.rows.forEach(item => {
  124. let picUrlArr = item.picUrl.split(',')
  125. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/750'
  126. item.status = JSON.parse(item.status)
  127. })
  128. this.total = res.total
  129. this.list = this.list.concat(res.rows)
  130. }
  131. }).catch(() => {
  132. uni.hideLoading();
  133. this.loading = false
  134. })
  135. },
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .activity {
  141. width: 100%;
  142. height: 100%;
  143. // 设置ios刘海屏底部横线安全区域
  144. padding-bottom: constant(safe-area-inset-bottom);
  145. padding-bottom: env(safe-area-inset-bottom);
  146. }
  147. .status {
  148. width: 100%;
  149. position: fixed;
  150. z-index: 100;
  151. background-color: #FFFFFF;
  152. box-shadow: 0 5rpx 5rpx #ececec;
  153. }
  154. .list {
  155. padding: 120rpx 20rpx 100rpx;
  156. &-view {
  157. text-align: center;
  158. height: 560rpx;
  159. &-slot {
  160. background-color: #FFFFFF;
  161. // margin-bottom: 20rpx;
  162. border-radius: 22rpx;
  163. &-img {
  164. width: 100%;
  165. height: 370rpx;
  166. border-radius: 22rpx 22rpx 0 0;
  167. }
  168. &-bor {
  169. line-height: 50rpx;
  170. width: 700rpx;
  171. height: 140rpx;
  172. margin: 0 auto;
  173. padding: 10rpx 20rpx 0 20rpx;
  174. border-radius: 0 0 22rpx 22rpx;
  175. &-title {
  176. text-align: left;
  177. float: left;
  178. .time {
  179. color: #333333;
  180. }
  181. .bor-title {
  182. font-size: 32rpx;
  183. }
  184. .timetwo {
  185. background: rgba(249, 130, 44, 0.08);
  186. margin-top: 10rpx;
  187. border: 2rpx solid #F9822C;
  188. font-size: 26rpx;
  189. border-radius: 6rpx;
  190. color: #F9822C;
  191. padding: 0 15rpx;
  192. line-height: 40rpx;
  193. }
  194. }
  195. .details {
  196. float: right;
  197. .details-button {
  198. width: 200rpx;
  199. height: 72rpx;
  200. line-height: 72rpx;
  201. background-color: #F9822C;
  202. color: #fff;
  203. margin-top: 30rpx;
  204. font-size: 30rpx;
  205. border-radius: 20rpx;
  206. }
  207. .details-buttonTwo {
  208. width: 200rpx;
  209. height: 72rpx;
  210. line-height: 72rpx;
  211. background-color: #BBBBBB;
  212. color: #fff;
  213. margin-top: 30rpx;
  214. font-size: 30rpx;
  215. border-radius: 20rpx;
  216. }
  217. }
  218. }
  219. }
  220. }
  221. }
  222. .empty {
  223. height: 60vh;
  224. .center {
  225. text-align: center;
  226. &-img {
  227. width: 228rpx;
  228. height: 320rpx;
  229. }
  230. &-font {
  231. font-size: 30rpx;
  232. font-weight: 400;
  233. color: #999999;
  234. margin-bottom: 250rpx;
  235. }
  236. }
  237. }
  238. </style>