金诚优选前端代码
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.

146 lines
3.5 KiB

  1. <template>
  2. <view id="pointstore-success">
  3. <view class="contents">
  4. <view class="is-ok" v-if="isOK === true">
  5. <view class="text">
  6. 兑换成功
  7. </view>
  8. <view>
  9. 感谢惠顾~
  10. </view>
  11. </view>
  12. <view class="is-ok" v-if="isOK === false">
  13. <view class="no-text">
  14. 兑换失败
  15. </view>
  16. <view>
  17. 我还会在回来的~
  18. </view>
  19. </view>
  20. <view class="point-box mx-1px-top" v-if="isOK === true">
  21. <view>本次消耗 <i class="red">{{order_info.pointUsed}}</i> 积分</view>
  22. <view>当前可用 <i>{{order_info.pointTotal}}</i> 积分</view>
  23. </view>
  24. <view class="button-box">
  25. <view class="lock" :style="'color: ' + config.mainColor" v-if="isOK === true" @tap="jumpOrder">
  26. 查看订单详情
  27. </view>
  28. <view @tap="jumpStore" :style="'background: ' + config.mainColor">
  29. 继续兑换
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  37. export default {
  38. data() {
  39. return {
  40. isOK: null,
  41. order_info: {},
  42. order_no: "",
  43. config: ''
  44. };
  45. },
  46. onLoad(e) {
  47. // 第三方平台配置颜色
  48. var gbConfig = this.$cookieStorage.get('globalConfig') || '';
  49. this.setData({
  50. config: gbConfig
  51. });
  52. console.log(e);
  53. var data = {
  54. order_no: e.order_no
  55. };
  56. this.setData({
  57. order_no: e.order_no
  58. });
  59. this.queryPaymentStatus(data);
  60. },
  61. components: {},
  62. props: {},
  63. methods: {
  64. jumpStore() {
  65. wx.redirectTo({
  66. url: '/pages/pointStore/index/index'
  67. });
  68. },
  69. jumpOrder() {
  70. wx.redirectTo({
  71. url: '/pages/pointStore/orderdetail/orderdetail?no=' + this.order_no
  72. });
  73. },
  74. queryPaymentStatus(data) {
  75. var oauth = this.$cookieStorage.get('user_token');
  76. this.$http.post({
  77. api: `api/shopping/order/paid`,
  78. header: {
  79. Authorization: oauth
  80. },
  81. data: data
  82. }).then(res => {
  83. res = res.data;
  84. if (res.status) {
  85. this.setData({
  86. isOK: !!(res && res.status && res.data.order.pay_status == 1)
  87. });
  88. if (this.isOK) {
  89. this.setData({
  90. order_info: {
  91. pointTotal: res.data.pointInfo.pointTotal,
  92. // 当前积分
  93. pointUsed: res.data.pointInfo.pointUsed // 消耗积分
  94. }
  95. });
  96. }
  97. } else {
  98. wx.showModal({
  99. content: res.message || '兑换失败',
  100. showCancel: false
  101. });
  102. this.setData({
  103. isOK: false
  104. });
  105. }
  106. });
  107. },
  108. setData: function (obj) {
  109. let that = this;
  110. let keys = [];
  111. let val, data;
  112. Object.keys(obj).forEach(function (key) {
  113. keys = key.split('.');
  114. val = obj[key];
  115. data = that.$data;
  116. keys.forEach(function (key2, index) {
  117. if (index + 1 == keys.length) {
  118. that.$set(data, key2, val);
  119. } else {
  120. if (!data[key2]) {
  121. that.$set(data, key2, {});
  122. }
  123. }
  124. data = data[key2];
  125. });
  126. });
  127. }
  128. },
  129. computed: {},
  130. watch: {}
  131. };
  132. </script>
  133. <style rel="stylesheet/less" lang="less">
  134. @import "success";
  135. </style>