cardetail.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // pages/cardetail/cardetail.js
  2. import { get,post } from "../../common/request.js"
  3. import pathmap from "../../common/pathmap"
  4. import stylemap from "../../common/stylemap"
  5. import { retCartData } from "../../data/car"
  6. import bindLog from "../../module/logs/logs"
  7. const app = getApp();
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. windowh: app.globalData.windowh,
  14. collocatetype:[{
  15. label:"基本参数",
  16. name:"jiben"
  17. },{
  18. label:"发动机参数",
  19. name:"fadongji"
  20. },{
  21. label:"底盘及制动",
  22. name:"dipan"
  23. },{
  24. label:"安全配置",
  25. name:"anquan"
  26. },{
  27. label:"外部配置",
  28. name:"waibu"
  29. },{
  30. label:"内部配置",
  31. name:"neibu"
  32. },{
  33. label:"操控/辅助配置",
  34. name:"caokong"
  35. }],
  36. imagemap:{
  37. "事故排查":"accident",
  38. "轻微碰撞":"checkcollide",
  39. "易损耗部件":"wastage",
  40. "常用功能":"comonuse",
  41. "启动检测":"startcheck"
  42. }
  43. },
  44. /**
  45. * 生命周期函数--监听页面加载
  46. */
  47. onLoad: function (options) {
  48. this.setData(Object.assign({id:options.id},stylemap));
  49. this.getDetail();
  50. bindLog(this);
  51. },
  52. /**
  53. * 生命周期函数--监听页面初次渲染完成
  54. */
  55. onReady: function () {
  56. },
  57. /**
  58. * 生命周期函数--监听页面显示
  59. */
  60. onShow: function () {
  61. },
  62. /**
  63. * 生命周期函数--监听页面隐藏
  64. */
  65. onHide: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面卸载
  69. */
  70. onUnload: function () {
  71. },
  72. /**
  73. * 页面相关事件处理函数--监听用户下拉动作
  74. */
  75. onPullDownRefresh: function () {
  76. },
  77. /**
  78. * 页面上拉触底事件的处理函数
  79. */
  80. onReachBottom: function () {
  81. },
  82. /**
  83. * 用户点击右上角分享
  84. */
  85. onShareAppMessage: function () {
  86. },
  87. getDetail:function(){
  88. var _self=this;
  89. get(pathmap.cardetail,{id:this.data.id},function(json){
  90. var detail = json.data;
  91. var time = detail.first_plate_at.split('-');
  92. /*数据结构处理*/
  93. detail.imgs = detail.imgs&&detail.imgs.split(",");
  94. detail.imgslength = detail.imgs.length;
  95. detail.first_plate_at = time[0]+"/"+time[1];
  96. detail.check_info.forEach(function(item){
  97. })
  98. _self.setData({
  99. detail:detail
  100. })
  101. })
  102. },
  103. switchTab:function(e){
  104. this.setData({
  105. currentimg: e.detail.current+1
  106. });
  107. },
  108. swCollocate:function(e){
  109. var name = e.currentTarget.dataset.name;
  110. var collocatetype = this.data.collocatetype.map(function(item){
  111. if(item.name==name){
  112. if(item.opened){
  113. item.opened=false;
  114. }else{
  115. item.opened=true;
  116. }
  117. }else{
  118. item.opened=false;
  119. }
  120. return item;
  121. })
  122. this.setData({collocatetype:collocatetype});
  123. },
  124. collectCar:function(){
  125. var authorization = wx.getStorageSync("authorization");
  126. if(authorization){
  127. post(pathmap.collect,{
  128. id:this.data.id
  129. },function(json){
  130. })
  131. }else{
  132. this.openLog();
  133. //setData({openlog:true});
  134. }
  135. }
  136. })