pay.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="shandow-box" v-if="box">
  3. <view class="pay_box">
  4. <view class="box_title fx-r fx-bc">
  5. <text>选择支付方式</text>
  6. <button class='nt fx-r fx-bc fx-ac' @tap="closeBox()">
  7. <image src="/static/img/m_close.png"></image>
  8. </button>
  9. </view>
  10. <view class="pay-contain">
  11. <view class="pay-item fx-r fx-bc" v-if="sysData.wxpay == 1" @tap="payTypeSelect('wxpay')">
  12. <view class="pay-ico fx-r fx-bc">
  13. <image src="/static/img/weixin_pay.png"></image>
  14. </view>
  15. <view class="pay-title">微信支付</view>
  16. <button class="nt pay-select-btn fx-r fx-bc fx-ac">
  17. <image :src="payType == 'wxpay'? '/static/img/pay_select_btn.png' : '/static/img/pay_select.png'"></image>
  18. </button>
  19. </view>
  20. <view v-if="sysData.ailpay == 1" class="pay-item fx-r fx-bc" @tap="payTypeSelect('ailpay')">
  21. <view class="pay-ico fx-r fx-bc">
  22. <image src="/static/img/alipay_pay.png"></image>
  23. </view>
  24. <view class="pay-title">支付宝</view>
  25. <button class="nt pay-select-btn fx-r fx-bc fx-ac">
  26. <image :src="payType == 'ailpay'? '/static/img/pay_select_btn.png' : '/static/img/pay_select.png'"></image>
  27. </button>
  28. </view>
  29. <view v-if="sysData.bank == 1" class="pay-item fx-r fx-bc" @tap="payTypeSelect('unionpay')">
  30. <view class="pay-ico fx-r fx-bc">
  31. <image src="/static/img/unionpay.png"></image>
  32. </view>
  33. <view class="pay-title">银联支付</view>
  34. <button class="nt pay-select-btn fx-r fx-bc fx-ac">
  35. <image :src="payType == 'unionpay'? '/static/img/pay_select_btn.png' : '/static/img/pay_select.png'"></image>
  36. </button>
  37. </view>
  38. <button class="pay-btn12" @tap="tapCheckPay(0)">确认支付</button>
  39. </view>
  40. </view>
  41. <ui-pay ref="uipay"></ui-pay>
  42. </view>
  43. </template>
  44. <style>
  45. .shandow-box{position: fixed;z-index: 9999;bottom:0px;left:0px;top:0px;width:100vw;background: rgba(0,0,0,0.4);
  46. /* #ifdef H5 */
  47. top:60px;
  48. /* #endif */
  49. }
  50. .pay_box{background: #ffffff;position: absolute;bottom:0px;left:0px;right:0px;padding: 5px 0px;z-index: 2;}
  51. .box_title{text-align: left;width:calc(100% - 24px);height:38px;line-height: 38px;border-bottom:1px solid #eeeeee;padding: 0px 12px;}
  52. .box_title text{color:#333333;font-size: 14px;font-weight: 700;width:calc(100% - 38px)}
  53. .box_title button{height:38px;width:38px;}
  54. .box_title button image{width:20px;height:20px;}
  55. .pay-contain{width:calc(100% - 24px);padding: 0px 12px;}
  56. .pay-item{width:100%;border-bottom:1px solid #eeeeee;height:50px;}
  57. .pay-ico{width:30px;height:50px;}
  58. .pay-ico image{height:20px;width:20px}
  59. .pay-title{height:50px;width:calc(100% - 30px - 50px);text-align: left;line-height: 50px;font-size: 14px;color:#3f454b;}
  60. button.pay-select-btn{width:50px;height:50px;}
  61. button.pay-select-btn image{width:20px;height:20px;}
  62. .pay-btn12{ background: #ff383e; color: #fff;}
  63. .pop-bank{ position: fixed;z-index: 9999;width: 100%;height: 100vh;top: 0;left: 0;background: rgba(0,0,0,0.2);}
  64. .pop-bank .pop-body{width: 90%;background: #fff;border-radius: 8px;height: 60vh;}
  65. .pop-bank .pop-top{height: 40px;border-bottom: 1px solid #F1F1F1; position: relative;}
  66. .pop-bank .pop-top{ text-align: center; line-height: 40px;font-size: 18px;}
  67. .pop-bank .pop-left{position: absolute;font-size: 14px;color: #007AFF;left: 10px;top: 0px;}
  68. .pop-bank .pop-top .close image{width: 20px;height: 20px; position: absolute; right: 10px;top: 10px;}
  69. .pop-bank scroll-view{height: calc(60vh - 100px);}
  70. .pop-bank .pop-bank-list{ border-bottom: 1px solid #F1F1F1; padding: 20px;}
  71. .pop-bank .pop-bank-list:hover{background: #F1F1F1;}
  72. .pop-bank .pop-bank-list image{width: 20px;height: 20px;}
  73. .pop-bank .pop-bank-list text{ margin-left: 10px;}
  74. .pop-bank .pop-bank-add{ height: 60px;text-align: center;line-height: 60px;font-size: 18px;}
  75. .view-btn{height: 40px;border-top: 1px solid #F1F1F1;line-height: 40px;text-align: center;color: #007AFF;}
  76. </style>
  77. <script>
  78. import {mapState,mapMutations} from 'vuex';
  79. import uiPay from '@/components/ui-pay/index.vue';
  80. export default {
  81. computed: mapState(['user','sysData']),
  82. components: {uiPay},
  83. name: 'ui-check-pay',
  84. props: {
  85. },
  86. data() {
  87. return {
  88. box : false,
  89. payType:"",
  90. orderId : "",
  91. isPopBank:false,
  92. bindBank : [],
  93. bankId : 0,
  94. isJbing : false,
  95. buyType : "shop",
  96. fn : null
  97. }
  98. },
  99. mounted() {
  100. },
  101. methods: {
  102. ...mapMutations(['payPayment']),
  103. setbuyType(v){
  104. this.buyType = v;
  105. },
  106. show(orderId,fn){
  107. this.orderId = orderId;
  108. this.fn = fn;
  109. this.box = true;
  110. },
  111. hide:function(){
  112. this.box = false;
  113. if(this.$refs['uipay'] != null)
  114. this.$refs.uipay.hide();
  115. uni.$off('bankInit');
  116. },
  117. //
  118. closeBox: function() {
  119. this.box = false;
  120. },
  121. /**
  122. * 支付类型
  123. * @param {Object} type
  124. */
  125. payTypeSelect: function(type) {
  126. this.payType = type;
  127. },
  128. /**
  129. * 提交支付
  130. */
  131. tapCheckPay:function(type){
  132. if(this.payType == ''){
  133. return this.utils.Tip("请选择支付类型");
  134. }
  135. if(type == 0 && this.payType == 'bank') {
  136. this.tapPayBank();
  137. return;
  138. }
  139. uni.showLoading({ title: '提交支付数据中..' });
  140. var post = {
  141. page : this,
  142. payType : this.payType,
  143. orderId : this.orderId,
  144. buyType : this.buyType,
  145. bankId : this.bankId,
  146. afterFn : ()=>{
  147. uni.hideLoading();
  148. },
  149. };
  150. if(this.fn != null) {
  151. post.payOk = this.fn;
  152. }
  153. this.payPayment(post);
  154. },
  155. /**
  156. * 选择银行卡
  157. */
  158. tapPayBank:function(){
  159. this.utils.loadIng("获取数据中..");
  160. this
  161. .request
  162. .post("JoinpayBindList")
  163. .then(res=>{
  164. uni.hideLoading();
  165. if(res.code == 200) {
  166. this.isPopBank = true;
  167. this.bindBank = res.data;
  168. } else {
  169. this.utils.Tip(res.msg);
  170. }
  171. })
  172. .catch(err=>{
  173. uni.hideLoading();
  174. this.utils.Tip("网络错误,请稍后尝试");
  175. });
  176. },
  177. /**
  178. * 选择支付
  179. */
  180. tapBankItem:function(id){
  181. if(this.isJbing) {
  182. uni.showModal({
  183. title: "提示",
  184. content: "确认要解绑本银行卡吗?",
  185. success: res => {
  186. if (res.confirm) {
  187. this.utils.loadIng("操作中..");
  188. this
  189. .request
  190. .post("JoinpayUnbind",{id:id})
  191. .then(res=>{
  192. uni.hideLoading();
  193. if(res.code == 200) {
  194. this.tapPayBank();
  195. } else {
  196. this.utils.Tip(res.msg);
  197. }
  198. })
  199. .catch(err=>{
  200. uni.hideLoading();
  201. this.utils.Tip("网络错误,请稍后尝试");
  202. });
  203. }
  204. },
  205. });
  206. } else {
  207. uni.showModal({
  208. title: "提示",
  209. content: "确定要支付吗?",
  210. success: res => {
  211. if (res.confirm) {
  212. this.bankId = id;
  213. this.tapCheckPay(1);
  214. }
  215. },
  216. });
  217. }
  218. },
  219. /**
  220. * 解绑操作
  221. */
  222. tapJbing:function(){
  223. this.isJbing = !this.isJbing;
  224. },
  225. /**
  226. * 添加银行卡
  227. */
  228. tapBankAdd:function(){
  229. uni.navigateTo({url:"/pages/user/buy/bankAdd"});
  230. uni.$on('bankInit',()=>{
  231. this.tapPayBank();
  232. });
  233. }
  234. }
  235. };
  236. </script>