drawCard_first.vue 9.0 KB

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