C端小程序
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

1055 Zeilen
26 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  2. const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
  3. let app = getApp();
  4. const format = require("../utils/util.js");
  5. let config = require("../config/config.js");
  6. let Http = require("../utils/HttpBasics");
  7. let Util = require("../utils/util");
  8. const imgurl = require("../utils/imgurl");
  9. Page({
  10. data: {
  11. navigationBarHeight,
  12. jianUrl: imgurl.jian.url,
  13. jianBlueUrl: imgurl.jianBlue.url,
  14. jiaofeiwm: imgurl.jiaofeiwm.url,
  15. parkUrl: imgurl.park.url,
  16. guanliHr: imgurl.guanliHr.url,
  17. qidaiUrl: imgurl.qidai.url,
  18. addUrl: imgurl.add.url,
  19. tingcheHr: imgurl.tingcheHr.url,
  20. cheUrl: imgurl.che.url,
  21. jiaofei: imgurl.jiaofei.url,
  22. wentiHr: imgurl.wentiHr.url,
  23. stopThat: imgurl.stopThat.url,
  24. park: null,
  25. carList: [],
  26. payList: [],
  27. addCar: null,
  28. tcq: 2,
  29. flag: "",
  30. extraData: {},
  31. desc: '',
  32. title: '',
  33. indicatorDots: true,
  34. autoplay: false,
  35. interval: 5000,
  36. duration: 1000,
  37. current: 0,
  38. stopFees: {},
  39. scroll: true,
  40. ifHaveCarModular: "",
  41. canIUse: wx.canIUse("navigator"),
  42. showTicketModal: false,
  43. ticketList: [],
  44. noCoupon: imgurl.noCoupon.url,
  45. loadingUrl: imgurl.loading.url,
  46. allow_load: true,
  47. curPageNum: 1,
  48. curPageSize: 15,
  49. curTotalpageNum: 0,
  50. quantitle: '',
  51. quanid: '',
  52. gouHr: imgurl.gouHr.url,
  53. totalTicketNum: 0,
  54. remark: '',
  55. generalPayPath: '',
  56. generalExtraData: {},
  57. goHomeUrl: "",
  58. supportPay: ""
  59. },
  60. getMoreList(e) {
  61. let totalNum = this.data.ticketList.length;
  62. if (this.data.curPageNum < this.data.curTotalpageNum) {
  63. this.setData({
  64. curPageNum: this.data.curPageNum + 1
  65. })
  66. this.getTicketList(0, this.data.curPageNum);
  67. }
  68. },
  69. /**
  70. * 选择使用的优惠券
  71. */
  72. choicecoupon: function (e) {
  73. var that = this;
  74. wx.showModal({
  75. title: '确定是否使用停车券',
  76. content: '使用后无法撤销',
  77. success(res) {
  78. if (res.confirm) {
  79. var quantitle = e.currentTarget.dataset.title;
  80. var quanid = e.currentTarget.dataset.id;
  81. that.setData({
  82. quanid: quanid,
  83. showTicketModal: false,
  84. });
  85. that.bindCoupon(that.data.quanid, quantitle);
  86. } else if (res.cancel) {
  87. console.log('用户点击取消')
  88. }
  89. }
  90. })
  91. },
  92. /*
  93. */
  94. getTicketList(key, pageNum) {
  95. var that = this;
  96. if (that.data.allow_load) {
  97. wx.showLoading({
  98. title: "加载中"
  99. });
  100. Http.get({
  101. url: config.api.couponOrderCarList,
  102. data: {
  103. pageNum: pageNum,
  104. pageSize: 15,
  105. couponOrderStatus: key
  106. }
  107. }).then(res => {
  108. that.setData({
  109. curTotalpageNum: res.data.pages,
  110. curPageNum: res.data.pageNum,
  111. totalTicketNum: res.data.total
  112. })
  113. res.data.list.map(file => {
  114. file.expiredTime = format.formatTime(
  115. file.expiredTime,
  116. "yyyy-MM-dd hh:mm:ss"
  117. );
  118. });
  119. setTimeout(function () {
  120. wx.hideLoading();
  121. }, 1200);
  122. if (pageNum >= res.data.pages) {
  123. that.setData({
  124. allow_load: false
  125. });
  126. }
  127. /**
  128. * 先赋值后渲染页面
  129. * concat 不会改变原数组值
  130. * push 会改变原数组值,但不会一条一条插入,而是整个数组插入
  131. */
  132. if (pageNum == 1) {
  133. that.setData({
  134. ticketList: res.data.list,
  135. curPageNum: pageNum
  136. });
  137. } else {
  138. that.setData({
  139. ticketList: that.data.ticketList.concat(res.data.list)
  140. });
  141. }
  142. // that.data.ticketList = that.data.ticketList.concat(res.data.list);
  143. wx.hideLoading();
  144. })
  145. .catch(err => {
  146. setTimeout(function () {
  147. wx.hideLoading();
  148. }, 1200);
  149. wx.showToast({
  150. title: err.errMsg,
  151. icon: 'none',
  152. duration: 2000,
  153. mask: false
  154. });
  155. })
  156. } else { }
  157. },
  158. //点击跳转到券详情页面
  159. gotouse: function (e) {
  160. wx.navigateTo({
  161. url: `/pages/passCar/couponDetail/couponDetail?quancode=${e.currentTarget.dataset.quancode
  162. }`,
  163. success: function (res) {
  164. // success
  165. },
  166. fail: function () {
  167. // fail
  168. },
  169. complete: function () {
  170. // complete
  171. }
  172. });
  173. },
  174. /**
  175. * 车牌轮播滑动
  176. */
  177. onSlideChangeEnd: function (e) {
  178. var that = this;
  179. /**
  180. * 获得当前的车牌号码
  181. */
  182. var listCardNum = (that.data.carList)[e.detail.current].carNumber;
  183. that.setData({
  184. listCardNum: listCardNum
  185. });
  186. /**
  187. * 获得停车费用
  188. */
  189. if (that.data.scroll) {
  190. that.getStopFee(listCardNum);
  191. }
  192. },
  193. callPay(data) {
  194. wx.requestPayment({
  195. timeStamp: data.timeStamp,
  196. nonceStr: data.nonceStr,
  197. package: data.package,
  198. signType: data.signType ? data.signType : "MD5",
  199. paySign: data.paySign,
  200. success: res => {
  201. wx.showLoading({
  202. title: '订单正在处理中...',
  203. })
  204. this.showList()
  205. },
  206. fail: res => {
  207. wx.hideLoading();
  208. wx.showToast({
  209. title: '支付失败',
  210. icon: 'error'
  211. })
  212. /**
  213. * 支付失败,需要更新订单的状态
  214. */
  215. },
  216. complete: res => { }
  217. });
  218. },
  219. //停车费用为0
  220. paySuccess: function () {
  221. wx.showModal({
  222. title: '支付成功',
  223. content: '请15分钟内离场',
  224. showCancel: false
  225. })
  226. },
  227. // supportPay等于1时
  228. goToPay() {
  229. Http.post({
  230. url: '/car/createPayOrder',
  231. data: {
  232. carNumber: this.data.listCardNum,
  233. carFee: String(this.data.stopFees.remainingFee * 100)
  234. }
  235. }).then(res => {
  236. console.log(res, 'res');
  237. const data = res.data.data
  238. this.callPay(data)
  239. }).catch(err => {
  240. console.log(err, 'err');
  241. wx.showToast({
  242. title: err.message,
  243. icon: 'none',
  244. mask: true
  245. })
  246. })
  247. },
  248. gotomange: function () {
  249. wx.navigateTo({
  250. url: '/pages/managelicenseplate/managelicenseplate',
  251. })
  252. },
  253. bindfail: function (res) {
  254. console.log(123)
  255. console.log(res)
  256. },
  257. gotoCarMini: function (e) {
  258. console.log(478)
  259. var that = this
  260. // etcp parkVendor1
  261. // 泊链停车 parkVendor5
  262. if (e.target.dataset.flag == 'parkVendor1') {
  263. wx.navigateToMiniProgram({
  264. appId: that.data.etcpAppId,
  265. extraData: that.data.extraData,
  266. envVersion: that.data.carMiniVersion,
  267. path: that.data.payPath
  268. })
  269. } else if (e.target.dataset.flag == 'parkVendor5') {
  270. wx.navigateToMiniProgram({
  271. appId: that.data.bolinkAppId,
  272. extraData: that.data.extraData,
  273. envVersion: that.data.carMiniVersion,
  274. path: that.data.payPath
  275. })
  276. }
  277. },
  278. showquan: function () {
  279. wx.navigateTo({
  280. url: '/pages/passCar/couponList/couponList',
  281. })
  282. },
  283. showList: function () {
  284. wx.navigateTo({
  285. url: '/pages/passCar/showList/showList',
  286. })
  287. },
  288. gotodetail: function (e) {
  289. wx.showModal({
  290. title: '缴费规则',
  291. content: e.target.dataset.rule,
  292. showCancel: false,
  293. })
  294. },
  295. onShow: function (options) {
  296. var that = this;
  297. Http.get({
  298. url: config.api.checkPhoneStatus,
  299. data: {}
  300. }).then(res => {
  301. this.setData({
  302. goHomeUrl: app.globalData.goHomeUrl
  303. })
  304. if (typeof this.getTabBar === 'function' &&
  305. this.getTabBar()) {
  306. this.getTabBar().setData({
  307. selected: 2
  308. })
  309. }
  310. that.setData({
  311. etcpAppId: extConfig.attr.car.etcp.etcpAppId,
  312. carMiniVersion: extConfig.attr.car.version,
  313. etcpCallbackUrl: extConfig.attr.car.etcp.etcpCallbackUrl,
  314. payPath: extConfig.attr.car.etcp.payPath,
  315. ifHaveCarModular: extConfig.attr.ifHaveCarModular
  316. })
  317. console.log(this.data.ifHaveCarModular, 'ifHaveCarModular');
  318. if (app.globalData.token) {
  319. that.getList();
  320. that.init();
  321. } else {
  322. that.init();
  323. }
  324. /**
  325. * 只有用户选择了优惠券
  326. * 才会进行券和车牌的绑定
  327. */
  328. /* if (wx.getStorageSync("chosed") && that.data.quanid) {
  329. that.getStopFee(that.data.listCardNum);
  330. that.bindCoupon(that.data.quanid);
  331. wx.setStorage({
  332. key: 'chosed',
  333. data: '',
  334. })
  335. }; */
  336. if (app.globalData.token) {
  337. // that.initUsrCarList();
  338. that.initUsrCarList("flags");
  339. that.setData({
  340. current: 0
  341. })
  342. }
  343. if (that.data.addCar) {
  344. // 绑车牌
  345. if (app.globalData.carLogin) {
  346. that.bindCar(that.data.addCar);
  347. } else {
  348. that.bindCar(that.data.addCar);
  349. }
  350. that.setData({
  351. addCar: null
  352. });
  353. }
  354. this.getTicketList(0, 1);
  355. }).catch(err => {
  356. that.init();
  357. })
  358. },
  359. cancelMove: function () {
  360. console.log(111)
  361. return false;
  362. },
  363. onHide: function () {
  364. this.setData({
  365. allow_load: true,
  366. showTicketModal: false,
  367. curPageNum: 1,
  368. ticketList: []
  369. })
  370. },
  371. onLoad: function (options) {
  372. var that = this;
  373. Http.get({
  374. url: config.api.checkPhoneStatus,
  375. data: {}
  376. }).then(res => {
  377. /**
  378. * 获得分享小程序的
  379. * title
  380. * desc
  381. */
  382. Http.get({
  383. url: config.api.getWeapNote,
  384. data: {
  385. appId: config.weapp.AppId,
  386. }
  387. })
  388. .then(res => {
  389. let weapNote = JSON.parse(res.data.weapNote);
  390. that.setData({
  391. desc: weapNote.carpage.desc,
  392. title: weapNote.carpage.title
  393. })
  394. })
  395. .catch(err => {
  396. console.log(err);
  397. })
  398. // 登录
  399. var scene = decodeURIComponent(options.scene);
  400. that.setData({
  401. scene: scene
  402. });
  403. if (app.globalData.token) { } else {
  404. // app.getLocation();
  405. that.userLogin()
  406. }
  407. }).catch(err => {
  408. return
  409. })
  410. },
  411. /**
  412. * 用户登录
  413. */
  414. userLogin: function () {
  415. var that = this;
  416. // 登录
  417. wx.login({
  418. success: ({
  419. code
  420. }) => {
  421. wx.getSystemInfo({
  422. success: function (res) {
  423. that.setData({
  424. systemInfo: JSON.stringify(res)
  425. })
  426. }
  427. })
  428. var usrdata = {
  429. appId: config.weapp.AppId,
  430. code: code,
  431. sceneAddress: app.globalData.sceneAddress,
  432. scene: that.data.scene,
  433. systemInfo: that.data.systemInfo
  434. };
  435. if (app.globalData.locationInfo) {
  436. usrdata = {
  437. appId: config.weapp.AppId,
  438. code: code,
  439. sceneAddress: app.globalData.sceneAddress,
  440. latitude: "" + app.globalData.locationInfo.latitude,
  441. longitude: "" + app.globalData.locationInfo.longitude,
  442. scene: that.data.scene,
  443. systemInfo: that.data.systemInfo
  444. };
  445. }
  446. Http.post({
  447. url: config.api.login,
  448. data: usrdata
  449. })
  450. .then(res => {
  451. app.globalData.token = res.data.token;
  452. Http.setToken(res.data.token);
  453. that.checkUserCarStatus();
  454. that.getList();
  455. that.init();
  456. that.initUsrCarList();
  457. return Http.get({
  458. url: config.api.checkUserStatus,
  459. data: {}
  460. });
  461. })
  462. .then(res => { })
  463. .catch(err => {
  464. if (err.code == 11004) {
  465. // 用户昵称未授权
  466. wx.redirectTo({
  467. url: "/pages/getuserinfo/index"
  468. });
  469. } else {
  470. wx.showModal({
  471. title: '提示',
  472. content: err.errMsg,
  473. showCancel: false
  474. })
  475. }
  476. });
  477. }
  478. });
  479. },
  480. /**
  481. * 检查用户是否有车
  482. */
  483. checkUserCarStatus: function () {
  484. var that = this;
  485. Http.get({
  486. url: config.api.userCarCount,
  487. data: {}
  488. }).then(res => {
  489. if (res.data > 0) {
  490. // 用户名下有车
  491. app.globalData.phone = res.data.phone;
  492. app.globalData.supportCar = true;
  493. // 共同登录
  494. that.userCarLogin();
  495. }
  496. })
  497. .catch(err => { })
  498. },
  499. jumpToAdd: function () {
  500. Http.get({
  501. url: config.api.checkPhoneStatus,
  502. data: {}
  503. }).then(res => {
  504. wx.navigateTo({
  505. url: `/pages/addPark/addPark?flags=managepalte`
  506. });
  507. }).catch(err => {
  508. wx.navigateTo({
  509. url: `/pages/getphoneInfo/index?mineFlag=passCar`,
  510. })
  511. })
  512. },
  513. passc: function () {
  514. wx.navigateTo({
  515. url: '/pages/ques/ques',
  516. })
  517. },
  518. goExplain: function () {
  519. wx.navigateTo({
  520. url: '/pages/tcExplain/tcExplain',
  521. })
  522. },
  523. /**
  524. * 券绑定车牌
  525. */
  526. bindCoupon: function (quanid, quantitle) {
  527. wx.showLoading({
  528. title: '使用中...',
  529. })
  530. var that = this;
  531. /**
  532. * etcp
  533. */
  534. var postCouponData = {
  535. etcpToken: app.globalData.etcpToken,
  536. carNumber: that.data.listCardNum,
  537. couponOrderId: quanid
  538. };
  539. if (app.globalData.parkVendor == 2) {
  540. // 停简单
  541. postCouponData = {
  542. carNumber: that.data.listCardNum
  543. }
  544. }
  545. if (app.globalData.parkVendor == 4) {
  546. // 尚安
  547. postCouponData = {
  548. carNumber: that.data.listCardNum,
  549. couponOrderId: quanid
  550. }
  551. }
  552. if (app.globalData.parkVendor == 5) {
  553. // 泊链
  554. postCouponData = {
  555. carNumber: that.data.listCardNum,
  556. orderId: that.data.bolinkOrderId,
  557. couponOrderId: quanid
  558. }
  559. }
  560. if (app.globalData.parkVendor >= 6) {
  561. console.log(123456789)
  562. postCouponData = {
  563. carNumber: that.data.listCardNum,
  564. // orderId: that.data.bolinkOrderId,
  565. couponOrderId: quanid,
  566. parkOrderId: that.data.stopFees.orderId
  567. }
  568. }
  569. Http.post({
  570. url: config.api.getCarCoupon,
  571. data: postCouponData
  572. })
  573. .then(res => {
  574. wx.hideLoading()
  575. // if(res.data){
  576. that.getStopFee(that.data.listCardNum);
  577. that.initUsrCarList();
  578. that.setData({
  579. quantitle: quantitle, //接口条用成功后在赋值
  580. })
  581. // }else{
  582. // wx.showToast({
  583. // title: res.message,
  584. // icon: 'none',
  585. // duration: 3000,
  586. // mask: false
  587. // });
  588. // }
  589. })
  590. .catch(err => {
  591. wx.hideLoading()
  592. if (err.message != undefined) {
  593. wx.showToast({
  594. title: err.message,
  595. icon: 'none',
  596. duration: 3000,
  597. mask: false
  598. });
  599. }
  600. })
  601. },
  602. /**
  603. * 选择优惠券
  604. */
  605. // gotoquan: function () {
  606. // let that = this;
  607. // if (that.data.quanid) {
  608. // wx.navigateTo({
  609. // url: `/pages/passCar/choicecoupon/choicecoupon?quanid=${that.data.quanid}`,
  610. // })
  611. // } else {
  612. // wx.navigateTo({
  613. // url: '/pages/passCar/choicecoupon/choicecoupon',
  614. // })
  615. // }
  616. // },
  617. closeTicketModal: function () {
  618. this.setData({
  619. showTicketModal: false
  620. })
  621. },
  622. /**
  623. * 停车券 弹框
  624. */
  625. openTicketModal: function () {
  626. this.setData({
  627. showTicketModal: true,
  628. allow_load: true,
  629. ticketList: [],
  630. curPageNum: 1,
  631. })
  632. this.getTicketList(0, 1);
  633. /* if (!this.data.ticketList.length){
  634. this.getTicketList(0, 1);
  635. } */
  636. },
  637. //获取名下停车券列表
  638. getList() {
  639. var that = this;
  640. Http.get({
  641. url: config.api.couponOrderCarList + "?type=5&couponOrderStatus=0",
  642. data: {
  643. pageNum: 1,
  644. pageSize: 15,
  645. couponOrderStatus: 0
  646. }
  647. }).then(res => {
  648. that.setData({
  649. couponList: res.data.list
  650. });
  651. })
  652. .catch(err => {
  653. console.log(err)
  654. })
  655. },
  656. /**
  657. * 共同登录
  658. */
  659. init: function (carNumber) {
  660. var that = this;
  661. app.parkInitCallback = token => {
  662. that.initPark();
  663. that.getParkStatus();
  664. if (!app.globalData.carLogin) {
  665. Http.get({
  666. url: config.api.checkUserStatus,
  667. data: {}
  668. }).then(res => {
  669. app.globalData.type = 'pc'
  670. /**
  671. * 判断是否授权手机号
  672. */
  673. Http.get({
  674. url: config.api.checkPhoneStatus,
  675. data: {}
  676. })
  677. .then(res => {
  678. Http.post({
  679. url: config.api.carInit,
  680. data: {
  681. phone: app.globalData.phone
  682. }
  683. }).then(res => {
  684. app.globalData.carLogin = true;
  685. app.globalData.parkVendor = res.data.vendor;
  686. if (res.data.token) {
  687. app.globalData.etcpToken = res.data.token;
  688. }
  689. if (res.data.supportPay && res.data.supportPay == 1) {
  690. that.setData({
  691. supportPay: 1
  692. })
  693. } else {
  694. that.setData({
  695. supportPay: 0
  696. })
  697. }
  698. /**
  699. * 获得停车费用
  700. */
  701. that.initUsrCarList("flags");
  702. });
  703. })
  704. .catch(err => {
  705. if (err.code == 11005) {
  706. // 用户手机未授权
  707. /**
  708. * 将值传到用户手机号授权的页面
  709. *
  710. */
  711. wx.redirectTo({
  712. url: "/pages/getphoneInfo/index"
  713. });
  714. } else if (err.code == 11006) {
  715. // 用户手机已加密
  716. wx.redirectTo({
  717. url: "/pages/phoneinput/phoneinput"
  718. });
  719. } else {
  720. wx.showToast({
  721. title: err.errMsg,
  722. icon: 'none',
  723. duration: 2000,
  724. mask: false
  725. });
  726. }
  727. })
  728. }).catch(err => {
  729. app.globalData.type = 'pc'
  730. if (err.code == 11004) {
  731. // 用户昵称未授权
  732. wx.redirectTo({
  733. url: "/pages/getuserinfo/index"
  734. });
  735. } else {
  736. wx.showModal({
  737. title: '提示',
  738. content: err.errMsg,
  739. showCancel: false
  740. })
  741. }
  742. });
  743. }
  744. };
  745. if (app.globalData.token && app.globalData.token != null) {
  746. app.parkInitCallback(app.globalData.token);
  747. }
  748. },
  749. bindCar: function (carNum) {
  750. var that = this;
  751. // ETCP
  752. var etcpData = {
  753. etcpToken: app.globalData.etcpToken,
  754. carNumber: carNum
  755. };
  756. var otherData = {
  757. carNumber: carNum
  758. };
  759. var postData = app.globalData.parkVendor == 1 ? etcpData : otherData;
  760. Http.post({
  761. url: config.api.bindCar,
  762. data: postData
  763. })
  764. .then(res => {
  765. that.setData({
  766. addCar: null
  767. });
  768. that.initUsrCarList();
  769. wx.showModal({
  770. title: "提示",
  771. showCancel: false,
  772. content: "绑车牌成功!",
  773. success: function () { }
  774. });
  775. })
  776. .catch(error => {
  777. wx.showModal({
  778. title: "提示",
  779. showCancel: false,
  780. content: error.data.message,
  781. success: function () { }
  782. });
  783. });
  784. },
  785. /**
  786. * 车场信息获取
  787. */
  788. initPark: function () {
  789. var that = this;
  790. Http.get({
  791. url: config.api.getParkInfo,
  792. data: {}
  793. })
  794. .then(res => {
  795. that.setData({
  796. park: res.data
  797. })
  798. if (res.data) {
  799. app.globalData.parkVendor = res.data.vendorType;
  800. if (app.globalData.parkVendor == 1) {
  801. console.log("payPath: " + extConfig.attr.car.etcp.payPath)
  802. // etcp
  803. that.setData({
  804. parkVendor: app.globalData.parkVendor,
  805. etcpAppId: extConfig.attr.car.etcp.etcpAppId,
  806. carMiniVersion: extConfig.attr.car.version,
  807. etcpCallbackUrl: extConfig.attr.car.etcp.etcpCallbackUrl,
  808. payPath: extConfig.attr.car.etcp.payPath
  809. })
  810. } else if (app.globalData.parkVendor == 2) {
  811. // TJD
  812. var vendorObj = JSON.parse(res.data.vendorParams)
  813. that.setData({
  814. parkVendor: app.globalData.parkVendor,
  815. tjdAppId: extConfig.attr.car.tjd.tjdAppId,
  816. carMiniVersion: extConfig.attr.car.version,
  817. payPath: extConfig.attr.car.tjd.payPath
  818. })
  819. } else if (app.globalData.parkVendor == 5) {
  820. // 泊链
  821. var vendorObj = JSON.parse(res.data.vendorParams)
  822. console.log("payPath: " + extConfig.attr.car.bolink.payPath)
  823. that.setData({
  824. parkVendor: app.globalData.parkVendor,
  825. bolinkAppId: extConfig.attr.car.bolink.bolinkAppId,
  826. carMiniVersion: extConfig.attr.car.version,
  827. payPath: extConfig.attr.car.bolink.payPath,
  828. bolinkComId: vendorObj.comid,
  829. bolinkUnionId: vendorObj.union_id
  830. })
  831. }
  832. }
  833. })
  834. .catch(err => {
  835. console.log(err);
  836. // wx.showToast({
  837. // title: err.message,
  838. // icon: 'none',
  839. // duration: 2000,
  840. // mask: false
  841. // });
  842. })
  843. },
  844. /**
  845. * 车场状态获取
  846. */
  847. getParkStatus: function () {
  848. var that = this;
  849. Http.get({
  850. url: config.api.getParkStatus,
  851. })
  852. .then(res => {
  853. console.log(res)
  854. })
  855. .catch(err => {
  856. console.log(err)
  857. // wx.showToast({
  858. // title: err.message,
  859. // icon:"none"
  860. // })
  861. })
  862. },
  863. /**
  864. * 绑定车获取
  865. */
  866. initUsrCarList: function (flag) {
  867. var that = this;
  868. Http.get({
  869. url: config.api.getUserCarList,
  870. data: {}
  871. }).then(res => {
  872. that.setData({
  873. carList: res.data
  874. });
  875. /**
  876. * flag ==flags
  877. * 表示从首页onShow进来的
  878. */
  879. if (flag == "flags" && res.data.length > 0) {
  880. var listCardNum = res.data[0].carNumber;
  881. that.setData({
  882. listCardNum: listCardNum
  883. })
  884. /**
  885. * 获得停车费用
  886. */
  887. that.getStopFee(listCardNum);
  888. }
  889. })
  890. .catch(err => {
  891. wx.showToast({
  892. title: err.message,
  893. icon: 'none',
  894. duration: 2000,
  895. mask: false
  896. });
  897. })
  898. },
  899. /**
  900. * 获得停车费用修改
  901. */
  902. getStopFee: function (carNumber) {
  903. let that = this;
  904. let postData =
  905. app.globalData.parkVendor == 1 ? {
  906. etcpToken: app.globalData.etcpToken,
  907. carNumber: carNumber
  908. } : {
  909. carNumber: carNumber
  910. };
  911. Http.post({
  912. url: config.api.getCarStopFee,
  913. data: postData
  914. })
  915. .then(res => {
  916. console.log(res)
  917. if (app.globalData.parkVendor == 1) { // ETCP
  918. var extraDataStr = {
  919. params: {
  920. token: app.globalData.etcpToken,
  921. syncId: res.data.orderId,
  922. payType: 6, // 小程序支付
  923. CarNumber: carNumber,
  924. returnUrl: that.data.etcpCallbackUrl,
  925. source: "FUMAO-001",
  926. actionId: "1" //操作ID,1:小程序支付
  927. }
  928. }
  929. that.setData({
  930. parkVendor: app.globalData.parkVendor,
  931. extraData: extraDataStr,
  932. stopFees: res.data,
  933. timecha: Util.timecha(res.data.exitTime, res.data.entranceTime)
  934. });
  935. } else if (app.globalData.parkVendor == 2) { // TJD // TODO
  936. var extraDataStr = {
  937. prePayType: that.data.prePayType,
  938. channel: res.data.channel,
  939. isShowDetail: true,
  940. orderId: res.data.orderId
  941. }
  942. that.setData({
  943. parkVendor: app.globalData.parkVendor,
  944. extraData: extraDataStr,
  945. stopFees: {
  946. orderId: res.data.orderId,
  947. entranceTime: res.data.start_time,
  948. remainingFee: res.data.money
  949. },
  950. timecha: res.data.duration
  951. });
  952. } else if (app.globalData.parkVendor == 5) { // BoLink
  953. var extraDataStr = {
  954. union_id: that.data.bolinkUnionId,
  955. order_id: res.data.order_id,
  956. park_id: that.data.bolinkComId,
  957. plate_number: res.data.plate_number,
  958. money: res.data.money,
  959. park_name: res.data.park_name
  960. }
  961. that.setData({
  962. parkVendor: app.globalData.parkVendor,
  963. bolinkOrderId: res.data.order_id,
  964. extraData: extraDataStr,
  965. stopFees: {
  966. orderId: res.data.order_id,
  967. entranceTime: res.data.start_time,
  968. remainingFee: res.data.money
  969. },
  970. timecha: res.data.duration
  971. });
  972. } else { // *#06#
  973. // var extraDataStr = {
  974. // params: {
  975. // token: app.globalData.etcpToken,
  976. // syncId: res.data.orderId,
  977. // payType: 6, // 小程序支付
  978. // CarNumber: carNumber,
  979. // returnUrl: that.data.etcpCallbackUrl,
  980. // source: "FUMAO-001",
  981. // actionId: "1",//操作ID,1:小程序支付
  982. // },
  983. // }
  984. that.setData({
  985. parkVendor: app.globalData.parkVendor,
  986. // extraData: extraDataStr,
  987. stopFees: res.data,
  988. timecha: Util.timecha(res.data.exitTime, res.data.entranceTime),
  989. remark: res.data.remark,
  990. generalAppId: res.data.appId,
  991. generalPayPath: res.data.payPath,
  992. generalExtraData: res.data.extraData,
  993. extraDataFlag: JSON.stringify(res.data.extraData)
  994. });
  995. console.log(that.data.extraDataFlag, "123456789")
  996. }
  997. that.setData({
  998. scroll: true
  999. })
  1000. })
  1001. .catch(error => {
  1002. that.setData({
  1003. stopFees: {},
  1004. scroll: true
  1005. })
  1006. });
  1007. },
  1008. /**
  1009. * 下拉刷新
  1010. */
  1011. onPullDownRefresh: function (e) {
  1012. let that = this;
  1013. that.initUsrCarList("flags");
  1014. that.setData({
  1015. current: 0
  1016. })
  1017. wx.stopPullDownRefresh();
  1018. }
  1019. });