C端小程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

1104 satır
27 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. Http.get({
  250. url: config.api.checkPhoneStatus,
  251. data: {}
  252. }).then(res => {
  253. wx.navigateTo({
  254. url: '/pages/managelicenseplate/managelicenseplate',
  255. })
  256. }).catch(err => {
  257. wx.navigateTo({
  258. url: `/pages/getphoneInfo/index?mineFlag=passCar`,
  259. })
  260. })
  261. },
  262. bindfail: function (res) {
  263. console.log(123)
  264. console.log(res)
  265. },
  266. gotoCarMini: function (e) {
  267. console.log(478)
  268. var that = this
  269. // etcp parkVendor1
  270. // 泊链停车 parkVendor5
  271. if (e.target.dataset.flag == 'parkVendor1') {
  272. wx.navigateToMiniProgram({
  273. appId: that.data.etcpAppId,
  274. extraData: that.data.extraData,
  275. envVersion: that.data.carMiniVersion,
  276. path: that.data.payPath
  277. })
  278. } else if (e.target.dataset.flag == 'parkVendor5') {
  279. wx.navigateToMiniProgram({
  280. appId: that.data.bolinkAppId,
  281. extraData: that.data.extraData,
  282. envVersion: that.data.carMiniVersion,
  283. path: that.data.payPath
  284. })
  285. }
  286. },
  287. showquan: function () {
  288. Http.get({
  289. url: config.api.checkPhoneStatus,
  290. data: {}
  291. }).then(res => {
  292. wx.navigateTo({
  293. url: '/pages/passCar/couponList/couponList',
  294. })
  295. }).catch(err => {
  296. wx.navigateTo({
  297. url: `/pages/getphoneInfo/index?mineFlag=passCar`,
  298. })
  299. })
  300. },
  301. showList: function () {
  302. Http.get({
  303. url: config.api.checkPhoneStatus,
  304. data: {}
  305. }).then(res => {
  306. wx.navigateTo({
  307. url: '/pages/passCar/showList/showList',
  308. })
  309. }).catch(err => {
  310. wx.navigateTo({
  311. url: `/pages/getphoneInfo/index?mineFlag=passCar`,
  312. })
  313. })
  314. },
  315. gotodetail: function (e) {
  316. wx.showModal({
  317. title: '缴费规则',
  318. content: e.target.dataset.rule,
  319. showCancel: false,
  320. })
  321. },
  322. onShow: function (options) {
  323. var that = this;
  324. Http.get({
  325. url: config.api.checkPhoneStatus,
  326. data: {}
  327. }).then(res => {
  328. this.setData({
  329. goHomeUrl: app.globalData.goHomeUrl
  330. })
  331. if (typeof this.getTabBar === 'function' &&
  332. this.getTabBar()) {
  333. this.getTabBar().setData({
  334. selected: 2
  335. })
  336. }
  337. that.setData({
  338. etcpAppId: extConfig.attr.car.etcp.etcpAppId,
  339. carMiniVersion: extConfig.attr.car.version,
  340. etcpCallbackUrl: extConfig.attr.car.etcp.etcpCallbackUrl,
  341. payPath: extConfig.attr.car.etcp.payPath,
  342. ifHaveCarModular: extConfig.attr.ifHaveCarModular
  343. })
  344. console.log(this.data.ifHaveCarModular, 'ifHaveCarModular');
  345. if (app.globalData.token) {
  346. that.getList();
  347. that.init();
  348. } else {
  349. that.init();
  350. }
  351. /**
  352. * 只有用户选择了优惠券
  353. * 才会进行券和车牌的绑定
  354. */
  355. /* if (wx.getStorageSync("chosed") && that.data.quanid) {
  356. that.getStopFee(that.data.listCardNum);
  357. that.bindCoupon(that.data.quanid);
  358. wx.setStorage({
  359. key: 'chosed',
  360. data: '',
  361. })
  362. }; */
  363. if (app.globalData.token) {
  364. // that.initUsrCarList();
  365. that.initUsrCarList("flags");
  366. that.setData({
  367. current: 0
  368. })
  369. }
  370. if (that.data.addCar) {
  371. // 绑车牌
  372. if (app.globalData.carLogin) {
  373. that.bindCar(that.data.addCar);
  374. } else {
  375. that.bindCar(that.data.addCar);
  376. }
  377. that.setData({
  378. addCar: null
  379. });
  380. }
  381. this.getTicketList(0, 1);
  382. }).catch(err => {
  383. that.setData({
  384. etcpAppId: extConfig.attr.car.etcp.etcpAppId,
  385. carMiniVersion: extConfig.attr.car.version,
  386. etcpCallbackUrl: extConfig.attr.car.etcp.etcpCallbackUrl,
  387. payPath: extConfig.attr.car.etcp.payPath,
  388. ifHaveCarModular: extConfig.attr.ifHaveCarModular
  389. })
  390. that.initPark();
  391. that.getParkStatus();
  392. })
  393. },
  394. cancelMove: function () {
  395. console.log(111)
  396. return false;
  397. },
  398. onHide: function () {
  399. this.setData({
  400. allow_load: true,
  401. showTicketModal: false,
  402. curPageNum: 1,
  403. ticketList: []
  404. })
  405. },
  406. onLoad: function (options) {
  407. var that = this;
  408. Http.get({
  409. url: config.api.checkPhoneStatus,
  410. data: {}
  411. }).then(res => {
  412. /**
  413. * 获得分享小程序的
  414. * title
  415. * desc
  416. */
  417. Http.get({
  418. url: config.api.getWeapNote,
  419. data: {
  420. appId: config.weapp.AppId,
  421. }
  422. })
  423. .then(res => {
  424. let weapNote = JSON.parse(res.data.weapNote);
  425. that.setData({
  426. desc: weapNote.carpage.desc,
  427. title: weapNote.carpage.title
  428. })
  429. })
  430. .catch(err => {
  431. console.log(err);
  432. })
  433. // 登录
  434. var scene = decodeURIComponent(options.scene);
  435. that.setData({
  436. scene: scene
  437. });
  438. if (app.globalData.token) { } else {
  439. // app.getLocation();
  440. that.userLogin()
  441. }
  442. }).catch(err => {
  443. return
  444. })
  445. },
  446. /**
  447. * 用户登录
  448. */
  449. userLogin: function () {
  450. var that = this;
  451. // 登录
  452. wx.login({
  453. success: ({
  454. code
  455. }) => {
  456. wx.getSystemInfo({
  457. success: function (res) {
  458. that.setData({
  459. systemInfo: JSON.stringify(res)
  460. })
  461. }
  462. })
  463. var usrdata = {
  464. appId: config.weapp.AppId,
  465. code: code,
  466. sceneAddress: app.globalData.sceneAddress,
  467. scene: that.data.scene,
  468. systemInfo: that.data.systemInfo
  469. };
  470. if (app.globalData.locationInfo) {
  471. usrdata = {
  472. appId: config.weapp.AppId,
  473. code: code,
  474. sceneAddress: app.globalData.sceneAddress,
  475. latitude: "" + app.globalData.locationInfo.latitude,
  476. longitude: "" + app.globalData.locationInfo.longitude,
  477. scene: that.data.scene,
  478. systemInfo: that.data.systemInfo
  479. };
  480. }
  481. Http.post({
  482. url: config.api.login,
  483. data: usrdata
  484. })
  485. .then(res => {
  486. app.globalData.token = res.data.token;
  487. Http.setToken(res.data.token);
  488. that.checkUserCarStatus();
  489. that.getList();
  490. that.init();
  491. that.initUsrCarList();
  492. return Http.get({
  493. url: config.api.checkUserStatus,
  494. data: {}
  495. });
  496. })
  497. .then(res => { })
  498. .catch(err => {
  499. if (err.code == 11004) {
  500. // 用户昵称未授权
  501. wx.redirectTo({
  502. url: "/pages/getuserinfo/index"
  503. });
  504. } else {
  505. wx.showModal({
  506. title: '提示',
  507. content: err.errMsg,
  508. showCancel: false
  509. })
  510. }
  511. });
  512. }
  513. });
  514. },
  515. /**
  516. * 检查用户是否有车
  517. */
  518. checkUserCarStatus: function () {
  519. var that = this;
  520. Http.get({
  521. url: config.api.userCarCount,
  522. data: {}
  523. }).then(res => {
  524. if (res.data > 0) {
  525. // 用户名下有车
  526. app.globalData.phone = res.data.phone;
  527. app.globalData.supportCar = true;
  528. // 共同登录
  529. that.userCarLogin();
  530. }
  531. })
  532. .catch(err => { })
  533. },
  534. jumpToAdd: function () {
  535. Http.get({
  536. url: config.api.checkPhoneStatus,
  537. data: {}
  538. }).then(res => {
  539. wx.navigateTo({
  540. url: `/pages/addPark/addPark?flags=managepalte`
  541. });
  542. }).catch(err => {
  543. wx.showModal({
  544. title: '提示',
  545. content: '登陆后方可添加车牌,现在登录?',
  546. showCancel: true,
  547. complete: (res) => {
  548. if (res.cancel) {
  549. return
  550. }
  551. if (res.confirm) {
  552. wx.navigateTo({
  553. url: `/pages/getphoneInfo/index?mineFlag=passCar`,
  554. })
  555. }
  556. }
  557. })
  558. })
  559. },
  560. passc: function () {
  561. wx.navigateTo({
  562. url: '/pages/ques/ques',
  563. })
  564. },
  565. goExplain: function () {
  566. wx.navigateTo({
  567. url: '/pages/tcExplain/tcExplain',
  568. })
  569. },
  570. /**
  571. * 券绑定车牌
  572. */
  573. bindCoupon: function (quanid, quantitle) {
  574. wx.showLoading({
  575. title: '使用中...',
  576. })
  577. var that = this;
  578. /**
  579. * etcp
  580. */
  581. var postCouponData = {
  582. etcpToken: app.globalData.etcpToken,
  583. carNumber: that.data.listCardNum,
  584. couponOrderId: quanid
  585. };
  586. if (app.globalData.parkVendor == 2) {
  587. // 停简单
  588. postCouponData = {
  589. carNumber: that.data.listCardNum
  590. }
  591. }
  592. if (app.globalData.parkVendor == 4) {
  593. // 尚安
  594. postCouponData = {
  595. carNumber: that.data.listCardNum,
  596. couponOrderId: quanid
  597. }
  598. }
  599. if (app.globalData.parkVendor == 5) {
  600. // 泊链
  601. postCouponData = {
  602. carNumber: that.data.listCardNum,
  603. orderId: that.data.bolinkOrderId,
  604. couponOrderId: quanid
  605. }
  606. }
  607. if (app.globalData.parkVendor >= 6) {
  608. console.log(123456789)
  609. postCouponData = {
  610. carNumber: that.data.listCardNum,
  611. // orderId: that.data.bolinkOrderId,
  612. couponOrderId: quanid,
  613. parkOrderId: that.data.stopFees.orderId
  614. }
  615. }
  616. Http.post({
  617. url: config.api.getCarCoupon,
  618. data: postCouponData
  619. })
  620. .then(res => {
  621. wx.hideLoading()
  622. // if(res.data){
  623. that.getStopFee(that.data.listCardNum);
  624. that.initUsrCarList();
  625. that.setData({
  626. quantitle: quantitle, //接口条用成功后在赋值
  627. })
  628. // }else{
  629. // wx.showToast({
  630. // title: res.message,
  631. // icon: 'none',
  632. // duration: 3000,
  633. // mask: false
  634. // });
  635. // }
  636. })
  637. .catch(err => {
  638. wx.hideLoading()
  639. if (err.message != undefined) {
  640. wx.showToast({
  641. title: err.message,
  642. icon: 'none',
  643. duration: 3000,
  644. mask: false
  645. });
  646. }
  647. })
  648. },
  649. /**
  650. * 选择优惠券
  651. */
  652. // gotoquan: function () {
  653. // let that = this;
  654. // if (that.data.quanid) {
  655. // wx.navigateTo({
  656. // url: `/pages/passCar/choicecoupon/choicecoupon?quanid=${that.data.quanid}`,
  657. // })
  658. // } else {
  659. // wx.navigateTo({
  660. // url: '/pages/passCar/choicecoupon/choicecoupon',
  661. // })
  662. // }
  663. // },
  664. closeTicketModal: function () {
  665. this.setData({
  666. showTicketModal: false
  667. })
  668. },
  669. /**
  670. * 停车券 弹框
  671. */
  672. openTicketModal: function () {
  673. this.setData({
  674. showTicketModal: true,
  675. allow_load: true,
  676. ticketList: [],
  677. curPageNum: 1,
  678. })
  679. this.getTicketList(0, 1);
  680. /* if (!this.data.ticketList.length){
  681. this.getTicketList(0, 1);
  682. } */
  683. },
  684. //获取名下停车券列表
  685. getList() {
  686. var that = this;
  687. Http.get({
  688. url: config.api.couponOrderCarList + "?type=5&couponOrderStatus=0",
  689. data: {
  690. pageNum: 1,
  691. pageSize: 15,
  692. couponOrderStatus: 0
  693. }
  694. }).then(res => {
  695. that.setData({
  696. couponList: res.data.list
  697. });
  698. })
  699. .catch(err => {
  700. console.log(err)
  701. })
  702. },
  703. /**
  704. * 共同登录
  705. */
  706. init: function (carNumber) {
  707. var that = this;
  708. app.parkInitCallback = token => {
  709. that.initPark();
  710. that.getParkStatus();
  711. if (!app.globalData.carLogin) {
  712. Http.get({
  713. url: config.api.checkUserStatus,
  714. data: {}
  715. }).then(res => {
  716. app.globalData.type = 'pc'
  717. /**
  718. * 判断是否授权手机号
  719. */
  720. Http.get({
  721. url: config.api.checkPhoneStatus,
  722. data: {}
  723. })
  724. .then(res => {
  725. Http.post({
  726. url: config.api.carInit,
  727. data: {
  728. phone: app.globalData.phone
  729. }
  730. }).then(res => {
  731. app.globalData.carLogin = true;
  732. app.globalData.parkVendor = res.data.vendor;
  733. if (res.data.token) {
  734. app.globalData.etcpToken = res.data.token;
  735. }
  736. if (res.data.supportPay && res.data.supportPay == 1) {
  737. that.setData({
  738. supportPay: 1
  739. })
  740. } else {
  741. that.setData({
  742. supportPay: 0
  743. })
  744. }
  745. /**
  746. * 获得停车费用
  747. */
  748. that.initUsrCarList("flags");
  749. });
  750. })
  751. .catch(err => {
  752. if (err.code == 11005) {
  753. // 用户手机未授权
  754. /**
  755. * 将值传到用户手机号授权的页面
  756. *
  757. */
  758. wx.redirectTo({
  759. url: "/pages/getphoneInfo/index"
  760. });
  761. } else if (err.code == 11006) {
  762. // 用户手机已加密
  763. wx.redirectTo({
  764. url: "/pages/phoneinput/phoneinput"
  765. });
  766. } else {
  767. wx.showToast({
  768. title: err.errMsg,
  769. icon: 'none',
  770. duration: 2000,
  771. mask: false
  772. });
  773. }
  774. })
  775. }).catch(err => {
  776. app.globalData.type = 'pc'
  777. if (err.code == 11004) {
  778. // 用户昵称未授权
  779. wx.redirectTo({
  780. url: "/pages/getuserinfo/index"
  781. });
  782. } else {
  783. wx.showModal({
  784. title: '提示',
  785. content: err.errMsg,
  786. showCancel: false
  787. })
  788. }
  789. });
  790. }
  791. };
  792. if (app.globalData.token && app.globalData.token != null) {
  793. app.parkInitCallback(app.globalData.token);
  794. }
  795. },
  796. bindCar: function (carNum) {
  797. var that = this;
  798. // ETCP
  799. var etcpData = {
  800. etcpToken: app.globalData.etcpToken,
  801. carNumber: carNum
  802. };
  803. var otherData = {
  804. carNumber: carNum
  805. };
  806. var postData = app.globalData.parkVendor == 1 ? etcpData : otherData;
  807. Http.post({
  808. url: config.api.bindCar,
  809. data: postData
  810. })
  811. .then(res => {
  812. that.setData({
  813. addCar: null
  814. });
  815. that.initUsrCarList();
  816. wx.showModal({
  817. title: "提示",
  818. showCancel: false,
  819. content: "绑车牌成功!",
  820. success: function () { }
  821. });
  822. })
  823. .catch(error => {
  824. wx.showModal({
  825. title: "提示",
  826. showCancel: false,
  827. content: error.data.message,
  828. success: function () { }
  829. });
  830. });
  831. },
  832. /**
  833. * 车场信息获取
  834. */
  835. initPark: function () {
  836. var that = this;
  837. Http.get({
  838. url: config.api.getParkInfo,
  839. data: {}
  840. })
  841. .then(res => {
  842. that.setData({
  843. park: res.data
  844. })
  845. if (res.data) {
  846. app.globalData.parkVendor = res.data.vendorType;
  847. if (app.globalData.parkVendor == 1) {
  848. console.log("payPath: " + extConfig.attr.car.etcp.payPath)
  849. // etcp
  850. that.setData({
  851. parkVendor: app.globalData.parkVendor,
  852. etcpAppId: extConfig.attr.car.etcp.etcpAppId,
  853. carMiniVersion: extConfig.attr.car.version,
  854. etcpCallbackUrl: extConfig.attr.car.etcp.etcpCallbackUrl,
  855. payPath: extConfig.attr.car.etcp.payPath
  856. })
  857. } else if (app.globalData.parkVendor == 2) {
  858. // TJD
  859. var vendorObj = JSON.parse(res.data.vendorParams)
  860. that.setData({
  861. parkVendor: app.globalData.parkVendor,
  862. tjdAppId: extConfig.attr.car.tjd.tjdAppId,
  863. carMiniVersion: extConfig.attr.car.version,
  864. payPath: extConfig.attr.car.tjd.payPath
  865. })
  866. } else if (app.globalData.parkVendor == 5) {
  867. // 泊链
  868. var vendorObj = JSON.parse(res.data.vendorParams)
  869. console.log("payPath: " + extConfig.attr.car.bolink.payPath)
  870. that.setData({
  871. parkVendor: app.globalData.parkVendor,
  872. bolinkAppId: extConfig.attr.car.bolink.bolinkAppId,
  873. carMiniVersion: extConfig.attr.car.version,
  874. payPath: extConfig.attr.car.bolink.payPath,
  875. bolinkComId: vendorObj.comid,
  876. bolinkUnionId: vendorObj.union_id
  877. })
  878. }
  879. }
  880. })
  881. .catch(err => {
  882. console.log(err);
  883. // wx.showToast({
  884. // title: err.message,
  885. // icon: 'none',
  886. // duration: 2000,
  887. // mask: false
  888. // });
  889. })
  890. },
  891. /**
  892. * 车场状态获取
  893. */
  894. getParkStatus: function () {
  895. var that = this;
  896. Http.get({
  897. url: config.api.getParkStatus,
  898. })
  899. .then(res => {
  900. console.log(res)
  901. })
  902. .catch(err => {
  903. console.log(err)
  904. // wx.showToast({
  905. // title: err.message,
  906. // icon:"none"
  907. // })
  908. })
  909. },
  910. /**
  911. * 绑定车获取
  912. */
  913. initUsrCarList: function (flag) {
  914. var that = this;
  915. Http.get({
  916. url: config.api.getUserCarList,
  917. data: {}
  918. }).then(res => {
  919. that.setData({
  920. carList: res.data
  921. });
  922. /**
  923. * flag ==flags
  924. * 表示从首页onShow进来的
  925. */
  926. if (flag == "flags" && res.data.length > 0) {
  927. var listCardNum = res.data[0].carNumber;
  928. that.setData({
  929. listCardNum: listCardNum
  930. })
  931. /**
  932. * 获得停车费用
  933. */
  934. that.getStopFee(listCardNum);
  935. }
  936. })
  937. .catch(err => {
  938. wx.showToast({
  939. title: err.message,
  940. icon: 'none',
  941. duration: 2000,
  942. mask: false
  943. });
  944. })
  945. },
  946. /**
  947. * 获得停车费用修改
  948. */
  949. getStopFee: function (carNumber) {
  950. let that = this;
  951. let postData =
  952. app.globalData.parkVendor == 1 ? {
  953. etcpToken: app.globalData.etcpToken,
  954. carNumber: carNumber
  955. } : {
  956. carNumber: carNumber
  957. };
  958. Http.post({
  959. url: config.api.getCarStopFee,
  960. data: postData
  961. })
  962. .then(res => {
  963. console.log(res)
  964. if (app.globalData.parkVendor == 1) { // ETCP
  965. var extraDataStr = {
  966. params: {
  967. token: app.globalData.etcpToken,
  968. syncId: res.data.orderId,
  969. payType: 6, // 小程序支付
  970. CarNumber: carNumber,
  971. returnUrl: that.data.etcpCallbackUrl,
  972. source: "FUMAO-001",
  973. actionId: "1" //操作ID,1:小程序支付
  974. }
  975. }
  976. that.setData({
  977. parkVendor: app.globalData.parkVendor,
  978. extraData: extraDataStr,
  979. stopFees: res.data,
  980. timecha: Util.timecha(res.data.exitTime, res.data.entranceTime)
  981. });
  982. } else if (app.globalData.parkVendor == 2) { // TJD // TODO
  983. var extraDataStr = {
  984. prePayType: that.data.prePayType,
  985. channel: res.data.channel,
  986. isShowDetail: true,
  987. orderId: res.data.orderId
  988. }
  989. that.setData({
  990. parkVendor: app.globalData.parkVendor,
  991. extraData: extraDataStr,
  992. stopFees: {
  993. orderId: res.data.orderId,
  994. entranceTime: res.data.start_time,
  995. remainingFee: res.data.money
  996. },
  997. timecha: res.data.duration
  998. });
  999. } else if (app.globalData.parkVendor == 5) { // BoLink
  1000. var extraDataStr = {
  1001. union_id: that.data.bolinkUnionId,
  1002. order_id: res.data.order_id,
  1003. park_id: that.data.bolinkComId,
  1004. plate_number: res.data.plate_number,
  1005. money: res.data.money,
  1006. park_name: res.data.park_name
  1007. }
  1008. that.setData({
  1009. parkVendor: app.globalData.parkVendor,
  1010. bolinkOrderId: res.data.order_id,
  1011. extraData: extraDataStr,
  1012. stopFees: {
  1013. orderId: res.data.order_id,
  1014. entranceTime: res.data.start_time,
  1015. remainingFee: res.data.money
  1016. },
  1017. timecha: res.data.duration
  1018. });
  1019. } else { // *#06#
  1020. // var extraDataStr = {
  1021. // params: {
  1022. // token: app.globalData.etcpToken,
  1023. // syncId: res.data.orderId,
  1024. // payType: 6, // 小程序支付
  1025. // CarNumber: carNumber,
  1026. // returnUrl: that.data.etcpCallbackUrl,
  1027. // source: "FUMAO-001",
  1028. // actionId: "1",//操作ID,1:小程序支付
  1029. // },
  1030. // }
  1031. that.setData({
  1032. parkVendor: app.globalData.parkVendor,
  1033. // extraData: extraDataStr,
  1034. stopFees: res.data,
  1035. timecha: Util.timecha(res.data.exitTime, res.data.entranceTime),
  1036. remark: res.data.remark,
  1037. generalAppId: res.data.appId,
  1038. generalPayPath: res.data.payPath,
  1039. generalExtraData: res.data.extraData,
  1040. extraDataFlag: JSON.stringify(res.data.extraData)
  1041. });
  1042. console.log(that.data.extraDataFlag, "123456789")
  1043. }
  1044. that.setData({
  1045. scroll: true
  1046. })
  1047. })
  1048. .catch(error => {
  1049. that.setData({
  1050. stopFees: {},
  1051. scroll: true
  1052. })
  1053. });
  1054. },
  1055. /**
  1056. * 下拉刷新
  1057. */
  1058. onPullDownRefresh: function (e) {
  1059. let that = this;
  1060. that.initUsrCarList("flags");
  1061. that.setData({
  1062. current: 0
  1063. })
  1064. wx.stopPullDownRefresh();
  1065. }
  1066. });