index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view>
  3. <!-- 非H5撑高元素 -->
  4. <view class="status_bar"></view>
  5. <view class="box">
  6. <view class="box-top">
  7. <view class="box-top-action">
  8. <view class="box-top-action-item">
  9. <view class="flex box-top-action-item-cir">
  10. <u-icon name="scan" color="#fff" size="45"></u-icon>
  11. </view>
  12. <view class="box-top-action-item-txt">扫一扫</view>
  13. </view>
  14. <view class="box-top-action-item">
  15. <view class="flex box-top-action-item-cir">
  16. <u-icon name="gift" color="#fff" size="45"></u-icon>
  17. </view>
  18. <view class="box-top-action-item-txt">奖品库</view>
  19. </view>
  20. </view>
  21. <view class="box-top-tip">
  22. <view class="flex box-top-tip-txt">
  23. <u-icon name="file-text" color="#fff" size="20"></u-icon>
  24. <text>规则说明</text>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="box-ticket">
  29. <carousel :img-list="imgList" url-key="picUrl" @selected="selectedBanner" @changeTicket="getTicket" />
  30. </view>
  31. <view class="box-ticket-tip">100%保底必中</view>
  32. <view class="box-start flex">
  33. <view class="flex box-start-action" @click="exchange">
  34. <text>立即</text>
  35. <text>开刮</text>
  36. </view>
  37. <view class="box-start-all" @click="toTicket">所有盲票</view>
  38. </view>
  39. </view>
  40. <custom-tab-bar :activeValue="'index'" />
  41. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="toProcess" />
  42. </view>
  43. </template>
  44. <script>
  45. import env from '../../config/env.js'
  46. import $http from '@/utils/request.js'
  47. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  48. import Carousel from '../../components/vear-carousel/vear-carousel'
  49. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  50. export default {
  51. components: {
  52. CustomTabBar,
  53. Carousel,
  54. PayPopup
  55. },
  56. data() {
  57. return {
  58. imgList: [],
  59. value: 1,
  60. payShow: false,
  61. checked: false,
  62. pageNum: 1,
  63. total: 100,
  64. list: [],
  65. currentIndex: 0,
  66. payInfo: {}
  67. };
  68. },
  69. onShow(opthios) {
  70. this.getList()
  71. },
  72. methods: {
  73. getList() {
  74. uni.showLoading({
  75. title: '加载中'
  76. });
  77. let data = {
  78. categoryId: '',
  79. tagId: '',
  80. type: 'online',
  81. noToken: true
  82. }
  83. $http.post(`/api/v1/mp/user/mall/ticket/list?pageNum=${this.pageNum}&pageSize=100`, data).then(
  84. res => {
  85. uni.hideLoading();
  86. if (res.code == 0) {
  87. res.rows.forEach(item => {
  88. let picUrlArr = item.picUrl.split(',')
  89. item.picUrl = env.filePublic + picUrlArr[0]
  90. })
  91. this.total = res.total
  92. this.imgList = res.rows
  93. }
  94. }).catch(() => {
  95. uni.hideLoading();
  96. })
  97. },
  98. selectedBanner(item, index) {
  99. uni.navigateTo({
  100. url: `/pages/ticketBox/detail?id=${ item.boxId }`
  101. })
  102. },
  103. getTicket(index) {
  104. this.currentIndex = index
  105. },
  106. close() {
  107. this.payShow = false
  108. },
  109. toProcess(id) {
  110. this.payShow = false
  111. uni.navigateTo({
  112. url: `/pages/process/index?id=${ id }`
  113. })
  114. },
  115. exchange() {
  116. this.payInfo = this.imgList[this.currentIndex]
  117. let data = {
  118. couponIds: [],
  119. autoCoupon: 1,
  120. boxId: this.payInfo.boxId,
  121. orderNum: 1
  122. }
  123. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  124. if (res.code == 0) {
  125. let info = {
  126. ...res.data,
  127. ...this.payInfo
  128. }
  129. this.payInfo = info
  130. this.payShow = true
  131. }
  132. }).catch(() => {
  133. uni.$u.toast('开刮失败,请重试!');
  134. })
  135. },
  136. toTicket() {
  137. uni.navigateTo({
  138. url: '/pages/ticketBox/index'
  139. })
  140. },
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .status_bar {
  146. width: 100%;
  147. height: var(--status-bar-height);
  148. }
  149. /deep/ .u-tabbar__placeholder {
  150. display: none;
  151. }
  152. </style>
  153. <style lang="scss" scoped>
  154. .box {
  155. width: 100%;
  156. height: calc(100vh - 50px);
  157. background: url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic3.zhimg.com%2F50%2Fv2-a6f5c8b5b66fe87e4e79c1fc82a61a36_hd.jpg&refer=http%3A%2F%2Fpic3.zhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1649658373&t=f216ee4825d5b36e62aa3a490516bfb1) center center;
  158. &-top {
  159. display: flex;
  160. justify-content: space-between;
  161. padding: 80rpx 40rpx 0;
  162. &-action {
  163. display: flex;
  164. &-item {
  165. margin-right: 76rpx;
  166. &-cir {
  167. width: 104rpx;
  168. height: 104rpx;
  169. background-color: #FCB824;
  170. border-radius: 50%;
  171. margin-bottom: 14rpx;
  172. }
  173. &-txt {
  174. text-align: center;
  175. color: #FFFFFF;
  176. }
  177. }
  178. }
  179. &-tip {
  180. display: flex;
  181. flex-direction: column;
  182. align-items: flex-end;
  183. justify-content: flex-end;
  184. color: #FFFFFF;
  185. }
  186. }
  187. &-ticket {
  188. margin: 200rpx 0 0;
  189. height: 480rpx;
  190. }
  191. &-ticket-tip {
  192. margin-top: 20rpx;
  193. line-height: 40rpx;
  194. text-align: center;
  195. font-size: 24rpx;
  196. color: #F44200;
  197. }
  198. &-start {
  199. position: relative;
  200. margin-top: 60rpx;
  201. &-action {
  202. flex-direction: column;
  203. width: 226rpx;
  204. height: 226rpx;
  205. border-radius: 50%;
  206. background-color: #EB7009;
  207. box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
  208. text {
  209. display: inline-block;
  210. color: #FFFFFF;
  211. line-height: 50rpx;
  212. }
  213. }
  214. &-all {
  215. position: absolute;
  216. right: 50rpx;
  217. text-align: center;
  218. width: 156rpx;
  219. height: 156rpx;
  220. line-height: 156rpx;
  221. border-radius: 50%;
  222. background-color: #FFFFFF;
  223. }
  224. }
  225. }
  226. </style>