AcontMoney.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. <template>
  2. <view class="content">
  3. <view class="acont_part1">
  4. <view class="part1_bg">
  5. <image src="../../../../static/rider/image-bg.png"></image>
  6. </view>
  7. <view class="part1_box">
  8. <view class="text-right margin-top-sm margin-right-sm" @click="goDet">查看明细</view>
  9. <view class="balance">
  10. <view class="balance_name">保证金余额(元)</view>
  11. <view class="balance_price">{{mayMoney?mayMoney:0}}</view>
  12. </view>
  13. <view class="part1_btn">
  14. <view class="btn_left" @click="tuiBtn()">退保证金</view>
  15. <view class="btn_right" @click="openPay()">缴纳保证金</view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="acont_part2">
  20. <view class="acount_type">保证金规则</view>
  21. <view class="acount_box" v-for="(item,index) in list" :key="item.id">
  22. <view class="name">{{item.name}}</view>
  23. <view class="tit">{{item.tit}}</view>
  24. </view>
  25. </view>
  26. <!-- 支付方式 -->
  27. <u-popup v-model="shows" mode="center" width="640rpx" height="640rpx" border-radius="14" :closeable="true"
  28. close-icon="close-circle" close-icon-size="50" close-icon-color="#CCCCCC" @close="closePopup()">
  29. <view style="width: 100%;height: 300upx;background: #FFFFFF;">
  30. <view class="receipt_code">
  31. <view class="code_title">请输入支付金额</view>
  32. <u-input v-model="earnestMoney" type="text" placeholder="请输入支付金额" :border="true" />
  33. <view class="margin-tb padding-lr radius bg-white" style="height: 220upx;">
  34. <view class="flex align-center justify-between padding-tb-sm" v-for="(item,index) in payList"
  35. :key='index'>
  36. <image :src="item.image" style="width: 80upx;height: 80upx;border-radius: 50upx;"></image>
  37. <view class="flex-sub text-xl text-bold margin-left">{{item.name}}</view>
  38. <radio-group name="openWay" style="margin-left: 20upx;" @change='selectWay(item)'>
  39. <label class="tui-radio">
  40. <radio class="red" :checked="openWay === item.id ? true : false" />
  41. </label>
  42. </radio-group>
  43. </view>
  44. </view>
  45. <view class="sure" @click="jiaoBtn">确定</view>
  46. </view>
  47. </view>
  48. </u-popup>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. shows: false,
  56. baozhengjin: 0,
  57. disabled: true,
  58. moneys: '',
  59. list: [{
  60. id: 1,
  61. name: '保证金退款',
  62. tit: '48小时内无订单记录即可申请退保证金,保证金统一退款至账户余额,实时到账。'
  63. }, {
  64. id: 2,
  65. name: '保证金缴纳',
  66. tit: '所有跑腿专人直送订单需缴纳保证金,没有缴纳者将无法接订单,建议您及时缴纳。'
  67. }],
  68. mayMoney: 0,
  69. openWay: 1,
  70. payList: [],
  71. earnestMoney: ''
  72. }
  73. },
  74. onLoad() {
  75. //获取保证金
  76. this.$Request.getT('/app/common/type/273').then(res => {
  77. if (res.code === 0) {
  78. this.baozhengjin = res.data.value;
  79. }
  80. });
  81. // #ifdef MP-WEIXIN
  82. this.payList = [{
  83. id: 1,
  84. image: '../../../../static/my/weixin.png',
  85. name: '微信'
  86. }]
  87. this.openWay = 1
  88. // #endif
  89. // #ifdef H5
  90. this.payList = [{
  91. id: 2,
  92. image: '../../../../static/my/zhifubao.png',
  93. name: '支付宝'
  94. }]
  95. this.openWay = 2
  96. // #endif
  97. // #ifdef APP-PLUS
  98. this.payList = [{
  99. id: 1,
  100. image: '../../../../static/my/weixin.png',
  101. name: '微信'
  102. },
  103. {
  104. id: 2,
  105. image: '../../../../static/my/zhifubao.png',
  106. name: '支付宝'
  107. }
  108. ]
  109. // #endif
  110. },
  111. onShow() {
  112. this.taskData()
  113. },
  114. methods: {
  115. openPay() {
  116. this.$Request.getT("/app/wxPayErrRider/selectCertificationFlag").then(res => {
  117. if (res.code == 0) {
  118. this.shows = true
  119. } else {
  120. uni.showToast({
  121. title: res.msg,
  122. icon: 'none'
  123. })
  124. }
  125. });
  126. },
  127. // 跳转保证金明细
  128. goDet() {
  129. uni.navigateTo({
  130. url: '/pages/riderMy/myAccount/AcontMoney/Acontlist'
  131. })
  132. },
  133. selectWay: function(item) {
  134. this.openWay = item.id;
  135. },
  136. zhifu() {
  137. this.shows = true
  138. },
  139. // 关闭底部弹出层
  140. closePopup() {
  141. this.shows = false
  142. },
  143. // 获取任务数据
  144. taskData() {
  145. let that = this;
  146. let token = this.$queue.getData('token');
  147. let userId = this.$queue.getData('userId');
  148. if (token) {
  149. //this.$queue.showLoading("加载中...");
  150. //可以提现金额查询预估收入查询
  151. this.$Request.getT("/app/userinfo/findUserInfoById").then(res => {
  152. uni.hideLoading();
  153. if (res.code === 0 && res.data) {
  154. that.mayMoney = res.data.cashDeposit;
  155. if (!res.data.cashDeposit) {
  156. // this.earnestMoney=this.baozhengjin;
  157. // this.disabled=true;
  158. } else {
  159. // this.disabled=false;
  160. }
  161. } else if (res.code === -102) {
  162. this.$queue.showToast(res.msg);
  163. this.$queue.logout();
  164. } else {
  165. that.mayMoney = '0';
  166. }
  167. });
  168. }
  169. },
  170. // 缴纳
  171. jiaoBtn() {
  172. let that = this;
  173. if (!that.earnestMoney) {
  174. that.$queue.showToast('请输入支付金额');
  175. return;
  176. }
  177. uni.showLoading({
  178. title: '支付中'
  179. });
  180. // 微信支付
  181. if (that.openWay == 1) {
  182. // #ifdef APP-PLUS
  183. uni.hideLoading();
  184. // 微信APP支付 根据订单id获取支付信息
  185. that.$Request.postT('/app/wxPayErrRider/wxPayCashDeposit?money=' + that.earnestMoney + '&type=1').then(
  186. ret => {
  187. // console.log(JSON.stringify(ret), '支付信息')
  188. if (ret.code == 0) {
  189. console.log(JSON.stringify(ret), '支付信息')
  190. that.isCheckPay(ret.code, 'wxpay', JSON.stringify(ret.data));
  191. } else {
  192. that.shows = false
  193. that.earnestMoney = ''
  194. that.$queue.showToast(res.msg);
  195. }
  196. });
  197. // #endif
  198. // #ifdef H5
  199. let ua = navigator.userAgent.toLowerCase();
  200. console.log(ua.indexOf('micromessenger'))
  201. if (ua.indexOf('micromessenger') !== -1) {
  202. let openId = that.$queue.getData('openid') ? that.$queue.getData('openid') : '';
  203. that.$Request.postT('/app/wxPayErrRider/wxPayCashDeposit?money=' + that.earnestMoney + '&type=2')
  204. .then(
  205. res => {
  206. if (res.code == 0) {
  207. that.callPay(res);
  208. } else {
  209. that.shows = false
  210. that.earnestMoney = ''
  211. that.$queue.showToast(res.msg);
  212. }
  213. });
  214. }
  215. // #endif
  216. // #ifdef MP-WEIXIN
  217. that.$Request.postT('/app/wxPayErrRider/wxPayCashDeposit?money=' + that.earnestMoney + '&type=3').then(
  218. res => {
  219. console.log('res', res)
  220. if (res.code == 0) {
  221. uni.requestPayment({
  222. provider: 'wxpay',
  223. timeStamp: res.data.timestamp,
  224. nonceStr: res.data.noncestr,
  225. package: res.data.package,
  226. signType: res.data.signType,
  227. paySign: res.data.sign,
  228. success: function(res) {
  229. that.shows = false
  230. that.earnestMoney = ''
  231. uni.hideLoading();
  232. that.taskData()
  233. that.$queue.showToast('支付成功');
  234. setTimeout(function() {
  235. uni.hideLoading();
  236. }, 1000);
  237. },
  238. fail: function(err) {
  239. that.shows = false
  240. that.earnestMoney = ''
  241. console.log('fail:' + JSON.stringify(err));
  242. uni.hideLoading();
  243. that.$queue.showToast('支付失败');
  244. }
  245. });
  246. } else {
  247. that.shows = false
  248. that.earnestMoney = ''
  249. that.$queue.showToast(res.msg);
  250. }
  251. });
  252. // #endif
  253. } else if (that.openWay == 2) { //支付宝支付
  254. uni.hideLoading();
  255. // #ifdef H5
  256. let userId = this.$queue.getData('userId');
  257. that.$Request.postT('/app/wxPayErrRider/wxPayCashDeposit?money=' + that.earnestMoney + '&type=5')
  258. .then(res => {
  259. if (res.code == 0) {
  260. const div = document.createElement('div')
  261. div.innerHTML = res.data //此处form就是后台返回接收到的数据
  262. document.body.appendChild(div)
  263. document.forms[0].submit()
  264. that.earnestMoney = ''
  265. that.shows = false
  266. } else {
  267. uni.hideLoading();
  268. that.$queue.showToast(res.msg);
  269. }
  270. });
  271. // #endif
  272. // #ifdef APP-PLUS
  273. that.$Request.postT('/app/wxPayErrRider/wxPayCashDeposit?money=' + that.earnestMoney + '&type=4').then(
  274. ret => {
  275. uni.hideLoading();
  276. // console.log(JSON.stringify(ret), '支付信息')
  277. if (ret.code == 0) {
  278. that.setPayment('alipay', ret.data);
  279. that.shows = false
  280. // that.isCheckPay(ret.code, 'alipay', ret.data);
  281. } else {
  282. that.shows = false
  283. that.earnestMoney = ''
  284. that.$queue.showToast(res.msg);
  285. }
  286. });
  287. // #endif
  288. }
  289. },
  290. callPay: function(response) {
  291. if (typeof WeixinJSBridge === "undefined") {
  292. if (document.addEventListener) {
  293. document.addEventListener('WeixinJSBridgeReady', that.onBridgeReady(response), false);
  294. } else if (document.attachEvent) {
  295. document.attachEvent('WeixinJSBridgeReady', that.onBridgeReady(response));
  296. document.attachEvent('onWeixinJSBridgeReady', that.onBridgeReady(response));
  297. }
  298. } else {
  299. that.onBridgeReady(response);
  300. }
  301. },
  302. onBridgeReady: function(response) {
  303. let that = this;
  304. console.log(!response.package, '2222222')
  305. // if (!response.package) {
  306. // return;
  307. // }
  308. that.earnestMoney = ''
  309. that.shows = false
  310. console.log(response, '1111111111')
  311. WeixinJSBridge.invoke(
  312. 'getBrandWCPayRequest', {
  313. "appId": response.data.appid, //公众号名称,由商户传入
  314. "timeStamp": response.data.timestamp, //时间戳,自1970年以来的秒数
  315. "nonceStr": response.data.noncestr, //随机串
  316. "package": response.data.package,
  317. "signType": response.data.signType, //微信签名方式:
  318. "paySign": response.data.sign //微信签名
  319. },
  320. function(res) {
  321. console.log(res, '/*-/*-/*-')
  322. if (res.err_msg === "get_brand_wcpay_request:ok") {
  323. // 使用以上方式判断前端返回,微信团队郑重提示:
  324. //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
  325. that.taskData()
  326. uni.showLoading({
  327. title: '支付成功'
  328. });
  329. setTimeout(function() {
  330. uni.hideLoading();
  331. }, 1000);
  332. } else {
  333. uni.hideLoading();
  334. }
  335. WeixinJSBridge.log(response.err_msg);
  336. }
  337. );
  338. },
  339. isCheckPay(status, name, order) {
  340. console.log(status, name, order, '111111')
  341. this.earnestMoney = ''
  342. this.shows = false
  343. if (status == 0) {
  344. this.setPayment(name, order);
  345. } else {
  346. uni.hideLoading();
  347. uni.showToast({
  348. title: '支付信息有误',
  349. icon: 'none'
  350. });
  351. }
  352. },
  353. setPayment(name, order) {
  354. let that = this
  355. console.log(name, '*-*-*', order)
  356. uni.requestPayment({
  357. provider: name,
  358. orderInfo: order, //微信、支付宝订单数据
  359. success: function(res) {
  360. console.log(res)
  361. that.taskData()
  362. uni.hideLoading();
  363. that.earnestMoney = ''
  364. that.shows = false
  365. uni.showLoading({
  366. title: '支付成功'
  367. });
  368. },
  369. fail: function(err) {
  370. console.log(err)
  371. uni.hideLoading();
  372. },
  373. complete() {
  374. uni.hideLoading();
  375. }
  376. });
  377. },
  378. // 退保证金
  379. tuiBtn() {
  380. let that = this
  381. if (that.mayMoney == 0) {
  382. uni.showToast({
  383. icon: 'none',
  384. title: '暂无保证金'
  385. })
  386. return
  387. }
  388. uni.showModal({
  389. title: '提示',
  390. content: '确认退还保证金吗?如果存在未完成订单和未处理完成的投诉无法退还,需要先处理完毕后再申请',
  391. success: function(res) {
  392. if (res.confirm) {
  393. that.$Request.getT('/app/cash/cashDepositMoney').then(res => {
  394. console.log(res)
  395. if (res.code == 0) {
  396. uni.showToast({
  397. title: '申请成功'
  398. })
  399. } else {
  400. uni.showToast({
  401. title: res.msg,
  402. icon: 'none'
  403. })
  404. }
  405. setTimeout(function() {
  406. that.taskData()
  407. }, 1000)
  408. });
  409. }
  410. },
  411. })
  412. }
  413. }
  414. }
  415. </script>
  416. <style>
  417. /* 支付金额弹框 */
  418. .receipt_code {
  419. width: 90%;
  420. margin: 0 auto;
  421. }
  422. .code_title {
  423. width: 100%;
  424. line-height: 100rpx;
  425. font-size: 31rpx;
  426. font-weight: bold;
  427. text-align: center;
  428. letter-spacing: 2rpx;
  429. margin-top: 21rpx;
  430. margin-bottom: 25rpx;
  431. }
  432. .u-input--border {
  433. border: 1px solid #F2F2F2 !important;
  434. background: #F2F2F2 !important;
  435. color: #999999 !important;
  436. font-weight: 500 !important;
  437. letter-spacing: 2rpx !important;
  438. }
  439. .u-input__input {
  440. font-size: 30rpx;
  441. font-weight: bold;
  442. flex: 1;
  443. color: #999999 !important;
  444. min-height: 85rpx !important;
  445. margin-top: 7rpx;
  446. }
  447. .sure {
  448. width: 100%;
  449. height: 80rpx;
  450. background: #FF7F00;
  451. color: white;
  452. border-radius: 46rpx;
  453. text-align: center;
  454. line-height: 80rpx;
  455. margin-top: 30rpx;
  456. letter-spacing: 2rpx;
  457. }
  458. .content {
  459. width: 100%;
  460. position: relative;
  461. }
  462. .acont_part1 {
  463. width: 100%;
  464. }
  465. .part1_bg image {
  466. width: 100%;
  467. height: 730rpx;
  468. }
  469. .part1_box {
  470. width: 90%;
  471. height: 400rpx;
  472. background: #ffffff;
  473. position: absolute;
  474. top: 70rpx;
  475. left: 37rpx;
  476. border-radius: 25rpx;
  477. }
  478. .balance {
  479. width: 90%;
  480. margin: 0 auto;
  481. text-align: center;
  482. /* margin-top: 50rpx; */
  483. line-height: 55rpx;
  484. }
  485. .balance_name {
  486. font-size: 26rpx;
  487. letter-spacing: 2rpx;
  488. }
  489. .balance_price {
  490. margin-top: 10rpx;
  491. font-weight: bold;
  492. font-size: 60rpx;
  493. }
  494. .part1_btn {
  495. width: 90%;
  496. margin: 0 auto;
  497. margin-top: 80rpx;
  498. display: flex;
  499. }
  500. .btn_left {
  501. flex: 1;
  502. border: 1rpx solid #CCCCCC;
  503. text-align: center;
  504. line-height: 80rpx;
  505. color: black;
  506. font-size: 24rpx;
  507. border-radius: 12rpx;
  508. margin-right: 10rpx;
  509. }
  510. .btn_right {
  511. flex: 1;
  512. border: 1rpx solid #CCCCCC;
  513. text-align: center;
  514. line-height: 80rpx;
  515. background: #FF7F00;
  516. color: white;
  517. font-size: 24rpx;
  518. border-radius: 12rpx;
  519. margin-left: 10rpx;
  520. }
  521. .acont_part2 {
  522. width: 90%;
  523. position: absolute;
  524. bottom: -100rpx;
  525. left: 37rpx;
  526. }
  527. .acount_type {
  528. font-size: 32rpx;
  529. font-weight: bold;
  530. letter-spacing: 2rpx;
  531. line-height: 75rpx;
  532. }
  533. .name {
  534. font-size: 26rpx;
  535. font-weight: bold;
  536. letter-spacing: 2rpx;
  537. line-height: 70rpx;
  538. }
  539. .tit {
  540. color: #666666;
  541. font-size: 25rpx;
  542. }
  543. </style>