C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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