C端小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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