result_com.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <view class="cu-modal" :class="{ show: visible }" v-if="visible">
  3. <view class="mask"></view>
  4. <view
  5. class="wrapper cu-dialog"
  6. :class="{
  7. listWrapper: tableData.length > 1
  8. }"
  9. :style="{
  10. backgroundImage: tableData.length == 1 ? 'url(' + ossurl.box.raffleBg + ')' : ''
  11. }"
  12. >
  13. <view class="relative">
  14. <view class="content paddingY21">
  15. <view
  16. v-if="tableData.length == 1"
  17. class="paddingT22 paddingB2"
  18. @click="showDetail(tableData[0])"
  19. >
  20. <view class="levelTitle">
  21. <image
  22. :src="LEVEL_MAP[tableData[0].level].titleText"
  23. mode="aspectFit"
  24. />
  25. </view>
  26. <view class="superTitle">
  27. {{ tableData[0].name }}
  28. </view>
  29. <image
  30. class="super-image translateX"
  31. :src="tableData[0].cover"
  32. mode="aspectFit"
  33. />
  34. </view>
  35. <view class="listBox" v-else>
  36. <view class="lotteryTitle">
  37. <image
  38. class="lotteryTitleimage"
  39. :src="ossurl.box.lotteryTitle"
  40. mode="aspectFit"
  41. />
  42. </view>
  43. <scroll-view scroll-y style="height: 700rpx">
  44. <view class="flex-wrap flex-align-center paddingT22 paddingB2">
  45. <view
  46. v-for="item in tableData"
  47. :key="item.id"
  48. class="marginB15 marginX5"
  49. @click="showDetail(item)"
  50. >
  51. <card
  52. v-if="num == 1"
  53. :data="item"
  54. :show-add="!!periodQuantity"
  55. />
  56. <!-- <view
  57. v-if="num == 1"
  58. class="paddingT22 paddingB2"
  59. @click="showDetail(tableData[0])"
  60. >
  61. <view class="levelTitle">
  62. <image
  63. :src="LEVEL_MAP[tableData[0].level].titleText"
  64. mode="aspectFit"
  65. />
  66. </view>
  67. <view class="superTitle">
  68. {{ tableData[0].name }}
  69. </view>
  70. <image
  71. class="super-image translateX"
  72. :src="tableData[0].cover"
  73. mode="aspectFit"
  74. />
  75. </view> -->
  76. <card
  77. v-else
  78. :data="item"
  79. :size="{ width: 196, height: 300 }"
  80. :cover-size="{ width: 160, height: 203, top: 18 }"
  81. :text-size="{ width: 129, height: 58, bottom: 21 }"
  82. :addSize="{ width: 124, height: 28 }"
  83. :show-add="!!periodQuantity"
  84. />
  85. </view>
  86. </view>
  87. </scroll-view>
  88. </view>
  89. <view v-if="!isDemo" class="flex-align-center paddingT10">
  90. <view
  91. v-if="!!total && showDh && hide"
  92. class="relative dhBtn"
  93. @click="dhAll"
  94. >
  95. <view>全部兑换</view>
  96. <view class="btnText">共兑换源石 {{ total }}</view>
  97. </view>
  98. <view class="relative agianBtn" @click="$router.back()">再来一发</view>
  99. </view>
  100. <view v-else class="flex-align-center paddingT10">
  101. <view class="relative">
  102. <view class="agianBtn" @click="$router.back()">来把真的</view>
  103. </view>
  104. </view>
  105. <view
  106. class="flex-align-center paddingT12 showStore"
  107. @click="$router.push('store')"
  108. >
  109. <view>
  110. 前往
  111. <span class="color-theme storeText">仓库</span>
  112. 查看
  113. </view>
  114. </view>
  115. </view>
  116. <view v-if="roll && roll > 0" class="roll translateX flex-align-center">
  117. 骰子 + {{ roll }}
  118. </view>
  119. </view>
  120. <view class="paddingT30 flex-align-center">
  121. <view class="close cuIcon-close" @click="$router.back()"></view>
  122. </view>
  123. <view class="flex-align-center paddingT20">
  124. <view class="color-theme">抽奖动画</view>
  125. <view class="marginL12">
  126. <switch
  127. class="purple"
  128. :checked="animalChecked"
  129. @change="changeAnimalChecked"
  130. ></switch>
  131. </view>
  132. </view>
  133. </view>
  134. <goods-detail ref="goodsDetailRef" />
  135. </view>
  136. </template>
  137. <script>
  138. import { throttle } from '@/utils'
  139. import resource from '@/utils/resource'
  140. import card from './card'
  141. import store from '@/store'
  142. import { SET_CLOSE_ANIMAL } from '@/store/mutation-types'
  143. import goodsDetail from './../store/goods_detail'
  144. import ossurl from '@/utils/ossurl'
  145. import { LEVEL_MAP } from '@/utils/config'
  146. export default {
  147. components: { card, goodsDetail },
  148. props: {
  149. num: Number,
  150. isDemo: Boolean,
  151. periodQuantity: Number
  152. },
  153. data() {
  154. return {
  155. LEVEL_MAP,
  156. ossurl,
  157. resource,
  158. tableData: [],
  159. total: 0,
  160. showDh: false,
  161. visible: false,
  162. animalChecked: true,
  163. roll: 0
  164. }
  165. },
  166. computed: {
  167. hide() {
  168. return !this.$store.state.hide
  169. }
  170. },
  171. methods: {
  172. show(value, rollValue = 0) {
  173. this.tableData = value
  174. this.cacuTotal()
  175. this.visible = true
  176. this.roll = rollValue
  177. if (rollValue) {
  178. setTimeout(() => {
  179. this.roll = 0
  180. }, 1500)
  181. }
  182. },
  183. close() {
  184. this.visible = false
  185. this.total = 0
  186. this.showDh = false
  187. this.tableData = []
  188. },
  189. async cacuTotal() {
  190. let total = 0
  191. let flag = false
  192. if (this.tableData && this.tableData.length > 0) {
  193. this.tableData.forEach((item) => {
  194. if (!!item.magicAmount) {
  195. total += item.magicAmount
  196. }
  197. })
  198. this.total = total
  199. this.showDh = this.tableData.every(
  200. (item) => item.level !== 'B' && item.level !== 'A'
  201. )
  202. }
  203. },
  204. changeAnimalChecked(e) {
  205. const checked = e.detail.value
  206. store.commit(SET_CLOSE_ANIMAL, !checked)
  207. },
  208. async dhAll() {
  209. if (!this.total) return
  210. throttle.call(() => {
  211. this.realDh()
  212. })
  213. },
  214. async realDh(item) {
  215. let ids = []
  216. if (item) {
  217. ids = [item.id]
  218. } else {
  219. this.tableData.forEach((item) => {
  220. if (item.magicAmount) {
  221. ids.push(item.id)
  222. }
  223. })
  224. }
  225. const res = await this.$service.award.convertApply(ids)
  226. if (res) {
  227. if (item) {
  228. this.$set(item, 'magicAmount', 0)
  229. } else {
  230. this.tableData.forEach((item) => {
  231. item.magicAmount = 0
  232. })
  233. this.tableData = [...this.tableData]
  234. }
  235. this.cacuTotal()
  236. if (this.total === 0) {
  237. this.$router.back()
  238. setTimeout(() => {
  239. this.$message.success('兑换成功')
  240. }, 200)
  241. } else {
  242. this.$message.success('兑换成功')
  243. }
  244. }
  245. },
  246. showDetail(item) {
  247. if (!item.spu) return
  248. this.$refs.goodsDetailRef.show(item.spu)
  249. }
  250. }
  251. }
  252. </script>
  253. <style lang="scss" scoped>
  254. .mask {
  255. position: absolute;
  256. left: 0;
  257. right: 0;
  258. top: 0;
  259. bottom: 0;
  260. }
  261. .wrapper {
  262. z-index: 1001;
  263. margin: 0 28rpx;
  264. width: calc(100vw - 56rpx);
  265. background-color: transparent;
  266. position: relative;
  267. background-size: 100% auto;
  268. background-repeat: no-repeat;
  269. padding-top: 200rpx;
  270. width: 646rpx;
  271. margin: 0 52rpx;
  272. &.listWrapper {
  273. height: auto;
  274. width: 100%;
  275. margin: 0;
  276. .showStore {
  277. color: #fff;
  278. }
  279. }
  280. .bg_popup {
  281. position: absolute;
  282. left: 0;
  283. top: 0;
  284. width: 100%;
  285. height: 100%;
  286. }
  287. .content {
  288. position: relative;
  289. width: 100%;
  290. .super-image {
  291. width: 500rpx;
  292. height: 420rpx;
  293. }
  294. .btn-image {
  295. height: 100%;
  296. }
  297. .levelTitle {
  298. font-size: 40rpx;
  299. font-family: Source Han Sans, Source Han Sans;
  300. font-weight: 700;
  301. color: #000000;
  302. text-align: center;
  303. image {
  304. width: 110rpx;
  305. height: 40rpx;
  306. }
  307. }
  308. .superTitle {
  309. font-size: 24rpx;
  310. font-family: Source Han Sans, Source Han Sans;
  311. font-weight: 350;
  312. color: #b58100;
  313. line-height: 34rpx;
  314. text-align: center;
  315. margin-top: 12rpx;
  316. }
  317. .text {
  318. position: absolute;
  319. bottom: 20rpx;
  320. font-size: 20rpx;
  321. color: #fff;
  322. width: 100%;
  323. text-align: center;
  324. }
  325. .dhBtn {
  326. background: #fff7e3;
  327. border-radius: 40rpx;
  328. text-align: center;
  329. height: 80rpx;
  330. padding: 0 36rpx;
  331. padding-top: 8rpx;
  332. font-size: 28rpx;
  333. font-family: Source Han Sans, Source Han Sans;
  334. font-weight: 350;
  335. color: #000000;
  336. margin-right: 20rpx;
  337. .btnText {
  338. font-size: 20rpx;
  339. font-family: Source Han Sans, Source Han Sans;
  340. font-weight: 350;
  341. color: #735200;
  342. }
  343. }
  344. .agianBtn {
  345. height: 80rpx;
  346. line-height: 80rpx;
  347. text-align: center;
  348. padding: 0 50rpx;
  349. background: #fec433;
  350. border-radius: 40rpx;
  351. }
  352. .showStore {
  353. font-size: 24rpx;
  354. }
  355. .storeText {
  356. display: inline-block;
  357. font-size: 24rpx;
  358. }
  359. }
  360. .prince-value {
  361. width: 374rpx;
  362. height: 52rpx;
  363. position: relative;
  364. .image {
  365. position: absolute;
  366. left: 0;
  367. top: 0;
  368. width: 374rpx;
  369. height: 52rpx;
  370. }
  371. .prince-text {
  372. color: white;
  373. font-size: 30rpx;
  374. position: relative;
  375. }
  376. }
  377. }
  378. .roll {
  379. position: absolute;
  380. opacity: 1;
  381. bottom: 55%;
  382. width: 250rpx;
  383. height: 70rpx;
  384. background: linear-gradient(270deg, #6c6fff, #a948ff);
  385. z-index: 2000;
  386. font-size: 40rpx;
  387. color: #fff;
  388. }
  389. .lotteryTitle {
  390. text-align: center;
  391. .lotteryTitleimage {
  392. width: 400rpx;
  393. height: 80rpx;
  394. }
  395. }
  396. .close {
  397. width: 64rpx;
  398. height: 64rpx;
  399. background: #d8d8d8;
  400. font-size: 32rpx;
  401. text-align: center;
  402. line-height: 64rpx;
  403. color: #444;
  404. border-radius: 50%;
  405. }
  406. </style>