drawCard_fullSet.vue 18 KB

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