prince.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view>
  3. <view class="wrapper flex-align-between" v-if="data">
  4. <image :src="resource.prince_bg" class="bg" mode="scaleToFill" />
  5. <view class="flex-column-around flex1 overflow-hidden">
  6. <view class="flex-align">
  7. <image v-if="data.status == 1" :src="resource.prince_ing" class="flag" />
  8. <image v-else-if="data.status == 0" :src="resource.prince_wait" class="flag" />
  9. </view>
  10. <view class="flex-align paddingY15">
  11. <image :src="resource.prince_fun1" class="item" @click="showRule" />
  12. <image :src="resource.prince_fun2" class="marginL5" style="width: 108rpx; height: 40rpx" @click="showRank" />
  13. </view>
  14. <view class="time-wrapper">
  15. <text v-if="data.status == 0">距开始:{{leftTimeStr}}</text>
  16. <text v-if="data.status == 1">距结束:{{leftTimeStr}}</text>
  17. </view>
  18. </view>
  19. <!-- <view class="goods-wrapper flex-shrink0">
  20. <image :src="data.spu.cover" class="cover" @click="showGoodsDetail(data.spu)" />
  21. </view> -->
  22. <view class="flex-column-align-center">
  23. <image :src="resource.prince_magic_current" style="height: 33rpx; width: 0" mode="heightFix"/>
  24. <view class="paddingT12 bold font10" style="color: #19F4FF">{{data.magicQuantity}}</view>
  25. </view>
  26. <prince-rule ref="ruleRef" v-if="data.luckKing" :luckKing="data.luckKing" />
  27. <prince-rank ref="rankRef" v-if="data.luckKing" :poolId="poolId" :luckKing="data.luckKing"/>
  28. <prince-goods ref="ruleGoods" :poolId="poolId" @showDetail="showGoodsDetail" />
  29. <goods-detail ref="goodsDetailRef" @close="goodsDetailColse" />
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import resource from '@/utils/resource'
  35. import princeRule from './prince_rule'
  36. import princeRank from './prince_rank'
  37. import princeGoods from './prince_goods'
  38. import goodsDetail from './../store/goods_detail'
  39. export default {
  40. components: { goodsDetail, princeRule, princeRank, princeGoods },
  41. props: {
  42. poolId: Number
  43. },
  44. data() {
  45. return {
  46. data: null,
  47. resource,
  48. leftTime: 0
  49. }
  50. },
  51. computed: {
  52. leftTimeStr() {
  53. if (!this.data || !this.leftTime) return ''
  54. return this.generaTimeStr(this.leftTime)
  55. }
  56. },
  57. mounted() {
  58. },
  59. beforeDestroy() {
  60. this.stopTimer()
  61. },
  62. methods: {
  63. refresh() {
  64. this.getData()
  65. },
  66. async getData() {
  67. const res = await this.$service.award.king(this.poolId)
  68. this.data = res
  69. if (res) {
  70. this.handleLeftTime()
  71. }
  72. },
  73. handleLeftTime() {
  74. if (!this.data || !this.data.leftTime) {
  75. this.stopTimer()
  76. return
  77. }
  78. this.leftTime = parseInt(this.data.leftTime / 1000)
  79. this.startTimer()
  80. },
  81. startTimer() {
  82. this.stopTimer()
  83. this.timer = setInterval(() => {
  84. this.leftTime -= 1
  85. if (this.leftTime <= -1) {
  86. this.stopTimer()
  87. this.$emit('refresh')
  88. }
  89. }, 1000)
  90. },
  91. stopTimer() {
  92. if (this.timer) {
  93. this.leftTime = 0
  94. clearInterval(this.timer)
  95. this.timer = null
  96. }
  97. },
  98. showRule() {
  99. this.$refs.ruleRef.show()
  100. },
  101. showRank() {
  102. this.$refs.rankRef.show()
  103. },
  104. showGoods() {
  105. this.$refs.ruleGoods.show()
  106. },
  107. showGoodsDetail(spu) {
  108. this.$parent.$parent.lock = true
  109. this.$refs.goodsDetailRef.show(spu)
  110. },
  111. goodsDetailColse() {
  112. this.$parent.$parent.lock = false
  113. },
  114. generaTimeStr(value) {
  115. let second = value
  116. let baseMin = 60
  117. let baseHour = baseMin * 60
  118. let baseDay = baseHour * 24
  119. let str = ''
  120. if (second >= baseHour) {
  121. let hours = parseInt(second / baseHour)
  122. str += (hours < 10 ? '0' + hours : hours) + ':'
  123. second = second % baseHour
  124. } else {
  125. str += '00:'
  126. }
  127. if (second >= baseMin) {
  128. let mins = parseInt(second / baseMin)
  129. str += (mins < 10 ? '0' + mins : mins) + ':'
  130. second = second % baseMin
  131. } else {
  132. str += '00:'
  133. }
  134. if (parseInt(second) > 0) {
  135. str += second < 10 ? '0' + second : second
  136. } else {
  137. str += '00'
  138. }
  139. return str
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .wrapper {
  146. position: relative;
  147. margin: 0 28rpx;
  148. height: 228rpx;
  149. background: rgba(10, 10, 25, 0.6);
  150. box-shadow: 0px 0px 4px 2px rgba(147, 67, 255, 0.3),
  151. inset 0px 0px 20px 0px rgba(0, 131, 255, 0.8);
  152. border-radius: 10px;
  153. border: 1px solid #5b9cff;
  154. overflow: hidden;
  155. padding: 0 32rpx 0 200rpx;
  156. .bg {
  157. position: absolute;
  158. left: 0;
  159. top: 0;
  160. width: 100%;
  161. height: 100%;
  162. }
  163. .goods-wrapper {
  164. margin-left: 10px;
  165. position: relative;
  166. width: 74px;
  167. height: 88px;
  168. box-shadow: 0px 0px 10px 10px rgba(147, 67, 255, 0.3);
  169. border-radius: 4px;
  170. border: 1px solid #00a2e7;
  171. overflow: hidden;
  172. .mask {
  173. position: absolute;
  174. left: 0;
  175. right: 0;
  176. top: 0;
  177. bottom: 0;
  178. background: rgba($color: #000000, $alpha: 0.4);
  179. }
  180. .last-flag {
  181. position: absolute;
  182. top: 8rpx;
  183. width: 80rpx;
  184. height: 20rpx;
  185. text-align: center;
  186. }
  187. .nickname {
  188. position: absolute;
  189. left: 0;
  190. right: 0;
  191. bottom: 12rpx;
  192. height: 24rpx;
  193. background: linear-gradient(315deg, #2bebe8 0%, #3ba1ff 100%);
  194. text-align: center;
  195. font-size: 20rpx;
  196. line-height: 24rpx;
  197. color: #fff;
  198. }
  199. .cover {
  200. width: 100%;
  201. height: 100%;
  202. }
  203. .avatar {
  204. position: absolute;
  205. width: 56rpx;
  206. height: 56rpx;
  207. border-radius: 28rpx;
  208. }
  209. }
  210. .refresh {
  211. position: absolute;
  212. right: 0;
  213. top: 0;
  214. width: 50rpx;
  215. height: 36rpx;
  216. }
  217. .flag {
  218. width: 104rpx;
  219. height: 32rpx;
  220. }
  221. .schedule-wrapper {
  222. background: rgba($color: #85bbff, $alpha: 0.3);
  223. width: 230rpx;
  224. height: 20rpx;
  225. overflow: hidden;
  226. border-radius: 2rpx;
  227. }
  228. .num-wrapper {
  229. width: 12px;
  230. height: 16px;
  231. line-height: 16px;
  232. background: linear-gradient(315deg, #2bebe8 0%, #3ba1ff 100%);
  233. color: white;
  234. font-size: 13px;
  235. text-align: center;
  236. }
  237. .item {
  238. width: 88rpx;
  239. height: 40rpx;
  240. }
  241. .time-wrapper {
  242. height: 16px;
  243. background: linear-gradient(315deg, #2bebe8 0%, #3ba1ff 100%);
  244. color: #000;
  245. font-size: 12px;
  246. text-align: center;
  247. }
  248. }
  249. </style>