index.vue 5.1 KB

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