index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. if (options.id) {
  50. console.log(options);
  51. this.serialNo = options.id
  52. }
  53. if (options.q) {
  54. let url = JSON.stringify(options.q)
  55. this.serialNo = url.substring(url.length - 22, url.length - 1)
  56. }
  57. },
  58. onShow() {
  59. if (this.serialNo) {
  60. this.getDetail()
  61. }
  62. },
  63. methods: {
  64. getDetail() {
  65. uni.showLoading({
  66. title: '加载中'
  67. });
  68. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  69. serialNo: this.serialNo,
  70. noToken: true
  71. }).then(res => {
  72. uni.hideLoading();
  73. if (res.code == 0) {
  74. if (res.data.status == 1) {
  75. this.info = res.data
  76. } else if (res.data.status == 2) {
  77. if (uni.getStorageSync('token')) {
  78. uni.redirectTo({
  79. url: `/pages/choice/index?id=${ res.data.ticketId }`
  80. })
  81. } else {
  82. uni.showModal({
  83. title: '提示',
  84. content: '您未登录或登录失效!',
  85. confirmText: '去登录',
  86. showCancel: false,
  87. success(res) {
  88. if (res.confirm) {
  89. uni.navigateTo({
  90. url: "/pages/login/index"
  91. })
  92. }
  93. }
  94. })
  95. }
  96. } else {
  97. this.showNull = true
  98. }
  99. } else {
  100. uni.$u.toast('该盲票不存在!');
  101. setTimeout(() => {
  102. uni.switchTab({
  103. url: '/pages/index/index'
  104. })
  105. }, 1000)
  106. }
  107. }).catch(() => {
  108. uni.hideLoading();
  109. })
  110. },
  111. getDetailInfo() {
  112. this.payShow = false
  113. uni.showLoading({
  114. title: '加载中'
  115. });
  116. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  117. serialNo: this.serialNo,
  118. noToken: true
  119. }).then(res => {
  120. uni.hideLoading();
  121. if (res.code == 0) {
  122. this.info = res.data
  123. }
  124. }).catch(() => {
  125. uni.hideLoading();
  126. })
  127. },
  128. close() {
  129. this.payShow = false
  130. },
  131. pay() {
  132. let data = {
  133. ticketId: this.info.ticketId,
  134. autoCoupon: 1
  135. }
  136. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  137. if (res.code == 0) {
  138. let info = {
  139. ...res.data,
  140. ...this.info,
  141. picUrl: env.filePublic + res.data.picUrl,
  142. }
  143. this.payInfo = info
  144. this.payShow = true
  145. }
  146. })
  147. },
  148. screen() {
  149. },
  150. toIndex() {
  151. uni.switchTab({
  152. url: '/pages/index/index'
  153. })
  154. },
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. .lucky {
  160. width: 100%;
  161. height: calc(100vh - 50px);
  162. background-image: linear-gradient(to right, #ebbba7 0%, #cfc7f8 100%);
  163. &-number {
  164. padding-top: 400rpx;
  165. &-circle {
  166. box-sizing: border-box;
  167. flex-direction: column;
  168. width: 336rpx;
  169. height: 336rpx;
  170. background-color: $uni-bg-color;
  171. border-radius: 50%;
  172. margin: auto;
  173. .title {
  174. margin-bottom: 20rpx;
  175. }
  176. .num {
  177. font-size: 100rpx;
  178. }
  179. .luckyNum {
  180. font-size: 36rpx;
  181. }
  182. }
  183. }
  184. &-title {
  185. margin-top: 40rpx;
  186. margin-bottom: 70rpx;
  187. .txt {
  188. text-align: center;
  189. font-size: 36rpx;
  190. font-weight: bold;
  191. line-height: 50rpx;
  192. margin-bottom: 8rpx;
  193. }
  194. .id {
  195. line-height: 40rpx;
  196. text-align: center;
  197. }
  198. }
  199. &-btn {
  200. .pay {
  201. width: 400rpx;
  202. height: 60rpx;
  203. line-height: 60rpx;
  204. border-radius: 8rpx;
  205. background-color: rgba(235, 112, 9, 100);
  206. color: #FFFFFF;
  207. text-align: center;
  208. }
  209. }
  210. .index {
  211. margin: 60rpx 0;
  212. text-align: center;
  213. font-weight: bold;
  214. color: $uni-color-primary;
  215. }
  216. }
  217. .null-prize {
  218. display: flex;
  219. flex-direction: column;
  220. align-items: center;
  221. justify-content: center;
  222. width: 80vw;
  223. height: 320rpx;
  224. background-color: #FFFFFF;
  225. border: 1px solid rgba(187, 187, 187, 100);
  226. .btn {
  227. margin-top: 60rpx;
  228. width: 160rpx;
  229. height: 60rpx;
  230. line-height: 60rpx;
  231. border-radius: 8rpx;
  232. background-color: rgba(235, 112, 9, 100);
  233. color: rgba(255, 255, 255, 100);
  234. font-size: 28rpx;
  235. text-align: center;
  236. }
  237. }
  238. </style>