drawCard_first.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  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: 5 })"
  16. class="button"
  17. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/invite/button1.png'"
  18. mode="widthFix"
  19. ></image>
  20. </view>
  21. <view class="row">
  22. <!-- <view class="users">
  23. <image
  24. class="photo"
  25. :style="'left:' + index * 11 + 'px'"
  26. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/Frame1.png'"
  27. v-for="(item, index) in userList"
  28. mode="widthFix"
  29. ></image>
  30. </view>
  31. <view class="hot">
  32. <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2' + /first/hot.png" mode="widthFix"></image>
  33. {{ detail.hotNum }}
  34. </view> -->
  35. </view>
  36. </view>
  37. </view>
  38. <view class="cardList">
  39. <image class="bk" :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/first/bk1.png'" mode="widthFix"></image>
  40. <view class="leftButton" @click="left"></view>
  41. <view class="rightButton" @click="right"></view>
  42. <view class="list">
  43. <view :class="['item', item.check ? 'active' : '']" v-for="(item, index) in cardList" @click="clickCard(item)">
  44. <image
  45. v-if="item.check"
  46. class="kaBkActive"
  47. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/ka/kabk' + cardType(1, item) + 'Active.png'"
  48. mode="heightFix"
  49. ></image>
  50. <image
  51. class="kaBk"
  52. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/ka/kabk' + cardType(1, item) + '.png'"
  53. mode="widthFix"
  54. ></image>
  55. <numImg class="num" :value="item" :type="1" />
  56. </view>
  57. </view>
  58. </view>
  59. <view class="examples">
  60. <view class="example">
  61. <image
  62. class="exampleImg"
  63. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/ka/kabk' + cardType(1, { status: 0 }) + '.png'"
  64. mode="widthFix"
  65. ></image>
  66. <image class="tip" :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/ka/bkType1.png'" mode="widthFix"></image>
  67. </view>
  68. <view class="example">
  69. <image
  70. class="exampleImg"
  71. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/ka/kabk' + cardType(1, { status: 2 }) + '.png'"
  72. mode="widthFix"
  73. ></image>
  74. <image class="tip" :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/ka/bkType5.png'" mode="widthFix"></image>
  75. </view>
  76. <view class="example">
  77. <image
  78. class="exampleImg"
  79. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/ka/kabk' + cardType(1, { status: 1 }) + '.png'"
  80. mode="widthFix"
  81. ></image>
  82. <image class="tip" :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/ka/bkType4.png'" mode="widthFix"></image>
  83. </view>
  84. </view>
  85. <view class="buttons">
  86. <image
  87. class="button1"
  88. @click="toKnapsack"
  89. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/first/button6.png'"
  90. mode="widthFix"
  91. ></image>
  92. <view class="">
  93. <image
  94. class="button2"
  95. @click="submit"
  96. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/first/button4.png'"
  97. mode="widthFix"
  98. ></image>
  99. <!-- <image class="button2" :src="'https://file.rongcyl.cn/festatic/bkm/imgv2' + /first/button1.png" mode="widthFix"></image> -->
  100. </view>
  101. <image
  102. @click="toWinningRecord"
  103. class="button1"
  104. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/first/button3.png'"
  105. mode="widthFix"
  106. ></image>
  107. </view>
  108. <view class="prizes">
  109. <image class="title" :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/first/title.png'" mode="widthFix"></image>
  110. <view class="prizesList" v-for="(item, index) in prizeList">
  111. <image class="bk" :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/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" @click="showImg(item2)">
  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" @click="showImg(item2)">
  122. <image :class="item2.leftNum == 0 ? 'grey' : ''" :src="item2.icon" mode="aspectFill"></image>
  123. </view>
  124. </view>
  125. </view>
  126. </view>
  127. <image
  128. class="refresh"
  129. @click="refresh"
  130. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/first/refresh.png'"
  131. mode="widthFix"
  132. ></image>
  133. <paymentPopup ref="paymentPopup" @callBack="paymentSuccess" />
  134. <imgPopup ref="imgPopup" />
  135. </view>
  136. </template>
  137. <script>
  138. import imgPopup from '@/component/imgPopup.vue'
  139. import { rewardType } from '@/utils/commonConfig.js'
  140. import { prizePoolStatusApi, drawCardSubmitApi, raffleDetailApi, prizeListApi } from '@/api/drawCard.js'
  141. import { cardType } from '@/utils/utils.js'
  142. import numImg from '@/component/numImg.vue'
  143. import paymentPopup from '@/component/paymentPopup.vue'
  144. export default {
  145. components: {
  146. numImg,
  147. paymentPopup,
  148. imgPopup,
  149. },
  150. data() {
  151. return {
  152. cardType: cardType,
  153. rewardType: rewardType,
  154. params: {
  155. raffleId: '',
  156. limit: 12,
  157. page: 1,
  158. },
  159. detail: {},
  160. total: 0,
  161. userList: 8,
  162. cardList: [],
  163. selectIndex: [],
  164. prizeList: [],
  165. }
  166. },
  167. onLoad(query) {
  168. console.log(query, 'query')
  169. if (query.id) {
  170. this.params.raffleId = query.id
  171. this.init()
  172. }
  173. this.paymentSuccess()
  174. },
  175. methods: {
  176. init() {
  177. // 获取卡牌商品列表
  178. this.getCardList()
  179. // 获取卡包详情
  180. this.getDetail()
  181. //获取奖池
  182. this.getPrizeList()
  183. },
  184. showImg(value) {
  185. this.$refs.imgPopup.show(value)
  186. },
  187. toKnapsack() {
  188. // 跳转背包界面
  189. wx.navigateTo({
  190. url: '/pages/knapsack/knapsack',
  191. })
  192. },
  193. showRule() {
  194. // 显示规则
  195. // this.$refs.popup.open('center')
  196. },
  197. refresh() {
  198. wx.showLoading()
  199. setTimeout(function () {
  200. wx.hideLoading()
  201. }, 1000)
  202. this.init()
  203. this.selectIndex = []
  204. for (var i = 0; i < this.cardList.length; i++) {
  205. this.cardList[i].check = false
  206. }
  207. },
  208. getPrizeList() {
  209. let params = {
  210. raffleId: this.params.raffleId,
  211. }
  212. prizeListApi(params).then(res => {
  213. console.log(res, '奖池预览')
  214. let newArray = res.data
  215. for (var i = 0; i < res.data.length; i++) {
  216. if (res.data[i].type == 21) {
  217. newArray = []
  218. newArray.push(res.data[i])
  219. res.data.splice(i, 1)
  220. newArray.push(...res.data)
  221. break
  222. }
  223. }
  224. this.prizeList = newArray
  225. })
  226. },
  227. toWinningRecord() {
  228. let params = {
  229. raffleId: this.params.raffleId,
  230. }
  231. this.$navigateTo('/pages/winningRecord/winningRecord', params)
  232. },
  233. getDetail() {
  234. let params = {
  235. raffleId: this.params.raffleId,
  236. }
  237. raffleDetailApi(params).then(res => {
  238. console.log(res, '详情')
  239. this.detail = res.data
  240. })
  241. },
  242. submit() {
  243. if (this.selectIndex.length == 0) {
  244. wx.showToast({
  245. title: '请选则要购买的卡牌。',
  246. icon: 'none',
  247. })
  248. return
  249. }
  250. let params = {
  251. raffleId: this.params.raffleId,
  252. }
  253. this.$refs.paymentPopup.show(params, number, this.detail)
  254. },
  255. // 支付成功后回调
  256. paymentSuccess() {
  257. let _this = this
  258. console.log('刷新抽卡界面')
  259. // 刷新界面
  260. _this.refresh()
  261. },
  262. // 选中取消选中卡牌
  263. clickCard(item) {
  264. if (item.status == 0) {
  265. item.check = !item.check
  266. }
  267. // 如果是选中
  268. let index = this.selectIndex.indexOf(item.number)
  269. if (item.check && index == -1) {
  270. this.selectIndex.push(item.number)
  271. } else if (!item.check && index != -1) {
  272. this.selectIndex.splice(index, 1)
  273. }
  274. },
  275. // 标记已经选中卡牌
  276. selectFormat() {
  277. for (var i = 0; i < this.cardList.length; i++) {
  278. if (this.selectIndex.includes(this.cardList[i].number)) {
  279. this.cardList[i].check = true
  280. }
  281. }
  282. },
  283. getCardList() {
  284. prizePoolStatusApi(this.params).then(res => {
  285. console.log(res, '卡牌分页')
  286. for (var i = 0; i < res.data.list.length; i++) {
  287. res.data.list[i].check = false
  288. }
  289. this.cardList = res.data.list
  290. this.selectFormat()
  291. this.total = res.data.total
  292. })
  293. },
  294. left() {
  295. console.log('上一页')
  296. if (this.params.page > 1) {
  297. this.params.page = this.params.page - 1
  298. }
  299. this.getCardList()
  300. },
  301. right() {
  302. console.log('下一页')
  303. let pages = Math.ceil(this.total / this.params.limit)
  304. if (this.params.page < pages) {
  305. this.params.page = this.params.page + 1
  306. }
  307. this.getCardList()
  308. },
  309. },
  310. }
  311. </script>
  312. <style scoped lang="scss">
  313. .container {
  314. background: #9ec8f9;
  315. padding-top: 15px;
  316. overflow: auto;
  317. .refresh {
  318. position: fixed;
  319. right: 4px;
  320. top: 55%;
  321. width: 45px;
  322. }
  323. .head {
  324. background: #fff;
  325. border: 10px;
  326. padding: 15px;
  327. border-radius: 10px 10px 0 0;
  328. display: flex;
  329. justify-content: space-between;
  330. .img {
  331. width: 106px;
  332. height: 106px;
  333. border-radius: 5px;
  334. overflow: hidden;
  335. margin-right: 10px;
  336. }
  337. .info {
  338. display: flex;
  339. flex-direction: column;
  340. justify-content: space-around;
  341. flex: 1;
  342. .row {
  343. display: flex;
  344. justify-content: space-between;
  345. color: #999999;
  346. .button {
  347. width: 67px;
  348. }
  349. .hot {
  350. display: flex;
  351. font-size: 12px;
  352. color: #999999;
  353. image {
  354. width: 16px;
  355. }
  356. }
  357. .users {
  358. position: relative;
  359. .photo {
  360. position: absolute;
  361. width: 20px;
  362. height: 20px;
  363. border-radius: 50%;
  364. }
  365. }
  366. }
  367. .title {
  368. font-weight: 600;
  369. color: #000;
  370. }
  371. .price {
  372. font-size: 14px;
  373. font-weight: 600;
  374. color: #ff2c43;
  375. .text {
  376. color: #999999;
  377. font-weight: 500;
  378. }
  379. }
  380. }
  381. }
  382. .cardList {
  383. margin-top: 10px;
  384. position: relative;
  385. .bk {
  386. width: 100%;
  387. }
  388. .leftButton {
  389. position: absolute;
  390. top: 50%;
  391. transform: translateY(-50%);
  392. left: 20px;
  393. height: 40px;
  394. width: 20px;
  395. z-index: 5;
  396. }
  397. .rightButton {
  398. position: absolute;
  399. top: 50%;
  400. transform: translateY(-50%);
  401. right: 20px;
  402. height: 40px;
  403. width: 20px;
  404. z-index: 5;
  405. }
  406. .list {
  407. padding: 35px 40px;
  408. width: calc(100% - 80px);
  409. height: calc(100% - 70px);
  410. position: absolute;
  411. top: 0;
  412. display: grid;
  413. grid-template-columns: 1fr 1fr 1fr 1fr;
  414. grid-template-rows: 1fr 1fr 1fr;
  415. .item {
  416. display: inline-flex;
  417. justify-content: center;
  418. align-items: center;
  419. position: relative;
  420. .kaBkActive {
  421. height: 132%;
  422. width: 100%;
  423. position: absolute;
  424. z-index: 1;
  425. }
  426. .kaBk {
  427. width: 70%;
  428. border-radius: 4px;
  429. z-index: 2;
  430. }
  431. .num {
  432. position: absolute;
  433. width: 100%;
  434. height: 100%;
  435. top: 0;
  436. z-index: 2;
  437. }
  438. }
  439. }
  440. }
  441. .buttons {
  442. display: flex;
  443. justify-content: space-between;
  444. align-items: flex-start;
  445. .button1 {
  446. width: 25vw;
  447. }
  448. .button2 {
  449. width: 35vw;
  450. margin-bottom: 5px;
  451. }
  452. }
  453. .prizes {
  454. .title {
  455. width: 103px;
  456. margin: 0 auto;
  457. }
  458. .prizesList {
  459. margin: 20px;
  460. position: relative;
  461. overflow: hidden;
  462. // z-index: 5;
  463. .bk {
  464. width: 100%;
  465. height: 100%;
  466. position: absolute;
  467. top: 0;
  468. }
  469. .prizesTitle {
  470. position: relative;
  471. height: 30px;
  472. line-height: 30px;
  473. width: 100%;
  474. margin-left: 1px;
  475. margin-top: 15px;
  476. padding-left: 15px;
  477. color: #fff;
  478. font-weight: 800;
  479. background: linear-gradient(90deg, rgba(89, 166, 255, 0.8) 0%, rgba(158, 200, 249, 0) 100%);
  480. }
  481. .prizesImg {
  482. position: relative;
  483. display: grid;
  484. grid-template-columns: 1fr 1fr;
  485. margin: 15px;
  486. white-space: wrap;
  487. text-align: center;
  488. // overflow: auto;
  489. .image {
  490. text-align: center;
  491. image {
  492. display: inline-block;
  493. width: 36vw;
  494. height: 36vw;
  495. border-radius: 10px;
  496. margin: 0 5px;
  497. }
  498. }
  499. }
  500. .prizesImgOne {
  501. position: relative;
  502. display: flex;
  503. justify-content: center;
  504. margin: 15px;
  505. .image {
  506. text-align: center;
  507. image {
  508. display: inline-block;
  509. width: 45vw;
  510. height: 45vw;
  511. border-radius: 10px;
  512. margin: 0 5px;
  513. }
  514. }
  515. }
  516. }
  517. }
  518. }
  519. .examples {
  520. width: 100%;
  521. margin-bottom: 20px;
  522. padding: 0 10px;
  523. display: flex;
  524. .example {
  525. width: 14vw;
  526. margin-right: 10px;
  527. display: flex;
  528. justify-content: center;
  529. flex-wrap: wrap;
  530. position: relative;
  531. .exampleImg {
  532. width: 13vw;
  533. }
  534. .tip {
  535. width: 100%;
  536. position: absolute;
  537. bottom: 0;
  538. transform: translateY(50%);
  539. }
  540. }
  541. }
  542. </style>