index.vue 6.0 KB

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