deposit.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view style="overflow: hidden;">
  3. <payment-pasword ref="paymentPassword" mode="1" @submit="balancePay"></payment-pasword>
  4. <timer-tips v-if="orders.length" :createtime="orders[0].createtime"></timer-tips>
  5. <view class="money-info">
  6. 保证金:{{deposit}}元
  7. </view>
  8. <!-- <view class="sum">合计:{{total_amount_sum|priceFilter}}元</view> -->
  9. <view class="pay-method">
  10. <view class="label">请选择支付方式</view>
  11. <view>
  12. <view class="item" :class="{'active':pay_method==='alipay'}"
  13. @tap="pay_method='alipay',pay_provider='alipay'">
  14. <image class="image" src="../../static/alipay.png" mode="scaleToFill"
  15. style="width: 50upx;height: 50upx;"></image>支付宝
  16. </view>
  17. <view class="item" :class="{'active':pay_method==='wechat'}"
  18. @tap="pay_method='wechat',pay_provider='wxpay'">
  19. <image class="image" src="../../static/wxpay.png" mode="scaleToFill"
  20. style="width: 50upx;height: 50upx;"></image>微信支付
  21. </view>
  22. <!-- <view class="item" :class="{'active':pay_method==='balance'}" @tap="pay_method='balance'">
  23. <image class="image" src="../../static/logo.png" mode="scaleToFill"
  24. style="width: 50upx;height: 50upx;"></image>使用余额({{$store.state.user.money}})
  25. </view> -->
  26. </view>
  27. <view class="" style="margin-top: 40upx;">
  28. <button class="pay-btn" type="default" @tap="pay">立即支付</button>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import paymentPasword from "@/components/sanshui-payment-password/index.vue"
  35. export default {
  36. data() {
  37. return {
  38. deposit: 2000,
  39. pay_method: "alipay",
  40. pay_provider: "alipay",
  41. orders: [],
  42. order_no: ""
  43. }
  44. },
  45. components: {
  46. paymentPasword
  47. },
  48. computed: {
  49. total_amount_sum() {
  50. return deposit;
  51. }
  52. },
  53. onLoad(option) {
  54. this.order_no = option.order_no;
  55. // this.getCashierData();
  56. },
  57. methods: {
  58. getCashierData() {
  59. this.$http.get({
  60. url: "/order/cashier",
  61. data: {
  62. order_no: this.order_no
  63. },
  64. success: (res) => {
  65. this.orders = res.data.data.map((value) => {
  66. value.products_json = JSON.parse(value.products_snapshot)
  67. return value;
  68. })
  69. }
  70. })
  71. },
  72. balancePay(e) {
  73. console.log(e)
  74. this.$http.post({
  75. url: '/order/balancePay',
  76. data: {
  77. 'order_no': this.order_no,
  78. 'pay_method': this.pay_method,
  79. 'amount': this.total_amount_sum,
  80. 'safe_pass': e.value
  81. },
  82. success: (res) => {
  83. uni.navigateTo({
  84. url: "/pages/order/order",
  85. })
  86. }
  87. })
  88. },
  89. pay() {
  90. if (this.pay_method !== 'balance') {
  91. this.$http.get({
  92. url: '/order/pay',
  93. data: {
  94. 'order_no': this.order_no,
  95. 'pay_method': this.pay_method,
  96. 'amount': this.total_amount_sum
  97. },
  98. success: (res) => {
  99. uni.requestPayment({
  100. provider: this.pay_provider,
  101. orderInfo: res.data.data,
  102. success: (res) => {
  103. uni.showModal({
  104. content: JSON.stringify(res)
  105. })
  106. },
  107. fail: (res) => {
  108. uni.showModal({
  109. content: "支付失败",
  110. })
  111. }
  112. })
  113. }
  114. })
  115. } else {
  116. this.$refs.paymentPassword.modalFun('show');
  117. }
  118. }
  119. }
  120. }
  121. </script>
  122. <style lang="scss" scoped>
  123. .order {
  124. overflow: hidden;
  125. }
  126. .money-info {
  127. font-size: 50upx;
  128. text-align: center;
  129. margin: 150upx;
  130. }
  131. .sum {
  132. margin: 20upx;
  133. font-size: 30upx;
  134. text-align: right;
  135. font-weight: bold;
  136. }
  137. .pay-method {
  138. margin: 20upx;
  139. padding: 20upx;
  140. background: white;
  141. .label {
  142. font-size: 30upx;
  143. margin-bottom: 20upx;
  144. }
  145. .item {
  146. height: 80upx;
  147. display: flex;
  148. align-items: center;
  149. font-size: 30upx;
  150. border-bottom: 2upx solid #F5F5F5;
  151. .image {
  152. margin-right: 10upx;
  153. }
  154. &.active {
  155. background: url(../../static/gou.png) no-repeat;
  156. background-size: 40upx 40upx;
  157. background-position: 600upx 20upx;
  158. }
  159. }
  160. }
  161. .pay-btn {
  162. margin: 20upx 0;
  163. background: $primary-color;
  164. color: white;
  165. font-size: 32upx;
  166. font-weight: bold;
  167. }
  168. </style>