raffle.vue 10 KB

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