list.js 1.53 KB
const navStyle = 'background-color: transparent;'

import { devMixin } from '~/mixins/index'
Page({
  behaviors: [devMixin],
  /**
   * 页面的初始数据
   */
  data: {
    navStyle: 'background-color: transparent;'
  },
  navbarReady(e) {
    console.log(e)
    let {
      height
    } = e.detail
    this.setData({
      top: height
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    if(wx.getStorageSync('device_info')){
      const devList = wx.getStorageSync('device_info')
      this.setData({devList})
    }
    this.getUserCarList()
  },
  init(){
    this.getUserCarList()
  },

  getUserCarList() {
    wx.p.api.mineApi.getUserCarList().then(({
      code,
      data
    }) => {
      this.setData({
        carFlag: true
      })
      if (code == '0') {
        let carInfo = null
        data.map(e => {
          if (e.carTypeName) carInfo = e
        })
        this.setData({
          carInfo
        })
      }
    })
  },
  setUp(e) {
    const {index} = e.currentTarget.dataset
    const {devList} = this.data
    const selectItem = devList[index]
    console.log(selectItem)
    devList.splice(index,1)
    devList.unshift(selectItem)
    wx.setStorageSync('device_info', devList)
    this.setData({
      devList
    })
  },
  goto(e) {
    let {
      url,
      item,
      name
    } = e.currentTarget.dataset
    let path = 'index'
    if (name) path = name
    console.log(`/packageMine/pages/${url}/${path}/${path}`);
    wx.p.router.go(`/packageMine/pages/${url}/${path}/${path}`, item)
  },
})