accountRecharge.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. <template>
  2. <view>
  3. <u-navbar title="账户充值" title-color="#101010">
  4. <view slot="right" class="slot" v-if="false" @click="gotoUrl('/pages/returnBalance/returnBalance')" >
  5. 退余额
  6. </view>
  7. </u-navbar>
  8. <view class="main">
  9. <view class="headline">
  10. <view class="title-left">
  11. <view class="icon">
  12. <image class="icon1" src="@/assets/img/PEokWS2@1x.png" mode=""></image>
  13. </view>
  14. <view class="text">
  15. 账户充值
  16. </view>
  17. </view>
  18. <view class="title-right" @click="gotoUrl('/pages/recharge/rechargeRecord')" >
  19. <view class="icon">
  20. <image class="icon2" src="@/assets/img/riLine-time-line.svg" mode=""></image>
  21. </view>
  22. <view class="text">
  23. 充值记录
  24. </view>
  25. </view>
  26. </view>
  27. <view class="content">
  28. <!-- 可用余额 -->
  29. <view class="balance">
  30. <view class="balance-left">
  31. 可用余额(元)
  32. </view>
  33. <view class="balance-right">
  34. {{personInfo.balance}}
  35. </view>
  36. </view>
  37. <!-- 提示 有余额-->
  38. <view class="hint" v-if="personInfo.balance>0">
  39. 有余额,可提前充值
  40. </view>
  41. <!-- 提示 无余额 已欠费 -->
  42. <view class="hint hint2" v-if="personInfo.balance==0" >
  43. 已扣完,请尽快缴费
  44. </view>
  45. <view class="hint hint2" v-if="personInfo.balance<0" >
  46. 有欠费,请尽快充值
  47. </view>
  48. <!-- 租户信息 -->
  49. <view class="infos" >
  50. <view class="item">
  51. <view class="item-title">
  52. 承租方
  53. </view>
  54. <view class="item-value">
  55. {{personInfo.fullName}}
  56. </view>
  57. </view>
  58. <view class="item" v-if="false">
  59. <view class="item-title">
  60. 户号
  61. </view>
  62. <view class="item-value">
  63. 00880088
  64. </view>
  65. </view>
  66. <view class="item">
  67. <view class="item-title">
  68. 联系人
  69. </view>
  70. <view class="item-value">
  71. {{personInfo.contacts}}
  72. </view>
  73. </view>
  74. <view class="item">
  75. <view class="item-title">
  76. 业主方
  77. </view>
  78. <view class="item-value">
  79. {{companyInfo.fullName}}
  80. </view>
  81. </view>
  82. </view>
  83. <!-- 缴费金额 -->
  84. <view class="payment-amount">
  85. <view class="title">
  86. 缴费金额
  87. </view>
  88. <view class="amount-options">
  89. <view v-for="(item,i) in amountList"
  90. class="options-item " :class="{
  91. chosen:selectNum==item
  92. }" @click="otherNum=item,selectNum=item" >
  93. {{item}}元
  94. </view>
  95. </view>
  96. </view>
  97. <!-- 输入金额 -->
  98. <view class="input-amount">
  99. <view class="symbol">
  100. </view>
  101. <input class="input" @input="ckInput" @focus="focus" type="text" v-model="otherNum" placeholder="点击输入缴费金额">
  102. </view>
  103. <!-- 支付方式 -->
  104. <view class="payment-way">
  105. <view class="title">
  106. 支付方式
  107. </view>
  108. <view class="way">
  109. <radio-group @change="radioChange">
  110. <view class="way-item" v-if="companyInfo.paymentMethod.indexOf('2')>-1" >
  111. <view class="way-name">
  112. <view class="icon">
  113. <image class="img" src="@/assets/img/riFill-wechat-pay-fill fTAsMwS.svg" mode="">
  114. </image>
  115. </view>
  116. <view class="text">
  117. 微信支付
  118. </view>
  119. </view>
  120. <view class="way-radio">
  121. <label class="radio">
  122. <radio value="0" name="selectType" :checked="submitType === '0'" /><text></text>
  123. </label>
  124. </view>
  125. </view>
  126. <view class="way-item" v-if="companyInfo.paymentMethod.indexOf('1')>-1" >
  127. <view class="way-name">
  128. <view class="icon">
  129. <image class="img" src="@/assets/img/antOutline-alipay-circle bQiHn7m.svg" mode="">
  130. </image>
  131. </view>
  132. <view class="text">
  133. 支付宝
  134. </view>
  135. </view>
  136. <view class="way-radio">
  137. <label class="radio">
  138. <radio value="1" name="selectType" :checked="submitType === '1'" /><text></text>
  139. </label>
  140. </view>
  141. </view>
  142. <view class="way-item" v-if="companyInfo.paymentMethod.indexOf('3')>-1" >
  143. <view class="way-name">
  144. <view class="icon">
  145. <image style="width: 40rpx;height: 40rpx; border-radius: 999px;" class="img"
  146. src="@/assets/img/modalIcon.svg" mode=""></image>
  147. </view>
  148. <view class="text">
  149. 对公转账
  150. </view>
  151. </view>
  152. <view class="way-radio" >
  153. <label class="radio">
  154. <radio value="2" name="selectType" /><text></text>
  155. </label>
  156. </view>
  157. </view>
  158. </radio-group>
  159. <!-- 对公转账弹窗 -->
  160. <u-modal v-model="show" :show-cancel-button="true"
  161. @confirm="copyUrl()"
  162. :show-title="false" confirm-text="复制"
  163. cancel-text="关闭">
  164. <view class="modal-content">
  165. <view class="title-icon">
  166. <image class="img" src="@/assets/img/modalIcon.svg" mode=""></image>
  167. </view>
  168. <view class="title">
  169. 对公转账信息
  170. </view>
  171. <view class="infos-group">
  172. <view class="item" >
  173. <view class="item-title">
  174. 收款户名
  175. </view>
  176. <view class="item-value">
  177. {{transferAccountsInfo.accountName}}
  178. </view>
  179. </view>
  180. <view class="item" >
  181. <view class="item-title">
  182. 开户银行
  183. </view>
  184. <view class="item-value">
  185. {{transferAccountsInfo.bankName}}
  186. </view>
  187. </view>
  188. <view class="item" >
  189. <view class="item-title">
  190. 收款账户
  191. </view>
  192. <view class="item-value">
  193. {{transferAccountsInfo.accountNo}}
  194. </view>
  195. </view>
  196. <view class="item" >
  197. <view class="item-title">
  198. 联系电话
  199. </view>
  200. <view class="item-value">
  201. {{transferAccountsInfo.telephone}}
  202. </view>
  203. </view>
  204. </view>
  205. </view>
  206. </u-modal>
  207. </view>
  208. </view>
  209. <!-- 按钮 -->
  210. <button class="btn" @click="submit">立即支付</button>
  211. </view>
  212. </view>
  213. <u-modal v-model="showModel" :show-cancel-button="true" @cancel="getUserInfo()" @confirm="confirm"
  214. confirm-text="支付成功?" title="扫码支付">
  215. <view style="
  216. text-align: center;
  217. ">
  218. <img id="qrcode2" :src="qrCodeImg">
  219. </view>
  220. <view style="
  221. text-align: center;
  222. ">请使用支付宝扫码</view>
  223. </u-modal>
  224. </view>
  225. </template>
  226. <script>
  227. import * as API from '@/apis/pagejs/wxPay.js'
  228. import * as API_index from '@/apis/pagejs/index.js'
  229. import * as API_weixin from '@/apis/weixin.js'
  230. import * as Pay from '@/apis/weixin.js'
  231. import QRCode from 'qrcodejs2'
  232. import {
  233. newDate,
  234. convertCanvasToImage,
  235. } from '@/apis/utils'
  236. import {
  237. wxPayJs
  238. } from '@/apis/utils/wxpay'
  239. export default {
  240. data() {
  241. return{
  242. amountList:[
  243. 100,200,500,1000,2000,5000
  244. ],
  245. show: false,
  246. showModel: false,
  247. qrCodeImg: "",
  248. submitType:"0",
  249. submitForm:{
  250. companyId: '',
  251. amount: '',
  252. },
  253. personInfo:{
  254. balance:0,
  255. },
  256. companyInfo:{
  257. paymentMethod:''
  258. },
  259. selectNum:'100',
  260. otherNum:'',
  261. transferAccountsInfo:{},
  262. }
  263. },
  264. onLoad() {
  265. //this.submitForm.companyId=this.carhelp.getPersonInfoPlus().companyInfo.id
  266. },
  267. onShow(){
  268. this.homePage()
  269. },
  270. methods: {
  271. copyUrl(){
  272. var transferAccountsInfo=this.transferAccountsInfo
  273. var textToCopy = `收款户名${transferAccountsInfo.accountName}\n开户银行${transferAccountsInfo.bankName}\n收款账户${transferAccountsInfo.accountNo}\n联系电话${transferAccountsInfo.telephone}`;
  274. uni.setClipboardData({
  275. data: textToCopy,
  276. success: function () {
  277. uni.showToast({
  278. title: "复制成功!",
  279. icon: "none"
  280. })
  281. }
  282. });
  283. },
  284. homePage(){
  285. // uni.showLoading({
  286. // title: "加载中",
  287. // mask: true,
  288. // })
  289. API_index.homePage({
  290. }).then((response) => {
  291. //uni.hideLoading();
  292. this.submitForm.companyId=response.data.companyInfo.id;
  293. //this.carhelp.getPersonInfoPlus().companyInfo.id
  294. this.personInfo=response.data.tenantInfo;
  295. this.companyInfo=response.data.companyInfo;
  296. if(this.companyInfo.transferAccountsInfo){
  297. this.transferAccountsInfo=JSON.parse(this.companyInfo.transferAccountsInfo)
  298. }
  299. var sz=this.companyInfo.paymentMethod.split(',');
  300. if(sz.length==1){
  301. this.submitType=sz[0]
  302. }
  303. }).catch(error => {
  304. //uni.hideLoading();
  305. })
  306. },
  307. radioChange: function(evt) {
  308. this.submitType=evt.detail.value
  309. },
  310. ckInput(e){
  311. var text=e.detail.value
  312. if(text.indexOf('.')>0){
  313. var k =text.split(".")[1]
  314. if(k.length>=3){
  315. this.$nextTick(()=>{
  316. text=parseFloat(text).toFixed(2);
  317. this.otherNum= text
  318. })
  319. }
  320. }
  321. var t =Number(text);
  322. if(t<1){
  323. this.$nextTick(()=>{
  324. this.otherNum='';
  325. })
  326. }
  327. if(t>5000){
  328. this.$nextTick(()=>{
  329. this.otherNum=5000;
  330. })
  331. }
  332. },
  333. focus(){
  334. console.log(0)
  335. uni.pageScrollTo({
  336. scrollTop:999999,
  337. duration:0
  338. })
  339. },
  340. open() {
  341. this.show = true;
  342. },
  343. submit() {
  344. if (this.submitType == 2) {
  345. this.show = true;
  346. }else{
  347. if(!this.otherNum){
  348. this.otherNum=this.selectNum;
  349. }
  350. this.submitForm.amount=this.otherNum
  351. if(!this.otherNum){
  352. uni.showToast({
  353. title: "请输入缴费金额"
  354. })
  355. return
  356. }
  357. if (this.submitType == 0) {
  358. this.wxpy()
  359. }
  360. if (this.submitType == 1) {
  361. this.alpy()
  362. }
  363. }
  364. },
  365. alpy() {
  366. uni.showLoading({
  367. title: "加载中",
  368. mask: true,
  369. })
  370. var listcanvas = document.getElementsByTagName('canvas')
  371. if (listcanvas.length > 0) {
  372. document.getElementById("qrcode").removeChild(document.getElementsByTagName('canvas')[0]);
  373. }
  374. Pay.alpay(this.submitForm).then((response) => {
  375. let qrcode = new QRCode('qrcode', {
  376. width: 200,
  377. height: 200,
  378. text: response.data.qr_code,
  379. correctLevel: QRCode.CorrectLevel.M,
  380. })
  381. this.outOrderNo = response.data.outOrderNo;
  382. var canvas = document.getElementsByTagName('canvas')[0];
  383. this.qrCodeImg = convertCanvasToImage(canvas);
  384. uni.hideLoading()
  385. this.showModel = true
  386. }).catch(error => {
  387. uni.showToast({
  388. title: error
  389. })
  390. })
  391. },
  392. wxpy() {
  393. Pay.wxpay(this.submitForm).then((response) => {
  394. if (!response.result) {
  395. uni.showToast({
  396. title: response.message
  397. })
  398. return
  399. }
  400. var data = response.data
  401. uni.hideLoading()
  402. //("Pay+"+new Date().getTime())
  403. wxPayJs(data);
  404. }).catch(error => {
  405. uni.showToast({
  406. title: error
  407. })
  408. })
  409. },
  410. }
  411. }
  412. </script>
  413. <style lang="scss" scoped>
  414. page {
  415. padding-bottom: 50px;
  416. }
  417. .slot {
  418. margin-right: 24rpx;
  419. color: rgba(16, 16, 16, 1);
  420. }
  421. .main {
  422. margin: 24rpx;
  423. overflow: hidden;
  424. .headline {
  425. background: linear-gradient(90deg, rgba(120, 175, 247, 1) 0%, rgba(39, 116, 226, 1) 100%);
  426. color: #fff;
  427. display: flex;
  428. justify-content: space-between;
  429. align-items: center;
  430. padding: 24rpx;
  431. .title-left {
  432. display: flex;
  433. align-items: center;
  434. font-size: 36rpx;
  435. .icon1 {
  436. width: 56rpx;
  437. height: 56rpx;
  438. margin-right: 8rpx;
  439. vertical-align: middle;
  440. }
  441. }
  442. .title-right {
  443. display: flex;
  444. font-size: 32rpx;
  445. line-height: 32rpx;
  446. .icon2 {
  447. width: 32rpx;
  448. height: 32rpx;
  449. margin-right: 8rpx;
  450. }
  451. }
  452. }
  453. .content {
  454. border-radius: 8px 8px 0 0;
  455. margin-top: -8rpx;
  456. z-index: 999;
  457. background-color: #fff;
  458. padding: 40rpx 32rpx;
  459. // 可用余额
  460. .balance {
  461. display: flex;
  462. justify-content: space-between;
  463. .balance-left {
  464. color: rgb(48, 48, 48);
  465. font-size: 36rpx;
  466. line-height: 40px;
  467. }
  468. .balance-right {
  469. color: rgb(48, 48, 48);
  470. font-size: 80rpx;
  471. }
  472. }
  473. // 提示
  474. .hint {
  475. font-size: 24rpx;
  476. color: #1677FF;
  477. margin-top: 16rpx;
  478. text-align: right;
  479. padding-bottom: 32rpx;
  480. border-bottom: 1px solid rgba(244, 244, 244, 1);
  481. }
  482. .hint2 {
  483. color: #E60012;
  484. }
  485. // 租户信息
  486. .infos {
  487. border-bottom: 1px solid rgba(244, 244, 244, 1);
  488. margin-top: 32rpx;
  489. padding-bottom: 32rpx;
  490. .item {
  491. display: flex;
  492. justify-content: space-between;
  493. margin-bottom: 24rpx;
  494. .item-title {
  495. color: rgb(119, 119, 119);
  496. white-space: pre;
  497. }
  498. .item-value {
  499. color: rgb(48, 48, 48);
  500. }
  501. }
  502. }
  503. // 缴费金额
  504. .payment-amount {
  505. margin-top: 32rpx;
  506. .title {
  507. color: rgb(48, 48, 48);
  508. font-size: 36rpx;
  509. }
  510. .amount-options {
  511. margin-top: 32rpx;
  512. display: flex;
  513. flex-wrap: wrap;
  514. justify-content: space-between;
  515. .options-item {
  516. width: 200rpx;
  517. height: 80rpx;
  518. line-height: 80rpx;
  519. border-radius: 4px;
  520. text-align: center;
  521. background-color: rgba(242, 242, 242, 1);
  522. color: rgba(16, 16, 16, 1);
  523. font-size: 32rpx;
  524. margin-bottom: 20rpx;
  525. }
  526. .chosen {
  527. background-color: rgba(22, 119, 255, 1);
  528. color: rgba(255, 255, 255, 1);
  529. }
  530. }
  531. }
  532. // 输入金额
  533. .input-amount {
  534. margin-top: 24rpx;
  535. display: flex;
  536. font-size: 48rpx;
  537. height: 100rpx;
  538. line-height: 100rpx;
  539. .symbol {
  540. margin-right: 32rpx;
  541. }
  542. .input {
  543. height: 100rpx;
  544. font-size: 48rpx;
  545. border-bottom: 1px solid;
  546. //color: rgba(204, 204, 204, 1);
  547. }
  548. /deep/.uni-input-placeholder {
  549. color: rgba(204, 204, 204, 1);
  550. }
  551. }
  552. // 支付方式
  553. .payment-way {
  554. margin-top: 24rpx;
  555. .title {
  556. color: rgb(48, 48, 48);
  557. font-size: 36rpx;
  558. }
  559. .way {
  560. margin-top: 24rpx;
  561. .way-item {
  562. display: flex;
  563. justify-content: space-between;
  564. align-items: center;
  565. margin-bottom: 24rpx;
  566. .way-name {
  567. display: flex;
  568. align-items: center;
  569. color: rgb(51, 51, 51);
  570. .img {
  571. width: 48rpx;
  572. height: 48rpx;
  573. vertical-align: middle;
  574. margin-right: 16rpx;
  575. }
  576. }
  577. /deep/.uni-radio-input {
  578. width: 40rpx;
  579. height: 40rpx;
  580. }
  581. }
  582. }
  583. }
  584. // 按钮
  585. .btn {
  586. height: 96rpx;
  587. border-radius: 50px;
  588. background-color: rgba(51, 133, 255, 1);
  589. color: rgba(255, 255, 255, 1);
  590. font-size: 36rpx;
  591. margin-top: 48rpx;
  592. }
  593. }
  594. }
  595. // 对公转账弹窗
  596. .modal-content {
  597. padding: 40rpx 0;
  598. .title-icon {
  599. text-align: center;
  600. }
  601. .img {
  602. width: 96rpx;
  603. height: 96rpx;
  604. }
  605. .title {
  606. text-align: center;
  607. color: rgba(16, 16, 16, 1);
  608. font-size: 36rpx;
  609. font-weight: 600;
  610. margin-top: 8rpx;
  611. }
  612. .infos-group {
  613. margin: 40rpx 32rpx 0;
  614. .item {
  615. display: flex;
  616. justify-content: space-between;
  617. margin-bottom: 16rpx;
  618. .item-title {
  619. color: rgba(119, 119, 119, 1);
  620. font-size: 32rpx;
  621. white-space: pre;
  622. }
  623. .item-value {
  624. color: rgba(51, 51, 51, 1);
  625. font-size: 32rpx;
  626. margin-left: 16rpx;
  627. }
  628. }
  629. }
  630. }
  631. </style>