index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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.pageList()
  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.pageList()
  91. },
  92. pageList() {
  93. this.pageNum = 1
  94. this.list = []
  95. this.getList()
  96. },
  97. getList() {
  98. uni.showLoading({
  99. title: '加载中'
  100. });
  101. this.loading = true
  102. $http.post(`/api/v1/mp/user/marketing/list?pageNum=${ this.pageNum }&pageSize=20`, {
  103. triggerStatus: this.triggerStatus,
  104. }).then(res => {
  105. uni.hideLoading();
  106. this.loading = false
  107. if (res.code == 0) {
  108. res.rows.forEach(item => {
  109. let picUrlArr = item.picUrl.split(',')
  110. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/750'
  111. item.status = JSON.parse(item.status)
  112. })
  113. this.total = res.total
  114. this.list = this.list.concat(res.rows)
  115. }
  116. }).catch(() => {
  117. uni.hideLoading();
  118. this.loading = false
  119. })
  120. },
  121. }
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. .activity {
  126. width: 100%;
  127. height: 100%;
  128. // 设置ios刘海屏底部横线安全区域
  129. padding-bottom: constant(safe-area-inset-bottom);
  130. padding-bottom: env(safe-area-inset-bottom);
  131. }
  132. .status {
  133. width: 100%;
  134. position: fixed;
  135. z-index: 100;
  136. background-color: #FFFFFF;
  137. box-shadow: 0 5rpx 5rpx #ececec;
  138. }
  139. .list {
  140. padding: 120rpx 20rpx 100rpx;
  141. &-view {
  142. text-align: center;
  143. height: 530rpx;
  144. &-slot {
  145. background-color: #FFFFFF;
  146. // margin-bottom: 20rpx;
  147. border-radius: 22rpx;
  148. &-img {
  149. width: 100%;
  150. height: 370rpx;
  151. border-radius: 22rpx 22rpx 0 0;
  152. }
  153. &-bor {
  154. line-height: 50rpx;
  155. width: 700rpx;
  156. height: 120rpx;
  157. margin: 0 auto;
  158. padding:10rpx 20rpx 0 20rpx;
  159. border-radius: 0 0 22rpx 22rpx ;
  160. &-title {
  161. text-align: left; float: left;
  162. .time {
  163. color: #333333;
  164. }
  165. .bor-title {
  166. font-size: 34rpx;
  167. }
  168. }
  169. .details {
  170. float: right;
  171. .details-button{
  172. width: 200rpx;
  173. height: 72rpx;
  174. line-height: 72rpx;
  175. background-color: #F9822C;
  176. color: #fff;
  177. margin-top: 18rpx;
  178. font-size: 30rpx;
  179. border-radius: 36rpx;
  180. }
  181. .details-buttonTwo{
  182. width: 200rpx;
  183. height: 72rpx;
  184. line-height: 72rpx;
  185. background-color: #BBBBBB;
  186. color: #fff;
  187. margin-top: 18rpx;
  188. font-size: 30rpx;
  189. border-radius: 36rpx;
  190. }
  191. }
  192. }
  193. }
  194. }
  195. }
  196. .empty {
  197. height: 60vh;
  198. }
  199. </style>