drawCard_fullSet.vue 16 KB

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