金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
3.6 KiB

  1. <template>
  2. <view id="recharge-success">
  3. <view class="contents" v-if="init">
  4. <view class="is-ok" v-if="isOK">
  5. <view class="text">
  6. <i class="iconfont icon-chenggong"></i> 充值成功
  7. </view>
  8. <view class="info">
  9. 本次充值 <span>{{amount / 100}}</span> 当前可用 <i>{{sum / 100}}</i>
  10. </view>
  11. </view>
  12. <view class="is-ok" v-if="!isOK">
  13. <view class="no-text">
  14. <i class="iconfont icon-shibai"></i> 充值失败
  15. </view>
  16. </view>
  17. <view class="point-box" v-if="isOK && text">
  18. {{text}}
  19. </view>
  20. <div class="button-box" @tap="jump">
  21. 查看余额
  22. </div>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  28. export default {
  29. data() {
  30. return {
  31. isOK: true,
  32. text: '',
  33. amount: 0,
  34. sum: 0,
  35. init:''
  36. };
  37. },
  38. onLoad(e) {
  39. wx.showLoading();
  40. pageLogin(getUrl(), () => {
  41. setTimeout(() => {
  42. this.queryBalanceStatus(e.order_no);
  43. }, 500);
  44. });
  45. },
  46. components: {},
  47. props: {},
  48. methods: {
  49. jump() {
  50. wx.redirectTo({
  51. url: '/pages/recharge/balance/balance'
  52. });
  53. },
  54. queryBalanceStatus(order_no) {
  55. var token = this.$cookieStorage.get('user_token');
  56. this.$http.get({
  57. api: 'api/users/balance/paid',
  58. header: {
  59. Authorization: token
  60. },
  61. data: {
  62. order_no: order_no
  63. }
  64. }).then(res => {
  65. if (res.statusCode == 200) {
  66. res = res.data;
  67. this.setData({
  68. isOK: Boolean(res && res.data && res.data.order.pay_status),
  69. init:true
  70. });
  71. if (this.isOK) {
  72. this.setData({
  73. amount: res.data.order.amount,
  74. sum: res.data.sum
  75. });
  76. if (res.data.order.recharge) {
  77. this.setData({
  78. text: res.data.order.recharge.title
  79. });
  80. }
  81. } else {
  82. this.setData({
  83. isOK: false
  84. });
  85. wx.showModal({
  86. content: res.message || "充值失败",
  87. showCancel: false,
  88. success: res => {
  89. if (res.confirm) {
  90. wx.redirectTo({
  91. url: '/pages/recharge/balance/balance'
  92. });
  93. }
  94. }
  95. });
  96. }
  97. wx.hideLoading();
  98. } else {
  99. wx.hideLoading();
  100. this.setData({
  101. isOK: false
  102. });
  103. wx.showModal({
  104. title: '',
  105. content: "充值失败",
  106. showCancel: false,
  107. success: res => {
  108. if (res.confirm) {
  109. wx.redirectTo({
  110. url: '/pages/recharge/balance/balance'
  111. });
  112. }
  113. }
  114. });
  115. }
  116. });
  117. },
  118. setData: function (obj) {
  119. let that = this;
  120. let keys = [];
  121. let val, data;
  122. Object.keys(obj).forEach(function (key) {
  123. keys = key.split('.');
  124. val = obj[key];
  125. data = that.$data;
  126. keys.forEach(function (key2, index) {
  127. if (index + 1 == keys.length) {
  128. that.$set(data, key2, val);
  129. } else {
  130. if (!data[key2]) {
  131. that.$set(data, key2, {});
  132. }
  133. }
  134. data = data[key2];
  135. });
  136. });
  137. }
  138. },
  139. computed: {},
  140. watch: {}
  141. };
  142. </script>
  143. <style rel="stylesheet/less" lang="less">
  144. @import "success";
  145. </style>