drawCard_last.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  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">/张明信片</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(2, item) + 'Active.png'"
  48. mode="heightFix"
  49. ></image>
  50. <image class="kaBk" :src="$fileUrl() + '/ka/kabk' + cardType(2, item) + '.png'" mode="widthFix"></image>
  51. <numImg class="num" :value="item" :type="2" />
  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 == 22) {
  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. this.$refs.paymentPopup.show(this.params.raffleId, this.selectIndex, this.detail)
  195. },
  196. // 支付成功后回调
  197. paymentSuccess() {
  198. let _this = this
  199. console.log('刷新抽卡界面')
  200. // 刷新界面
  201. _this.refresh()
  202. },
  203. // 选中取消选中卡牌
  204. clickCard(item) {
  205. if (item.status == 0) {
  206. item.check = !item.check
  207. }
  208. // 如果是选中
  209. let index = this.selectIndex.indexOf(item.number)
  210. if (item.check && index == -1) {
  211. this.selectIndex.push(item.number)
  212. } else if (!item.check && index != -1) {
  213. this.selectIndex.splice(index, 1)
  214. }
  215. },
  216. // 标记已经选中卡牌
  217. selectFormat() {
  218. for (var i = 0; i < this.cardList.length; i++) {
  219. if (this.selectIndex.includes(this.cardList[i].number)) {
  220. this.cardList[i].check = true
  221. }
  222. }
  223. },
  224. getCardList() {
  225. prizePoolStatusApi(this.params).then(res => {
  226. console.log(res, '卡牌分页')
  227. for (var i = 0; i < res.data.list.length; i++) {
  228. res.data.list[i].check = false
  229. }
  230. this.cardList = res.data.list
  231. this.selectFormat()
  232. this.total = res.data.total
  233. })
  234. },
  235. left() {
  236. console.log('上一页')
  237. if (this.params.page > 1) {
  238. this.params.page = this.params.page - 1
  239. }
  240. this.getCardList()
  241. },
  242. right() {
  243. console.log('下一页')
  244. let pages = Math.ceil(this.total / this.params.limit)
  245. if (this.params.page < pages) {
  246. this.params.page = this.params.page + 1
  247. }
  248. this.getCardList()
  249. },
  250. },
  251. }
  252. </script>
  253. <style scoped lang="scss">
  254. .container {
  255. background: #9ec8f9;
  256. padding-top: 15px;
  257. overflow: auto;
  258. .refresh {
  259. position: fixed;
  260. right: 4px;
  261. top: 55%;
  262. width: 45px;
  263. }
  264. .head {
  265. background: #fff;
  266. border: 10px;
  267. padding: 15px;
  268. border-radius: 10px 10px 0 0;
  269. display: flex;
  270. justify-content: space-between;
  271. .img {
  272. width: 106px;
  273. height: 106px;
  274. border-radius: 5px;
  275. overflow: hidden;
  276. margin-right: 10px;
  277. }
  278. .info {
  279. display: flex;
  280. flex-direction: column;
  281. justify-content: space-around;
  282. flex: 1;
  283. .row {
  284. display: flex;
  285. justify-content: space-between;
  286. color: #999999;
  287. .button {
  288. width: 67px;
  289. }
  290. .hot {
  291. display: flex;
  292. font-size: 12px;
  293. color: #999999;
  294. image {
  295. width: 16px;
  296. }
  297. }
  298. .users {
  299. position: relative;
  300. .photo {
  301. position: absolute;
  302. width: 20px;
  303. height: 20px;
  304. border-radius: 50%;
  305. }
  306. }
  307. }
  308. .title {
  309. font-weight: 600;
  310. color: #000;
  311. }
  312. .price {
  313. font-size: 14px;
  314. font-weight: 600;
  315. color: #ff2c43;
  316. .text {
  317. color: #999999;
  318. font-weight: 500;
  319. }
  320. }
  321. }
  322. }
  323. .cardList {
  324. margin: 10px 0;
  325. position: relative;
  326. .bk {
  327. width: 100%;
  328. }
  329. .leftButton {
  330. position: absolute;
  331. top: 50%;
  332. transform: translateY(-50%);
  333. left: 20px;
  334. height: 40px;
  335. width: 20px;
  336. z-index: 5;
  337. }
  338. .rightButton {
  339. position: absolute;
  340. top: 50%;
  341. transform: translateY(-50%);
  342. right: 20px;
  343. height: 40px;
  344. width: 20px;
  345. z-index: 5;
  346. }
  347. .list {
  348. padding: 35px 40px;
  349. width: calc(100% - 80px);
  350. height: calc(100% - 70px);
  351. position: absolute;
  352. top: 0;
  353. display: grid;
  354. grid-template-columns: 1fr 1fr 1fr 1fr;
  355. grid-template-rows: 1fr 1fr 1fr;
  356. .item {
  357. display: inline-flex;
  358. justify-content: center;
  359. align-items: center;
  360. position: relative;
  361. .kaBkActive {
  362. height: 132%;
  363. width: 100%;
  364. position: absolute;
  365. z-index: 1;
  366. }
  367. .kaBk {
  368. width: 70%;
  369. border-radius: 4px;
  370. z-index: 2;
  371. }
  372. .num {
  373. position: absolute;
  374. width: 100%;
  375. height: 100%;
  376. top: 0;
  377. z-index: 2;
  378. }
  379. }
  380. .active {
  381. .kaBk {
  382. // box-shadow: 0px 1px 6px 3px rgba(255,77,0,0.65);
  383. }
  384. }
  385. }
  386. }
  387. .buttons {
  388. display: flex;
  389. justify-content: space-between;
  390. align-items: flex-start;
  391. .button1 {
  392. width: 25vw;
  393. }
  394. .button2 {
  395. width: 35vw;
  396. margin-bottom: 5px;
  397. }
  398. }
  399. .prizes {
  400. .title {
  401. width: 103px;
  402. margin: 0 auto;
  403. }
  404. .prizesList {
  405. margin: 20px;
  406. position: relative;
  407. overflow: hidden;
  408. // z-index: 5;
  409. .bk {
  410. width: 100%;
  411. height: 100%;
  412. position: absolute;
  413. top: 0;
  414. }
  415. .prizesTitle {
  416. position: relative;
  417. height: 30px;
  418. line-height: 30px;
  419. width: 100%;
  420. margin-left: 1px;
  421. margin-top: 15px;
  422. padding-left: 15px;
  423. color: #fff;
  424. font-weight: 800;
  425. background: linear-gradient(90deg, rgba(89, 166, 255, 0.8) 0%, rgba(158, 200, 249, 0) 100%);
  426. }
  427. .prizesImg {
  428. position: relative;
  429. display: grid;
  430. grid-template-columns: 1fr 1fr;
  431. margin: 15px;
  432. white-space: wrap;
  433. text-align: center;
  434. // overflow: auto;
  435. .image {
  436. text-align: center;
  437. image {
  438. display: inline-block;
  439. width: 36vw;
  440. height: 36vw;
  441. border-radius: 10px;
  442. margin: 0 5px;
  443. }
  444. }
  445. }
  446. .prizesImgOne {
  447. position: relative;
  448. display: flex;
  449. justify-content: center;
  450. margin: 15px;
  451. .image {
  452. text-align: center;
  453. image {
  454. display: inline-block;
  455. width: 45vw;
  456. height: 45vw;
  457. border-radius: 10px;
  458. margin: 0 5px;
  459. }
  460. }
  461. }
  462. }
  463. }
  464. }
  465. </style>