charge.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402
  1. <template>
  2. <view>
  3. <ujp-navbar title="开始充电" :is-back="isback" ></ujp-navbar>
  4. <!-- 优惠 -->
  5. <view class="discounts" style="padding:0 18px;" v-if="bannerList.length">
  6. <u-swiper bg-color="#fff" :img-mode="'scaleToFill'" height="160" :list="bannerList" @click="clickBanner"
  7. :name="'picUrl'">
  8. </u-swiper>
  9. </view>
  10. <view class="recharge" >
  11. <view class="title">
  12. <view class="left lefttitle">
  13. 请选择充电金额
  14. </view>
  15. <!-- <view class="to-recharge" @click="show=true,recordId='',otherNum_f='',fee=0">
  16. 去充值
  17. </view> -->
  18. </view>
  19. <view class="card"
  20. @click="payValue=0"
  21. :class="{
  22. cardselect:payValue==0,
  23. cardno:payValue!=0
  24. }">
  25. <view class="cardgo" >
  26. <view class="cardinfo">
  27. <img src="@/assets/img/icon_success.png" alt="">
  28. </view>
  29. </view>
  30. <view class="title">先付后退</view>
  31. <p>充电结束后,余额自动退还,不享受会员优惠</p>
  32. <view class="rechargeMain" v-show="payValue==0">
  33. <view class="recharge-item" @click="moneyActiveClass_n=(item.id)"
  34. :class="moneyActiveClass_n == item.id ? 'active' : ''" v-for="(item,index) in moneyListN"
  35. :key="item.id">
  36. {{item.name}}
  37. </view>
  38. </view>
  39. </view>
  40. <view class="card"
  41. @click="paySelectMethod"
  42. :class="{
  43. cardselect:payValue==1,
  44. cardno:payValue!=1
  45. }">
  46. <view class="cardgo" >
  47. <view class="cardinfo">
  48. <img src="@/assets/img/icon_success.png" width="32" alt="">
  49. </view>
  50. </view>
  51. <view class="title">会员账户余额充电</view>
  52. <p>当前余额{{user.balance>0?user.balance.toFixed(2):'0.00'}}元
  53. <span
  54. @click="paySelectShow()"
  55. style="color:#00B962;margin-left: 20px; ">去充值></span>
  56. </p>
  57. <view class="rechargeMain" v-show="payValue==1">
  58. <view @click="moneyClick(-1)" :class="!otherNum&&moneyActiveClass == -1? 'active' : ''" class=" recharge-item ">
  59. 充满自停
  60. </view>
  61. <view class="recharge-item" @click="moneyClick(item.id)"
  62. :class="!otherNum&&moneyActiveClass == item.id ? 'active' : ''" v-for="(item,index) in moneyList"
  63. :key="item.id">
  64. {{item.name}}元
  65. </view>
  66. <view class="recharge-item recharge-item2" :class="otherNum ? 'active' : ''" style="
  67. padding: 1px 0px;">
  68. <u-input v-model="otherNum" @input="ckInput" @focus="focus" type="digit" placeholder="其他充电金额" />
  69. </view>
  70. </view>
  71. </view>
  72. <!-- 优惠券2 -->
  73. <view class="discounts2" v-if="false">
  74. <view class="left lefttitle">
  75. 支付方式
  76. </view>
  77. <view class="right" @click="paySelect=true" style="color:#101010" >
  78. {{payName}}
  79. <view class="iconfont">&#xe600;</view>
  80. </view>
  81. </view>
  82. <view class="discounts2">
  83. <view class="left lefttitle">
  84. 优惠券
  85. </view>
  86. <view class="right" v-if="payValue=='0'">
  87. 先付后退不享受会员优惠活动
  88. </view>
  89. <view class="right" @click="chooseCoupons" v-else-if="selectObj.id">
  90. {{selectObj.threshold == 0 ? '无门槛' : '满'+selectObj.threshold.toFixed(2)+'元可用'}},
  91. <span class="price" v-if="selectObj.classify == '1'||selectObj.classify == '3'">抵扣{{selectObj.value.toFixed(2)}}元</span>
  92. <span class="price" v-if="selectObj.classify == '2'">服务费{{selectObj.value}}折</span>
  93. <view class="iconfont">&#xe600;</view>
  94. </view>
  95. <view class="right" @click="chooseCoupons" v-else-if="listlength">
  96. 未选择,剩余{{listlength}}张优惠券
  97. <view class="iconfont">&#xe600;</view>
  98. </view>
  99. <view class="right" @click="chooseCoupons" v-else>
  100. 无优惠券
  101. <view class="iconfont">&#xe600;</view>
  102. </view>
  103. </view>
  104. <!-- 会员活动 -->
  105. <view class="member" v-if="userCardBool" >
  106. <view class="actively ">
  107. 会员活动
  108. </view>
  109. <view class="right" v-if="payValue=='0'">
  110. 先付后退不享受会员优惠活动
  111. </view>
  112. <view class="type" v-else-if="!vin" style="color: red;" >
  113. vin码不一致
  114. </view>
  115. <view class="type" v-else-if="canUse">
  116. 充电服务费月卡
  117. </view>
  118. <view class="type" style="color: red;" v-else>
  119. 此充电站不支持月卡服务
  120. </view>
  121. </view>
  122. </view>
  123. <view class="bottom">
  124. <view class="botton"
  125. @click="submit"
  126. >开始充电</view>
  127. </view>
  128. <view class="textinfo">
  129. <p>充电说明:</p>
  130. <view>
  131. 1.最终结算金额将以实际充入电量为准;<br/>
  132. 2.充满自停模式需要您的余额不低于10元才可充电;<br/>
  133. 3.充电金额请输入1元~500元的整数。实际充电金额与所选金额会略有出入(一般误差约几分钱);<br/>
  134. 4.完成充电后,在满足条件的情况下,优惠券自动抵扣;提前结束充电则不使用优惠券并返还至您的卡包。<br/>
  135. 5.先付后退模式,无法享受平台会员的服务费折扣、优惠券等优惠活动。<br/>
  136. </view>
  137. </view>
  138. <!-- <view class="but-box" style="margin-bottom: 20px;">
  139. <u-button
  140. style=" background-color: rgba(0, 185, 98, 100);
  141. color: rgba(255, 255, 255, 100);
  142. font-size: 16px;
  143. text-align: center;"
  144. @click="submit" shape="circle">开始充电</u-button>
  145. </view> -->
  146. <u-modal v-model="showmodal"
  147. :show-cancel-button="true"
  148. title="余额不足" confirm-text="前往充值"
  149. content="账户余额不足,充值成功后开始充电" @confirm="show=true"></u-modal>
  150. <!-- 弹窗2 -->
  151. <template >
  152. <view >
  153. <u-popup v-model="paySelect" mode="bottom" >
  154. <view class="paySelect">
  155. <view class="title lefttitle " >选择支付方式</view>
  156. <u-radio-group v-model="payValueTemp">
  157. <p >
  158. <u-radio
  159. name="0"
  160. active-color="#2979f6" shape="circle" size="48">
  161. <p >{{payList[0].name}}<span>({{payList[0].tips}})</span> </p>
  162. </u-radio>
  163. </p>
  164. <p v-if="personInfo&&personInfo.userType=='2'" >
  165. <u-radio
  166. name="1"
  167. active-color="#2979f6" shape="circle" size="48">
  168. <p >{{payList[1].name}}<span>({{payList[1].tips}})</span> </p>
  169. </u-radio>
  170. </p>
  171. <p v-if="false" >
  172. <u-radio
  173. name="2"
  174. active-color="#2979f6" shape="circle" size="48">
  175. <p >{{payList[2].name}}<span>(其他充值金额)</span> </p>
  176. </u-radio>
  177. </p>
  178. </u-radio-group>
  179. </view>
  180. <view class="recharge" style="padding-bottom: 0;">
  181. <view class="recharge-btn transactionClass" style="margin-top: 60px;">
  182. <u-button
  183. class="success-btn" @click="paySelectMethod"
  184. shape="circle" type="success" style="margin-top: 12px;margin-bottom: 16px;">
  185. <span>确定</span>
  186. </u-button>
  187. </view>
  188. </view>
  189. </u-popup>
  190. </view>
  191. </template>
  192. <!-- 弹窗 -->
  193. <template >
  194. <view >
  195. <u-popup v-model="show" mode="bottom" >
  196. <view class="recharge" style="padding-bottom: 0;">
  197. <view class="title lefttitle " >选择充值金额</view>
  198. <p>当前余额{{user.balance>0?user.balance.toFixed(2):'0.00'}}元</p>
  199. <view class="rechargeMain">
  200. <view class="recharge-item" :class="!otherNum_f&&moneyActiveClass_f == item.id ? 'active' : ''"
  201. v-for="(item,index) in moneyList_f" :key="item.id" @click="moneyClick_f(item.id,item)">
  202. {{item.amountDesc?item.amountDesc:item.rechargeAmount+'元'}}
  203. <view class="amount" v-if="item.amountRemark">{{item.amountRemark}}</view>
  204. </view>
  205. </view>
  206. <p class="oldTextjp2" oldstyle="font-size:16px">其他充值金额</p>
  207. <view style="margin-bottom: 32px;">
  208. <view
  209. :class="otherNum_f? 'active' : ''"
  210. class="recharge-input self-stop" style="height: 100%;width: 100%;margin-bottom: 8px;">
  211. <u-input v-model="otherNum_f" @input="ckInput_f" @focus="focus" type="digit" :border="true" />
  212. </view>
  213. <view style="color: rgba(153, 153, 153, 100);
  214. font-size: 12px;
  215. text-align: left;
  216. font-family: AlibabaPuHui-regular;"><span style="color:red">*</span>金额范围为1元-500元</view>
  217. </view>
  218. <view class="recharge-btn transactionClass" style="margin-top: 60px;">
  219. <view >
  220. <u-checkbox-group>
  221. <u-checkbox active-color="green" v-model="checked" shape="circle"></u-checkbox>
  222. </u-checkbox-group>
  223. 我已阅读并同意<span @click="gotoUrl('pages/article/details?code=CZXY')" style="color:#00B962" >《充值协议》</span>
  224. </view>
  225. <u-button
  226. class="success-btn"
  227. shape="circle" type="success" @click="rechargeNow" style="margin-top: 12px;margin-bottom: 16px;">
  228. <span>微信充值</span>
  229. </u-button>
  230. </view>
  231. </view>
  232. </u-popup>
  233. </view>
  234. </template>
  235. </view>
  236. </template>
  237. <script>
  238. import * as API from '@/apis/chargeProcess.js'
  239. import * as userApi from '@/apis/user.js'
  240. import * as newsApi from '@/apis/news.js'
  241. import * as API_finance from '@/apis/finance.js'
  242. import {
  243. wxPayJs
  244. } from '@/utils/wxpay'
  245. import * as Pay from '@/apis/weixin.js'
  246. export default {
  247. data() {
  248. return {
  249. fee:0,
  250. recordId:"",
  251. show2:false,
  252. stationId:"",
  253. elderMode:false,
  254. isback:true,
  255. show: false,
  256. moneyActiveClass_n: "50",
  257. moneyActiveClass: "-1",
  258. moneyActiveClass_f: "-1",
  259. detail: {},
  260. couponsuse:'',
  261. showmodal:false,
  262. //提交信息
  263. //提交信息
  264. submitForm_f: {
  265. //paytype:'YE',
  266. },
  267. submitForm: {
  268. deviceNo: '',
  269. channelNo: '',
  270. carNumber: '',
  271. chargeStrategy: 2,
  272. amount: 0
  273. //paytype:'YE',
  274. },
  275. uuid:0,
  276. user: {},
  277. otherNum_f: '',
  278. otherNum: '',
  279. moneyList_f:[],
  280. paySelect:false,
  281. payName:"",
  282. payValueTemp:0,
  283. payValue:0,
  284. payList:[{
  285. name:"先付后退",
  286. tips:"游客不享受平台优惠活动",
  287. value:"1",
  288. select:false,
  289. },{
  290. name:"个人账户支付",
  291. tips:"享受平台充电8.5折等优惠活动",
  292. value:"2",
  293. select:false,
  294. },{
  295. name:"单位账户支付",
  296. tips:"账户余额:99999元",
  297. value:"3",
  298. select:false,
  299. }],
  300. moneyList: [
  301. {
  302. id: '10',
  303. name: '10'
  304. },
  305. {
  306. id: '20',
  307. name: '20'
  308. },
  309. {
  310. id: '50',
  311. name: '50'
  312. },
  313. {
  314. id: '100',
  315. name: '100'
  316. },
  317. ],
  318. moneyListN: [
  319. {
  320. id: '10',
  321. name: '10元'
  322. },
  323. {
  324. id: '20',
  325. name: '20元'
  326. },
  327. {
  328. id: '50',
  329. name: '50元'
  330. }
  331. ],
  332. userCard:null,
  333. canUse:false,
  334. selectObj:{},
  335. value:"",
  336. // 优惠券
  337. listlength:0,
  338. vin:true,
  339. bannerList:[],
  340. checked:true,
  341. selectItem:{},
  342. personInfo:{},
  343. }
  344. },
  345. computed:{
  346. userCardBool(){
  347. if(this.userCard){
  348. var date=new Date().getTime()
  349. var reg=new RegExp('-','gi')
  350. var str=this.userCard.endTime;
  351. //console.log(str.replace(reg,'/'))
  352. var date2=new Date(str.replace(reg,'/')).getTime();
  353. if(date<date2){
  354. return true;
  355. }
  356. }
  357. return false
  358. }
  359. },
  360. onLoad(op) {
  361. this.personInfo=this.carhelp.getPersonInfo()
  362. // if(plus){
  363. // this.userCard=plus.userCard;
  364. // }
  365. this.uuid=new Date().getTime();
  366. this.stationId= op.stationId;
  367. if (op.deviceNo) {
  368. this.submitForm.deviceNo = op.deviceNo;
  369. this.submitForm.channelNo = op.gun;
  370. this.submitForm.carNumber = op.carNumber;
  371. this.carhelp.setGunIdCharge(this.submitForm);
  372. }
  373. if(op.vin=='no'){
  374. this.vin=false;
  375. }
  376. if(op.isback){
  377. this.isback=false;
  378. }
  379. this.useCoupon()
  380. var couponsuse=this.carhelp.getConfig().couponsuse
  381. // img="https://yktwechat.xiaoxinda.com/config/xxd2021.jpg"
  382. if(couponsuse){
  383. this.couponsuse=couponsuse
  384. }
  385. this.init()
  386. },
  387. onReady(){
  388. this.personInfo=this.carhelp.getPersonInfo()
  389. if(this.personInfo.userType=="1"){
  390. this.payValueTemp=0;
  391. this.payValue=0;
  392. }else{
  393. this.payValueTemp=1;
  394. this.payValue=1;
  395. }
  396. this.payName=this.payList[this.payValue].name;
  397. this.getBannerInfo("charge-start")
  398. this.elderMode = this.carhelp.get('getElderModeClass') == '长辈模式';
  399. if(this.elderMode)
  400. this.theme('elder')
  401. else
  402. this.theme('standard')
  403. },
  404. onShow() {
  405. this.personInfo=this.carhelp.getPersonInfo()
  406. var obj=this.carhelp.get("chooseCoupons");
  407. if(obj){
  408. if(obj.uuid==this.uuid){
  409. this.selectObj=obj.selectObj;
  410. }
  411. }
  412. this.getHomePage()
  413. },
  414. methods: {
  415. paySelectShow(){
  416. if(this.personInfo.userType=="1"){
  417. }else{
  418. this.show=true;
  419. this.recordId='';
  420. this.otherNum_f='';
  421. this.fee=0
  422. }
  423. },
  424. paySelectMethod(){
  425. if(this.personInfo.userType=="1"){
  426. uni.showToast({
  427. title:"游客模式只支持“先付后退”"
  428. })
  429. }else{
  430. this.payValue=1
  431. }
  432. },
  433. moneyClick_f(index,item) {
  434. this.otherNum_f='';
  435. this.moneyActiveClass_f = index;
  436. if(item){
  437. this.selectItem=item;
  438. // if(item.imgUrl){
  439. // this.selectImg=item
  440. // }
  441. }
  442. },
  443. rechargeNow2() {
  444. //先付后退
  445. this.submitForm_f={};
  446. var fee=0;
  447. this.submitForm_f.amount=this.fee;
  448. uni.showLoading({
  449. title: "加载中",
  450. mask: true,
  451. })
  452. if(this.recordId){
  453. this.submitForm_f.recordId=this.recordId
  454. }
  455. //(this.submitForm)
  456. this.wxpy()
  457. },
  458. rechargeNow() {
  459. if(!this.checked){
  460. uni.showToast({
  461. title:"请同意《充值协议》后进行充值"
  462. })
  463. return
  464. }
  465. this.submitForm_f={};
  466. var fee=0;
  467. if(!this.otherNum_f){
  468. this.submitForm_f.chargingMarketingId=this.selectItem.id;
  469. fee=this.selectItem.rechargeAmount
  470. }else{
  471. this.submitForm_f.amount=this.otherNum_f
  472. fee=this.otherNum_f
  473. }
  474. if(this.fee){
  475. var thisfee=this.fee
  476. if(this.fee>parseFloat(fee)){
  477. uni.showToast({
  478. title:`最少充值${thisfee}元才能启动充电`
  479. })
  480. return
  481. }
  482. }
  483. uni.showLoading({
  484. title: "加载中",
  485. mask: true,
  486. })
  487. if(this.recordId){
  488. this.submitForm_f.recordId=this.recordId
  489. }
  490. //(this.submitForm)
  491. this.wxpy()
  492. },
  493. wxpy(){
  494. Pay.wxpay(this.submitForm_f).then((response) => {
  495. if(!response.result){
  496. uni.showToast({
  497. title: response.message
  498. })
  499. return
  500. }
  501. var data = response.data
  502. uni.hideLoading()
  503. //("Pay+"+new Date().getTime())
  504. wxPayJs(data);
  505. }).catch(error => {
  506. uni.showToast({
  507. title: error
  508. })
  509. })
  510. },
  511. focus(){
  512. console.log(0)
  513. uni.pageScrollTo({
  514. scrollTop:999999,
  515. duration:0
  516. })
  517. },
  518. init() {
  519. var data = {
  520. type:2 ,
  521. };
  522. API_finance.marketingData(data).then((res) => {
  523. this.moneyList_f = res.data.chargingMarketingList
  524. if (this.moneyList_f.length > 0) {
  525. this.selectItem = this.moneyList_f[0];
  526. this.moneyActiveClass_f = this.moneyList_f[0].id
  527. //(this.moneyActiveClass)
  528. }
  529. var list=res.data.priceList
  530. if(list.length){
  531. this.moneyListN=[];
  532. for(var i in list){
  533. this.moneyListN.push({
  534. id:list[i],
  535. name:list[i]+"元"
  536. })
  537. }
  538. this.moneyActiveClass_n=list[0]
  539. }
  540. }).catch(error => {
  541. uni.showToast({
  542. title: error
  543. })
  544. })
  545. },
  546. clickBanner(index){
  547. var mod= this.bannerList[index]
  548. if(mod.linkUrl.indexOf('http')==0){
  549. window.location=mod.linkUrl;
  550. }
  551. else if(mod.linkUrl.indexOf('#/')==0){
  552. if(mod.linkUrl.indexOf("?")==-1){
  553. mod.linkUrl+='?';
  554. }
  555. //window.location=mod.linkUrl;
  556. var url=mod.linkUrl.split("#")[1]
  557. //window.location = mod.clickUrl;
  558. uni.navigateTo({
  559. url: url
  560. })
  561. }
  562. else if(mod.linkUrl=='#'||mod.linkUrl==''){
  563. }
  564. else{
  565. uni.navigateTo({
  566. url:mod.linkUrl
  567. })
  568. }
  569. },
  570. getBannerInfo(code){
  571. uni.showLoading({
  572. title: "加载中",
  573. mask: true,
  574. })
  575. newsApi.getBannerInfo(code).then((res) => {
  576. uni.hideLoading();
  577. this.bannerList =res.data;
  578. // document.getElementsByClassName("uni-swiper-wrapper")[0].parentNode.style="background-color: rgb(255, 255, 255); height: 300px;"
  579. }).catch(error => {
  580. uni.showToast({
  581. title: error,icon: "none"
  582. })
  583. })
  584. },
  585. getPile(){
  586. },
  587. theme(type) {
  588. if(type == 'elder')
  589. {
  590. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  591. }
  592. else
  593. {
  594. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  595. }
  596. },
  597. chooseCoupons(){
  598. this.submitInit()
  599. this.gotoUrl('pages/user/coupon/chooseCoupons?uuid='+this.uuid+"&amount="+this.submitForm.amount+"&stationId="+this.stationId)
  600. },
  601. ckInput_f(text) {
  602. if (text.indexOf('.') > 0) {
  603. var k =text.split(".")[1]
  604. if(k.length>=3){
  605. this.$nextTick(()=>{
  606. text=parseFloat(text).toFixed(2);
  607. this.otherNum_f= text
  608. })
  609. }
  610. }
  611. var t = Number(text);
  612. if (t < 1) {
  613. this.$nextTick(() => {
  614. this.otherNum_f = '';
  615. })
  616. }
  617. if (t > 500) {
  618. this.$nextTick(() => {
  619. this.otherNum_f = 500;
  620. })
  621. }
  622. },
  623. ckInput(text) {
  624. if (text.indexOf('.') > 0) {
  625. this.$nextTick(() => {
  626. this.otherNum = text.substring(0, text.indexOf('.'))
  627. uni.showToast({
  628. title: "请输入正整数"
  629. })
  630. })
  631. }
  632. var t = Number(text);
  633. if (t < 1) {
  634. this.$nextTick(() => {
  635. this.otherNum = '';
  636. })
  637. }
  638. if (t > 500) {
  639. this.$nextTick(() => {
  640. this.otherNum = 500;
  641. })
  642. }
  643. this.selectJudge();
  644. },
  645. moneyClick(index) {
  646. this.otherNum = ''
  647. this.moneyActiveClass = index;
  648. this.selectJudge();
  649. },
  650. selectJudge(){
  651. this.submitInit()
  652. if(this.submitForm.amount==0){
  653. return
  654. }
  655. if(this.selectObj.id&&this.selectObj.threshold>this.submitForm.amount){
  656. uni.showToast({
  657. title:"请重新选择优惠券"
  658. })
  659. this.selectObj={}
  660. }
  661. },
  662. radioChange(e){},
  663. confirm() {
  664. ////(JSON.stringify(this.submitForm))
  665. if(this.payValue!=0){
  666. if(this.selectObj.id){
  667. this.submitForm.userCouponId=this.selectObj.id
  668. }
  669. if(this.userCardBool&&this.canUse&&this.vin){
  670. this.submitForm.userCardId=this.userCard.id
  671. }
  672. }
  673. uni.showLoading({
  674. title: "加载中",
  675. mask: true,
  676. })
  677. //this.submitForm.deviceNo = this.detail.deviceNo;
  678. API.startCarCharging(this.submitForm).then((res) => {
  679. //(JSON.stringify(this.res))
  680. if(res.data.status=="5"){
  681. uni.hideLoading()
  682. if(this.submitForm.payType=="1"){
  683. this.recordId=res.data.recordId;
  684. this.fee=res.data.fee;
  685. this.rechargeNow2()//先付后退
  686. }else{
  687. this.showmodal=true;
  688. this.recordId=res.data.recordId;
  689. var fee=res.data.fee;
  690. this.fee=(fee-this.user.balance).toFixed(2);
  691. this.otherNum_f=this.fee;
  692. }
  693. }else{
  694. this.gotoUrl("pages/searchPile/chargeProcess/dcCharging?id=" + res.data.recordId);
  695. }
  696. }).catch(error => {
  697. uni.hideLoading()
  698. if (error == '用户账户余额不足!') {
  699. } else {
  700. uni.showToast({
  701. title: error
  702. })
  703. }
  704. })
  705. },
  706. getHomePage() {
  707. uni.showLoading({
  708. title: "加载中",
  709. mask: true,
  710. })
  711. API.userCard({
  712. stationId:this.stationId
  713. }).then((res) => {
  714. console.log(res)
  715. this.userCard=res.data.regUserCard
  716. this.canUse=res.data.canUse
  717. //this.user = res.data
  718. API.personalCenter().then((res2) => {
  719. this.user = res2.data
  720. this.isReady = true;
  721. uni.hideLoading()
  722. }).catch(error => {
  723. uni.showToast({
  724. title: error
  725. })
  726. })
  727. }).catch(error => {
  728. uni.showToast({
  729. title: error
  730. })
  731. })
  732. },
  733. useCoupon(){
  734. var obj={
  735. status:0,
  736. stationId:this.stationId,
  737. hideCardCoupon:1
  738. }
  739. if(this.userCardBool) {
  740. obj.userCardId=this.userCard.id
  741. }
  742. userApi.couponList(obj).then((res) => {
  743. this.listlength= res.data.recordsTotal;
  744. //uni.hideLoading()
  745. }).catch(error => {
  746. uni.showToast({
  747. title: error
  748. })
  749. })
  750. },
  751. submitInit(){
  752. if (this.moneyActiveClass == -1 && !this.otherNum) {
  753. this.submitForm.chargeStrategy = 0;
  754. this.submitForm.amount = 0
  755. } else {
  756. this.submitForm.chargeStrategy = 2;
  757. if (this.otherNum) {
  758. this.submitForm.amount = this.otherNum
  759. } else {
  760. this.submitForm.amount = this.moneyActiveClass
  761. }
  762. }
  763. },
  764. submit() {
  765. if (!this.submitForm.channelNo) {
  766. uni.showToast({
  767. title: '请先选择充电通道'
  768. })
  769. return
  770. }
  771. this.submitForm.payType=this.payList[this.payValue].value;
  772. if(this.submitForm.payType=="1"){
  773. this.submitForm.amount = this.moneyActiveClass_n
  774. this.submitForm.chargeStrategy = 2;
  775. }else{
  776. this.submitInit()
  777. }
  778. this.confirm()
  779. },
  780. }
  781. }
  782. </script>
  783. <style>
  784. page {
  785. background-color: #fff;
  786. }
  787. </style>
  788. <style lang="scss" scoped>
  789. .textinfo{
  790. padding: 40rpx;
  791. font-size: 14px !important;
  792. color: #999999;
  793. p{
  794. font-size: 16px !important;
  795. color:#101010;
  796. font-weight: bold;
  797. }
  798. }
  799. .lefttitle{
  800. font-weight: bold;
  801. font-size: 16px
  802. }
  803. @import "@/_theme.scss";
  804. .listlength{
  805. float: right;
  806. padding-right: 10px;
  807. }
  808. /deep/.u-drawer-content{
  809. border-radius: 10px 10px 0 0
  810. }
  811. /deep/.u-radio-group {
  812. width: 100%;
  813. }
  814. /deep/.u-radio {
  815. position: relative;
  816. }
  817. /deep/.u-radio__icon-wrap {
  818. position: absolute;
  819. right: 0;
  820. }
  821. .recharge-item2 {
  822. @include themeify{
  823. font-size: themed('font-size2') !important;
  824. }
  825. /* font-size: 14px !important;*/
  826. color: #999999;
  827. }
  828. .paySelect{
  829. padding: 16px;
  830. .title{
  831. font-size:40rpx
  832. }
  833. p {
  834. width: 100%;
  835. span{
  836. color: #666;
  837. }
  838. .u-radio__label{
  839. color: #333333 ;
  840. }
  841. .u-radio{
  842. width: 100% !important;;
  843. }
  844. color: #333333 ;
  845. margin-top: 16rpx;
  846. font-size:32rpx;
  847. }
  848. }
  849. .recharge {
  850. padding: 16px;
  851. // padding-bottom: 80px;
  852. .title {
  853. @include themeify{
  854. font-size: themed('font-size3');
  855. }
  856. /* font-size: 16px;*/
  857. position: relative;
  858. }
  859. p {
  860. color: #666;
  861. margin-top: 4px;
  862. }
  863. .self-stop.active {
  864. background-color: #EFFFF7;
  865. border-color: #00B962;
  866. color: #00B962;
  867. }
  868. .rechargeMain {
  869. display: flex;
  870. flex-wrap: wrap;
  871. // justify-content: space-between;
  872. margin-top: 12px;
  873. margin-bottom: 5px;
  874. .recharge-item {
  875. .u-input {
  876. text-align: center !important;
  877. }
  878. width: 31%;
  879. border: 1px solid #e3e3e3;
  880. padding: 10px 0;
  881. border-radius: 4px;
  882. text-align: center;
  883. margin-bottom: 10px;
  884. position: relative;
  885. margin-left: 5px;
  886. @include themeify{
  887. font-size: themed('font-size3');
  888. }
  889. /* font-size: 16px;*/
  890. }
  891. .active {
  892. background-color: #EFFFF7;
  893. border-color: #00B962;
  894. color: #00B962;
  895. }
  896. }
  897. .self-stop {
  898. width: 105px;
  899. /* height: 48px;
  900. line-height: 48px;*/
  901. border-radius: 4px;
  902. color: #101010;
  903. @include themeify{
  904. font-size: themed('font-size3');
  905. height:themed('font-size19');
  906. line-height:themed('font-size19')
  907. }
  908. /* font-size: 16px;*/
  909. text-align: center;
  910. font-family: Arial;
  911. border: 1px solid rgba(227, 227, 227, 100);
  912. margin-top: 12px;
  913. }
  914. }
  915. .recharge-input {
  916. margin-top: 8px;
  917. margin-bottom: 32px;
  918. }
  919. .recharge-radio {
  920. margin-top: 10px;
  921. .recharge-radio-item {
  922. display: flex;
  923. align-items: center;
  924. }
  925. .recharge-radio-name {
  926. margin-left: 8px;
  927. }
  928. }
  929. .but-box {
  930. width: 89.3%;
  931. height: 44px;
  932. margin: 0 auto;
  933. position: fixed;
  934. bottom: 0;
  935. right: 0;
  936. left: 0;
  937. }
  938. //优惠券
  939. .discounts {
  940. margin-top: 10px;
  941. width: 100%;
  942. .title {
  943. width: 100%;
  944. .title-1 {
  945. /* height: 22px;*/
  946. color: rgba(16, 16, 16, 100);
  947. @include themeify{
  948. font-size: themed('font-size3');
  949. height:themed('font-size6');
  950. }
  951. /* font-size: 16px;*/
  952. }
  953. .title-2 {
  954. margin-left: 4px;
  955. @include themeify{
  956. font-size: themed('font-size2');
  957. line-height:themed('font-size5');
  958. }
  959. /* font-size: 14px;
  960. line-height: 20px;*/
  961. }
  962. .title-3 {
  963. float: right;
  964. @include themeify{
  965. font-size: themed('font-size3');
  966. line-height:themed('font-size5');
  967. }
  968. /* height: 19px;
  969. font-size: 16px;*/
  970. }
  971. }
  972. .select {
  973. position: relative;
  974. /deep/.u-radio {
  975. padding: 18px 16px;
  976. margin-top: 12px;
  977. width: 100%;
  978. height: 48px;
  979. border-radius: 4px;
  980. background-color: rgba(255, 255, 255, 100);
  981. text-align: center;
  982. border: 1px solid rgba(227, 227, 227, 100);
  983. position: relative;
  984. }
  985. // /deep/.u-radio:nth-child(3) {
  986. //
  987. // }
  988. /deep/.u-radio__icon-wrap {
  989. left: 16px;
  990. background-color: #fff;
  991. }
  992. /deep/.u-radio__label {
  993. margin-left: 40px;
  994. }
  995. }
  996. .explain {
  997. width: 64px;
  998. /* height: 24px;
  999. line-height: 24px;*/
  1000. position: absolute;
  1001. top: 10px;
  1002. right: 12px;
  1003. border-radius: 4px;
  1004. background-color: rgba(255, 255, 255, 100);
  1005. text-align: center;
  1006. border: 1px solid rgba(227, 227, 227, 100);
  1007. color: rgba(0, 185, 98, 100);
  1008. /* font-size: 12px;*/
  1009. @include themeify{
  1010. font-size: themed('font-size1');
  1011. line-height:themed('font-size7');
  1012. height:themed('font-size7');
  1013. }
  1014. }
  1015. }
  1016. // 优惠券2
  1017. .discounts2{
  1018. margin-top: 10px;
  1019. width: 100%;
  1020. display: flex;
  1021. justify-content: space-between;
  1022. .left{
  1023. /* width: 70px;*/
  1024. // height: 20px;
  1025. color: rgba(16, 16, 16, 100);
  1026. /* font-size: 20px;*/
  1027. @include themeify{
  1028. width:160rpx;
  1029. font-size: 40rpx;
  1030. }
  1031. }
  1032. .right{
  1033. /*
  1034. height: 16px;
  1035. line-height: 28px;*/
  1036. color: rgba(255, 61, 0, 100);
  1037. @include themeify{
  1038. font-size: themed('font-size3');
  1039. height: themed('font-size3');
  1040. line-height: themed('font-size9');
  1041. }
  1042. /* font-size: 16px;*/
  1043. text-align: right;
  1044. display: flex;
  1045. }
  1046. .iconfont{
  1047. @include themeify{
  1048. font-size: themed('font-size7');
  1049. line-height: themed('font-size10');
  1050. }
  1051. /* line-height: 29px;*/
  1052. text-align: center;
  1053. color: #b3b3b3;
  1054. /* font-size: 24px;*/
  1055. }
  1056. }
  1057. // 会员活动
  1058. .member{
  1059. margin-top: 20px;
  1060. display: flex;
  1061. justify-content: space-between;
  1062. .actively{
  1063. color: rgba(16, 16, 16, 100);
  1064. font-size: 20px;
  1065. }
  1066. .type{
  1067. color: rgba(16, 18, 18, 100);
  1068. font-size: 16px;
  1069. line-height: 28px;
  1070. padding-right: 10px;
  1071. }
  1072. }
  1073. // 尾部
  1074. .bottom {
  1075. background: #fff;
  1076. width: 100%;
  1077. // height: 64px;
  1078. // line-height: 64px;
  1079. // position: fixed;
  1080. // bottom: 0;
  1081. // left: 0;
  1082. z-index: 999;
  1083. padding: 0px 16px 16px;
  1084. .botton {
  1085. //width: 343px;
  1086. height: 40px;
  1087. line-height: 40px;
  1088. font-size:16px;
  1089. border-radius: 50px;
  1090. background-color: rgba(0, 185, 98, 100);
  1091. color: rgba(255, 255, 255, 100);
  1092. /* font-size: 16px;*/
  1093. // @include themeify{
  1094. // font-size: themed('font-size3');
  1095. // line-height: themed('font-size15');
  1096. // height: themed('font-size15');
  1097. // }
  1098. text-align: center;
  1099. margin: 0 auto;
  1100. }
  1101. }
  1102. .couponsuse{
  1103. color: rgba(153, 153, 153, 100);
  1104. margin-top: 10px;
  1105. font-size: 14px;
  1106. text-align: left;
  1107. font-family: AlibabaPuHui-regular;
  1108. }
  1109. .to-recharge{
  1110. padding: 0 16px;
  1111. line-height: 36px;
  1112. border-radius: 50px 0px 0px 50px;
  1113. background:linear-gradient(#FF9000,#FFB700);
  1114. color: rgba(255, 255, 255, 100);
  1115. font-size: 16px;
  1116. text-align: center;
  1117. position: absolute;
  1118. right: -16px;
  1119. top: 0;
  1120. }
  1121. /deep/.u-checkbox__icon-wrap--checked{
  1122. background-color: #2979ff !important;
  1123. border-color: #2979ff !important;
  1124. }
  1125. .amount {
  1126. // width: 41.9%;
  1127. height: 16px;
  1128. line-height: 15px;
  1129. border-radius: 0px 4px 0px 4px;
  1130. background-color: #ec4530;//rgba(0, 185, 98, 100)
  1131. color: rgba(255, 255, 255, 100);
  1132. font-size: 10px;
  1133. text-align: center;
  1134. position: absolute;
  1135. top: 0;
  1136. right: 0;
  1137. }
  1138. .card {
  1139. overflow: hidden;
  1140. padding: 10px;
  1141. margin-top: 10px;
  1142. .title{
  1143. font-weight: bold;
  1144. }
  1145. }
  1146. .cardselect {
  1147. border-radius: 8px;
  1148. border: 2px solid rgba(0, 185, 98, 1);
  1149. .title{
  1150. color:#00B962;
  1151. font-weight: bold;
  1152. }
  1153. .cardgo{
  1154. position: relative;
  1155. .cardinfo{
  1156. background-color: #57ad55;
  1157. width: 64rpx;
  1158. height: 64rpx;
  1159. position: absolute;
  1160. top: -12px;
  1161. right: -12px;
  1162. border-radius: 0 0 0 8px;
  1163. img{
  1164. width: 64rpx;
  1165. }
  1166. }
  1167. }
  1168. }
  1169. .cardno {
  1170. border: 2px solid rgba(204, 204, 204, 1);
  1171. border-radius: 8px;
  1172. .title{
  1173. font-weight: bold;
  1174. }
  1175. .cardgo{
  1176. display: none;
  1177. }
  1178. }
  1179. </style>