index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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" @click="toPrize">
  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. toPrize() {
  142. uni.navigateTo({
  143. url: '/pages/prize/index'
  144. })
  145. },
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. .status_bar {
  151. width: 100%;
  152. height: var(--status-bar-height);
  153. }
  154. /deep/ .u-tabbar__placeholder {
  155. display: none;
  156. }
  157. </style>
  158. <style lang="scss" scoped>
  159. .box {
  160. width: 100%;
  161. height: calc(100vh - 50px);
  162. background-image: linear-gradient(to right, #ebbba7 0%, #cfc7f8 100%);
  163. &-top {
  164. display: flex;
  165. justify-content: space-between;
  166. padding: 80rpx 40rpx 0;
  167. &-action {
  168. display: flex;
  169. &-item {
  170. margin-right: 76rpx;
  171. &-cir {
  172. width: 104rpx;
  173. height: 104rpx;
  174. background-color: #FCB824;
  175. border-radius: 50%;
  176. margin-bottom: 14rpx;
  177. }
  178. &-txt {
  179. text-align: center;
  180. color: #FFFFFF;
  181. }
  182. }
  183. }
  184. &-tip {
  185. display: flex;
  186. flex-direction: column;
  187. align-items: flex-end;
  188. justify-content: flex-end;
  189. color: #FFFFFF;
  190. }
  191. }
  192. &-ticket {
  193. margin: 100rpx 0 0;
  194. height: 580rpx;
  195. }
  196. &-ticket-tip {
  197. margin-top: 20rpx;
  198. line-height: 40rpx;
  199. text-align: center;
  200. font-size: 24rpx;
  201. color: #F44200;
  202. }
  203. &-start {
  204. position: relative;
  205. margin-top: 60rpx;
  206. &-action {
  207. flex-direction: column;
  208. width: 226rpx;
  209. height: 226rpx;
  210. border-radius: 50%;
  211. background-color: #EB7009;
  212. box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
  213. text {
  214. display: inline-block;
  215. color: #FFFFFF;
  216. line-height: 50rpx;
  217. }
  218. }
  219. &-all {
  220. position: absolute;
  221. right: 50rpx;
  222. text-align: center;
  223. width: 156rpx;
  224. height: 156rpx;
  225. line-height: 156rpx;
  226. border-radius: 50%;
  227. background-color: #FFFFFF;
  228. }
  229. }
  230. }
  231. </style>