baozhengjin.vue 14 KB

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