cardetail.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // pages/cardetail/cardetail.js
  2. import { get } from "../../common/request.js"
  3. import pathmap from "../../common/pathmap"
  4. import stylemap from "../../common/stylemap"
  5. import { retCartData } from "../../data/car"
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. this.setData(stylemap);
  17. this.getDetail(options.id);
  18. },
  19. /**
  20. * 生命周期函数--监听页面初次渲染完成
  21. */
  22. onReady: function () {
  23. },
  24. /**
  25. * 生命周期函数--监听页面显示
  26. */
  27. onShow: function () {
  28. },
  29. /**
  30. * 生命周期函数--监听页面隐藏
  31. */
  32. onHide: function () {
  33. },
  34. /**
  35. * 生命周期函数--监听页面卸载
  36. */
  37. onUnload: function () {
  38. },
  39. /**
  40. * 页面相关事件处理函数--监听用户下拉动作
  41. */
  42. onPullDownRefresh: function () {
  43. },
  44. /**
  45. * 页面上拉触底事件的处理函数
  46. */
  47. onReachBottom: function () {
  48. },
  49. /**
  50. * 用户点击右上角分享
  51. */
  52. onShareAppMessage: function () {
  53. },
  54. getDetail:function(id){
  55. var _self=this;
  56. get(pathmap.cardetail,{id:id},function(json){
  57. var detail = json.data;
  58. var time = detail.first_plate_at.split('-');
  59. /*数据结构处理*/
  60. detail.imgs = detail.imgs.split(",");
  61. detail.imgslength = detail.imgs.length;
  62. detail.first_plate_at = time[0]+"/"+time[1];
  63. _self.setData({
  64. detail:detail,
  65. id:id
  66. })
  67. })
  68. },
  69. switchTab:function(e){
  70. this.setData({
  71. currentimg: e.detail.current+1
  72. });
  73. }
  74. })