index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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="scaleToFill" 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 flex">
  28. <view class="list-view-slot-bor-title">
  29. <view class="time bor-title ells-one">{{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="scaleToFill"></image>
  50. <view class="center-font">新的活动正在准备中...</view>
  51. </view>
  52. </view>
  53. <view class="flex empty" v-if="!list.length && !loading && triggerStatus != 0">
  54. <view class="center">
  55. <image class="center-img"
  56. src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/nodata_3.png" mode="scaleToFill"></image>
  57. <view class="center-font">还没有已开奖活动</view>
  58. </view>
  59. </view>
  60. </view>
  61. <custom-tab-bar :activeValue="'activity'" />
  62. </view>
  63. </template>
  64. <script>
  65. import env from '../../config/env.js'
  66. import $http from '@/utils/request.js'
  67. export default {
  68. data() {
  69. return {
  70. list: [],
  71. statusArr: [{
  72. name: '参与抽奖'
  73. }, {
  74. name: '已开奖',
  75. }, {
  76. disabled: true
  77. }, {
  78. disabled: true
  79. }, {
  80. disabled: true
  81. }],
  82. triggerStatus: 0,
  83. userInfo: '',
  84. }
  85. },
  86. onLoad(opthios) {
  87. if (opthios.triggerStatus) {
  88. this.triggerStatus = opthios.triggerStatus
  89. }
  90. if (opthios.userId) {
  91. uni.setStorageSync('shareUid', opthios.userId)
  92. }
  93. if (opthios.type) {
  94. uni.setStorageSync('shareType', opthios.type)
  95. }
  96. },
  97. onShow() {
  98. if(uni.getStorageSync('token')) {
  99. this.getBaseInfo()
  100. }
  101. this.pageList()
  102. },
  103. methods: {
  104. toRecord(item) {
  105. if (!uni.getStorageSync('token')) {
  106. uni.navigateTo({
  107. url: '/pages/login/index'
  108. })
  109. return
  110. }
  111. uni.navigateTo({
  112. url: item.status.value == 4 ? `/packageOperate/activity/record?id=${ item.id }` :
  113. `/packageOperate/activity/index?id=${ item.id }`
  114. })
  115. },
  116. changeTab(e) {
  117. if (e.index == 0) {
  118. this.triggerStatus = 0
  119. } else if (e.index == 1) {
  120. this.triggerStatus = 1
  121. }
  122. this.pageList()
  123. },
  124. pageList() {
  125. this.list = []
  126. this.getList()
  127. },
  128. getList() {
  129. uni.showLoading({
  130. title: '加载中'
  131. });
  132. this.loading = true
  133. $http.post(`/api/v1/mp/user/marketing/list?pageNum=1&pageSize=30`, {
  134. triggerStatus: this.triggerStatus,
  135. }).then(res => {
  136. uni.hideLoading();
  137. this.loading = false
  138. if (res.code == 0) {
  139. res.rows.forEach(item => {
  140. let picUrlArr = item.picUrl.split(',')
  141. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/750'
  142. item.status = JSON.parse(item.status)
  143. })
  144. this.total = res.total
  145. this.list = this.list.concat(res.rows)
  146. }
  147. }).catch(() => {
  148. uni.hideLoading();
  149. this.loading = false
  150. })
  151. },
  152. getBaseInfo() {
  153. $http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
  154. uni.hideLoading();
  155. if (res.code == 0) {
  156. this.userInfo = res.data
  157. }
  158. })
  159. },
  160. },
  161. //分享好友
  162. onShareAppMessage(res) {
  163. return {
  164. title: '盲票,玩的就是有趣',
  165. path: '/pages/index/index'
  166. }
  167. },
  168. //分享朋友圈
  169. onShareTimeline() {
  170. return {
  171. title: '盲票,玩的就是有趣',
  172. // query: { userId: this.userInfo.userId,
  173. // type: 1, }
  174. query: `userId=${ this.userInfo.userId }&type=1`
  175. }
  176. }
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. .activity {
  181. width: 100%;
  182. height: 100%;
  183. // 设置ios刘海屏底部横线安全区域
  184. padding-bottom: constant(safe-area-inset-bottom);
  185. padding-bottom: env(safe-area-inset-bottom);
  186. }
  187. .status {
  188. width: 100%;
  189. position: fixed;
  190. z-index: 100;
  191. background-color: #FFFFFF;
  192. box-shadow: 0 5rpx 5rpx #ececec;
  193. }
  194. .list {
  195. padding: 120rpx 20rpx 100rpx;
  196. &-view {
  197. text-align: center;
  198. height: 560rpx;
  199. &-slot {
  200. background-color: #FFFFFF;
  201. // margin-bottom: 20rpx;
  202. border-radius: 22rpx;
  203. &-img {
  204. width: 100%;
  205. height: 370rpx;
  206. border-radius: 22rpx 22rpx 0 0;
  207. }
  208. &-bor {
  209. justify-content: space-between;
  210. line-height: 50rpx;
  211. width: 700rpx;
  212. height: 140rpx;
  213. margin: 0 auto;
  214. padding: 10rpx 20rpx 0 20rpx;
  215. border-radius: 0 0 22rpx 22rpx;
  216. &-title {
  217. text-align: left;
  218. float: left;
  219. .time {
  220. color: #333333;
  221. }
  222. .bor-title {
  223. font-size: 32rpx;
  224. // width: 70%;
  225. }
  226. .timetwo {
  227. width: 430rpx;
  228. background: rgba(249, 130, 44, 0.08);
  229. margin-top: 10rpx;
  230. border: 2rpx solid #F9822C;
  231. font-size: 26rpx;
  232. border-radius: 6rpx;
  233. color: #F9822C;
  234. padding: 0 15rpx;
  235. line-height: 40rpx;
  236. }
  237. }
  238. .details {
  239. float: right;
  240. .details-button {
  241. width: 200rpx;
  242. height: 72rpx;
  243. line-height: 72rpx;
  244. background-color: #F9822C;
  245. color: #fff;
  246. margin-top: 30rpx;
  247. font-size: 30rpx;
  248. border-radius: 20rpx;
  249. }
  250. .details-buttonTwo {
  251. width: 200rpx;
  252. height: 72rpx;
  253. line-height: 72rpx;
  254. background-color: #BBBBBB;
  255. color: #fff;
  256. margin-top: 30rpx;
  257. font-size: 30rpx;
  258. border-radius: 20rpx;
  259. }
  260. }
  261. }
  262. }
  263. }
  264. }
  265. .empty {
  266. height: 60vh;
  267. .center {
  268. text-align: center;
  269. &-img {
  270. width: 228rpx;
  271. height: 320rpx;
  272. }
  273. &-font {
  274. font-size: 30rpx;
  275. font-weight: 400;
  276. color: #999999;
  277. margin-bottom: 250rpx;
  278. }
  279. }
  280. }
  281. </style>