accountRecharge.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  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" :key="i"
  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="img2" 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 class="img3"
  146. src="@/assets/img/riFill-exchange-cny-fill@1x.png" 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">{{submitType==2?'查看对公转账信息':'立即支付'}}</button>
  211. </view>
  212. </view>
  213. <img id="qrcode" style="display: none;">
  214. <u-modal v-model="showModel" :show-cancel-button="true" @confirm="homePage"
  215. confirm-text="刷新余额" title="扫码支付">
  216. <view style="
  217. text-align: center;
  218. ">
  219. <img id="qrcode2" :src="qrCodeImg">
  220. </view>
  221. <view style="
  222. text-align: center;
  223. ">请使用支付宝扫码</view>
  224. </u-modal>
  225. </view>
  226. </template>
  227. <script>
  228. import * as API from '@/apis/pagejs/wxPay.js'
  229. import * as API_index from '@/apis/pagejs/index.js'
  230. import * as API_weixin from '@/apis/weixin.js'
  231. import * as Pay from '@/apis/weixin.js'
  232. import QRCode from 'qrcodejs2'
  233. import {
  234. newDate,
  235. convertCanvasToImage,
  236. } from '@/apis/utils'
  237. import {
  238. wxPayJs
  239. } from '@/apis/utils/wxpay'
  240. export default {
  241. data() {
  242. return{
  243. amountList:[
  244. 100,200,500,1000,2000,5000
  245. ],
  246. show: false,
  247. showModel: false,
  248. qrCodeImg: "",
  249. submitType:"0",
  250. submitForm:{
  251. companyId: '',
  252. amount: '',
  253. },
  254. personInfo:{
  255. balance:0,
  256. },
  257. companyInfo:{
  258. paymentMethod:''
  259. },
  260. selectNum:'100',
  261. otherNum:'',
  262. transferAccountsInfo:{},
  263. }
  264. },
  265. onLoad() {
  266. //this.submitForm.companyId=this.carhelp.getPersonInfoPlus().companyInfo.id
  267. },
  268. onShow(){
  269. this.homePage()
  270. },
  271. methods: {
  272. copyUrl(){
  273. var transferAccountsInfo=this.transferAccountsInfo
  274. var textToCopy = `收款户名${transferAccountsInfo.accountName}\n开户银行${transferAccountsInfo.bankName}\n收款账户${transferAccountsInfo.accountNo}\n联系电话${transferAccountsInfo.telephone}`;
  275. uni.setClipboardData({
  276. data: textToCopy,
  277. success: function () {
  278. uni.showToast({
  279. title: "复制成功!",
  280. icon: "none"
  281. })
  282. }
  283. });
  284. },
  285. homePage(){
  286. // uni.showLoading({
  287. // title: "加载中",
  288. // mask: true,
  289. // })
  290. API_index.homePage({
  291. }).then((response) => {
  292. //uni.hideLoading();
  293. this.submitForm.companyId=response.data.companyInfo.id;
  294. //this.carhelp.getPersonInfoPlus().companyInfo.id
  295. this.personInfo=response.data.tenantInfo;
  296. this.companyInfo=response.data.companyInfo;
  297. if(this.companyInfo.transferAccountsInfo){
  298. this.transferAccountsInfo=JSON.parse(this.companyInfo.transferAccountsInfo)
  299. }
  300. var sz=this.companyInfo.paymentMethod.split(',');
  301. if(sz.length==1){
  302. this.submitType=sz[0]
  303. }
  304. }).catch(error => {
  305. //uni.hideLoading();
  306. uni.showToast({
  307. title: error,
  308. icon: "none"
  309. })
  310. })
  311. },
  312. radioChange: function(evt) {
  313. this.submitType=evt.detail.value
  314. },
  315. ckInput(e){
  316. var text=e.detail.value
  317. if(text.indexOf('.')>0){
  318. var k =text.split(".")[1]
  319. if(k.length>=3){
  320. this.$nextTick(()=>{
  321. text=parseFloat(text).toFixed(2);
  322. this.otherNum= text
  323. })
  324. }
  325. }
  326. var t =Number(text);
  327. if(t<1){
  328. this.$nextTick(()=>{
  329. this.otherNum='';
  330. })
  331. }
  332. if(t>5000){
  333. this.$nextTick(()=>{
  334. this.otherNum=5000;
  335. })
  336. }
  337. },
  338. focus(){
  339. console.log(0)
  340. uni.pageScrollTo({
  341. scrollTop:999999,
  342. duration:0
  343. })
  344. },
  345. open() {
  346. this.show = true;
  347. },
  348. submit() {
  349. if (this.submitType == 2) {
  350. this.show = true;
  351. }else{
  352. if(!this.otherNum){
  353. this.otherNum=this.selectNum;
  354. }
  355. this.submitForm.amount=this.otherNum
  356. if(!this.otherNum){
  357. uni.showToast({
  358. title: "请输入缴费金额"
  359. })
  360. return
  361. }
  362. if (this.submitType == 0) {
  363. this.wxpy()
  364. }
  365. if (this.submitType == 1) {
  366. this.alpy()
  367. }
  368. }
  369. },
  370. alpy() {
  371. uni.showLoading({
  372. title: "加载中",
  373. mask: true,
  374. })
  375. var listcanvas = document.getElementsByTagName('canvas')
  376. if (listcanvas.length > 0) {
  377. document.getElementById("qrcode").removeChild(document.getElementsByTagName('canvas')[0]);
  378. }
  379. Pay.alpay(this.submitForm).then((response) => {
  380. let qrcode = new QRCode('qrcode', {
  381. width: 200,
  382. height: 200,
  383. text: response.data.qr_code,
  384. correctLevel: QRCode.CorrectLevel.M,
  385. })
  386. this.outOrderNo = response.data.outOrderNo;
  387. var canvas = document.getElementsByTagName('canvas')[0];
  388. this.qrCodeImg = convertCanvasToImage(canvas);
  389. uni.hideLoading()
  390. this.showModel = true
  391. }).catch(error => {
  392. uni.showToast({
  393. title: error
  394. })
  395. })
  396. },
  397. wxpy() {
  398. Pay.wxpay(this.submitForm).then((response) => {
  399. if (!response.result) {
  400. uni.showToast({
  401. title: response.message
  402. })
  403. return
  404. }
  405. var data = response.data
  406. uni.hideLoading()
  407. //("Pay+"+new Date().getTime())
  408. wxPayJs(data);
  409. }).catch(error => {
  410. uni.showToast({
  411. title: error
  412. })
  413. })
  414. },
  415. }
  416. }
  417. </script>
  418. <style lang="scss" scoped>
  419. page {
  420. padding-bottom: 50px;
  421. }
  422. .slot {
  423. margin-right: 24rpx;
  424. color: rgba(16, 16, 16, 1);
  425. }
  426. .main {
  427. margin: 24rpx;
  428. overflow: hidden;
  429. .headline {
  430. background: linear-gradient(90deg, rgba(120, 175, 247, 1) 0%, rgba(39, 116, 226, 1) 100%);
  431. color: #fff;
  432. display: flex;
  433. justify-content: space-between;
  434. align-items: center;
  435. padding: 24rpx;
  436. border-radius: 8px;
  437. .title-left {
  438. display: flex;
  439. align-items: center;
  440. font-size: 36rpx;
  441. .icon1 {
  442. width: 56rpx;
  443. height: 56rpx;
  444. margin-right: 8rpx;
  445. vertical-align: middle;
  446. }
  447. }
  448. .title-right {
  449. display: flex;
  450. font-size: 32rpx;
  451. line-height: 32rpx;
  452. .icon2 {
  453. width: 32rpx;
  454. height: 32rpx;
  455. margin-right: 8rpx;
  456. }
  457. }
  458. }
  459. .content {
  460. border-radius: 8px 8px 0 0;
  461. margin-top: -8rpx;
  462. z-index: 999;
  463. background-color: #fff;
  464. padding: 40rpx 32rpx;
  465. // 可用余额
  466. .balance {
  467. display: flex;
  468. justify-content: space-between;
  469. .balance-left {
  470. color: rgb(48, 48, 48);
  471. font-size: 36rpx;
  472. line-height: 40px;
  473. }
  474. .balance-right {
  475. color: rgb(48, 48, 48);
  476. font-size: 80rpx;
  477. }
  478. }
  479. // 提示
  480. .hint {
  481. font-size: 24rpx;
  482. color: #1677FF;
  483. margin-top: 16rpx;
  484. text-align: right;
  485. padding-bottom: 32rpx;
  486. border-bottom: 1px solid rgba(244, 244, 244, 1);
  487. }
  488. .hint2 {
  489. color: #E60012;
  490. }
  491. // 租户信息
  492. .infos {
  493. border-bottom: 1px solid rgba(244, 244, 244, 1);
  494. margin-top: 32rpx;
  495. padding-bottom: 32rpx;
  496. .item {
  497. display: flex;
  498. justify-content: space-between;
  499. margin-bottom: 24rpx;
  500. .item-title {
  501. color: rgb(119, 119, 119);
  502. white-space: pre;
  503. }
  504. .item-value {
  505. color: rgb(48, 48, 48);
  506. }
  507. }
  508. }
  509. // 缴费金额
  510. .payment-amount {
  511. margin-top: 32rpx;
  512. .title {
  513. color: rgb(48, 48, 48);
  514. font-size: 36rpx;
  515. }
  516. .amount-options {
  517. margin-top: 32rpx;
  518. display: flex;
  519. flex-wrap: wrap;
  520. justify-content: space-between;
  521. .options-item {
  522. width: 200rpx;
  523. height: 80rpx;
  524. line-height: 80rpx;
  525. border-radius: 4px;
  526. text-align: center;
  527. background-color: rgba(242, 242, 242, 1);
  528. color: rgba(16, 16, 16, 1);
  529. font-size: 32rpx;
  530. margin-bottom: 20rpx;
  531. }
  532. .chosen {
  533. background-color: rgba(22, 119, 255, 1);
  534. color: rgba(255, 255, 255, 1);
  535. }
  536. }
  537. }
  538. // 输入金额
  539. .input-amount {
  540. margin-top: 24rpx;
  541. display: flex;
  542. font-size: 48rpx;
  543. height: 100rpx;
  544. line-height: 100rpx;
  545. border-bottom: 1px solid rgba(242,242,242,1);
  546. .symbol {
  547. margin-right: 32rpx;
  548. }
  549. .input {
  550. height: 100rpx;
  551. font-size: 40rpx;
  552. }
  553. /deep/.uni-input-placeholder {
  554. color: rgba(204, 204, 204, 1);
  555. }
  556. }
  557. // 支付方式
  558. .payment-way {
  559. margin-top: 24rpx;
  560. .title {
  561. color: rgb(48, 48, 48);
  562. font-size: 36rpx;
  563. }
  564. .way {
  565. margin-top: 24rpx;
  566. .way-item {
  567. display: flex;
  568. justify-content: space-between;
  569. align-items: center;
  570. margin-bottom: 24rpx;
  571. .way-name {
  572. display: flex;
  573. align-items: center;
  574. color: rgb(51, 51, 51);
  575. .text{
  576. font-size: 36rpx;
  577. }
  578. .img {
  579. width: 48rpx;
  580. height: 48rpx;
  581. vertical-align: middle;
  582. margin-right: 16rpx;
  583. margin-left: -3rpx;
  584. }
  585. .img2{
  586. width: 40rpx;
  587. height: 40rpx;
  588. vertical-align: middle;
  589. margin-right: 20rpx;
  590. }
  591. .img3{
  592. background-color: #1677FF;
  593. width: 40rpx;
  594. height: 40rpx;
  595. vertical-align: middle;
  596. margin-right: 20rpx;
  597. border-radius: 999px;
  598. }
  599. }
  600. /deep/.uni-radio-input {
  601. width: 40rpx;
  602. height: 40rpx;
  603. }
  604. }
  605. }
  606. }
  607. // 按钮
  608. .btn {
  609. height: 96rpx;
  610. border-radius: 50px;
  611. background-color: rgba(51, 133, 255, 1);
  612. color: rgba(255, 255, 255, 1);
  613. font-size: 36rpx;
  614. margin-top: 48rpx;
  615. }
  616. }
  617. }
  618. // 对公转账弹窗
  619. .modal-content {
  620. padding: 40rpx 0;
  621. .title-icon {
  622. text-align: center;
  623. }
  624. .img {
  625. width: 96rpx;
  626. height: 96rpx;
  627. }
  628. .title {
  629. text-align: center;
  630. color: rgba(16, 16, 16, 1);
  631. font-size: 36rpx;
  632. font-weight: 600;
  633. margin-top: 8rpx;
  634. }
  635. .infos-group {
  636. margin: 40rpx 32rpx 0;
  637. .item {
  638. display: flex;
  639. justify-content: space-between;
  640. margin-bottom: 16rpx;
  641. .item-title {
  642. color: rgba(119, 119, 119, 1);
  643. font-size: 32rpx;
  644. white-space: pre;
  645. }
  646. .item-value {
  647. color: rgba(51, 51, 51, 1);
  648. font-size: 32rpx;
  649. margin-left: 16rpx;
  650. }
  651. }
  652. }
  653. }
  654. </style>