VehicleList.js 2.7 KB
import {
  request
} from "../../request/index.js"
const a = getApp()
Page({
  data: {
    imagesUrl: a.globalData.baseUrl,
    storeList: [],
    storeListPin: '',
    noCar: '',
    s4_id: '',
  },
  onLoad: function (options) {
    //  console.log(options);
    this.setData({
      s4_id: options.id
    })

  },
  onShow: function () {
    let that = this
    let token = wx.getStorageSync("token")
    if (token) {
      setTimeout(() => {
        that.getStoreList()
      }, 1000);
    } else {
      that.popConfirm()
    }


  },
  getStoreList() { // 推列
    let that = this;
    request({
        url: 'api/shop4s/carList',
        data: {
          s4_id: that.data.s4_id
        }
      })
      .then(res => {
        //  console.log(res);
        if (res.data.data.list.length > 0) {
          that.setData({
            noCar: 0,
            storeList: res.data.data.list,
            storeListPin: res.data.data.pin
          })
        } else {
          that.setData({
            noCar: 1,
            // storeList: res.data.data.list,
            storeListPin: res.data.data.pin
          })


        }


      })
  },

  toVehicleListDetail(e) {
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/VehicleListDetail/VehicleListDetail?id=' + id
    })
  },
  onShareAppMessage(options) {
    var that = this;
    //  console.log(that.data.user_id)
    // 设置菜单中的转发按钮触发转发事件时的转发内容
    var shareObj = {
      title: "同放分享", // 默认是小程序的名称(可以写slogan等)
      path: '/pages/VehicleList/VehicleList', // 默认是当前页面,必须是以‘/’开头的完整路径
      imageUrl: '', //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
      success: function (res) {
        // 转发成功之后的回调
        //  console.log(res);
        that.setData({
          msg: '易分享'
        })
        that.popMaskTest()
      },
      fail: function () {
        // 转发失败之后的回调
        if (res.errMsg == 'shareAppMessage:fail cancel') {
          // 用户取消转发
        } else if (res.errMsg == 'shareAppMessage:fail') {}
      },
    };
    // 返回shareObj
    return shareObj;

  },
  popConfirm: function () {
    wx.showModal({
      title: '提示',
      content: '您尚未登录,请登录后操作',
      success: function (res) {
        if (res.confirm) {
          wx.navigateTo({
            url: '/pages/authorization/authorization'
          })
        } else {
          wx.switchTab({
            url: '/pages/home/home'
          })
        }
      }
    })

  },

})