C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1090 line
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.navigateTo({
  544. url: `/pages/getphoneInfo/index?mineFlag=passCar`,
  545. })
  546. })
  547. },
  548. passc: function () {
  549. wx.navigateTo({
  550. url: '/pages/ques/ques',
  551. })
  552. },
  553. goExplain: function () {
  554. wx.navigateTo({
  555. url: '/pages/tcExplain/tcExplain',
  556. })
  557. },
  558. /**
  559. * 券绑定车牌
  560. */
  561. bindCoupon: function (quanid, quantitle) {
  562. wx.showLoading({
  563. title: '使用中...',
  564. })
  565. var that = this;
  566. /**
  567. * etcp
  568. */
  569. var postCouponData = {
  570. etcpToken: app.globalData.etcpToken,
  571. carNumber: that.data.listCardNum,
  572. couponOrderId: quanid
  573. };
  574. if (app.globalData.parkVendor == 2) {
  575. // 停简单
  576. postCouponData = {
  577. carNumber: that.data.listCardNum
  578. }
  579. }
  580. if (app.globalData.parkVendor == 4) {
  581. // 尚安
  582. postCouponData = {
  583. carNumber: that.data.listCardNum,
  584. couponOrderId: quanid
  585. }
  586. }
  587. if (app.globalData.parkVendor == 5) {
  588. // 泊链
  589. postCouponData = {
  590. carNumber: that.data.listCardNum,
  591. orderId: that.data.bolinkOrderId,
  592. couponOrderId: quanid
  593. }
  594. }
  595. if (app.globalData.parkVendor >= 6) {
  596. console.log(123456789)
  597. postCouponData = {
  598. carNumber: that.data.listCardNum,
  599. // orderId: that.data.bolinkOrderId,
  600. couponOrderId: quanid,
  601. parkOrderId: that.data.stopFees.orderId
  602. }
  603. }
  604. Http.post({
  605. url: config.api.getCarCoupon,
  606. data: postCouponData
  607. })
  608. .then(res => {
  609. wx.hideLoading()
  610. // if(res.data){
  611. that.getStopFee(that.data.listCardNum);
  612. that.initUsrCarList();
  613. that.setData({
  614. quantitle: quantitle, //接口条用成功后在赋值
  615. })
  616. // }else{
  617. // wx.showToast({
  618. // title: res.message,
  619. // icon: 'none',
  620. // duration: 3000,
  621. // mask: false
  622. // });
  623. // }
  624. })
  625. .catch(err => {
  626. wx.hideLoading()
  627. if (err.message != undefined) {
  628. wx.showToast({
  629. title: err.message,
  630. icon: 'none',
  631. duration: 3000,
  632. mask: false
  633. });
  634. }
  635. })
  636. },
  637. /**
  638. * 选择优惠券
  639. */
  640. // gotoquan: function () {
  641. // let that = this;
  642. // if (that.data.quanid) {
  643. // wx.navigateTo({
  644. // url: `/pages/passCar/choicecoupon/choicecoupon?quanid=${that.data.quanid}`,
  645. // })
  646. // } else {
  647. // wx.navigateTo({
  648. // url: '/pages/passCar/choicecoupon/choicecoupon',
  649. // })
  650. // }
  651. // },
  652. closeTicketModal: function () {
  653. this.setData({
  654. showTicketModal: false
  655. })
  656. },
  657. /**
  658. * 停车券 弹框
  659. */
  660. openTicketModal: function () {
  661. this.setData({
  662. showTicketModal: true,
  663. allow_load: true,
  664. ticketList: [],
  665. curPageNum: 1,
  666. })
  667. this.getTicketList(0, 1);
  668. /* if (!this.data.ticketList.length){
  669. this.getTicketList(0, 1);
  670. } */
  671. },
  672. //获取名下停车券列表
  673. getList() {
  674. var that = this;
  675. Http.get({
  676. url: config.api.couponOrderCarList + "?type=5&couponOrderStatus=0",
  677. data: {
  678. pageNum: 1,
  679. pageSize: 15,
  680. couponOrderStatus: 0
  681. }
  682. }).then(res => {
  683. that.setData({
  684. couponList: res.data.list
  685. });
  686. })
  687. .catch(err => {
  688. console.log(err)
  689. })
  690. },
  691. /**
  692. * 共同登录
  693. */
  694. init: function (carNumber) {
  695. var that = this;
  696. app.parkInitCallback = token => {
  697. that.initPark();
  698. that.getParkStatus();
  699. if (!app.globalData.carLogin) {
  700. Http.get({
  701. url: config.api.checkUserStatus,
  702. data: {}
  703. }).then(res => {
  704. app.globalData.type = 'pc'
  705. /**
  706. * 判断是否授权手机号
  707. */
  708. Http.get({
  709. url: config.api.checkPhoneStatus,
  710. data: {}
  711. })
  712. .then(res => {
  713. Http.post({
  714. url: config.api.carInit,
  715. data: {
  716. phone: app.globalData.phone
  717. }
  718. }).then(res => {
  719. app.globalData.carLogin = true;
  720. app.globalData.parkVendor = res.data.vendor;
  721. if (res.data.token) {
  722. app.globalData.etcpToken = res.data.token;
  723. }
  724. if (res.data.supportPay && res.data.supportPay == 1) {
  725. that.setData({
  726. supportPay: 1
  727. })
  728. } else {
  729. that.setData({
  730. supportPay: 0
  731. })
  732. }
  733. /**
  734. * 获得停车费用
  735. */
  736. that.initUsrCarList("flags");
  737. });
  738. })
  739. .catch(err => {
  740. if (err.code == 11005) {
  741. // 用户手机未授权
  742. /**
  743. * 将值传到用户手机号授权的页面
  744. *
  745. */
  746. wx.redirectTo({
  747. url: "/pages/getphoneInfo/index"
  748. });
  749. } else if (err.code == 11006) {
  750. // 用户手机已加密
  751. wx.redirectTo({
  752. url: "/pages/phoneinput/phoneinput"
  753. });
  754. } else {
  755. wx.showToast({
  756. title: err.errMsg,
  757. icon: 'none',
  758. duration: 2000,
  759. mask: false
  760. });
  761. }
  762. })
  763. }).catch(err => {
  764. app.globalData.type = 'pc'
  765. if (err.code == 11004) {
  766. // 用户昵称未授权
  767. wx.redirectTo({
  768. url: "/pages/getuserinfo/index"
  769. });
  770. } else {
  771. wx.showModal({
  772. title: '提示',
  773. content: err.errMsg,
  774. showCancel: false
  775. })
  776. }
  777. });
  778. }
  779. };
  780. if (app.globalData.token && app.globalData.token != null) {
  781. app.parkInitCallback(app.globalData.token);
  782. }
  783. },
  784. bindCar: function (carNum) {
  785. var that = this;
  786. // ETCP
  787. var etcpData = {
  788. etcpToken: app.globalData.etcpToken,
  789. carNumber: carNum
  790. };
  791. var otherData = {
  792. carNumber: carNum
  793. };
  794. var postData = app.globalData.parkVendor == 1 ? etcpData : otherData;
  795. Http.post({
  796. url: config.api.bindCar,
  797. data: postData
  798. })
  799. .then(res => {
  800. that.setData({
  801. addCar: null
  802. });
  803. that.initUsrCarList();
  804. wx.showModal({
  805. title: "提示",
  806. showCancel: false,
  807. content: "绑车牌成功!",
  808. success: function () { }
  809. });
  810. })
  811. .catch(error => {
  812. wx.showModal({
  813. title: "提示",
  814. showCancel: false,
  815. content: error.data.message,
  816. success: function () { }
  817. });
  818. });
  819. },
  820. /**
  821. * 车场信息获取
  822. */
  823. initPark: function () {
  824. var that = this;
  825. Http.get({
  826. url: config.api.getParkInfo,
  827. data: {}
  828. })
  829. .then(res => {
  830. that.setData({
  831. park: res.data
  832. })
  833. if (res.data) {
  834. app.globalData.parkVendor = res.data.vendorType;
  835. if (app.globalData.parkVendor == 1) {
  836. console.log("payPath: " + extConfig.attr.car.etcp.payPath)
  837. // etcp
  838. that.setData({
  839. parkVendor: app.globalData.parkVendor,
  840. etcpAppId: extConfig.attr.car.etcp.etcpAppId,
  841. carMiniVersion: extConfig.attr.car.version,
  842. etcpCallbackUrl: extConfig.attr.car.etcp.etcpCallbackUrl,
  843. payPath: extConfig.attr.car.etcp.payPath
  844. })
  845. } else if (app.globalData.parkVendor == 2) {
  846. // TJD
  847. var vendorObj = JSON.parse(res.data.vendorParams)
  848. that.setData({
  849. parkVendor: app.globalData.parkVendor,
  850. tjdAppId: extConfig.attr.car.tjd.tjdAppId,
  851. carMiniVersion: extConfig.attr.car.version,
  852. payPath: extConfig.attr.car.tjd.payPath
  853. })
  854. } else if (app.globalData.parkVendor == 5) {
  855. // 泊链
  856. var vendorObj = JSON.parse(res.data.vendorParams)
  857. console.log("payPath: " + extConfig.attr.car.bolink.payPath)
  858. that.setData({
  859. parkVendor: app.globalData.parkVendor,
  860. bolinkAppId: extConfig.attr.car.bolink.bolinkAppId,
  861. carMiniVersion: extConfig.attr.car.version,
  862. payPath: extConfig.attr.car.bolink.payPath,
  863. bolinkComId: vendorObj.comid,
  864. bolinkUnionId: vendorObj.union_id
  865. })
  866. }
  867. }
  868. })
  869. .catch(err => {
  870. console.log(err);
  871. // wx.showToast({
  872. // title: err.message,
  873. // icon: 'none',
  874. // duration: 2000,
  875. // mask: false
  876. // });
  877. })
  878. },
  879. /**
  880. * 车场状态获取
  881. */
  882. getParkStatus: function () {
  883. var that = this;
  884. Http.get({
  885. url: config.api.getParkStatus,
  886. })
  887. .then(res => {
  888. console.log(res)
  889. })
  890. .catch(err => {
  891. console.log(err)
  892. // wx.showToast({
  893. // title: err.message,
  894. // icon:"none"
  895. // })
  896. })
  897. },
  898. /**
  899. * 绑定车获取
  900. */
  901. initUsrCarList: function (flag) {
  902. var that = this;
  903. Http.get({
  904. url: config.api.getUserCarList,
  905. data: {}
  906. }).then(res => {
  907. that.setData({
  908. carList: res.data
  909. });
  910. /**
  911. * flag ==flags
  912. * 表示从首页onShow进来的
  913. */
  914. if (flag == "flags" && res.data.length > 0) {
  915. var listCardNum = res.data[0].carNumber;
  916. that.setData({
  917. listCardNum: listCardNum
  918. })
  919. /**
  920. * 获得停车费用
  921. */
  922. that.getStopFee(listCardNum);
  923. }
  924. })
  925. .catch(err => {
  926. wx.showToast({
  927. title: err.message,
  928. icon: 'none',
  929. duration: 2000,
  930. mask: false
  931. });
  932. })
  933. },
  934. /**
  935. * 获得停车费用修改
  936. */
  937. getStopFee: function (carNumber) {
  938. let that = this;
  939. let postData =
  940. app.globalData.parkVendor == 1 ? {
  941. etcpToken: app.globalData.etcpToken,
  942. carNumber: carNumber
  943. } : {
  944. carNumber: carNumber
  945. };
  946. Http.post({
  947. url: config.api.getCarStopFee,
  948. data: postData
  949. })
  950. .then(res => {
  951. console.log(res)
  952. if (app.globalData.parkVendor == 1) { // ETCP
  953. var extraDataStr = {
  954. params: {
  955. token: app.globalData.etcpToken,
  956. syncId: res.data.orderId,
  957. payType: 6, // 小程序支付
  958. CarNumber: carNumber,
  959. returnUrl: that.data.etcpCallbackUrl,
  960. source: "FUMAO-001",
  961. actionId: "1" //操作ID,1:小程序支付
  962. }
  963. }
  964. that.setData({
  965. parkVendor: app.globalData.parkVendor,
  966. extraData: extraDataStr,
  967. stopFees: res.data,
  968. timecha: Util.timecha(res.data.exitTime, res.data.entranceTime)
  969. });
  970. } else if (app.globalData.parkVendor == 2) { // TJD // TODO
  971. var extraDataStr = {
  972. prePayType: that.data.prePayType,
  973. channel: res.data.channel,
  974. isShowDetail: true,
  975. orderId: res.data.orderId
  976. }
  977. that.setData({
  978. parkVendor: app.globalData.parkVendor,
  979. extraData: extraDataStr,
  980. stopFees: {
  981. orderId: res.data.orderId,
  982. entranceTime: res.data.start_time,
  983. remainingFee: res.data.money
  984. },
  985. timecha: res.data.duration
  986. });
  987. } else if (app.globalData.parkVendor == 5) { // BoLink
  988. var extraDataStr = {
  989. union_id: that.data.bolinkUnionId,
  990. order_id: res.data.order_id,
  991. park_id: that.data.bolinkComId,
  992. plate_number: res.data.plate_number,
  993. money: res.data.money,
  994. park_name: res.data.park_name
  995. }
  996. that.setData({
  997. parkVendor: app.globalData.parkVendor,
  998. bolinkOrderId: res.data.order_id,
  999. extraData: extraDataStr,
  1000. stopFees: {
  1001. orderId: res.data.order_id,
  1002. entranceTime: res.data.start_time,
  1003. remainingFee: res.data.money
  1004. },
  1005. timecha: res.data.duration
  1006. });
  1007. } else { // *#06#
  1008. // var extraDataStr = {
  1009. // params: {
  1010. // token: app.globalData.etcpToken,
  1011. // syncId: res.data.orderId,
  1012. // payType: 6, // 小程序支付
  1013. // CarNumber: carNumber,
  1014. // returnUrl: that.data.etcpCallbackUrl,
  1015. // source: "FUMAO-001",
  1016. // actionId: "1",//操作ID,1:小程序支付
  1017. // },
  1018. // }
  1019. that.setData({
  1020. parkVendor: app.globalData.parkVendor,
  1021. // extraData: extraDataStr,
  1022. stopFees: res.data,
  1023. timecha: Util.timecha(res.data.exitTime, res.data.entranceTime),
  1024. remark: res.data.remark,
  1025. generalAppId: res.data.appId,
  1026. generalPayPath: res.data.payPath,
  1027. generalExtraData: res.data.extraData,
  1028. extraDataFlag: JSON.stringify(res.data.extraData)
  1029. });
  1030. console.log(that.data.extraDataFlag, "123456789")
  1031. }
  1032. that.setData({
  1033. scroll: true
  1034. })
  1035. })
  1036. .catch(error => {
  1037. that.setData({
  1038. stopFees: {},
  1039. scroll: true
  1040. })
  1041. });
  1042. },
  1043. /**
  1044. * 下拉刷新
  1045. */
  1046. onPullDownRefresh: function (e) {
  1047. let that = this;
  1048. that.initUsrCarList("flags");
  1049. that.setData({
  1050. current: 0
  1051. })
  1052. wx.stopPullDownRefresh();
  1053. }
  1054. });