raffle.vue 7.8 KB

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