123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- // pages/cardetail/cardetail.js
- import { get,post } from "../../common/request.js"
- import pathmap from "../../common/pathmap"
- import stylemap from "../../common/stylemap"
- import { retCartData } from "../../data/car"
- import bindLog from "../../module/logs/logs"
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- windowh: app.globalData.windowh,
- collocatetype:[{
- label:"基本参数",
- name:"jiben"
- },{
- label:"发动机参数",
- name:"fadongji"
- },{
- label:"底盘及制动",
- name:"dipan"
- },{
- label:"安全配置",
- name:"anquan"
- },{
- label:"外部配置",
- name:"waibu"
- },{
- label:"内部配置",
- name:"neibu"
- },{
- label:"操控/辅助配置",
- name:"caokong"
- }],
- imagemap:{
- "事故排查":"accident",
- "轻微碰撞":"checkcollide",
- "易损耗部件":"wastage",
- "常用功能":"comonuse",
- "启动检测":"startcheck"
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData(Object.assign({id:options.id},stylemap));
- this.getDetail();
- bindLog(this);
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- },
- loginback:function(){
- this.getDetail();
- },
- getDetail:function(){
- var _self=this;
- get(pathmap.cardetail,{id:this.data.id},function(json){
- if(json.statusCode==200){
- var detail = json.data;
- var time = detail.first_plate_at.split('-');
- /*数据结构处理*/
- detail.imgs = detail.imgs&&detail.imgs.split(",");
- detail.imgslength = detail.imgs.length;
- detail.first_plate_at = time[0]+"/"+time[1];
- detail.check_info.forEach(function(item){
- })
- _self.setData({
- detail:detail
- })
- }else{
- wx.showToast({
- title:json.data.message,
- icon:"none",
- duration:2000
- })
- }
- })
- },
- switchTab:function(e){
- this.setData({
- currentimg: e.detail.current+1
- });
- },
- swCollocate:function(e){
- var name = e.currentTarget.dataset.name;
- var collocatetype = this.data.collocatetype.map(function(item){
- if(item.name==name){
- if(item.opened){
- item.opened=false;
- }else{
- item.opened=true;
- }
- }else{
- item.opened=false;
- }
- return item;
- })
- this.setData({collocatetype:collocatetype});
- },
- collectCar:function(){
- var _self=this;
- if(this.data.detail.is_collect=="0"){
- post(pathmap.collect,{
- id:this.data.id
- },function(json){
- if(json.statusCode==200){
- wx.showToast({
- title:json.data.message
- });
- _self.setData({detail:Object.assign(_self.data.detail,{is_collect:'1'})});
- }else{
- wx.showToast({
- title:json.data.message,
- icon:"none"
- });
- }
- },null,function(){
- _self.openLog();
- })
- }else{
- post(pathmap.collectdel,{
- id:this.data.id
- },function(json){
- if(json.statusCode==200){
- wx.showToast({
- title:json.data.msg
- });
- _self.setData({detail:Object.assign(_self.data.detail,{is_collect:'0'})});
- }else{
- wx.showToast({
- title:json.data.message,
- icon:"none"
- });
- }
- },null,function(){
- _self.openLog();
- })
- }
- }
- })
|