|
|
import {
|
|
|
request
|
|
|
} from "../../request/index.js";
|
|
|
var QQMapWX = require('../../qqmap/qqmap-wx-jssdk.min.js');
|
|
|
var qqmapsdk;
|
|
|
const a = getApp()
|
|
|
Page({
|
|
|
data: {
|
|
|
baseUrl: a.globalData.baseUrl,
|
|
|
statusTop: a.globalData.statusHeight,
|
|
|
imagesUrl: a.globalData.imagesUrl,
|
|
|
four: 4,
|
|
|
six: 6,
|
|
|
msg: '',
|
|
|
autoplay: true,
|
|
|
interval: 3000,
|
|
|
indicatorDots: true,
|
|
|
indicator: '#F9F9F9',
|
|
|
indicatorActive: '#E8370F',
|
|
|
bind_car: 1,
|
|
|
time: 30 * 60 * 60 * 1000,
|
|
|
timeData: {},
|
|
|
pin_id: '1',
|
|
|
rest: false,
|
|
|
groom: [], // 推荐
|
|
|
homeInfo: [],
|
|
|
homeChe: {},
|
|
|
homeGouDay: {},
|
|
|
homeLoop: [],
|
|
|
S4Info: '',
|
|
|
id: '',
|
|
|
nobindCar: false,
|
|
|
goodDetal: {},
|
|
|
index4S: [],
|
|
|
city_id: '',
|
|
|
},
|
|
|
onLoad: function (options) {
|
|
|
let that = this
|
|
|
console.log(options);
|
|
|
qqmapsdk = new QQMapWX({
|
|
|
key: 'B4MBZ-3VICV-THBPQ-UCLHB-SLCEK-B7FIK'
|
|
|
});
|
|
|
},
|
|
|
onShow: function () {
|
|
|
let that = this
|
|
|
that.gethomeIndex()
|
|
|
that.gethomeLoop()
|
|
|
that.getS4Info()
|
|
|
that.getindexUser()
|
|
|
that.getCitied()
|
|
|
},
|
|
|
|
|
|
gohome() {
|
|
|
wx.switchTab({
|
|
|
url: '/pages/home/home'
|
|
|
})
|
|
|
},
|
|
|
onChange(e) {
|
|
|
this.setData({
|
|
|
timeData: e.detail,
|
|
|
});
|
|
|
},
|
|
|
more4SList() {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/Vmore4SList/Vmore4SList'
|
|
|
})
|
|
|
},
|
|
|
goSearch() {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/Vmore4SList/Vmore4SList?home=1'
|
|
|
})
|
|
|
},
|
|
|
addLoveCared() { // 去添加车辆
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token) {
|
|
|
if (that.data.nobindCar) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/addcars/addcars'
|
|
|
})
|
|
|
} else {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/addcar/addcar'
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
async gethomeIndex() { // 获取首页
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data: {
|
|
|
data
|
|
|
}
|
|
|
} = await request({
|
|
|
url: 'api/index2/index',
|
|
|
})
|
|
|
console.log(data);
|
|
|
that.setData({
|
|
|
homeChe: data.che,
|
|
|
homeInfo: data.info,
|
|
|
homeGouDay: data.gou_day
|
|
|
})
|
|
|
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
that.setData({
|
|
|
msg: err.msg
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
|
|
|
},
|
|
|
async gethomeLoop() { // 获取轮播
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data: {
|
|
|
data
|
|
|
}
|
|
|
} = await request({
|
|
|
url: 'api/index2/img',
|
|
|
})
|
|
|
console.log(data);
|
|
|
that.setData({
|
|
|
homeLoop: data,
|
|
|
})
|
|
|
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
that.setData({
|
|
|
msg: err.msg
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
|
|
|
},
|
|
|
async getS4Info() { // 获取4s店数据
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data
|
|
|
} = await request({
|
|
|
url: 'api/index2/s4Info',
|
|
|
})
|
|
|
console.log(data);
|
|
|
if (data.code == 1) {
|
|
|
that.setData({
|
|
|
S4Info: data.data.name,
|
|
|
id: data.data.id,
|
|
|
bind_car: 1
|
|
|
})
|
|
|
} else {
|
|
|
//code为0的话,说明没绑定4s店
|
|
|
that.setData({
|
|
|
msg: data.msg,
|
|
|
bind_car: 0,
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
that.setData({
|
|
|
msg: err.msg
|
|
|
})
|
|
|
// that.popTest()
|
|
|
if (err.code == 0) {
|
|
|
that.setData({
|
|
|
bind_car: 0,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},
|
|
|
async getindexUser() { // 获取 4s关注数据
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data: {
|
|
|
data
|
|
|
}
|
|
|
} = await request({
|
|
|
url: 'api/index2/indexUnder',
|
|
|
})
|
|
|
console.log(data, "4SD店列表");
|
|
|
if (data.length == 0) { // 如果是空数组,你调用的是【推荐4s店】这个接口
|
|
|
that.getCitied()
|
|
|
}
|
|
|
that.setData({
|
|
|
index4S: data
|
|
|
})
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
a.popTest(err.msg)
|
|
|
}
|
|
|
|
|
|
},
|
|
|
getCitied() { // 获取城市信息
|
|
|
let that = this
|
|
|
wx.getLocation({
|
|
|
type: 'wgs84', //默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
|
|
|
success: function (res) {
|
|
|
qqmapsdk.reverseGeocoder({
|
|
|
//位置坐标,默认获取当前位置,非必须参数
|
|
|
//Object格式
|
|
|
location: {
|
|
|
latitude: res.latitude,
|
|
|
longitude: res.longitude
|
|
|
},
|
|
|
success: function (res) { //成功后的回调
|
|
|
console.log(res);
|
|
|
var res = res.result;
|
|
|
let city = res.ad_info.city
|
|
|
that.saveCity(city)
|
|
|
},
|
|
|
fail: function (error) {
|
|
|
console.error(error);
|
|
|
},
|
|
|
complete: function (res) {
|
|
|
// console.log(res);
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
fail: res => {}
|
|
|
})
|
|
|
return
|
|
|
},
|
|
|
async saveCity(city) {
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data: {
|
|
|
data
|
|
|
}
|
|
|
} = await request({
|
|
|
url: 'api/citys/getCity',
|
|
|
data: {
|
|
|
city: city
|
|
|
}
|
|
|
})
|
|
|
console.log(data, "首页全局城市定位");
|
|
|
that.setData({
|
|
|
city_id: data.city_id
|
|
|
})
|
|
|
if (that.data.index4S.length == 0) {
|
|
|
that.getSuccessPage()
|
|
|
}
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
a.popTest(err.msg)
|
|
|
}
|
|
|
},
|
|
|
async getSuccessPage() { // 获取推荐
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data: {
|
|
|
data
|
|
|
}
|
|
|
} = await request({
|
|
|
url: 'api/index2/tuiList2',
|
|
|
data: {
|
|
|
city_id: that.data.city_id
|
|
|
}
|
|
|
})
|
|
|
console.log(data);
|
|
|
that.setData({
|
|
|
groom: data
|
|
|
})
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
that.setData({
|
|
|
msg: err.msg
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
|
|
|
},
|
|
|
async clickAttention(e) { // 点击关注
|
|
|
let that = this
|
|
|
let id = e.currentTarget.dataset.id
|
|
|
let token = wx.getStorageSync('token')
|
|
|
if (token) {
|
|
|
try {
|
|
|
const {
|
|
|
data
|
|
|
} = await request({
|
|
|
url: 'api/index2/guan',
|
|
|
data: {
|
|
|
id: id
|
|
|
}
|
|
|
})
|
|
|
console.log(data);
|
|
|
if (data.code == 1) {
|
|
|
a.popSuccessTest(data.msg)
|
|
|
}
|
|
|
setTimeout(() => { // 一旦有关注的店,就不显示推荐好店
|
|
|
// that.getSuccessPage()
|
|
|
that.getindexUser()
|
|
|
}, 500);
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
a.popTest(err.msg)
|
|
|
}
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
goToAccess(e) {
|
|
|
let id = e.currentTarget.dataset.id
|
|
|
console.log(e);
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/goAccessoriesDetailIMG/goAccessoriesDetailIMG?id=' + id
|
|
|
})
|
|
|
},
|
|
|
gobind4S() { // 立即绑定4S店
|
|
|
let that = this
|
|
|
let pin_id = that.data.pin_id
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/my4S/my4S?pin_id=' + pin_id,
|
|
|
})
|
|
|
|
|
|
},
|
|
|
goViolationQuery() { //
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync('token')
|
|
|
if (token) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/ViolationQuery/ViolationQuery'
|
|
|
})
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
goAccessoriesDetailIMG(e) { //进入配件详情
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync('token')
|
|
|
let goodDetal = that.data.goodDetal
|
|
|
let tir = e.currentTarget.dataset.tir
|
|
|
if (token) {
|
|
|
if (tir == 1) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/productdetailsImg/productdetailsImg?id=' + goodDetal.good1_id
|
|
|
})
|
|
|
} else if (tir == 2) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/productdetailsImg/productdetailsImg?id=' + goodDetal.good2_id
|
|
|
})
|
|
|
} else {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/productdetailsImg/productdetailsImg?id=' + goodDetal.good3_id
|
|
|
})
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
goV4Sstores(e) { // 进入我的4s店
|
|
|
let that = this
|
|
|
console.log(e);
|
|
|
let s4_id = e.currentTarget.dataset.id
|
|
|
let token = wx.getStorageSync('token')
|
|
|
// a.globalData.stores_id = s4_id
|
|
|
console.log(s4_id);
|
|
|
if (token) {
|
|
|
wx.navigateTo({
|
|
|
// url: '/pages/4Sstore/4Sstore'
|
|
|
url: '/pages/Vnew4Sstore/Vnew4Sstore?s4_id=' + s4_id
|
|
|
|
|
|
})
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
ToV4Sstores(e) {
|
|
|
let that = this
|
|
|
let id = e.currentTarget.dataset.id
|
|
|
let token = wx.getStorageSync('token')
|
|
|
if (token) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/Vnew4Sstore/Vnew4Sstore?s4_id=' + id
|
|
|
})
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
goUpkeepimg() { // 保养预约
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync('token')
|
|
|
let id = that.data.id
|
|
|
let homeChe = that.data.homeChe
|
|
|
if (token) {
|
|
|
if (id == '') {
|
|
|
that.setData({
|
|
|
msg: '您尚未绑定4S店'
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
if (homeChe.length == 0) {
|
|
|
that.setData({
|
|
|
msg: '请先绑定爱车'
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
if (homeChe.length != 0 && id != '') {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/upkeepImg/upkeepImg?id=' + id
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
toMyGarage() { // 我的车库
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/MyGarage/MyGarage?tdTap=1'
|
|
|
})
|
|
|
} else {
|
|
|
this.goLogin()
|
|
|
}
|
|
|
|
|
|
},
|
|
|
goVopenPolicy() {
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync('token')
|
|
|
let id = that.data.id
|
|
|
let homeChe = that.data.homeChe
|
|
|
console.log(homeChe);
|
|
|
if (token) {
|
|
|
if (id == '') {
|
|
|
that.setData({
|
|
|
msg: '您尚未绑定4S店'
|
|
|
})
|
|
|
that.popTest()
|
|
|
|
|
|
}
|
|
|
if (homeChe == null) {
|
|
|
that.setData({
|
|
|
msg: '请先绑定爱车'
|
|
|
})
|
|
|
that.popTest()
|
|
|
|
|
|
}
|
|
|
if (homeChe != null && id != '') {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/VopenPolicy/VopenPolicy?che_id=' + homeChe.id
|
|
|
})
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
goVopenPolicyB() {
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync('token')
|
|
|
let id = that.data.id
|
|
|
let homeChe = that.data.homeChe
|
|
|
if (token) {
|
|
|
if (id == '') {
|
|
|
that.setData({
|
|
|
msg: '您尚未绑定4S店'
|
|
|
})
|
|
|
that.popTest()
|
|
|
|
|
|
}
|
|
|
if (homeChe == null) {
|
|
|
that.setData({
|
|
|
msg: '请先绑定爱车'
|
|
|
})
|
|
|
that.popTest()
|
|
|
|
|
|
}
|
|
|
if (homeChe != null && id != '') {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/VopenPolicyB/VopenPolicyB?che_id=' + homeChe.id
|
|
|
})
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
goVopenPolicyC() {
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync('token')
|
|
|
let id = that.data.id
|
|
|
let homeChe = that.data.homeChe
|
|
|
if (token) {
|
|
|
if (id == '') {
|
|
|
that.setData({
|
|
|
msg: '您尚未绑定4S店'
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
if (homeChe == null) {
|
|
|
that.setData({
|
|
|
msg: '请先绑定爱车'
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
if (homeChe != null && id != '') {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/VopenPolicyC/VopenPolicyC?che_id=' + homeChe.id
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
gobindChe() {
|
|
|
let that = this
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: that.data.msg,
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/MyGarage/MyGarage?tdTap=1'
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
onShareAppMessage(options) {
|
|
|
var that = this;
|
|
|
var shareObj = {
|
|
|
title: "汽车互联网4S店",
|
|
|
path: '/pages/home/home',
|
|
|
imageUrl: '',
|
|
|
};
|
|
|
return shareObj;
|
|
|
|
|
|
},
|
|
|
toGoDetailA(e) {
|
|
|
let that = this
|
|
|
let idata = e.currentTarget.dataset.idata
|
|
|
let jump = idata.jump_type
|
|
|
let good_type = Number(idata.good_type1)
|
|
|
let good_id = idata.good1_id
|
|
|
that.publicDetails(jump, good_type, good_id)
|
|
|
},
|
|
|
toGoDetailB(e) {
|
|
|
let that = this
|
|
|
let idata = e.currentTarget.dataset.idata
|
|
|
let jump = idata.jump_type
|
|
|
let good_type = Number(idata.good_type2)
|
|
|
let good_id = idata.good2_id
|
|
|
that.publicDetails(jump, good_type, good_id)
|
|
|
},
|
|
|
toGoDetailC(e) {
|
|
|
let that = this
|
|
|
let idata = e.currentTarget.dataset.idata
|
|
|
let jump = idata.jump_type
|
|
|
let good_type = Number(idata.good_type3)
|
|
|
let good_id = idata.good3_id
|
|
|
that.publicDetails(jump, good_type, good_id)
|
|
|
},
|
|
|
publicDetails(jump, good_type, good_id) {
|
|
|
if (jump == 1) { //可以跳转
|
|
|
switch (good_type) {
|
|
|
case 1: // 人气好物
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/detail/detail?id=' + good_id
|
|
|
})
|
|
|
break;
|
|
|
case 2: // 精选推荐
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/productdetailsImg/productdetailsImg?id=' + good_id
|
|
|
})
|
|
|
break;
|
|
|
case 3: // 团购热卖
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/VtuanDetail/VtuanDetail?id=' + good_id
|
|
|
})
|
|
|
break;
|
|
|
case 4: //限时抢购
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/VSpikeMallDetail/VSpikeMallDetail?id=' + good_id
|
|
|
})
|
|
|
break;
|
|
|
case 5: //车型商品
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/carDetails/carDetails?id=' + good_id
|
|
|
})
|
|
|
break;
|
|
|
case -1: //推广活动详情
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/activityDetails/activityDetails?id=' + good_id + '&type=1' + '&tap=0'
|
|
|
})
|
|
|
break;
|
|
|
case -2: //限时活动详情
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/details/details?id=' + good_id + '&type=2'
|
|
|
})
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
} else {
|
|
|
a.popTest('该4s店暂未运营')
|
|
|
}
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async public() {
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data: {
|
|
|
data
|
|
|
}
|
|
|
} = await request({
|
|
|
url: '',
|
|
|
data: {
|
|
|
goods_id: that.data.goods_id
|
|
|
}
|
|
|
})
|
|
|
console.log(data);
|
|
|
that.setData({
|
|
|
public: data
|
|
|
})
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
that.setData({
|
|
|
msg: err.msg
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
},
|
|
|
popTest() {
|
|
|
wx.showToast({
|
|
|
title: this.data.msg,
|
|
|
icon: 'none', //如果要纯文本,不要icon,将值设为'none'
|
|
|
duration: 1300
|
|
|
})
|
|
|
},
|
|
|
goLogin() {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您尚未登录,前往登录',
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/authorization/authorization?num=1'
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
// wx.switchTab({
|
|
|
// url: '/pages/home/home'
|
|
|
// })
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
popSuccessTest() {
|
|
|
wx.showToast({
|
|
|
title: this.data.msg,
|
|
|
icon: '', //默认值是success,就算没有icon这个值,就算有其他值最终也显示success
|
|
|
duration: 1300, //停留时间
|
|
|
})
|
|
|
},
|
|
|
|
|
|
import {
|
|
|
request
|
|
|
} from "../../request/index.js";
|
|
|
var QQMapWX = require('../../qqmap/qqmap-wx-jssdk.min.js');
|
|
|
var qqmapsdk;
|
|
|
const a = getApp()
|
|
|
Page({
|
|
|
data: {
|
|
|
baseUrl: a.globalData.baseUrl,
|
|
|
statusTop: a.globalData.statusHeight,
|
|
|
imagesUrl: a.globalData.imagesUrl,
|
|
|
four: 4,
|
|
|
six: 6,
|
|
|
msg: '',
|
|
|
autoplay: true,
|
|
|
interval: 3000,
|
|
|
indicatorDots: true,
|
|
|
indicator: '#F9F9F9',
|
|
|
indicatorActive: '#E8370F',
|
|
|
bind_car: 1,
|
|
|
time: 30 * 60 * 60 * 1000,
|
|
|
timeData: {},
|
|
|
pin_id: '1',
|
|
|
rest: false,
|
|
|
groom: [], // 推荐
|
|
|
homeInfo: [],
|
|
|
homeChe: {},
|
|
|
homeGouDay: {},
|
|
|
homeLoop: [],
|
|
|
S4Info: '',
|
|
|
id: '',
|
|
|
nobindCar: false,
|
|
|
goodDetal: {},
|
|
|
index4S: [],
|
|
|
city_id: '',
|
|
|
},
|
|
|
onLoad: function (options) {
|
|
|
let that = this
|
|
|
console.log(options);
|
|
|
qqmapsdk = new QQMapWX({
|
|
|
key: 'B4MBZ-3VICV-THBPQ-UCLHB-SLCEK-B7FIK'
|
|
|
});
|
|
|
},
|
|
|
onShow: function () {
|
|
|
let that = this
|
|
|
that.gethomeIndex()
|
|
|
that.gethomeLoop()
|
|
|
that.getS4Info()
|
|
|
that.getindexUser()
|
|
|
that.getCitied()
|
|
|
},
|
|
|
|
|
|
gohome() {
|
|
|
wx.switchTab({
|
|
|
url: '/pages/home/home'
|
|
|
})
|
|
|
},
|
|
|
onChange(e) {
|
|
|
this.setData({
|
|
|
timeData: e.detail,
|
|
|
});
|
|
|
},
|
|
|
more4SList() {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/Vmore4SList/Vmore4SList'
|
|
|
})
|
|
|
},
|
|
|
goSearch() {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/Vmore4SList/Vmore4SList?home=1'
|
|
|
})
|
|
|
},
|
|
|
linkWebview() {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/webview/webview?url=' + 'http://h5.goorcar.com/'
|
|
|
})
|
|
|
},
|
|
|
addLoveCared() { // 去添加车辆
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token) {
|
|
|
if (that.data.nobindCar) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/addcars/addcars'
|
|
|
})
|
|
|
} else {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/addcar/addcar'
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
async gethomeIndex() { // 获取首页
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data: {
|
|
|
data
|
|
|
}
|
|
|
} = await request({
|
|
|
url: 'api/index2/index',
|
|
|
})
|
|
|
console.log(data);
|
|
|
that.setData({
|
|
|
homeChe: data.che,
|
|
|
homeInfo: data.info,
|
|
|
homeGouDay: data.gou_day
|
|
|
})
|
|
|
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
that.setData({
|
|
|
msg: err.msg
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
|
|
|
},
|
|
|
async gethomeLoop() { // 获取轮播
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data: {
|
|
|
data
|
|
|
}
|
|
|
} = await request({
|
|
|
url: 'api/index2/img',
|
|
|
})
|
|
|
console.log(data);
|
|
|
that.setData({
|
|
|
homeLoop: data,
|
|
|
})
|
|
|
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
that.setData({
|
|
|
msg: err.msg
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
|
|
|
},
|
|
|
async getS4Info() { // 获取4s店数据
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data
|
|
|
} = await request({
|
|
|
url: 'api/index2/s4Info',
|
|
|
})
|
|
|
console.log(data);
|
|
|
if (data.code == 1) {
|
|
|
that.setData({
|
|
|
S4Info: data.data.name,
|
|
|
id: data.data.id,
|
|
|
bind_car: 1
|
|
|
})
|
|
|
} else {
|
|
|
//code为0的话,说明没绑定4s店
|
|
|
that.setData({
|
|
|
msg: data.msg,
|
|
|
bind_car: 0,
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
that.setData({
|
|
|
msg: err.msg
|
|
|
})
|
|
|
// that.popTest()
|
|
|
if (err.code == 0) {
|
|
|
that.setData({
|
|
|
bind_car: 0,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},
|
|
|
async getindexUser() { // 获取 4s关注数据
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data: {
|
|
|
data
|
|
|
}
|
|
|
} = await request({
|
|
|
url: 'api/index2/indexUnder',
|
|
|
})
|
|
|
console.log(data, "4SD店列表");
|
|
|
if (data.length == 0) { // 如果是空数组,你调用的是【推荐4s店】这个接口
|
|
|
that.getCitied()
|
|
|
}
|
|
|
that.setData({
|
|
|
index4S: data
|
|
|
})
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
a.popTest(err.msg)
|
|
|
}
|
|
|
|
|
|
},
|
|
|
getCitied() { // 获取城市信息
|
|
|
let that = this
|
|
|
wx.getLocation({
|
|
|
type: 'wgs84', //默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
|
|
|
success: function (res) {
|
|
|
qqmapsdk.reverseGeocoder({
|
|
|
//位置坐标,默认获取当前位置,非必须参数
|
|
|
//Object格式
|
|
|
location: {
|
|
|
latitude: res.latitude,
|
|
|
longitude: res.longitude
|
|
|
},
|
|
|
success: function (res) { //成功后的回调
|
|
|
console.log(res);
|
|
|
var res = res.result;
|
|
|
let city = res.ad_info.city
|
|
|
that.saveCity(city)
|
|
|
},
|
|
|
fail: function (error) {
|
|
|
console.error(error);
|
|
|
},
|
|
|
complete: function (res) {
|
|
|
// console.log(res);
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
fail: res => {}
|
|
|
})
|
|
|
return
|
|
|
},
|
|
|
async saveCity(city) {
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data: {
|
|
|
data
|
|
|
}
|
|
|
} = await request({
|
|
|
url: 'api/citys/getCity',
|
|
|
data: {
|
|
|
city: city
|
|
|
}
|
|
|
})
|
|
|
console.log(data, "首页全局城市定位");
|
|
|
that.setData({
|
|
|
city_id: data.city_id
|
|
|
})
|
|
|
if (that.data.index4S.length == 0) {
|
|
|
that.getSuccessPage()
|
|
|
}
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
a.popTest(err.msg)
|
|
|
}
|
|
|
},
|
|
|
async getSuccessPage() { // 获取推荐
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data: {
|
|
|
data
|
|
|
}
|
|
|
} = await request({
|
|
|
url: 'api/index2/tuiList2',
|
|
|
data: {
|
|
|
city_id: that.data.city_id
|
|
|
}
|
|
|
})
|
|
|
console.log(data);
|
|
|
that.setData({
|
|
|
groom: data
|
|
|
})
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
that.setData({
|
|
|
msg: err.msg
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
|
|
|
},
|
|
|
async clickAttention(e) { // 点击关注
|
|
|
let that = this
|
|
|
let id = e.currentTarget.dataset.id
|
|
|
let token = wx.getStorageSync('token')
|
|
|
if (token) {
|
|
|
try {
|
|
|
const {
|
|
|
data
|
|
|
} = await request({
|
|
|
url: 'api/index2/guan',
|
|
|
data: {
|
|
|
id: id
|
|
|
}
|
|
|
})
|
|
|
console.log(data);
|
|
|
if (data.code == 1) {
|
|
|
a.popSuccessTest(data.msg)
|
|
|
}
|
|
|
setTimeout(() => { // 一旦有关注的店,就不显示推荐好店
|
|
|
// that.getSuccessPage()
|
|
|
that.getindexUser()
|
|
|
}, 500);
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
a.popTest(err.msg)
|
|
|
}
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
goToAccess(e) {
|
|
|
let id = e.currentTarget.dataset.id
|
|
|
console.log(e);
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/goAccessoriesDetailIMG/goAccessoriesDetailIMG?id=' + id
|
|
|
})
|
|
|
},
|
|
|
gobind4S() { // 立即绑定4S店
|
|
|
let that = this
|
|
|
let pin_id = that.data.pin_id
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/my4S/my4S?pin_id=' + pin_id,
|
|
|
})
|
|
|
|
|
|
},
|
|
|
goViolationQuery() { //
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync('token')
|
|
|
if (token) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/ViolationQuery/ViolationQuery'
|
|
|
})
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
goAccessoriesDetailIMG(e) { //进入配件详情
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync('token')
|
|
|
let goodDetal = that.data.goodDetal
|
|
|
let tir = e.currentTarget.dataset.tir
|
|
|
if (token) {
|
|
|
if (tir == 1) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/productdetailsImg/productdetailsImg?id=' + goodDetal.good1_id
|
|
|
})
|
|
|
} else if (tir == 2) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/productdetailsImg/productdetailsImg?id=' + goodDetal.good2_id
|
|
|
})
|
|
|
} else {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/productdetailsImg/productdetailsImg?id=' + goodDetal.good3_id
|
|
|
})
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
goV4Sstores(e) { // 进入我的4s店
|
|
|
let that = this
|
|
|
console.log(e);
|
|
|
let s4_id = e.currentTarget.dataset.id
|
|
|
let token = wx.getStorageSync('token')
|
|
|
// a.globalData.stores_id = s4_id
|
|
|
console.log(s4_id);
|
|
|
if (token) {
|
|
|
wx.navigateTo({
|
|
|
// url: '/pages/4Sstore/4Sstore'
|
|
|
url: '/pages/Vnew4Sstore/Vnew4Sstore?s4_id=' + s4_id
|
|
|
|
|
|
})
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
ToV4Sstores(e) {
|
|
|
let that = this
|
|
|
let id = e.currentTarget.dataset.id
|
|
|
let token = wx.getStorageSync('token')
|
|
|
if (token) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/Vnew4Sstore/Vnew4Sstore?s4_id=' + id
|
|
|
})
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
goUpkeepimg() { // 保养预约
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync('token')
|
|
|
let id = that.data.id
|
|
|
let homeChe = that.data.homeChe
|
|
|
if (token) {
|
|
|
if (id == '') {
|
|
|
that.setData({
|
|
|
msg: '您尚未绑定4S店'
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
if (homeChe.length == 0) {
|
|
|
that.setData({
|
|
|
msg: '请先绑定爱车'
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
if (homeChe.length != 0 && id != '') {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/upkeepImg/upkeepImg?id=' + id
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
toMyGarage() { // 我的车库
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/MyGarage/MyGarage?tdTap=1'
|
|
|
})
|
|
|
} else {
|
|
|
this.goLogin()
|
|
|
}
|
|
|
|
|
|
},
|
|
|
goVopenPolicy() {
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync('token')
|
|
|
let id = that.data.id
|
|
|
let homeChe = that.data.homeChe
|
|
|
console.log(homeChe);
|
|
|
if (token) {
|
|
|
if (id == '') {
|
|
|
that.setData({
|
|
|
msg: '您尚未绑定4S店'
|
|
|
})
|
|
|
that.popTest()
|
|
|
|
|
|
}
|
|
|
if (homeChe == null) {
|
|
|
that.setData({
|
|
|
msg: '请先绑定爱车'
|
|
|
})
|
|
|
that.popTest()
|
|
|
|
|
|
}
|
|
|
if (homeChe != null && id != '') {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/VopenPolicy/VopenPolicy?che_id=' + homeChe.id
|
|
|
})
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
goVopenPolicyB() {
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync('token')
|
|
|
let id = that.data.id
|
|
|
let homeChe = that.data.homeChe
|
|
|
if (token) {
|
|
|
if (id == '') {
|
|
|
that.setData({
|
|
|
msg: '您尚未绑定4S店'
|
|
|
})
|
|
|
that.popTest()
|
|
|
|
|
|
}
|
|
|
if (homeChe == null) {
|
|
|
that.setData({
|
|
|
msg: '请先绑定爱车'
|
|
|
})
|
|
|
that.popTest()
|
|
|
|
|
|
}
|
|
|
if (homeChe != null && id != '') {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/VopenPolicyB/VopenPolicyB?che_id=' + homeChe.id
|
|
|
})
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
goVopenPolicyC() {
|
|
|
let that = this
|
|
|
let token = wx.getStorageSync('token')
|
|
|
let id = that.data.id
|
|
|
let homeChe = that.data.homeChe
|
|
|
if (token) {
|
|
|
if (id == '') {
|
|
|
that.setData({
|
|
|
msg: '您尚未绑定4S店'
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
if (homeChe == null) {
|
|
|
that.setData({
|
|
|
msg: '请先绑定爱车'
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
if (homeChe != null && id != '') {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/VopenPolicyC/VopenPolicyC?che_id=' + homeChe.id
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
gobindChe() {
|
|
|
let that = this
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: that.data.msg,
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/MyGarage/MyGarage?tdTap=1'
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
onShareAppMessage(options) {
|
|
|
var that = this;
|
|
|
var shareObj = {
|
|
|
title: "汽车互联网4S店",
|
|
|
path: '/pages/home/home',
|
|
|
imageUrl: '',
|
|
|
};
|
|
|
return shareObj;
|
|
|
|
|
|
},
|
|
|
toGoDetailA(e) {
|
|
|
let that = this
|
|
|
let idata = e.currentTarget.dataset.idata
|
|
|
let jump = idata.jump_type
|
|
|
let good_type = Number(idata.good_type1)
|
|
|
let good_id = idata.good1_id
|
|
|
that.publicDetails(jump, good_type, good_id)
|
|
|
},
|
|
|
toGoDetailB(e) {
|
|
|
let that = this
|
|
|
let idata = e.currentTarget.dataset.idata
|
|
|
let jump = idata.jump_type
|
|
|
let good_type = Number(idata.good_type2)
|
|
|
let good_id = idata.good2_id
|
|
|
that.publicDetails(jump, good_type, good_id)
|
|
|
},
|
|
|
toGoDetailC(e) {
|
|
|
let that = this
|
|
|
let idata = e.currentTarget.dataset.idata
|
|
|
let jump = idata.jump_type
|
|
|
let good_type = Number(idata.good_type3)
|
|
|
let good_id = idata.good3_id
|
|
|
that.publicDetails(jump, good_type, good_id)
|
|
|
},
|
|
|
publicDetails(jump, good_type, good_id) {
|
|
|
if (jump == 1) { //可以跳转
|
|
|
switch (good_type) {
|
|
|
case 1: // 人气好物
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/detail/detail?id=' + good_id
|
|
|
})
|
|
|
break;
|
|
|
case 2: // 精选推荐
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/productdetailsImg/productdetailsImg?id=' + good_id
|
|
|
})
|
|
|
break;
|
|
|
case 3: // 团购热卖
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/VtuanDetail/VtuanDetail?id=' + good_id
|
|
|
})
|
|
|
break;
|
|
|
case 4: //限时抢购
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/VSpikeMallDetail/VSpikeMallDetail?id=' + good_id
|
|
|
})
|
|
|
break;
|
|
|
case 5: //车型商品
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/carDetails/carDetails?id=' + good_id
|
|
|
})
|
|
|
break;
|
|
|
case -1: //推广活动详情
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/activityDetails/activityDetails?id=' + good_id + '&type=1' + '&tap=0'
|
|
|
})
|
|
|
break;
|
|
|
case -2: //限时活动详情
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/details/details?id=' + good_id + '&type=2'
|
|
|
})
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
} else {
|
|
|
a.popTest('该4s店暂未运营')
|
|
|
}
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async public() {
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
|
|
data: {
|
|
|
data
|
|
|
}
|
|
|
} = await request({
|
|
|
url: '',
|
|
|
data: {
|
|
|
goods_id: that.data.goods_id
|
|
|
}
|
|
|
})
|
|
|
console.log(data);
|
|
|
that.setData({
|
|
|
public: data
|
|
|
})
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
that.setData({
|
|
|
msg: err.msg
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
},
|
|
|
popTest() {
|
|
|
wx.showToast({
|
|
|
title: this.data.msg,
|
|
|
icon: 'none', //如果要纯文本,不要icon,将值设为'none'
|
|
|
duration: 1300
|
|
|
})
|
|
|
},
|
|
|
goLogin() {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您尚未登录,前往登录',
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/authorization/authorization?num=1'
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
// wx.switchTab({
|
|
|
// url: '/pages/home/home'
|
|
|
// })
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
popSuccessTest() {
|
|
|
wx.showToast({
|
|
|
title: this.data.msg,
|
|
|
icon: '', //默认值是success,就算没有icon这个值,就算有其他值最终也显示success
|
|
|
duration: 1300, //停留时间
|
|
|
})
|
|
|
},
|
|
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|