index.vue 5.5 KB

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