C端小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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