drawCard_fullSet.vue 16 KB

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