drawCard_first.vue 9.5 KB

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