charge.vue 31 KB

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