drawCard_first.vue 12 KB

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