pay.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="">
  3. <u-navbar
  4. title="收银台"
  5. @leftClick="leftClick"
  6. :autoBack="false"
  7. :safeAreaInsetTop="true"
  8. >
  9. </u-navbar>
  10. <view class="page-wrap">
  11. <view class="pay-way page-wrap">
  12. <u-radio-group v-model="params.paymentMode" placement="column" @change="groupChange">
  13. <!-- <view class="pay-way-item u-flex u-row-between">
  14. <view class="left">微信支付</view>
  15. <u-radio :name="1" activeColor="#00A447" size="36rpx"></u-radio>
  16. </view> -->
  17. <view :class="{disabled:customBalance<params.payAmount}" class="pay-way-item u-flex u-row-between">
  18. <view class="left">旭烁余额支付(¥ {{customBalance}})</view>
  19. <u-radio :name="2" :disabled="customBalance<params.payAmount" activeColor="#00A447" size="36rpx"></u-radio>
  20. </view>
  21. <!-- <view class="pay-way-item u-flex u-row-between">
  22. <view class="left">积分支付(¥ {{credit}})</view>
  23. <u-radio :name="3" :disabled="fromPage!=creditOrder&&customBalance<params.payAmount" activeColor="#00A447" size="36rpx"></u-radio>
  24. </view> -->
  25. <view class="pay-way-item u-flex u-row-between">
  26. <view class="left">农商行支付</view>
  27. <u-radio :name="4" activeColor="#00A447" size="36rpx"></u-radio>
  28. </view>
  29. </u-radio-group>
  30. </view>
  31. <view class="full-btn" @click="gotoPay">去支付<text>¥ {{params.payAmount}}</text></view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. fromPage:'',
  40. customBalance:'',
  41. credit:'',
  42. params:{
  43. paymentMode:null,
  44. orderId:'',
  45. openid:'',
  46. payAmount:'',
  47. payResult:{},
  48. }
  49. }
  50. },
  51. onShow() {
  52. this.getMemberInfo();
  53. },
  54. onLoad(page) {
  55. console.log('page',page);
  56. this.fromPage = page.fromPage;
  57. this.params.orderId = page.orderId;
  58. this.params.openid = this.vuex_wechatOpenid;
  59. this.params.payAmount = page.payAmount;
  60. this.params.paymentMode = page.paymentMode || 4;
  61. },
  62. methods: {
  63. leftClick(){
  64. uni.showModal({
  65. title: '提示',
  66. content: '是否放弃本次付款!',
  67. success: res => {
  68. if (res.confirm) {
  69. uni.navigateBack()
  70. } else if (res.cancel) {
  71. console.log('用户点击取消');
  72. }
  73. }
  74. });
  75. },
  76. getMemberInfo(){
  77. this.$u.api.memberInfo({id:this.vuex_user_info.userid}).then(res=>{
  78. this.customBalance= res.data.balance;
  79. this.credit= res.data.credit;
  80. }).catch(err=>{
  81. console.log('memberInfo',err.data);
  82. })
  83. },
  84. gotoPay(){
  85. console.log('gotoPay',this.params);
  86. this.$u.api.gotoPay(this.params).then(res=>{
  87. this.payResult = res.data.payResult;
  88. if(this.params.paymentMode==1||this.params.paymentMode==4){
  89. this.wxPay()
  90. }else{
  91. uni.$u.route('/shopping/paysuccess');
  92. }
  93. console.log('gotoPayres',res.data);
  94. }).catch(err=>{
  95. console.log('gotoPay',err);
  96. })
  97. },
  98. wxPay(){
  99. uni.requestPayment({
  100. ... this.payResult,
  101. "provider": "wxpay",
  102. "orderInfo": {
  103. // "appid": "wx499********7c70e", // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
  104. // "noncestr": "c5sEwbaNPiXAF3iv", // 随机字符串
  105. // "package": "Sign=WXPay", // 固定值
  106. // "partnerid": "148*****52", // 微信支付商户号
  107. // "prepayid": "wx202254********************fbe90000", // 统一下单订单号
  108. // "timestamp": 1597935292, // 时间戳(单位:秒)
  109. // "sign": "A842B45937F6EFF60DEC7A2EAA52D5A0" // 签名,这里用的 MD5/RSA 签名
  110. },
  111. success(res) {
  112. uni.$u.route('/shopping/paysuccess');
  113. },
  114. fail(e) {
  115. console.log('wxPayfail',e);
  116. }
  117. })
  118. },
  119. groupChange(e){
  120. console.log('groupChange',e);
  121. }
  122. }
  123. }
  124. </script>
  125. <style>
  126. page{
  127. background-color: #F5F5F5;
  128. }
  129. </style>
  130. <style lang="scss" scoped>
  131. .pay-way{
  132. background-color: #fff;
  133. border-radius: 8rpx;
  134. .pay-way-item {
  135. padding: 30rpx;
  136. &:not(:last-child){
  137. border-bottom: 0.5px solid #eee;
  138. }
  139. &.disabled{
  140. .left{
  141. color: #D8D8D8;
  142. }
  143. }
  144. }
  145. .left{
  146. font-size: 30rpx;
  147. font-weight: 500;
  148. color: #333333;
  149. line-height: 42rpx;
  150. }
  151. }
  152. .full-btn{
  153. margin-top: 100rpx;
  154. }
  155. </style>