drawCard_fullSet.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. <template>
  2. <view class="container">
  3. <view class="head">
  4. <image class="img" :src="$fileUrl() + '/ka.jpeg'" mode="aspectFill"></image>
  5. <view class="info">
  6. <view class="title row">
  7. {{ detail.name }}
  8. </view>
  9. <view class="row">
  10. <view class="price">
  11. ¥{{ detail.price }}
  12. <span class="text fontPFR">/张明信片</span>
  13. </view>
  14. <image @click="$navigateTo('/pages/rule/rule', {type: 3})" class="button" :src="$fileUrl() + '/invite/button1.png'" mode="widthFix"></image>
  15. </view>
  16. <view class="row">
  17. <!-- <view class="users">
  18. <image class="photo" :style="'left:' + index * 11 + 'px'" :src="$fileUrl() + '/Frame1.png'"
  19. v-for="(item, index) in userList" mode="widthFix"></image>
  20. </view> -->
  21. <!-- <view class="hot">
  22. <image :src="$fileUrl() + /first/hot.png" mode="widthFix"></image>
  23. {{ detail.hotNum }}
  24. </view> -->
  25. </view>
  26. </view>
  27. </view>
  28. <view class="cardList">
  29. <image class="itemHead" :src="$fileUrl() + '/drawCard_fullSet/headBk.png'" mode="widthFix"></image>
  30. <view class="countdown textColor5">
  31. {{ countdown }}
  32. </view>
  33. <view class="title">
  34. <view class="left">
  35. <image class="text1" :src="$fileUrl() + '/drawCard_fullSet/icon1.png'" mode="widthFix"></image>
  36. <view class="row text2" style="font-size: 14px;">
  37. 已选择 {{0}} 个
  38. </view>
  39. </view>
  40. <view class="right">
  41. <view class="text">
  42. 分享福袋有几率提高<span style="color: #63FFF6;">S赏</span>概率
  43. </view>
  44. <image class="button" :src="$fileUrl() + '/drawCard_fullSet/button1.png'" mode="widthFix"></image>
  45. </view>
  46. </view>
  47. <view class="list">
  48. <view :class="['item', item.check ? 'active' : '']" v-for="(item,index) in cardList"
  49. @click="clickCard(item)">
  50. <image v-if="item.check" class="kaBkActive" :src="$fileUrl() + '/ka/kabk' + cardType(3, item) + 'Active.png'" mode="heightFix"></image>
  51. <image class="kaBk" :src="$fileUrl() + '/ka/kabk' + cardType(3, item) + '.png'" mode="widthFix">
  52. </image>
  53. <numImg class="num" :value="item" :type="3" />
  54. </view>
  55. </view>
  56. <image class="buyButton" @click="submit" :src="$fileUrl() + '/drawCard_fullSet/button2.png'" mode="widthFix"></image>
  57. </view>
  58. <view class="buttons">
  59. <image class="button1" @click="toKnapsack" :src="$fileUrl() + '/drawCard_fullSet/button3.png'" mode="heightFix"></image>
  60. <!-- <image class="button1" :src="$fileUrl() + '/drawCard_fullSet/button4.png'" mode="heightFix"></image> -->
  61. <image class="button1" :src="$fileUrl() + '/drawCard_fullSet/button5.png'" mode="heightFix"></image>
  62. </view>
  63. <view class="winningList" v-if="prizeUserList.length > 0">
  64. <image class="winningListTitle" :src="$fileUrl() + '/drawCard_fullSet/icon2.png'" mode="widthFix"></image>
  65. <view class="list">
  66. <view class="item" v-for="(item, index) in prizeUserList">
  67. <image class="photo" :src="item.userAvtar" mode="aspectFill"></image>
  68. <view class="name">
  69. {{ item.userName }}
  70. </view>
  71. </view>
  72. <view class="item" v-if="prizeUserList.length == 5">
  73. <image class="photo" :src="$fileUrl() + '/drawCard_fullSet/icon3.png'" mode="aspectFill"></image>
  74. <view class="name" style="color: #6478FD;">
  75. 查看更多
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <view class="prizes" style="display: none;" >
  81. <image class="title" :src="$fileUrl() + '/first/title.png'" mode="widthFix"></image>
  82. <view class="prizesList" v-for="(item, index) in prizeList">
  83. <image class="bk" :src="$fileUrl() + '/first/bk2.png'" mode="scaleToFill"></image>
  84. <view class="prizesTitle">
  85. {{ $selectDictLabel(rewardType, item.type) }}
  86. </view>
  87. <view class="prizesImgOne" v-if="item.type == 22">
  88. <view class="image" v-for="(item2, index2) in item.prizeList">
  89. <image :class="item2.leftNum == 0 ? 'grey' : ''" :src="item2.icon" mode="aspectFill"></image>
  90. </view>
  91. </view>
  92. <view class="prizesImg" v-else>
  93. <view class="image" v-for="(item2, index2) in item.prizeList">
  94. <image :class="item2.leftNum == 0 ? 'grey' : ''" :src="item2.icon" mode="aspectFill"></image>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. <image class="refresh" @click="refresh" :src="$fileUrl() + '/first/refresh.png'" mode="widthFix"></image>
  100. <paymentPopup ref="paymentPopup" @callBack="paymentSuccess" />
  101. </view>
  102. </template>
  103. <script>
  104. import {
  105. rewardType,
  106. } from "@/utils/commonConfig.js"
  107. import {
  108. prizePoolStatusApi,
  109. drawCardSubmitApi,
  110. raffleDetailApi,
  111. prizeListApi,
  112. prizeUserListApi
  113. } from "@/api/drawCard.js"
  114. import {
  115. cardType,
  116. formatSeconds
  117. } from "@/utils/utils.js"
  118. import numImg from "@/component/numImg.vue"
  119. import paymentPopup from "@/component/paymentPopup.vue"
  120. export default {
  121. components: {
  122. numImg,
  123. paymentPopup
  124. },
  125. data() {
  126. return {
  127. countdown: '',
  128. countdownInfinity: null,
  129. cardType: cardType,
  130. rewardType: rewardType,
  131. params: {
  132. raffleId: '',
  133. limit: 20,
  134. page: 1
  135. },
  136. detail: {},
  137. total: 0,
  138. userList: 8,
  139. cardList: [],
  140. selectIndex: [],
  141. prizeList: [],
  142. prizeUserList: []
  143. }
  144. },
  145. onLoad(query) {
  146. console.log(query, 'query')
  147. if (query.id) {
  148. this.params.raffleId = query.id
  149. this.init()
  150. }
  151. this.paymentSuccess()
  152. },
  153. onHide() {
  154. if (!this.countdownInfinity) {
  155. clearInterval(this.countdownInfinity)
  156. }
  157. },
  158. methods: {
  159. init() {
  160. // 获取卡牌商品列表
  161. this.getCardList()
  162. // 获取卡包详情
  163. this.getDetail()
  164. //获取奖池
  165. this.getPrizeList()
  166. // 获取中奖记录
  167. this.getPrizeUserList()
  168. },
  169. toKnapsack() {
  170. // 跳转背包界面
  171. wx.navigateTo({
  172. url: "/pages/knapsack/knapsack"
  173. })
  174. },
  175. refresh() {
  176. wx.showLoading()
  177. setTimeout(function () {
  178. wx.hideLoading()
  179. }, 1000)
  180. this.init()
  181. this.selectIndex = []
  182. for (var i = 0; i < this.cardList.length; i++) {
  183. this.cardList[i].check = false
  184. }
  185. },
  186. getPrizeUserList() {
  187. let params = {
  188. limit: 5,
  189. page: 1,
  190. raffleId: this.params.raffleId
  191. }
  192. prizeUserListApi(params).then(res => {
  193. console.log(res, '中奖记录')
  194. // for (var i = 0; i < res.data.length; i++) {
  195. // res.data[i]
  196. // }
  197. this.prizeUserList = res.data
  198. })
  199. },
  200. getPrizeList() {
  201. let params = {
  202. raffleId: this.params.raffleId
  203. }
  204. prizeListApi(params).then(res => {
  205. console.log(res, '奖池预览')
  206. let newArray = res.data
  207. for (var i = 0; i < res.data.length; i++) {
  208. if (res.data[i].type == 21) {
  209. newArray = []
  210. newArray.push(res.data[i])
  211. res.data.splice(i, 1)
  212. newArray.push(...res.data)
  213. break
  214. }
  215. }
  216. this.prizeList = newArray
  217. })
  218. },
  219. toWinningRecord() {
  220. let params = {
  221. raffleId: this.params.raffleId
  222. }
  223. this.$navigateTo('/pages/winningRecord/winningRecord', params)
  224. },
  225. getDetail() {
  226. let params = {
  227. raffleId: this.params.raffleId
  228. }
  229. raffleDetailApi(params).then(res => {
  230. console.log(res, '详情')
  231. this.detail = res.data
  232. this.endTime = new Date(this.detail.endTime).getTime()
  233. // this.endTime = new Date('2023-11-10 14:48:00').getTime()
  234. // 初始化倒计时
  235. this.initCountdown()
  236. if (this.countdown != '已结束') {
  237. this.countdownInfinity = setInterval(() => {
  238. if (this.countdown == '已结束') {
  239. clearInterval(this.countdownInfinity)
  240. this.countdownInfinity = null
  241. return
  242. }
  243. this.initCountdown()
  244. }, 1000)
  245. }
  246. })
  247. },
  248. initCountdown() {
  249. let nowTime = new Date().getTime()
  250. let endTime = this.endTime
  251. let countdownText = ''
  252. let countdown = endTime - nowTime
  253. if (countdown <= 0) {
  254. countdownText = '已结束'
  255. } else {
  256. countdownText = formatSeconds(countdown)
  257. }
  258. // console.log(countdownText, 'countdownText')
  259. this.countdown = countdownText
  260. },
  261. submit() {
  262. if (this.selectIndex.length == 0) {
  263. wx.showToast({
  264. title: '请选则要购买的卡牌。',
  265. icon: 'none',
  266. })
  267. return
  268. }
  269. this.$refs.paymentPopup.show(this.params.raffleId, this.selectIndex, this.detail)
  270. },
  271. // 支付成功后回调
  272. paymentSuccess() {
  273. let _this = this
  274. console.log('刷新抽卡界面')
  275. // 刷新界面
  276. _this.refresh()
  277. },
  278. // 选中取消选中卡牌
  279. clickCard(item) {
  280. if (item.status == 0) {
  281. item.check = !item.check
  282. }
  283. // 如果是选中
  284. let index = this.selectIndex.indexOf(item.number)
  285. if (item.check && index == -1) {
  286. this.selectIndex.push(item.number)
  287. } else if (!item.check && index != -1) {
  288. this.selectIndex.splice(index, 1)
  289. }
  290. },
  291. // 标记已经选中卡牌
  292. selectFormat() {
  293. for (var i = 0; i < this.cardList.length; i++) {
  294. if (this.selectIndex.includes(this.cardList[i].number)) {
  295. this.cardList[i].check = true
  296. }
  297. }
  298. },
  299. getCardList() {
  300. prizePoolStatusApi(this.params).then(res => {
  301. console.log(res, '卡牌分页')
  302. for (var i = 0; i < res.data.list.length; i++) {
  303. res.data.list[i].check = false
  304. }
  305. this.cardList = res.data.list
  306. this.selectFormat()
  307. this.total = res.data.total
  308. })
  309. },
  310. left() {
  311. console.log('上一页')
  312. if (this.params.page > 1) {
  313. this.params.page = this.params.page - 1
  314. }
  315. this.getCardList()
  316. },
  317. right() {
  318. console.log('下一页')
  319. let pages = Math.ceil(this.total / this.params.limit)
  320. if (this.params.page < pages) {
  321. this.params.page = this.params.page + 1
  322. }
  323. this.getCardList()
  324. }
  325. }
  326. }
  327. </script>
  328. <style scoped lang="scss">
  329. .container {
  330. background: #9EC8F9;
  331. padding-top: 15px;
  332. overflow: auto;
  333. .refresh {
  334. position: fixed;
  335. display: none;
  336. right: 4px;
  337. top: 75%;
  338. width: 40px;
  339. z-index: 5;
  340. }
  341. .head {
  342. background: #fff;
  343. border: 10px;
  344. padding: 15px;
  345. border-radius: 10px 10px 0 0;
  346. display: flex;
  347. justify-content: space-between;
  348. margin-bottom: 20px;
  349. .img {
  350. width: 106px;
  351. height: 106px;
  352. border-radius: 5px;
  353. overflow: hidden;
  354. margin-right: 10px;
  355. }
  356. .info {
  357. display: flex;
  358. flex-direction: column;
  359. justify-content: start;
  360. flex: 1;
  361. .row {
  362. margin: 5px 0;
  363. display: flex;
  364. justify-content: space-between;
  365. color: #999999;
  366. .button {
  367. width: 67px;
  368. }
  369. .hot {
  370. display: flex;
  371. font-size: 12px;
  372. color: #999999;
  373. image {
  374. width: 16px;
  375. }
  376. }
  377. .users {
  378. position: relative;
  379. .photo {
  380. position: absolute;
  381. width: 20px;
  382. height: 20px;
  383. border-radius: 50%;
  384. }
  385. }
  386. }
  387. .title {
  388. font-weight: 600;
  389. color: #000;
  390. }
  391. .price {
  392. font-size: 16px;
  393. font-weight: 600;
  394. color: #FF2C43;
  395. .text {
  396. font-size: 14px;
  397. color: #999999;
  398. font-weight: 500;
  399. }
  400. }
  401. }
  402. }
  403. .cardList {
  404. margin: 10px;
  405. border-radius: 12px;
  406. position: relative;
  407. background: linear-gradient(180deg, #31B7FD 10%, #6478FD 90%);
  408. // overflow: scroll;
  409. padding-bottom: 1px;
  410. .countdown {
  411. position: absolute;
  412. top: 1px;
  413. padding-left: 70px;
  414. font-size: 15px;
  415. }
  416. .itemHead {
  417. position: relative;
  418. left: -10px;
  419. top: -10px;
  420. width: calc(100% + 10px);
  421. }
  422. .title {
  423. display: flex;
  424. justify-content: space-between;
  425. color: #fff;
  426. padding: 0 15px 6px 15px;
  427. .left {
  428. .text1 {
  429. width: 6.5rem;
  430. // font-size: 24px;
  431. // font-weight: 600;
  432. // text-shadow: 1px 1px 0px #0A57BA;
  433. // font-family: YouSheBiaoTiHei-Regular, YouSheBiaoTiHei;
  434. }
  435. .text2 {
  436. font-family: Alimama FangYuanTi VF-Medium-Round, Alimama FangYuanTi VF-Medium;
  437. }
  438. }
  439. .right {
  440. display: flex;
  441. .text {
  442. width: 100px;
  443. font-size: 12px;
  444. text-align: right;
  445. }
  446. .button {
  447. width: 72px;
  448. height: 30px;
  449. }
  450. }
  451. }
  452. .bk {
  453. width: 100%;
  454. }
  455. .list {
  456. background: #fff;
  457. padding: 15px;
  458. border-radius: 12px;
  459. // width: calc(100% - 80px);
  460. // height: calc(100% - 70px);
  461. // position: absolute;
  462. // top: 0;
  463. display: grid;
  464. grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  465. grid-template-rows: 1fr 1fr 1fr;
  466. grid-gap: 15px;
  467. .item {
  468. display: inline-flex;
  469. justify-content: center;
  470. align-items: center;
  471. position: relative;
  472. .kaBkActive {
  473. height: 142%;
  474. width: 100%;
  475. position: absolute;
  476. z-index: 1;
  477. }
  478. .kaBk {
  479. width: 100%;
  480. border-radius: 4px;
  481. z-index: 2;
  482. }
  483. .num {
  484. position: absolute;
  485. width: 100%;
  486. height: 100%;
  487. top: 0;
  488. z-index: 2;
  489. }
  490. }
  491. }
  492. .buyButton {
  493. width: 40%;
  494. margin: 10px auto;
  495. }
  496. }
  497. .winningList {
  498. margin: 20px 10px;
  499. padding: 15px;
  500. background: linear-gradient(180deg, #31B7FD 10%, #6478FD 90%);
  501. border-radius: 12px;
  502. .winningListTitle {
  503. width: 92px;
  504. margin-bottom: 12px;
  505. }
  506. .list {
  507. position: relative;
  508. padding: 12px;
  509. border-radius: 12px;
  510. background: #fff;
  511. display: flex;
  512. .item {
  513. width: calc(100% / 6 - 5px);
  514. margin: 0 auto;
  515. position: relative;
  516. display: inline-flex;
  517. flex-direction: column;
  518. justify-content: center;
  519. align-items: center;
  520. .photo {
  521. width: 40px;
  522. height: 40px;
  523. border-radius: 50%;
  524. }
  525. .name {
  526. margin-top: 5px;
  527. display: inline-block;
  528. font-size: 11px;
  529. max-width: 100%;
  530. overflow: hidden;
  531. white-space: nowrap;
  532. text-overflow: ellipsis;
  533. }
  534. }
  535. }
  536. }
  537. .buttons {
  538. display: flex;
  539. justify-content: center;
  540. align-items: flex-start;
  541. padding: 0 10px;
  542. .button1 {
  543. height: 40px;
  544. }
  545. }
  546. .prizes {
  547. .title {
  548. width: 103px;
  549. margin: 0 auto;
  550. }
  551. .prizesList {
  552. margin: 20px;
  553. position: relative;
  554. overflow: hidden;
  555. // z-index: 5;
  556. .bk {
  557. width: 100%;
  558. height: 100%;
  559. position: absolute;
  560. top: 0;
  561. }
  562. .prizesTitle {
  563. position: relative;
  564. height: 30px;
  565. line-height: 30px;
  566. width: 100%;
  567. margin-left: 1px;
  568. margin-top: 15px;
  569. padding-left: 15px;
  570. color: #fff;
  571. font-weight: 800;
  572. background: linear-gradient(90deg, rgba(89,166,255,0.8) 0%, rgba(158,200,249,0) 100%);
  573. }
  574. .prizesImg {
  575. position: relative;
  576. display: grid;
  577. grid-template-columns: 1fr 1fr;
  578. margin: 15px;
  579. white-space: wrap;
  580. text-align: center;
  581. // overflow: auto;
  582. .image {
  583. text-align: center;
  584. image {
  585. display: inline-block;
  586. width: 36vw;
  587. height: 36vw;
  588. border-radius: 10px;
  589. margin: 0 5px;
  590. }
  591. }
  592. }
  593. .prizesImgOne {
  594. position: relative;
  595. display: flex;
  596. justify-content: center;
  597. margin: 15px;
  598. .image {
  599. text-align: center;
  600. image {
  601. display: inline-block;
  602. width: 45vw;
  603. height: 45vw;
  604. border-radius: 10px;
  605. margin: 0 5px;
  606. }
  607. }
  608. }
  609. }
  610. }
  611. }
  612. </style>