rechargeByPhone.vue 9.6 KB

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