index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <div class="checkBox">
  3. <div class="check-tip">
  4. <div class="check-content">
  5. <h3 class="b-text2" >支付订单</h3>
  6. <img :src="`${$cdn}images/weixin-pay.png`" alt />
  7. <div class="check-detail">
  8. <p>
  9. <span >1. 如果已完成支付,请点击</span>
  10. <strong >完成支付</strong>
  11. </p>
  12. <p>
  13. <span >2. 如果未打开微信客户端或未完成支付,请点击</span>
  14. <strong>稍后支付</strong>
  15. <span>返回我的订单页</span>
  16. </p>
  17. </div>
  18. </div>
  19. <div class="check-footer">
  20. <div class="btn" @click="backto">稍后支付</div>
  21. <div class="btn" @click="queryOrderStatus">完成支付</div>
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import { mapState } from 'vuex'
  28. export default {
  29. computed: {
  30. ...mapState({
  31. token: state => state.user.token,
  32. orderinfo: state => {
  33. let type = Object.prototype.toString.call(state.user.orderinfo)
  34. if (type === '[object Object]') {
  35. return state.user.orderinfo
  36. }
  37. let condition = state.user.orderinfo && state.user.orderinfo !== 'null' && type !== '[object Array]'
  38. return condition ? JSON.parse(state.user.orderinfo) : {}
  39. }
  40. })
  41. },
  42. methods: {
  43. backto () {
  44. let to = this.orderinfo.orderType === 0 ? {
  45. path: '/order'
  46. } : {
  47. name: 'device',
  48. params: {
  49. id: 4
  50. }
  51. }
  52. this.$router.replace(to)
  53. },
  54. async queryOrderStatus () {
  55. let {orderSn, orderType} = this.orderinfo
  56. if (!orderSn) {
  57. return this.$toast.show('error', '获取订单信息失败')
  58. }
  59. let params = {
  60. orderSn,
  61. orderType,
  62. payType: 0
  63. }
  64. let res = await this.$http
  65. .post('/user/order/queryOrderStatus', params, {
  66. headers: {
  67. token: this.token
  68. }
  69. })
  70. let response = res.data
  71. if (response.code !== 0) {
  72. return this.$toast.show('warn', '查询交易失败,请稍后再试')
  73. }
  74. response.data ? this.$router.replace({
  75. name: 'payresult',
  76. params: {
  77. isSuccess: 'success'
  78. }
  79. }) : this.$router.replace({
  80. name: 'payresult',
  81. params: {
  82. isSuccess: 'fail'
  83. }
  84. })
  85. }
  86. },
  87. mounted () {
  88. }
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .checkBox{
  93. width: 100%;
  94. margin: 10% 0;
  95. .check-tip{
  96. text-align: center;
  97. .check-content{
  98. img{
  99. width: 15%;
  100. margin: 8% auto;
  101. }
  102. }
  103. .check-detail{
  104. border-top: 1px solid #ddd;
  105. padding-top: 8%;
  106. margin:0 5%;
  107. text-align: left;
  108. p{
  109. margin-bottom: 20px;
  110. line-height: 1.5;
  111. span{
  112. color: #999;
  113. }
  114. strong{
  115. font-weight: normal;
  116. }
  117. }
  118. }
  119. .check-footer{
  120. margin:0 5%;
  121. .btn {
  122. width: 100%;
  123. background: white;
  124. border-radius: 3px;
  125. height: 45px;
  126. line-height: 45px;
  127. border: 1px solid #ccc;
  128. margin-bottom: 5%;
  129. &:last-child{
  130. border: 1px solid #333;
  131. }
  132. }
  133. }
  134. }
  135. }
  136. </style>