drawCard_first.vue 11 KB

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