coupon-buy.vue 6.3 KB

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