raffle.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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>
  33. <view class="list2" v-if="tabActive == 2">
  34. <view class="ka" v-for="(item, index) in list" @click="toDrawCard({id: item.id})">
  35. <view class="top">
  36. <image mode="widthFix" :src="item.icon"></image>
  37. </view>
  38. <view class="ka-info">
  39. <view class="ka-name">
  40. {{item.name}}
  41. </view>
  42. <view class="row">
  43. <uni-tag class="tag" text="创意热销" inverted type="default"></uni-tag>
  44. <view class="money">
  45. ¥{{item.price}}
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="list2 three" v-if="tabActive > 2">
  52. <view class="ka" v-for="(item, index) in list" @click="toDrawCard({id: item.id})">
  53. <view class="top">
  54. <image mode="widthFix" :src="item.icon"></image>
  55. </view>
  56. <view class="ka-info">
  57. <view class="ka-name">
  58. {{item.name}}
  59. </view>
  60. <view class="row">
  61. <uni-tag class="tag" text="创意热销" inverted type="default"></uni-tag>
  62. <view class="money">
  63. ¥{{item.price}}
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. import {
  73. raffleListApi
  74. } from "@/api/drawCard.js"
  75. export default {
  76. data() {
  77. return {
  78. tabActive: 1,
  79. list: [],
  80. info: [{
  81. content: '内容 A'
  82. }, {
  83. content: '内容 B'
  84. }, {
  85. content: '内容 C'
  86. }],
  87. dotsStyles: {},
  88. current: 0,
  89. mode: 'dot',
  90. swiperDotIndex: 0
  91. }
  92. },
  93. onShow() {
  94. this.getList()
  95. },
  96. methods: {
  97. toDrawCard(params) {
  98. let url = ''
  99. if (this.tabActive == 1) {
  100. url = 'xxx'
  101. } else if (this.tabActive == 2) {
  102. url = '/pages/drawCard_last/drawCard_last'
  103. } else if (this.tabActive == 3) {
  104. url = '/pages/drawCard_fullSet/drawCard_fullSet'
  105. } else if (this.tabActive == 4) {
  106. url = '/pages/drawCard_fullSet/drawCard_fullSet'
  107. }
  108. this.$navigateTo(url, params)
  109. },
  110. getList () {
  111. let params = {
  112. limit: 999,
  113. page: 1,
  114. type: this.tabActive
  115. }
  116. raffleListApi(params).then(res => {
  117. console.log(res, 'res')
  118. this.list = res.data.list
  119. })
  120. },
  121. tabImg(index) {
  122. let url = 'https://mall.rongtongh.cn/storage/img/raffle/tab'
  123. + index
  124. + (this.tabActive == index ? 'a' : '' )
  125. + '.png'
  126. return url
  127. },
  128. clickTab(index) {
  129. this.tabActive = index
  130. this.getList()
  131. },
  132. clickItem() {
  133. },
  134. change() {
  135. }
  136. }
  137. }
  138. </script>
  139. <style scoped lang="scss">
  140. .swiperItem {
  141. width: 100%;
  142. height: 100%;
  143. }
  144. .tabs {
  145. margin: 10px 0;
  146. height: 36px;
  147. display: flex;
  148. justify-content: space-around;
  149. align-items: center;
  150. .tab {
  151. .tabImg {
  152. width: 18vw;
  153. height: 100%;
  154. }
  155. }
  156. }
  157. .list2 {
  158. display: grid;
  159. grid-template-columns: 1fr 1fr;
  160. grid-gap: 10px;
  161. padding: 10px;
  162. width: calc(100% - 20px);
  163. .ka {
  164. width: calc(50vw - 15px);
  165. box-shadow: 0px 2px 8px 2px rgba(0,0,0,0.1);
  166. border-radius: 10px;
  167. // height: 60vw;
  168. .top {
  169. // height: 60vw;
  170. background: linear-gradient(180deg, #FAF1A7 0%, #FFE456 100%);
  171. text-align: center;
  172. display: flex;
  173. justify-content: center;
  174. image {
  175. width: 80%;
  176. height: 50vw;
  177. // height: 50vw;
  178. }
  179. }
  180. .ka-info {
  181. padding: 10px;
  182. .ka-name {
  183. font-size: 15px;
  184. font-weight: 600;
  185. width: 100%;
  186. white-space: nowrap;
  187. overflow: hidden;
  188. text-overflow: ellipsis;
  189. }
  190. .row {
  191. position: relative;
  192. margin-top: 5px;
  193. display: flex;
  194. justify-content: space-between;
  195. .tag {
  196. }
  197. .money {
  198. font-size: 12px;
  199. font-weight: 600;
  200. color: #FF2C43;
  201. }
  202. }
  203. }
  204. }
  205. }
  206. .three {
  207. grid-template-columns: 1fr 1fr 1fr;
  208. .ka {
  209. width: 100%;
  210. .top {
  211. image {
  212. width: 80%;
  213. height: 30vw;
  214. }
  215. }
  216. .ka-info {
  217. padding: 5px 5px 10px 5px;
  218. .ka-name {
  219. font-size: 12px;
  220. }
  221. .row {
  222. margin-top: 2px;
  223. justify-content: flex-end;
  224. .tag {
  225. display: none;
  226. }
  227. }
  228. }
  229. }
  230. }
  231. </style>