drawCard_fullSet.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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" @click="$navigateTo('/pages/drawCard_fullSet/goods', {raffleId: params.raffleId})" :src="$fileUrl() + '/drawCard_fullSet/button5.png'" mode="heightFix"></image>
  62. </view>
  63. <view class="winningList" v-if="prizeUserList.length > 0" @click="$navigateTo('/pages/drawCard_fullSet/winningList', {raffleId: params.raffleId})">
  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.slice(0, 5)">
  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: 999,
  189. page: 1,
  190. raffleId: this.params.raffleId
  191. }
  192. prizeUserListApi(params).then(res => {
  193. console.log(res, '中奖记录')
  194. let userIds = []
  195. let list = []
  196. for (var i = 0; i < res.data.length; i++) {
  197. let item = res.data[i]
  198. if (userIds.indexOf(item.userId) == -1) {
  199. userIds.push(item.userId)
  200. console.log(userIds.indexOf(item.userId))
  201. let index = userIds.indexOf(item.userId)
  202. list[index] = {
  203. userId: item.userId,
  204. userAvtar: item.userAvtar,
  205. userName: item.userName,
  206. prizes: [],
  207. }
  208. list[index].prizes.push(item)
  209. } else {
  210. let index = userIds.indexOf(item.userId)
  211. list[index].prizes.push(item)
  212. }
  213. }
  214. this.userIds = userIds
  215. this.prizeUserList = list
  216. })
  217. },
  218. getPrizeList() {
  219. let params = {
  220. raffleId: this.params.raffleId
  221. }
  222. prizeListApi(params).then(res => {
  223. console.log(res, '奖池预览')
  224. let newArray = res.data
  225. for (var i = 0; i < res.data.length; i++) {
  226. if (res.data[i].type == 21) {
  227. newArray = []
  228. newArray.push(res.data[i])
  229. res.data.splice(i, 1)
  230. newArray.push(...res.data)
  231. break
  232. }
  233. }
  234. this.prizeList = newArray
  235. })
  236. },
  237. toWinningRecord() {
  238. let params = {
  239. raffleId: this.params.raffleId
  240. }
  241. this.$navigateTo('/pages/winningRecord/winningRecord', params)
  242. },
  243. getDetail() {
  244. let params = {
  245. raffleId: this.params.raffleId
  246. }
  247. raffleDetailApi(params).then(res => {
  248. console.log(res, '详情')
  249. this.detail = res.data
  250. this.endTime = new Date(this.detail.endTime).getTime()
  251. // this.endTime = new Date('2023-11-10 14:48:00').getTime()
  252. // 初始化倒计时
  253. this.initCountdown()
  254. if (this.countdown != '已结束') {
  255. this.countdownInfinity = setInterval(() => {
  256. if (this.countdown == '已结束') {
  257. clearInterval(this.countdownInfinity)
  258. this.countdownInfinity = null
  259. return
  260. }
  261. this.initCountdown()
  262. }, 1000)
  263. }
  264. })
  265. },
  266. initCountdown() {
  267. let nowTime = new Date().getTime()
  268. let endTime = this.endTime
  269. let countdownText = ''
  270. let countdown = endTime - nowTime
  271. if (countdown <= 0) {
  272. countdownText = '已结束'
  273. } else {
  274. countdownText = formatSeconds(countdown)
  275. }
  276. // console.log(countdownText, 'countdownText')
  277. this.countdown = countdownText
  278. },
  279. submit() {
  280. if (this.selectIndex.length == 0) {
  281. wx.showToast({
  282. title: '请选则要购买的卡牌。',
  283. icon: 'none',
  284. })
  285. return
  286. }
  287. this.$refs.paymentPopup.show(this.params.raffleId, this.selectIndex, this.detail)
  288. },
  289. // 支付成功后回调
  290. paymentSuccess() {
  291. let _this = this
  292. console.log('刷新抽卡界面')
  293. // 刷新界面
  294. _this.refresh()
  295. },
  296. // 选中取消选中卡牌
  297. clickCard(item) {
  298. if (item.status == 0) {
  299. item.check = !item.check
  300. }
  301. // 如果是选中
  302. let index = this.selectIndex.indexOf(item.number)
  303. if (item.check && index == -1) {
  304. this.selectIndex.push(item.number)
  305. } else if (!item.check && index != -1) {
  306. this.selectIndex.splice(index, 1)
  307. }
  308. },
  309. // 标记已经选中卡牌
  310. selectFormat() {
  311. for (var i = 0; i < this.cardList.length; i++) {
  312. if (this.selectIndex.includes(this.cardList[i].number)) {
  313. this.cardList[i].check = true
  314. }
  315. }
  316. },
  317. getCardList() {
  318. prizePoolStatusApi(this.params).then(res => {
  319. console.log(res, '卡牌分页')
  320. for (var i = 0; i < res.data.list.length; i++) {
  321. res.data.list[i].check = false
  322. }
  323. this.cardList = res.data.list
  324. this.selectFormat()
  325. this.total = res.data.total
  326. })
  327. },
  328. left() {
  329. console.log('上一页')
  330. if (this.params.page > 1) {
  331. this.params.page = this.params.page - 1
  332. }
  333. this.getCardList()
  334. },
  335. right() {
  336. console.log('下一页')
  337. let pages = Math.ceil(this.total / this.params.limit)
  338. if (this.params.page < pages) {
  339. this.params.page = this.params.page + 1
  340. }
  341. this.getCardList()
  342. }
  343. }
  344. }
  345. </script>
  346. <style scoped lang="scss">
  347. .container {
  348. background: #9EC8F9;
  349. padding-top: 15px;
  350. overflow: auto;
  351. .refresh {
  352. position: fixed;
  353. display: none;
  354. right: 4px;
  355. top: 75%;
  356. width: 40px;
  357. z-index: 5;
  358. }
  359. .head {
  360. background: #fff;
  361. border: 10px;
  362. padding: 15px;
  363. border-radius: 10px 10px 0 0;
  364. display: flex;
  365. justify-content: space-between;
  366. margin-bottom: 20px;
  367. .img {
  368. width: 106px;
  369. height: 106px;
  370. border-radius: 5px;
  371. overflow: hidden;
  372. margin-right: 10px;
  373. }
  374. .info {
  375. display: flex;
  376. flex-direction: column;
  377. justify-content: start;
  378. flex: 1;
  379. .row {
  380. margin: 5px 0;
  381. display: flex;
  382. justify-content: space-between;
  383. color: #999999;
  384. .button {
  385. width: 67px;
  386. }
  387. .hot {
  388. display: flex;
  389. font-size: 12px;
  390. color: #999999;
  391. image {
  392. width: 16px;
  393. }
  394. }
  395. .users {
  396. position: relative;
  397. .photo {
  398. position: absolute;
  399. width: 20px;
  400. height: 20px;
  401. border-radius: 50%;
  402. }
  403. }
  404. }
  405. .title {
  406. font-weight: 600;
  407. color: #000;
  408. }
  409. .price {
  410. font-size: 16px;
  411. font-weight: 600;
  412. color: #FF2C43;
  413. .text {
  414. font-size: 14px;
  415. color: #999999;
  416. font-weight: 500;
  417. }
  418. }
  419. }
  420. }
  421. .cardList {
  422. margin: 10px;
  423. border-radius: 12px;
  424. position: relative;
  425. background: linear-gradient(180deg, #31B7FD 10%, #6478FD 90%);
  426. // overflow: scroll;
  427. padding-bottom: 1px;
  428. .countdown {
  429. position: absolute;
  430. top: 1px;
  431. padding-left: 70px;
  432. font-size: 15px;
  433. }
  434. .itemHead {
  435. position: relative;
  436. left: -10px;
  437. top: -10px;
  438. width: calc(100% + 10px);
  439. }
  440. .title {
  441. display: flex;
  442. justify-content: space-between;
  443. color: #fff;
  444. padding: 0 15px 6px 15px;
  445. .left {
  446. .text1 {
  447. width: 6.5rem;
  448. // font-size: 24px;
  449. // font-weight: 600;
  450. // text-shadow: 1px 1px 0px #0A57BA;
  451. // font-family: YouSheBiaoTiHei-Regular, YouSheBiaoTiHei;
  452. }
  453. .text2 {
  454. font-family: Alimama FangYuanTi VF-Medium-Round, Alimama FangYuanTi VF-Medium;
  455. }
  456. }
  457. .right {
  458. display: flex;
  459. .text {
  460. width: 100px;
  461. font-size: 12px;
  462. text-align: right;
  463. }
  464. .button {
  465. width: 72px;
  466. height: 30px;
  467. }
  468. }
  469. }
  470. .bk {
  471. width: 100%;
  472. }
  473. .list {
  474. background: #fff;
  475. padding: 15px;
  476. border-radius: 12px;
  477. // width: calc(100% - 80px);
  478. // height: calc(100% - 70px);
  479. // position: absolute;
  480. // top: 0;
  481. display: grid;
  482. grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
  483. grid-template-rows: 1fr 1fr 1fr;
  484. grid-gap: 15px;
  485. .item {
  486. display: inline-flex;
  487. justify-content: center;
  488. align-items: center;
  489. position: relative;
  490. .kaBkActive {
  491. height: 142%;
  492. width: 100%;
  493. position: absolute;
  494. z-index: 1;
  495. }
  496. .kaBk {
  497. width: 100%;
  498. border-radius: 4px;
  499. z-index: 2;
  500. }
  501. .num {
  502. position: absolute;
  503. width: 100%;
  504. height: 100%;
  505. top: 0;
  506. z-index: 2;
  507. }
  508. }
  509. }
  510. .buyButton {
  511. width: 40%;
  512. margin: 10px auto;
  513. }
  514. }
  515. .winningList {
  516. margin: 20px 10px;
  517. padding: 15px;
  518. background: linear-gradient(180deg, #31B7FD 10%, #6478FD 90%);
  519. border-radius: 12px;
  520. .winningListTitle {
  521. width: 92px;
  522. margin-bottom: 12px;
  523. }
  524. .list {
  525. position: relative;
  526. padding: 12px 7px 12px 12px;
  527. border-radius: 12px;
  528. background: #fff;
  529. display: flex;
  530. .item {
  531. width: calc(100% / 6 - 5px);
  532. // margin: 0 auto;
  533. position: relative;
  534. display: inline-flex;
  535. flex-direction: column;
  536. justify-content: center;
  537. align-items: center;
  538. margin-right: 5px;
  539. .photo {
  540. width: 40px;
  541. height: 40px;
  542. border-radius: 50%;
  543. background: #b6b6b6;
  544. }
  545. .name {
  546. margin-top: 5px;
  547. display: inline-block;
  548. font-size: 11px;
  549. max-width: 100%;
  550. overflow: hidden;
  551. white-space: nowrap;
  552. text-overflow: ellipsis;
  553. }
  554. }
  555. }
  556. }
  557. .buttons {
  558. display: flex;
  559. justify-content: center;
  560. align-items: flex-start;
  561. padding: 0 10px;
  562. .button1 {
  563. height: 40px;
  564. }
  565. }
  566. .prizes {
  567. .title {
  568. width: 103px;
  569. margin: 0 auto;
  570. }
  571. .prizesList {
  572. margin: 20px;
  573. position: relative;
  574. overflow: hidden;
  575. // z-index: 5;
  576. .bk {
  577. width: 100%;
  578. height: 100%;
  579. position: absolute;
  580. top: 0;
  581. }
  582. .prizesTitle {
  583. position: relative;
  584. height: 30px;
  585. line-height: 30px;
  586. width: 100%;
  587. margin-left: 1px;
  588. margin-top: 15px;
  589. padding-left: 15px;
  590. color: #fff;
  591. font-weight: 800;
  592. background: linear-gradient(90deg, rgba(89,166,255,0.8) 0%, rgba(158,200,249,0) 100%);
  593. }
  594. .prizesImg {
  595. position: relative;
  596. display: grid;
  597. grid-template-columns: 1fr 1fr;
  598. margin: 15px;
  599. white-space: wrap;
  600. text-align: center;
  601. // overflow: auto;
  602. .image {
  603. text-align: center;
  604. image {
  605. display: inline-block;
  606. width: 36vw;
  607. height: 36vw;
  608. border-radius: 10px;
  609. margin: 0 5px;
  610. }
  611. }
  612. }
  613. .prizesImgOne {
  614. position: relative;
  615. display: flex;
  616. justify-content: center;
  617. margin: 15px;
  618. .image {
  619. text-align: center;
  620. image {
  621. display: inline-block;
  622. width: 45vw;
  623. height: 45vw;
  624. border-radius: 10px;
  625. margin: 0 5px;
  626. }
  627. }
  628. }
  629. }
  630. }
  631. }
  632. </style>