rechargeByPhone.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <template>
  2. <view>
  3. <ujp-navbar title="帮人充值" :isBack="isBack" :customBack="customBack">
  4. <view class="slot-wrap">
  5. <span class="navBtn " @click="toRefundList"> <u-icon name="clock"></u-icon>充值记录</span>
  6. </view>
  7. </ujp-navbar>
  8. <view class="recharge">
  9. <view class="recharge-text">
  10. <p >充值手机号 </p >
  11. <p v-show="queryCard.query&&queryCard.name">
  12. 用户姓名:{{queryCard.name}}
  13. </p>
  14. <u-input v-model="phone" style=" border-bottom: 1px solid rgb(220, 223, 230);"
  15. :custom-style="{
  16. 'font-size': '48rpx',
  17. 'line-height': '48rpx',
  18. }"
  19. :placeholder-style="{
  20. 'font-size': '48rpx',
  21. 'line-height': '48rpx',
  22. 'color':' rgba(204, 204, 204, 1)',
  23. }"
  24. height="82" placeholder="请输入充值手机号" ></u-input>
  25. <view style="
  26. color: red;
  27. font-size: 16px;
  28. ">{{errorText}}</view>
  29. </view>
  30. </view>
  31. <view class="rechargeBk" v-if="queryCard.query&&queryCard.chargingCardList&&queryCard.chargingCardList.length">
  32. <view class="rechargeBkInfo" >
  33. <view class="recharge-text">
  34. <p>账户余额(元)</p>
  35. <h1>{{queryCard.amount}}</h1>
  36. </view>
  37. <view class="recharge-text">
  38. <p>充电卡号</p>
  39. <h1>{{queryCard.chargingCardList[0].cardNo}}</h1>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="rechargeList" v-if="queryCard.query&&queryCard.chargingCardList&&queryCard.chargingCardList.length" >
  44. <view class="rechargeList1" @click="showCardBtn(queryCard.chargingCardList.length)">
  45. <view>
  46. 您的手机号下共有<span class="span">{{queryCard.chargingCardList.length}}</span>张卡
  47. </view>
  48. <view v-if="queryCard.chargingCardList.length>5">
  49. <span v-show="showCard" >
  50. <u-icon name="arrow-up" ></u-icon>收起
  51. </span>
  52. <span v-show="!showCard" >
  53. <u-icon name="arrow-down" ></u-icon>展开
  54. </span>
  55. </view>
  56. </view>
  57. <view v-show="showCard" class="rechargeList2">
  58. 充电卡号:
  59. <template v-for="(item,i) in queryCard.chargingCardList">
  60. <template v-if="i!=0">
  61. ,
  62. </template>
  63. <span class="rechargeList2Item" :key="i">
  64. {{item.cardNo}}
  65. </span>
  66. </template>
  67. </view>
  68. </view>
  69. <view >
  70. <view class="charge" >
  71. <view class="chargeTit">
  72. 选择充值金额
  73. </view>
  74. <view class="chargeMain">
  75. <template v-for="(item,i) in list">
  76. <view :key="i" :class="{
  77. 'active':amount==item
  78. }" @click="amount=item"
  79. class="chargeMain-item "><p>{{item}}元</p></view>
  80. </template>
  81. </view>
  82. </view>
  83. <view style=" padding-bottom: 240rpx; " >
  84. <view class="charge">
  85. <view class="chargeRadio">
  86. <view class="u-flex">
  87. <u-icon name="weixinzhifu" custom-prefix="custom-icon" color="#22ac38" size="80"></u-icon>
  88. <view class="chargeRadio-text">
  89. <h4>微信支付</h4>
  90. <p>推荐微信支付</p>
  91. </view>
  92. </view>
  93. <u-radio-group>
  94. <u-radio></u-radio>
  95. </u-radio-group>
  96. </view>
  97. </view>
  98. </view>
  99. <view class="foot-btn" >
  100. <view class="foot-pirce">
  101. <u-icon name="tikuan" custom-prefix="custom-icon" color="#FF9502" size="48"></u-icon>
  102. <span>支付 {{amount}} 元</span>
  103. </view>
  104. <u-button type="primary" @click="submit" :custom-style="customStyle" shape="square">{{btnText}}</u-button>
  105. </view>
  106. </view>
  107. </view>
  108. </template>
  109. <script>
  110. import * as Pay from '@/apis/weixin.js'
  111. import {
  112. checkPhone
  113. } from '@/utils'
  114. import {
  115. wxPayJs
  116. } from '@/utils/wxpay'
  117. import * as API from '@/apis/otherRecharge.js'
  118. export default {
  119. data() {
  120. return {
  121. queryCard:{},
  122. showCard:false,
  123. isReady:false,
  124. customStyle: {
  125. background: '#1677ff'
  126. },
  127. detail:{},
  128. isBack:true,
  129. chargingMarketingId:'',
  130. selectItem:{},
  131. list:[5,10,20,50,100,200],
  132. amount:5,
  133. phone:"",
  134. btnText:"请输入手机号",
  135. errorText:"",
  136. }
  137. },
  138. onLoad(op){
  139. if(op.phone){
  140. this.phone=op.phone
  141. this.findByPhone()
  142. }
  143. },
  144. onReady() {
  145. },
  146. watch:{
  147. phone(old){
  148. if(old&&old.length==11){
  149. var checkPhoneResult = checkPhone(old);
  150. if ( checkPhoneResult !== true) {
  151. this.btnText=checkPhoneResult
  152. }else{
  153. this.findByPhone()
  154. }
  155. }else{
  156. this.btnText="请输入手机号"
  157. this.queryCard={
  158. query:false,
  159. chargingCardList:[]
  160. }
  161. this.errorText="";
  162. }
  163. },
  164. },
  165. methods: {
  166. showCardBtn(num){
  167. if(num>5){
  168. this.showCard=!this.showCard
  169. }
  170. },
  171. findByPhone(){
  172. var checkPhoneResult = checkPhone(this.phone);
  173. if ( checkPhoneResult !== true) {
  174. uni.showToast({
  175. title: checkPhoneResult,
  176. })
  177. return;
  178. }
  179. uni.showLoading({
  180. title: "加载中",
  181. mask: true,
  182. })
  183. API.findByPhone({
  184. phone: this.phone,
  185. }).then((response) => {
  186. var data = response.data
  187. uni.hideLoading()
  188. this.queryCard={
  189. query:true,
  190. amount:data.userAccount.availableBalance,
  191. name:data.regUser.realName,
  192. chargingCardList:data.chargingCardList
  193. }
  194. if(data.chargingCardList>5){
  195. this.showCard=false
  196. }else{
  197. this.showCard=true
  198. }
  199. this.btnText="充值"
  200. }).catch(error => {
  201. uni.hideLoading()
  202. this.queryCard={
  203. query:false,
  204. chargingCardList:[]
  205. }
  206. this.errorText=error;
  207. })
  208. },
  209. customBack(){
  210. uni.reLaunch({
  211. url: '/pages/user/rechargeIndex'
  212. })
  213. },
  214. toRefundList() {
  215. uni.navigateTo({
  216. url: '/pages/user/rechargeListByPhone'
  217. })
  218. },
  219. submit(){
  220. if(!this.queryCard.query){
  221. uni.showModal({
  222. title:"提示",
  223. content:this.errorText?this.errorText:this.btnText,
  224. showCancel:false,
  225. })
  226. return
  227. }
  228. var checkPhoneResult = checkPhone(this.phone);
  229. // if ( checkPhoneResult !== true) {
  230. // uni.showToast({
  231. // title: checkPhoneResult,
  232. // })
  233. // return;
  234. // }
  235. uni.showLoading({
  236. title: "加载中",
  237. mask: true,
  238. })
  239. Pay.wxJsapiPayByPhone({
  240. openId:this.carhelp.getOpenId(),
  241. phone:this.phone,
  242. amount:this.amount
  243. }).then((response) => {
  244. if(!response.result){
  245. uni.showToast({
  246. title: response.message
  247. })
  248. return
  249. }
  250. var data = response.data
  251. uni.hideLoading()
  252. console.log("Pay+"+new Date().getTime())
  253. wxPayJs(data);
  254. }).catch(error => {
  255. uni.hideLoading()
  256. uni.showModal({
  257. title:"提示",
  258. content:error,
  259. showCancel:false,
  260. })
  261. })
  262. },
  263. },onShow(){
  264. if(this.isReady){
  265. }
  266. }
  267. }
  268. </script>
  269. <style>
  270. page{
  271. background-color: #f7f7f7;
  272. }
  273. </style>
  274. <style lang="scss" scoped>
  275. .rechargeList{
  276. padding: 30rpx;
  277. background-color: #fff;
  278. margin-bottom: 20rpx;
  279. .rechargeList1{
  280. display: flex;
  281. justify-content: space-between;
  282. width: 100%;
  283. .span{
  284. color: #FF5722;
  285. margin: 0 6rpx;
  286. }
  287. }
  288. .rechargeList2{
  289. margin-top: 10rpx;
  290. }
  291. .rechargeList2Item{
  292. margin: 12rpx;
  293. font-size: 32rpx;
  294. }
  295. }
  296. .slot-wrap{
  297. flex: 1;
  298. }
  299. .navBtn{
  300. float: right;
  301. margin-right: 30rpx;
  302. color:#1677FF ;
  303. }
  304. .rechargePhone{
  305. display: flex;
  306. justify-content: space-between;
  307. align-items: center;
  308. //padding: 15px;
  309. //background-color: #1677FF;
  310. background-color: #fff;
  311. .recharge-btn{
  312. width: 120rpx;
  313. height: 60rpx;
  314. text-align: center;
  315. line-height: 60rpx;
  316. background-color: #589EFF;
  317. color:#fff;
  318. border-radius: 15px;
  319. }
  320. }
  321. .rechargeBk{
  322. .rechargeBkInfo{
  323. display: flex;
  324. justify-content: space-around;
  325. align-items: center;
  326. }
  327. .recharge-text-name{
  328. width: 200rpx;
  329. white-space: nowrap;
  330. overflow: hidden;
  331. text-overflow: ellipsis;
  332. }
  333. padding: 30rpx;
  334. background-color: #1677FF;
  335. margin-bottom: 20rpx;
  336. .recharge-text{
  337. color:#fff;
  338. // width: 100%;
  339. white-space: pre;
  340. }
  341. }
  342. .recharge{
  343. padding: 30rpx;
  344. //background-color: #1677FF;
  345. background-color: #fff;
  346. .recharge-text{
  347. //color:#fff;
  348. width: 100%;
  349. }
  350. .recharge-btn{
  351. width: 120rpx;
  352. height: 60rpx;
  353. text-align: center;
  354. line-height: 60rpx;
  355. background-color: #589EFF;
  356. color:#fff;
  357. border-radius: 15px;
  358. }
  359. }
  360. .charge{
  361. padding: 30rpx;
  362. background-color: #fff;
  363. margin-bottom: 40rpx;
  364. }
  365. .chargeRadio{
  366. display: flex;
  367. justify-content: space-between;
  368. align-items: center;
  369. width: 100%;
  370. .chargeRadio-text{
  371. margin-left: 10rpx;
  372. h4{
  373. font-weight: normal;
  374. font-size: 30rpx;
  375. }
  376. p{
  377. font-size: 24rpx;
  378. color:#999;
  379. margin-top: 10rpx;
  380. }
  381. }
  382. }
  383. .chargeTit{
  384. border-bottom: 1px solid #f7f7f7;
  385. padding-bottom: 20rpx;
  386. font-size: 30rpx;
  387. }
  388. .chargeMain{
  389. display: flex;
  390. flex-wrap: wrap;
  391. justify-content: space-between;
  392. margin-top: 40rpx;
  393. .chargeMain-item{
  394. width: 32%;
  395. text-align: center;
  396. padding: 20rpx;
  397. border: 1px solid rgba(22, 119, 255, 1);
  398. margin-bottom: 20rpx;
  399. border-radius: 5px;
  400. color:#333;
  401. color: rgba(22, 119, 255, 1);
  402. position: relative;
  403. p{
  404. font-size: 40rpx;
  405. }
  406. span{
  407. background-color: #ff8d00;
  408. color:#fff;
  409. padding: 4rpx 20rpx;
  410. border-radius:0 10px 0 10px;
  411. position: absolute;
  412. font-size: 24rpx;
  413. right: -4rpx;
  414. top: -4rpx;
  415. }
  416. }
  417. .active{
  418. border-color:rgba(22, 119, 255, 1);
  419. background-color: rgba(22, 119, 255, 1);
  420. color: rgba(255, 255, 255, 1);
  421. }
  422. .fault{
  423. background-color:#e1e1e1;
  424. color:#666;
  425. border: 1px solid #ccc;
  426. }
  427. .occupy{
  428. color:#FF4F3F;
  429. border: 1px solid #FF4F3F;
  430. }
  431. }
  432. .foot-btn{
  433. padding: 20rpx;
  434. position: fixed;
  435. left: 0;
  436. right: 0;
  437. bottom: 0;
  438. background-color: #fff;
  439. .foot-pirce{
  440. display: flex;
  441. align-items: center;
  442. span{
  443. margin-left: 10rpx;
  444. font-size: 32rpx;
  445. }
  446. padding-bottom: 20rpx;
  447. border-bottom: 1px solid #f7f7f7;
  448. margin-bottom: 20rpx;
  449. }
  450. }
  451. </style>