index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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" @click="toRule">
  22. <view class="flex box-top-tip-txt">
  23. <u-icon name="file-text" color="#5F5F5F" 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">
  38. <view class="flex icon">
  39. <image class="icon-image" src="../../static/icon/index_all.png" mode="aspectFill"></image>
  40. </view>
  41. <view class="title">更多盲票</view>
  42. </view>
  43. </view>
  44. </view>
  45. <custom-tab-bar :activeValue="'index'" />
  46. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="toProcess" />
  47. </view>
  48. </template>
  49. <script>
  50. import env from '../../config/env.js'
  51. import $http from '@/utils/request.js'
  52. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  53. import Carousel from '../../components/vear-carousel/vear-carousel'
  54. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  55. export default {
  56. components: {
  57. CustomTabBar,
  58. Carousel,
  59. PayPopup
  60. },
  61. data() {
  62. return {
  63. imgList: [],
  64. value: 1,
  65. payShow: false,
  66. checked: false,
  67. pageNum: 1,
  68. total: 100,
  69. list: [],
  70. currentIndex: 0,
  71. payInfo: {}
  72. };
  73. },
  74. onShow(opthios) {
  75. this.getList()
  76. },
  77. methods: {
  78. getList() {
  79. uni.showLoading({
  80. title: '加载中'
  81. });
  82. let data = {
  83. categoryId: '',
  84. tagId: '',
  85. type: 'online',
  86. noToken: true
  87. }
  88. $http.post(`/api/v1/mp/user/mall/ticket/list?pageNum=${this.pageNum}&pageSize=100`, data).then(
  89. res => {
  90. uni.hideLoading();
  91. if (res.code == 0) {
  92. res.rows.forEach(item => {
  93. let picUrlArr = item.picUrl.split(',')
  94. item.picUrl = env.filePublic + picUrlArr[0]
  95. })
  96. this.total = res.total
  97. this.imgList = res.rows
  98. }
  99. }).catch(() => {
  100. uni.hideLoading();
  101. })
  102. },
  103. selectedBanner(item, index) {
  104. uni.navigateTo({
  105. url: `/pages/ticketBox/detail?id=${ item.boxId }`
  106. })
  107. },
  108. getTicket(index) {
  109. this.currentIndex = index
  110. },
  111. close() {
  112. this.payShow = false
  113. },
  114. toProcess(id) {
  115. this.payShow = false
  116. uni.navigateTo({
  117. url: `/pages/process/index?id=${ id }`
  118. })
  119. },
  120. exchange() {
  121. this.payInfo = this.imgList[this.currentIndex]
  122. let data = {
  123. couponIds: [],
  124. autoCoupon: 1,
  125. boxId: this.payInfo.boxId,
  126. orderNum: 1
  127. }
  128. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  129. if (res.code == 0) {
  130. let info = {
  131. ...res.data,
  132. ...this.payInfo
  133. }
  134. this.payInfo = info
  135. this.payShow = true
  136. }
  137. }).catch(() => {
  138. uni.$u.toast('开刮失败,请重试!');
  139. })
  140. },
  141. toTicket() {
  142. uni.navigateTo({
  143. url: '/pages/ticketBox/index'
  144. })
  145. },
  146. toPrize() {
  147. uni.navigateTo({
  148. url: '/pages/prize/index'
  149. })
  150. },
  151. toRule(){
  152. uni.navigateTo({
  153. url: '/pages/about/rule'
  154. })
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang="scss" scoped>
  160. .status_bar {
  161. width: 100%;
  162. height: var(--status-bar-height);
  163. }
  164. /deep/ .u-tabbar__placeholder {
  165. display: none;
  166. }
  167. </style>
  168. <style lang="scss" scoped>
  169. .box {
  170. width: 100%;
  171. min-height: calc(100vh - 50px);
  172. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/background.png) center center;
  173. &-top {
  174. display: flex;
  175. justify-content: space-between;
  176. padding: 100rpx 40rpx 0;
  177. &-action {
  178. display: flex;
  179. &-item {
  180. margin-right: 76rpx;
  181. &-cir {
  182. width: 104rpx;
  183. height: 104rpx;
  184. background-color: #FE5924;
  185. border-radius: 50%;
  186. margin-bottom: 14rpx;
  187. }
  188. &-txt {
  189. text-align: center;
  190. color: #5F5F5F;
  191. }
  192. }
  193. }
  194. &-tip {
  195. display: flex;
  196. flex-direction: column;
  197. align-items: flex-end;
  198. justify-content: flex-end;
  199. color: #5F5F5F;
  200. }
  201. }
  202. &-ticket {
  203. margin: 100rpx 0 0;
  204. height: 580rpx;
  205. }
  206. &-ticket-tip {
  207. margin-top: 20rpx;
  208. line-height: 40rpx;
  209. text-align: center;
  210. font-size: 40rpx;
  211. color: #FE5924;
  212. }
  213. &-start {
  214. align-items: flex-end;
  215. position: relative;
  216. margin-top: 60rpx;
  217. &-action {
  218. flex-direction: column;
  219. width: 220rpx;
  220. height: 220rpx;
  221. font-size: 36rpx;
  222. border-radius: 50%;
  223. background-color: #FE5924;
  224. border: 4rpx solid #FFFFFF;
  225. text {
  226. display: inline-block;
  227. padding-left: 8rpx;
  228. text-align: center;
  229. color: #FFFFFF;
  230. line-height: 50rpx;
  231. letter-spacing: 8rpx;
  232. }
  233. }
  234. &-all {
  235. position: absolute;
  236. right: 70rpx;
  237. .icon{
  238. width: 120rpx;
  239. height: 120rpx;
  240. border-radius: 50%;
  241. background-color: #FE5924;
  242. .icon-image{
  243. width: 80rpx;
  244. height: 80rpx;
  245. }
  246. }
  247. .title{
  248. margin-top: 8rpx;
  249. font-size: 34rpx;
  250. color: #EA350A;
  251. text-align: center;
  252. }
  253. }
  254. }
  255. }
  256. </style>