payment.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. (function (global, factory) {
  2. typeof define == 'function' && define(['store', 'helper', 'vue'], factory);
  3. })(this, function (app, $h, Vue) {
  4. var u = navigator.userAgent;
  5. var phone_ios = false;
  6. if (u.indexOf('iPhone') > -1) {//苹果手机
  7. phone_ios = false;
  8. }
  9. Vue.component('payment', {
  10. props: {
  11. payment: {
  12. type: Boolean,
  13. default: false
  14. },
  15. money: {
  16. type: String,
  17. default: '0.00'
  18. },
  19. now_money: {
  20. type: String,
  21. default: '0.00'
  22. },
  23. special_id: {
  24. type: Number,
  25. default: 0,
  26. },
  27. pay_type_num: {
  28. type: Number,
  29. default: -1,
  30. },
  31. pinkId: {
  32. type: Number,
  33. default: 0,
  34. },
  35. link_pay_uid: {
  36. type: Number,
  37. default: 0
  38. },
  39. iswechat: {
  40. type: Boolean,
  41. default: false
  42. },
  43. isyue: {
  44. type: Boolean,
  45. default: false
  46. },
  47. isalipay: {
  48. type: Boolean,
  49. default: false
  50. },
  51. signs: {
  52. type: Object,
  53. default: {}
  54. }
  55. },
  56. template: `<div>
  57. <div class="payment" :class="payment ? '' : 'up'">
  58. <div class="title"><span class="knowledge iconguanbi2" @click="close"></span>支付方式</div>
  59. <div class="total acea-row row-between-wrapper">
  60. <div>支付总额</div>
  61. <div class="money">¥ {{money}}</div>
  62. </div>
  63. <div class="select-btn" style="height: auto;">
  64. <div v-if="!phoneIos && iswechat" class="checkbox-wrapper">
  65. <label class="well-check">
  66. <input v-model="payType" type="radio" name="payment" value="weixin">
  67. <i class="icon"></i>
  68. <span class="iconfont icon-weixinzhifu"></span>
  69. <span class="sex">微信支付</span>
  70. </label>
  71. </div>
  72. <div v-if="isalipay" class="checkbox-wrapper">
  73. <label class="well-check">
  74. <input v-model="payType" type="radio" name="payment" value="zhifubao">
  75. <i class="icon"></i>
  76. <span class="iconfont icon-umidd17" style="color: #00A0E9"></span>
  77. <span class="sex">支付宝</span>
  78. </label>
  79. </div>
  80. <div v-if="isyue" class="checkbox-wrapper">
  81. <label class="well-check">
  82. <input v-model="payType" type="radio" name="payment" value="yue">
  83. <i class="icon"></i>
  84. <span class="iconfont icon-qiandai" style="color: #FC992C"></span>
  85. <span class="sex">余额<b style="color: #aaa;font-size: 14px;">(可用余额:{{now_money}})</b></span>
  86. </label>
  87. </div>
  88. </div>
  89. <div class="payBnt" @click="goPay">确认支付</div>
  90. </div>
  91. <div class="mask" :hidden="payment" @touchmove.prevent></div>
  92. </div>`,
  93. data: function () {
  94. return {
  95. payType: phone_ios ? (this.isalipay ?'zhifubao' : 'yue') : (this.iswechat ? 'weixin': (this.isalipay ?'zhifubao' : 'yue')),
  96. phoneIos: phone_ios,
  97. }
  98. },
  99. mounted: function () {
  100. },
  101. methods: {
  102. close: function () {
  103. this.$emit("change", { action: 'payClose', value: true })//$emit():注册事件;
  104. },
  105. goPay: function () {
  106. var that = this;
  107. if(!that.isalipay && !that.iswechat && !that.isyue){
  108. that.$emit("change",{action:'payClose',value:true});
  109. return $h.showMsg('支付未开启');
  110. }
  111. $h.loadFFF();
  112. app.basePost($h.U({
  113. c: 'special',
  114. a: 'create_order',
  115. }), {
  116. special_id: that.special_id,
  117. pay_type_num: that.pay_type_num,
  118. payType: that.payType,
  119. pinkId: that.pinkId,
  120. link_pay_uid: that.link_pay_uid,
  121. sign: JSON.stringify(that.signs)
  122. }, function (res) {
  123. $h.loadClear();
  124. res.data.data.msg=res.data.msg;
  125. that.$emit('change',{action:'pay_order',value:res.data.data});
  126. },function () {
  127. that.$emit("change",{action:'payClose',value:true});
  128. $h.loadClear();
  129. });
  130. }
  131. }
  132. });
  133. })