index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. if (res.code == 0) {
  110. let info = {
  111. ...res.data,
  112. ...this.info,
  113. picUrl: env.filePublic + res.data.picUrl,
  114. }
  115. this.payInfo = info
  116. this.payShow = true
  117. }
  118. })
  119. },
  120. screen() {
  121. },
  122. toIndex() {
  123. uni.switchTab({
  124. url: '/pages/index/index'
  125. })
  126. },
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. .lucky {
  132. width: 100%;
  133. height: calc(100vh - 50px);
  134. background-image: linear-gradient(to right, #ebbba7 0%, #cfc7f8 100%);
  135. &-number {
  136. padding-top: 400rpx;
  137. &-circle {
  138. box-sizing: border-box;
  139. flex-direction: column;
  140. width: 336rpx;
  141. height: 336rpx;
  142. background-color: $uni-bg-color;
  143. border-radius: 50%;
  144. margin: auto;
  145. .title {
  146. margin-bottom: 20rpx;
  147. }
  148. .num {
  149. font-size: 100rpx;
  150. }
  151. .luckyNum {
  152. font-size: 36rpx;
  153. }
  154. }
  155. }
  156. &-title {
  157. margin-top: 40rpx;
  158. margin-bottom: 70rpx;
  159. .txt {
  160. text-align: center;
  161. font-size: 36rpx;
  162. font-weight: bold;
  163. line-height: 50rpx;
  164. margin-bottom: 8rpx;
  165. }
  166. .id {
  167. line-height: 40rpx;
  168. text-align: center;
  169. }
  170. }
  171. &-btn {
  172. .pay {
  173. width: 400rpx;
  174. height: 60rpx;
  175. line-height: 60rpx;
  176. border-radius: 8rpx;
  177. background-color: rgba(235, 112, 9, 100);
  178. color: #FFFFFF;
  179. text-align: center;
  180. }
  181. }
  182. .index {
  183. margin: 60rpx 0;
  184. text-align: center;
  185. font-weight: bold;
  186. color: $uni-color-primary;
  187. }
  188. }
  189. .null-prize {
  190. display: flex;
  191. flex-direction: column;
  192. align-items: center;
  193. justify-content: center;
  194. width: 70vw;
  195. height: 260rpx;
  196. background-color: #FFFFFF;
  197. border: 1px solid rgba(187, 187, 187, 100);
  198. .btn {
  199. margin-top: 50rpx;
  200. width: 160rpx;
  201. height: 60rpx;
  202. line-height: 60rpx;
  203. border-radius: 8rpx;
  204. background-color: rgba(235, 112, 9, 100);
  205. color: rgba(255, 255, 255, 100);
  206. font-size: 28rpx;
  207. text-align: center;
  208. }
  209. }
  210. </style>