index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view>
  3. <u-navbar leftIconSize="0" title="幸运数字" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
  4. <view class="lucky">
  5. <view class="lucky-number">
  6. <view class="flex lucky-number-circle">
  7. <view class="title">幸运数字</view>
  8. <view class="num" v-if="info.status == 1">?</view>
  9. <view class="luckyNum" v-else>{{ info.plainLuckyNum }}</view>
  10. </view>
  11. </view>
  12. <view class="lucky-title">
  13. <view class="txt">{{ info.title }}</view>
  14. <view class="id">盲票序列号:{{ info.serialNo }}</view>
  15. </view>
  16. <view class="flex lucky-btn">
  17. <view class="pay" @click="pay" v-if="info.status == 1">支付{{ info.facePrice / 100 }}元 立即查看</view>
  18. <view class="pay" @click="screen" v-else>保存至手机相册</view>
  19. </view>
  20. <view class="index" @click="toIndex">去首页</view>
  21. </view>
  22. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="getDetailInfo" />
  23. <u-popup :show="showNull" :round="10" mode="center">
  24. <view class="null-prize">
  25. <view class="title">该盲票已兑奖</view>
  26. <view class="btn" @click="toIndex">确认</view>
  27. </view>
  28. </u-popup>
  29. </view>
  30. </template>
  31. <script>
  32. import env from '../../config/env.js'
  33. import $http from '@/utils/request.js'
  34. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  35. export default {
  36. components: {
  37. PayPopup
  38. },
  39. data() {
  40. return {
  41. serialNo: '',
  42. info: '',
  43. payInfo: {},
  44. payShow: false,
  45. showNull: false
  46. };
  47. },
  48. onLoad(options) {
  49. this.serialNo = options.id
  50. this.getDetail()
  51. },
  52. methods: {
  53. getDetail() {
  54. uni.showLoading({
  55. title: '加载中'
  56. });
  57. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  58. serialNo: this.serialNo,
  59. noToken: true
  60. }).then(res => {
  61. uni.hideLoading();
  62. if (res.code == 0) {
  63. if (res.data.status == 1) {
  64. this.info = res.data
  65. } else if (res.data.status == 2) {
  66. uni.redirectTo({
  67. url: `/pages/choice/index?id=${ res.data.ticketId }`
  68. })
  69. } else {
  70. this.showNull = true
  71. }
  72. } else {
  73. setTimeout(() => {
  74. uni.switchTab({
  75. url: '/pages/index/index'
  76. })
  77. }, 500)
  78. }
  79. }).catch(() => {
  80. uni.hideLoading();
  81. })
  82. },
  83. getDetailInfo() {
  84. this.payShow = false
  85. uni.showLoading({
  86. title: '加载中'
  87. });
  88. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  89. serialNo: this.serialNo,
  90. noToken: true
  91. }).then(res => {
  92. uni.hideLoading();
  93. if (res.code == 0) {
  94. this.info = res.data
  95. }
  96. }).catch(() => {
  97. uni.hideLoading();
  98. })
  99. },
  100. close() {
  101. this.payShow = false
  102. },
  103. pay() {
  104. let data = {
  105. ticketId: this.info.ticketId,
  106. autoCoupon: 1
  107. }
  108. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  109. console.log(res);
  110. if (res.code == 0) {
  111. let info = {
  112. ...res.data,
  113. ...this.info,
  114. picUrl: env.filePublic + res.data.picUrl,
  115. }
  116. this.payInfo = info
  117. this.payShow = true
  118. console.log(info);
  119. }
  120. })
  121. },
  122. screen() {
  123. },
  124. toIndex() {
  125. uni.switchTab({
  126. url: '/pages/index/index'
  127. })
  128. },
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. .lucky {
  134. width: 100%;
  135. height: calc(100vh - 50px);
  136. 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;
  137. &-number {
  138. padding-top: 400rpx;
  139. &-circle {
  140. box-sizing: border-box;
  141. flex-direction: column;
  142. width: 336rpx;
  143. height: 336rpx;
  144. background-color: $uni-bg-color;
  145. border-radius: 50%;
  146. margin: auto;
  147. .title {
  148. margin-bottom: 20rpx;
  149. }
  150. .num {
  151. font-size: 100rpx;
  152. }
  153. .luckyNum {
  154. font-size: 36rpx;
  155. }
  156. }
  157. }
  158. &-title {
  159. margin-top: 40rpx;
  160. margin-bottom: 70rpx;
  161. .txt {
  162. text-align: center;
  163. font-size: 36rpx;
  164. font-weight: bold;
  165. line-height: 50rpx;
  166. margin-bottom: 8rpx;
  167. }
  168. .id {
  169. line-height: 40rpx;
  170. text-align: center;
  171. }
  172. }
  173. &-btn {
  174. .pay {
  175. width: 400rpx;
  176. height: 60rpx;
  177. line-height: 60rpx;
  178. border-radius: 8rpx;
  179. background-color: rgba(235, 112, 9, 100);
  180. color: #FFFFFF;
  181. text-align: center;
  182. }
  183. }
  184. .index {
  185. margin: 60rpx 0;
  186. text-align: center;
  187. font-weight: bold;
  188. color: $uni-color-primary;
  189. }
  190. }
  191. .null-prize {
  192. display: flex;
  193. flex-direction: column;
  194. align-items: center;
  195. justify-content: center;
  196. width: 70vw;
  197. height: 260rpx;
  198. background-color: #FFFFFF;
  199. border: 1px solid rgba(187, 187, 187, 100);
  200. .btn {
  201. margin-top: 50rpx;
  202. width: 160rpx;
  203. height: 60rpx;
  204. line-height: 60rpx;
  205. border-radius: 8rpx;
  206. background-color: rgba(235, 112, 9, 100);
  207. color: rgba(255, 255, 255, 100);
  208. font-size: 28rpx;
  209. text-align: center;
  210. }
  211. }
  212. </style>