raffle.vue 8.7 KB

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