index.vue 5.6 KB

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