raffle.vue 9.0 KB

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