index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. console.log(index);
  105. this.currentIndex = index
  106. },
  107. close() {
  108. this.payShow = false
  109. },
  110. toProcess(id) {
  111. this.payShow = false
  112. uni.navigateTo({
  113. url: `/pages/process/index?id=${ id }`
  114. })
  115. },
  116. exchange() {
  117. this.payInfo = this.imgList[this.currentIndex]
  118. let data = {
  119. couponIds: [],
  120. autoCoupon: 1,
  121. boxId: this.payInfo.boxId,
  122. orderNum: 1
  123. }
  124. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  125. console.log(res);
  126. if (res.code == 0) {
  127. let info = {
  128. ...res.data,
  129. ...this.payInfo
  130. }
  131. this.payInfo = info
  132. this.payShow = true
  133. console.log(info);
  134. }
  135. }).catch(() => {
  136. uni.$u.toast('开刮失败,请重试!');
  137. })
  138. },
  139. toTicket() {
  140. uni.navigateTo({
  141. url: '/pages/ticketBox/index'
  142. })
  143. },
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. .status_bar {
  149. width: 100%;
  150. height: var(--status-bar-height);
  151. }
  152. /deep/ .u-tabbar__placeholder {
  153. display: none;
  154. }
  155. </style>
  156. <style lang="scss" scoped>
  157. .box {
  158. width: 100%;
  159. height: calc(100vh - 50px);
  160. 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;
  161. &-top {
  162. display: flex;
  163. justify-content: space-between;
  164. padding: 80rpx 40rpx 0;
  165. &-action {
  166. display: flex;
  167. &-item {
  168. margin-right: 76rpx;
  169. &-cir {
  170. width: 104rpx;
  171. height: 104rpx;
  172. background-color: #FCB824;
  173. border-radius: 50%;
  174. margin-bottom: 14rpx;
  175. }
  176. &-txt {
  177. text-align: center;
  178. color: #FFFFFF;
  179. }
  180. }
  181. }
  182. &-tip {
  183. display: flex;
  184. flex-direction: column;
  185. align-items: flex-end;
  186. justify-content: flex-end;
  187. color: #FFFFFF;
  188. }
  189. }
  190. &-ticket {
  191. margin: 200rpx 0 0;
  192. height: 480rpx;
  193. }
  194. &-ticket-tip {
  195. margin-top: 20rpx;
  196. line-height: 40rpx;
  197. text-align: center;
  198. font-size: 24rpx;
  199. color: #F44200;
  200. }
  201. &-start {
  202. position: relative;
  203. margin-top: 60rpx;
  204. &-action {
  205. flex-direction: column;
  206. width: 226rpx;
  207. height: 226rpx;
  208. border-radius: 50%;
  209. background-color: #EB7009;
  210. box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
  211. text {
  212. display: inline-block;
  213. color: #FFFFFF;
  214. line-height: 50rpx;
  215. }
  216. }
  217. &-all {
  218. position: absolute;
  219. right: 50rpx;
  220. text-align: center;
  221. width: 156rpx;
  222. height: 156rpx;
  223. line-height: 156rpx;
  224. border-radius: 50%;
  225. background-color: #FFFFFF;
  226. }
  227. }
  228. }
  229. </style>