raffle.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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 =
  174. 'https://mall.rongtongh.cn/storage/img/raffle/tab' + index + (this.tabActive == index ? 'a' : '') + '.png'
  175. return url
  176. },
  177. clickTab(index) {
  178. this.list = []
  179. this.tabActive = index
  180. this.getList()
  181. },
  182. clickItem() {},
  183. change() {},
  184. },
  185. }
  186. </script>
  187. <style scoped lang="scss">
  188. .swiperItem {
  189. width: 100%;
  190. height: 100%;
  191. }
  192. .tabs {
  193. margin: 10px 0;
  194. height: 36px;
  195. display: flex;
  196. justify-content: space-around;
  197. align-items: center;
  198. .tab {
  199. .tabImg {
  200. width: 18vw;
  201. height: 100%;
  202. }
  203. }
  204. }
  205. .list {
  206. padding: 10px;
  207. .kabk {
  208. padding: 1px;
  209. background: linear-gradient(180deg, rgba(211, 74, 216, 0.3) 0%, rgba(58, 67, 207, 0.3) 25%);
  210. border-radius: 13px;
  211. box-shadow: 1px 1px 4px rgba(176, 123, 255, 0.5);
  212. margin-bottom: 10px;
  213. overflow: hidden;
  214. }
  215. .ka1 {
  216. padding: 10px;
  217. display: flex;
  218. background: #fff;
  219. border-radius: 12px;
  220. position: relative;
  221. .leftImg {
  222. width: 30vw;
  223. height: 30vw;
  224. border-radius: 10px;
  225. margin-right: 8px;
  226. }
  227. .rightInfo {
  228. flex: 1;
  229. .row {
  230. margin-bottom: 5px;
  231. .price {
  232. font-size: 14px;
  233. font-weight: 600;
  234. color: #ff2c43;
  235. }
  236. }
  237. .title {
  238. font-size: 17px;
  239. font-weight: 600;
  240. width: 100%;
  241. white-space: nowrap;
  242. text-overflow: ellipsis;
  243. overflow: hidden;
  244. }
  245. .prizes {
  246. display: grid;
  247. grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
  248. .prize {
  249. border-radius: 4px;
  250. width: 10vw;
  251. height: 10vw;
  252. margin-right: 5px;
  253. }
  254. }
  255. .tags {
  256. position: absolute;
  257. right: -1px;
  258. bottom: -2px;
  259. display: flex;
  260. flex-direction: row-reverse;
  261. justify-content: flex-end;
  262. .tag {
  263. position: relative;
  264. width: 50px;
  265. height: 20px;
  266. }
  267. .tag_0 {
  268. z-index: 3;
  269. }
  270. .tag_1 {
  271. right: -9px;
  272. z-index: 2;
  273. }
  274. .tag_2 {
  275. right: -18px;
  276. z-index: 1;
  277. }
  278. }
  279. }
  280. }
  281. }
  282. .list2 {
  283. display: grid;
  284. grid-template-columns: 1fr 1fr;
  285. grid-gap: 10px;
  286. padding: 10px;
  287. width: calc(100% - 20px);
  288. .ka {
  289. width: calc(50vw - 15px);
  290. box-shadow: 0px 2px 8px 2px rgba(0, 0, 0, 0.1);
  291. border-radius: 10px;
  292. // height: 60vw;
  293. .top {
  294. // height: 60vw;
  295. background: linear-gradient(180deg, #faf1a7 0%, #ffe456 100%);
  296. text-align: center;
  297. display: flex;
  298. justify-content: center;
  299. image {
  300. width: 80%;
  301. height: 50vw;
  302. // height: 50vw;
  303. }
  304. }
  305. .ka-info {
  306. padding: 10px;
  307. .ka-name {
  308. font-size: 15px;
  309. font-weight: 600;
  310. width: 100%;
  311. white-space: nowrap;
  312. overflow: hidden;
  313. text-overflow: ellipsis;
  314. }
  315. .row {
  316. position: relative;
  317. margin-top: 5px;
  318. display: flex;
  319. justify-content: space-between;
  320. .tag {
  321. }
  322. .money {
  323. font-size: 12px;
  324. font-weight: 600;
  325. color: #ff2c43;
  326. }
  327. }
  328. }
  329. }
  330. }
  331. .three {
  332. grid-template-columns: 1fr 1fr 1fr;
  333. .ka {
  334. width: 100%;
  335. .top {
  336. image {
  337. width: 80%;
  338. height: 30vw;
  339. }
  340. }
  341. .ka-info {
  342. padding: 5px 5px 10px 5px;
  343. .ka-name {
  344. font-size: 12px;
  345. }
  346. .row {
  347. margin-top: 2px;
  348. justify-content: flex-end;
  349. .tag {
  350. display: none;
  351. }
  352. }
  353. }
  354. }
  355. }
  356. </style>