drawCard_first.vue 11 KB

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