coupon-buy.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <ax-body blank="0">
  3. <view class="page-background">
  4. <image :src="pageBg" mode="widthFix"></image>
  5. </view>
  6. <view style="height: 324rpx;"></view>
  7. <view class="body">
  8. <!-- 统计卡 -->
  9. <view class="app-flex c-between">
  10. <view class="sta-card">
  11. <view class="value">{{ userinfo.integral }}</view>
  12. <view class="name">我的积分</view>
  13. <image src="@/static/img/my-sta-bg01.png" mode="heightFix" class="bg"></image>
  14. </view>
  15. <view class="sta-card">
  16. <view class="value">{{ userinfo.accountBalance }}</view>
  17. <view class="name">可抵扣余量</view>
  18. <image src="@/static/img/my-sta-bg03.png" mode="heightFix" class="bg"></image>
  19. <view class="overflow-payment" v-if="order_info != null" @click="topage_order">
  20. <text v-if="order_info.maspStatus === 1">超{{ (order_info.maspAmount +
  21. order_info.maspRealAmount).toFixed(2) || '0.00' }}元</text>
  22. <text class="ax ax-iconline i-arrow-right icon"></text>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 购券 -->
  27. <view class="card">
  28. <view class="title">
  29. <view>请选择抵扣券</view>
  30. <template v-if="order_info != null">
  31. <view class="title-text" v-if="order_info.maspStatus === 1">
  32. 至少充值{{ (3 + ((order_info.maspAmount + order_info.maspRealAmount))).toFixed(2) || '0.00'
  33. }}元(超充{{ (order_info.maspAmount + order_info.maspRealAmount).toFixed(2) || '0.00'
  34. }}元,余量需大于3元才能启动)
  35. </view>
  36. </template>
  37. </view>
  38. <!-- <view class="coupons">
  39. <view v-for="(item,index) in coupons.data" :key="index"
  40. :style="{opacity:`${(3+(order_info.maspAmount+order_info.maspRealAmount)).toFixed(2)>item.levelMoney?'0.4':''}`}"
  41. :class="{active:coupons.index==index}" @click="choose(item,index)" class="coupon-item">
  42. <view class="ticket">
  43. <view class="value"><text class="val">{{item.levelMoney}}</text>
  44. <view class="unit">元</view>
  45. </view>
  46. <view class="line-wrap">
  47. <view class="circle"></view>
  48. <view class="line"></view>
  49. <view class="circle"></view>
  50. </view>
  51. <view class="margin"></view>
  52. </view>
  53. <view class="trapezium"></view>
  54. <view class="text">充电券</view>
  55. </view>
  56. </view> -->
  57. <view class="new-coupons-box">
  58. <view v-for="(item, index) in coupons.data" :key="index"
  59. :class="{ newCouponsActive: coupons.index == index }" class="new-coupons"
  60. @click="choose(item, index)">
  61. <!-- :style="{ opacity: `${(3 + (order_info.maspAmount + order_info.maspRealAmount)).toFixed(2) > item.levelMoney ? '0.4' : ''}` }" -->
  62. <view class="new-coupons-price">{{ item.money }}<text style="font-size: 22rpx;">元</text>
  63. </view>
  64. <view class="new-coupons-text">充电券</view>
  65. </view>
  66. </view>
  67. </view>
  68. <!-- 提示 -->
  69. <view class="card tips">
  70. <view class="title">温馨提示</view>
  71. <view class="li">1. 抵扣券仅用于充电结算中抵扣资费,未使用完的余量,可手动发起退还</view>
  72. <view class="li">2. 抵扣券为专属专用不可转赠和出售</view>
  73. <view class="li">3. 抵扣券金额未抵扣完结,可累计到下次继续抵扣</view>
  74. <view class="li">4. 使用时可抵扣按照当前电价进行预估计算</view>
  75. <view class="li">5. 实际结算价以具体充电时段为准</view>
  76. </view>
  77. <view style="height: 100rpx;"></view>
  78. <view class="footer">
  79. <template v-if="order_info != null">
  80. <view class="payment-tips" v-if="coupons.index >= 0">
  81. 购买{{ select_num }}元,补缴{{ (order_info.maspAmount + order_info.maspRealAmount).toFixed(2) }}元,剩余{{
  82. (select_num - (order_info.maspAmount + order_info.maspRealAmount)).toFixed(2) }}元
  83. </view>
  84. </template>
  85. <button @click="pay()" class="pay" :disabled="coupons.index < 0">立即支付购买</button>
  86. <ax-ios-indicator></ax-ios-indicator>
  87. </view>
  88. </view>
  89. </ax-body>
  90. </template>
  91. <script>
  92. import app from '../../../static/js/app'
  93. export default {
  94. data() {
  95. return {
  96. pageBg: 'https://charge.hub.zswlgz.com/apifile//2025/11/17/X8YskVhD8AvJ9ac83ff9418869e4eec3c40fe1fd9146_20251117102852A001.png',
  97. userinfo: {},
  98. select_num: null,
  99. payment: null,
  100. order_info: null,
  101. coupons: {
  102. index: -1,
  103. data: []
  104. }
  105. }
  106. },
  107. onShow() {
  108. this.getMyAccount()
  109. this.getLevel()
  110. // this.select_orderstatus()
  111. // this.get_orderPayment()
  112. },
  113. onLoad(options) {
  114. this.payment = options.payment
  115. },
  116. methods: {
  117. getLevel() {
  118. this.$api.base("get", "/applet/v1/order/getReChargeLevel", {}, {}).then(res => {
  119. this.coupons.data = res.data;
  120. })
  121. },
  122. choose(item, index) {
  123. if (this.order_info != null) {
  124. let num = ((this.order_info.maspAmount + this.order_info.maspRealAmount) + 3).toFixed(2)
  125. if (num > item.levelMoney) {
  126. this.$app.popup.toast(`购买金额必须大于${num}元`)
  127. return
  128. }
  129. }
  130. this.coupons.index = this.coupons.index != index ? index : -1;
  131. this.select_num = item.levelMoney
  132. },
  133. pay() {
  134. if (!this.userinfo.appletUserId) {
  135. this.$app.url.goto('/pages/login/login')
  136. return;
  137. }
  138. // this.$app.popup.toast('充值入口正在维护,敬请期待!')
  139. // return
  140. this.$api.base("post", "/applet/v1/wft/order/createOrder", {
  141. levelId: this.coupons.data[this.coupons.index].id
  142. }, {}).then(addRes => {
  143. console.log(addRes, '创建订单返回');
  144. if (addRes.data.orderId) {
  145. this.$api.base("put", `/applet/v1/wft/order/payOrder/${addRes.data.orderId}`, {}, {}).then(res => {
  146. var payInfo = JSON.parse(res.data.params.pay_info)
  147. console.log(payInfo, '11');
  148. uni.requestPayment({
  149. provider: 'wxpay',
  150. timeStamp: payInfo.timeStamp,
  151. nonceStr: payInfo.nonceStr,
  152. package: payInfo.package,
  153. signType: payInfo.signType,
  154. paySign: payInfo.paySign,
  155. success: (res) => {
  156. console.log('success:', res);
  157. // 查询支付状态
  158. this.$api.base("get", `/applet/v1/wft/order/query/${addRes.data.orderNo}`, {}, {}).then(queryRes => {
  159. console.log(queryRes, '查询订单返回');
  160. if (queryRes.data) {
  161. setTimeout(() => {
  162. this.$app.popup.alert('支付成功', '温馨提示', {
  163. showCancel: false
  164. }).then(() => {
  165. this.$app.url.back()
  166. });
  167. }, 1000)
  168. } else {
  169. this.$app.popup.alert('支付失败,请稍后重试', '温馨提示', {
  170. showCancel: false
  171. }).then(() => {
  172. this.$app.url.back()
  173. });
  174. }
  175. })
  176. },
  177. fail: (err) => {
  178. console.log('fail:', err);
  179. this.$api.base("put", `/applet/v1/wft/order/closeOrder/${addRes.data.orderNo}`, {}, {}).then(cancelRes => {
  180. console.log(cancelRes, '取消订单返回');
  181. if (cancelRes.data) {
  182. this.$app.popup.alert('支付已取消', '温馨提示', {
  183. showCancel: false
  184. });
  185. }
  186. });
  187. //注册一个用户取消支付的事件
  188. }
  189. });
  190. })
  191. }
  192. })
  193. },
  194. get_orderPayment() {
  195. // maspStatus(1:待补缴,2:已补缴)realPredictServiceCost平台;maspAmount第三方
  196. this.$api.base("post", "/chargeApi/queryOrderList-arrearage", {}, {}).then(res => {
  197. this.order_info = res.data
  198. })
  199. },
  200. topage_order() {
  201. this.$app.url.goto('/subPackages/order/order-detail/order-detail?orderId=' + this.order_info.id);
  202. },
  203. getMyAccount() {
  204. this.$api.base("get", "/applet/v1/user/getUserInfo", {}, {}).then(res => {
  205. this.userinfo = res.data
  206. })
  207. },
  208. }
  209. }
  210. </script>
  211. <style scoped>
  212. @import url("coupon-buy.css");
  213. </style>