result_com.vue 13 KB

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