drawCard_fullSet.vue 16 KB

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