rechargeByPhone.vue 8.0 KB

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