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.

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