raffle.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. <template>
  2. <view class="container">
  3. <uni-swiper-dot
  4. class="uni-swiper-dot-box"
  5. @clickItem="clickItem"
  6. :info="info"
  7. :current="current"
  8. :mode="mode"
  9. :dots-styles="dotsStyles"
  10. field="content"
  11. >
  12. <swiper class="swiper-box" @change="change" :current="swiperDotIndex">
  13. <swiper-item>
  14. <image
  15. class="swiperItem"
  16. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/raffle/2.jpg'"
  17. mode="aspectFill"
  18. />
  19. </swiper-item>
  20. <swiper-item>
  21. <image
  22. class="swiperItem"
  23. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/raffle/3.jpg'"
  24. mode="aspectFill"
  25. />
  26. </swiper-item>
  27. <swiper-item>
  28. <image
  29. class="swiperItem"
  30. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/raffle/1.jpg'"
  31. mode="aspectFill"
  32. />
  33. </swiper-item>
  34. </swiper>
  35. </uni-swiper-dot>
  36. <view class="tabs">
  37. <view class="tab" @click="clickTab(1)">
  38. <image
  39. class="tabImg"
  40. v-show="tabActive == 1"
  41. src="https://file.rongcyl.cn/festatic/bkm/imgv2/raffle/tab1a.png"
  42. mode="widthFix"
  43. />
  44. <image
  45. class="tabImg"
  46. v-show="tabActive != 1"
  47. src="https://file.rongcyl.cn/festatic/bkm/imgv2/raffle/tab1.png"
  48. mode="widthFix"
  49. />
  50. </view>
  51. <view class="tab" @click="clickTab(2)">
  52. <image
  53. class="tabImg"
  54. v-show="tabActive == 2"
  55. src="https://file.rongcyl.cn/festatic/bkm/imgv2/raffle/tab2a.png"
  56. mode="widthFix"
  57. />
  58. <image
  59. class="tabImg"
  60. v-show="tabActive != 2"
  61. src="https://file.rongcyl.cn/festatic/bkm/imgv2/raffle/tab2.png"
  62. mode="widthFix"
  63. />
  64. </view>
  65. <view class="tab" @click="clickTab(3)">
  66. <image
  67. class="tabImg"
  68. v-show="tabActive == 3"
  69. src="https://file.rongcyl.cn/festatic/bkm/imgv2/raffle/tab3a.png"
  70. mode="widthFix"
  71. />
  72. <image
  73. class="tabImg"
  74. v-show="tabActive != 3"
  75. src="https://file.rongcyl.cn/festatic/bkm/imgv2/raffle/tab3.png"
  76. mode="widthFix"
  77. />
  78. </view>
  79. <view class="tab" @click="clickTab(4)">
  80. <image
  81. class="tabImg"
  82. v-show="tabActive == 4"
  83. src="https://file.rongcyl.cn/festatic/bkm/imgv2/raffle/tab4a.png"
  84. mode="widthFix"
  85. />
  86. <image
  87. class="tabImg"
  88. v-show="tabActive != 4"
  89. src="https://file.rongcyl.cn/festatic/bkm/imgv2/raffle/tab4.png"
  90. mode="widthFix"
  91. />
  92. </view>
  93. </view>
  94. <view class="list" v-if="tabActive == 1">
  95. <view class="kabk" v-for="(item, index) in list" @click="toDrawCard({ id: item.id })" :key="index">
  96. <view class="ka1">
  97. <image class="leftImg" :src="item.icon" mode="aspectFill"></image>
  98. <view class="rightInfo">
  99. <view class="row title">
  100. {{ item.name }}
  101. </view>
  102. <view class="row">
  103. <span class="price">
  104. <span style="font-size: 40rpx">{{ item.price }}</span>
  105. </span>
  106. </view>
  107. <view class="row prizes">
  108. <image
  109. v-for="(item2, index2) in item.prizeIconList"
  110. class="prize"
  111. :src="item2"
  112. mode="aspectFill"
  113. :key="index2"
  114. ></image>
  115. </view>
  116. <view class="tags">
  117. <image
  118. :key="index3"
  119. v-for="(item3, index3) in item.subType"
  120. :class="['tag', 'tag_' + index3]"
  121. :src="'https://file.rongcyl.cn/festatic/bkm/imgv2' + `/raffle/tag${subType(item3)}.png`"
  122. mode="widthFix"
  123. ></image>
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. <view class="list2" v-if="tabActive == 2">
  130. <view class="ka" v-for="(item, index) in list" @click="toDrawCard({ id: item.id })" :key="index">
  131. <view class="top">
  132. <image mode="aspectFit" :src="item.icon"></image>
  133. </view>
  134. <view class="ka-info">
  135. <view class="ka-name">
  136. {{ item.name }}
  137. </view>
  138. <view class="row">
  139. <uni-tag class="tag" text="创意热销" inverted type="default"></uni-tag>
  140. <view class="money">¥{{ item.price }}</view>
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. <view class="list2 three" v-if="tabActive > 2">
  146. <view class="ka" v-for="(item, index) in list" @click="toDrawCard({ id: item.id })" :key="index">
  147. <view class="top">
  148. <image mode="aspectFit" :src="item.icon"></image>
  149. </view>
  150. <view class="ka-info">
  151. <view class="ka-name">
  152. {{ item.name }}
  153. </view>
  154. <view class="row">
  155. <uni-tag class="tag" text="创意热销" inverted type="default"></uni-tag>
  156. <view class="money">¥{{ item.price }}</view>
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. </view>
  162. </template>
  163. <script>
  164. import { raffleListApi } from '@/api/drawCard.js'
  165. export default {
  166. data() {
  167. return {
  168. tabActive: 1,
  169. list: [],
  170. info: [
  171. {
  172. content: '内容 A',
  173. },
  174. {
  175. content: '内容 B',
  176. },
  177. {
  178. content: '内容 C',
  179. },
  180. ],
  181. dotsStyles: {},
  182. current: 0,
  183. mode: 'dot',
  184. swiperDotIndex: 0,
  185. }
  186. },
  187. onShow() {
  188. this.getList()
  189. },
  190. methods: {
  191. toDrawCard(params) {
  192. let url = ''
  193. if (this.tabActive == 1) {
  194. url = '/pages/drawCard_infinite/drawCard_infinite'
  195. } else if (this.tabActive == 2) {
  196. url = '/pages/drawCard_last/drawCard_last'
  197. } else if (this.tabActive == 3) {
  198. url = '/pages/drawCard_fullSet/drawCard_fullSet'
  199. } else if (this.tabActive == 4) {
  200. url = '/pages/drawCard_box/drawCard_box'
  201. }
  202. this.$navigateTo(url, params)
  203. },
  204. getList() {
  205. let params = {
  206. limit: 999,
  207. page: 1,
  208. type: this.tabActive,
  209. }
  210. raffleListApi(params).then(res => {
  211. console.log(res, 'res')
  212. let list = res.data.list
  213. for (var i = 0; i < list.length; i++) {
  214. if (list[i].subType) {
  215. list[i].subType = list[i].subType.split(',')
  216. }
  217. }
  218. console.log('list', list)
  219. this.list = list
  220. })
  221. },
  222. subType(value) {
  223. let index = null
  224. if (value == 120) {
  225. index = 1
  226. } else if (value == 110) {
  227. index = 2
  228. } else if (value == 111) {
  229. index = 3
  230. } else if (value == 112) {
  231. index = 4
  232. }
  233. return index
  234. },
  235. tabImg(index) {
  236. let url =
  237. 'https://file.rongcyl.cn/festatic/bkm/imgv2/raffle/tab' + index + (this.tabActive == index ? 'a' : '') + '.png'
  238. return url
  239. },
  240. clickTab(index) {
  241. this.list = []
  242. this.tabActive = index
  243. this.getList()
  244. },
  245. clickItem() {},
  246. change() {},
  247. },
  248. }
  249. </script>
  250. <style scoped lang="scss">
  251. .swiperItem {
  252. width: 100%;
  253. height: 100%;
  254. }
  255. .tabs {
  256. margin: 20rpx 0;
  257. height: 72rpx;
  258. display: flex;
  259. justify-content: space-around;
  260. align-items: center;
  261. .tab {
  262. .tabImg {
  263. width: 18vw;
  264. height: 100%;
  265. }
  266. }
  267. }
  268. .list {
  269. padding: 20rpx;
  270. .kabk {
  271. padding: 2rpx;
  272. background: linear-gradient(180deg, rgba(211, 74, 216, 0.3) 0%, rgba(58, 67, 207, 0.3) 25%);
  273. border-radius: 26rpx;
  274. box-shadow: 2rpx 2rpx 8rpx rgba(176, 123, 255, 0.5);
  275. margin-bottom: 20rpx;
  276. overflow: hidden;
  277. }
  278. .ka1 {
  279. padding: 20rpx;
  280. display: flex;
  281. background: #fff;
  282. border-radius: 24rpx;
  283. position: relative;
  284. .leftImg {
  285. width: 30vw;
  286. height: 30vw;
  287. border-radius: 20rpx;
  288. margin-right: 16rpx;
  289. }
  290. .rightInfo {
  291. flex: 1;
  292. .row {
  293. margin-bottom: 10rpx;
  294. .price {
  295. font-size: 28rpx;
  296. font-weight: 600;
  297. color: #ff2c43;
  298. }
  299. }
  300. .title {
  301. font-size: 34rpx;
  302. font-weight: 600;
  303. width: 100%;
  304. white-space: nowrap;
  305. text-overflow: ellipsis;
  306. overflow: hidden;
  307. }
  308. .prizes {
  309. display: grid;
  310. grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
  311. .prize {
  312. border-radius: 8rpx;
  313. width: 10vw;
  314. height: 10vw;
  315. margin-right: 10rpx;
  316. }
  317. }
  318. .tags {
  319. position: absolute;
  320. right: -2rpx;
  321. bottom: -4rpx;
  322. display: flex;
  323. flex-direction: row-reverse;
  324. justify-content: flex-end;
  325. .tag {
  326. position: relative;
  327. width: 100rpx;
  328. height: 40rpx;
  329. }
  330. .tag_0 {
  331. z-index: 3;
  332. }
  333. .tag_1 {
  334. right: -18rpx;
  335. z-index: 2;
  336. }
  337. .tag_2 {
  338. right: -36rpx;
  339. z-index: 1;
  340. }
  341. }
  342. }
  343. }
  344. }
  345. .list2 {
  346. display: grid;
  347. grid-template-columns: 1fr 1fr;
  348. grid-gap: 20rpx;
  349. padding: 20rpx;
  350. width: calc(100% - 40rpx);
  351. .ka {
  352. width: calc(50vw - 30rpx);
  353. box-shadow: 0rpx 4rpx 16rpx 4rpx rgba(0, 0, 0, 0.1);
  354. border-radius: 20rpx;
  355. // height: 60vw;
  356. .top {
  357. // height: 60vw;
  358. background: linear-gradient(180deg, #faf1a7 0%, #ffe456 100%);
  359. text-align: center;
  360. display: flex;
  361. justify-content: center;
  362. image {
  363. width: 80%;
  364. height: 50vw;
  365. // height: 50vw;
  366. }
  367. }
  368. .ka-info {
  369. padding: 20rpx;
  370. .ka-name {
  371. font-size: 30rpx;
  372. font-weight: 600;
  373. width: 100%;
  374. white-space: nowrap;
  375. overflow: hidden;
  376. text-overflow: ellipsis;
  377. }
  378. .row {
  379. position: relative;
  380. margin-top: 10rpx;
  381. display: flex;
  382. justify-content: space-between;
  383. .tag {
  384. }
  385. .money {
  386. font-size: 24rpx;
  387. font-weight: 600;
  388. color: #ff2c43;
  389. }
  390. }
  391. }
  392. }
  393. }
  394. .three {
  395. grid-template-columns: 1fr 1fr 1fr;
  396. .ka {
  397. width: 100%;
  398. .top {
  399. image {
  400. width: 80%;
  401. height: 30vw;
  402. }
  403. }
  404. .ka-info {
  405. padding: 10rpx 10rpx 20rpx 10rpx;
  406. .ka-name {
  407. font-size: 24rpx;
  408. }
  409. .row {
  410. margin-top: 4rpx;
  411. justify-content: flex-end;
  412. .tag {
  413. display: none;
  414. }
  415. }
  416. }
  417. }
  418. }
  419. </style>