coupon-buy.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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.integralNum }}</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.balance }}</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. order_status: [],
  102. coupons: {
  103. index: -1,
  104. data: []
  105. }
  106. }
  107. },
  108. onShow() {
  109. this.getMyAccount()
  110. this.getLevel()
  111. this.select_orderstatus()
  112. this.get_orderPayment()
  113. },
  114. onLoad(options) {
  115. this.payment = options.payment
  116. },
  117. methods: {
  118. getLevel() {
  119. this.$api.base("get", "/applet/v1/order/getReChargeLevel", {}, {}).then(res => {
  120. this.coupons.data = res.data;
  121. })
  122. },
  123. choose(item, index) {
  124. if (this.order_info != null) {
  125. let num = ((this.order_info.maspAmount + this.order_info.maspRealAmount) + 3).toFixed(2)
  126. if (num > item.levelMoney) {
  127. this.$app.popup.toast(`购买金额必须大于${num}元`)
  128. return
  129. }
  130. }
  131. this.coupons.index = this.coupons.index != index ? index : -1;
  132. this.select_num = item.levelMoney
  133. },
  134. pay() {
  135. if (!this.userinfo.phone) {
  136. this.$app.url.goto('/pages/login/login')
  137. return;
  138. }
  139. if (this.order_status.length > 0) {
  140. this.$app.popup.confirm('您当前有正在进行中的订单,请结束订单后再进行充值并重新发起操作', '提示', {
  141. showCancel: true,
  142. confirmText: "查看订单"
  143. }).then((res) => {
  144. if (res) {
  145. this.$app.url.goto('/pages/order/order?index=' + 1);
  146. }
  147. })
  148. return
  149. }
  150. this.$api.base("post", "/applet/v1/order/createOrder", {
  151. levelId: this.coupons.data[this.coupons.index].id
  152. }, {}).then(addRes => {
  153. console.log(addRes, '创建订单返回');
  154. if (addRes.data.orderId) {
  155. this.$api.base("put", `/applet/v1/order/payOrder/${addRes.data.orderId}`, {}, {}).then(res => {
  156. var payInfo = JSON.parse(res.wx.wx.pay_info)
  157. uni.requestPayment({
  158. provider: 'wxpay',
  159. timeStamp: payInfo.timeStamp,
  160. nonceStr: payInfo.nonceStr,
  161. package: payInfo.package,
  162. signType: payInfo.signType,
  163. paySign: payInfo.paySign,
  164. success: (res) => {
  165. console.log('success:', res);
  166. //注册一个用户支付成功后点确定的事件
  167. this.$app.popup.alert('支付成功', '温馨提示', {
  168. showCancel: false
  169. }).then(() => {
  170. this.$app.url.back()
  171. });
  172. },
  173. fail: (err) => {
  174. console.log('fail:', err);
  175. //注册一个用户取消支付的事件
  176. }
  177. });
  178. })
  179. }
  180. })
  181. },
  182. select_orderstatus() {
  183. this.$api.base("post", "/chargeApi/queryOrderList", {
  184. type: 1
  185. }, {}).then(res => {
  186. this.order_status = res.table.rows
  187. })
  188. },
  189. get_orderPayment() {
  190. // maspStatus(1:待补缴,2:已补缴)realPredictServiceCost平台;maspAmount第三方
  191. this.$api.base("post", "/chargeApi/queryOrderList-arrearage", {}, {}).then(res => {
  192. this.order_info = res.data
  193. })
  194. },
  195. topage_order() {
  196. this.$app.url.goto('/pages/order-detail/order-detail?orderId=' + this.order_info.id);
  197. },
  198. getMyAccount() {
  199. this.$api.base("get", "/applet/v1/user/getUserInfo", {}, {}).then(res => {
  200. this.userinfo = res.data
  201. })
  202. },
  203. }
  204. }
  205. </script>
  206. <style scoped>
  207. @import url("coupon-buy.css");
  208. </style>