...
|
...
|
@@ -45,64 +45,11 @@ Page({ |
|
|
let that = this
|
|
|
that.gethomeIndex()
|
|
|
that.gethomeLoop()
|
|
|
that.getStarModel()
|
|
|
that.getS4Info()
|
|
|
that.getindexUser()
|
|
|
that.getCitied()
|
|
|
},
|
|
|
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
|
|
|
})
|
|
|
that.getSuccessPage()
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
that.popTest(err.msg)
|
|
|
}
|
|
|
},
|
|
|
|
|
|
gohome() {
|
|
|
wx.switchTab({
|
|
|
url: '/pages/home/home'
|
...
|
...
|
@@ -140,33 +87,6 @@ Page({ |
|
|
that.goLogin()
|
|
|
}
|
|
|
},
|
|
|
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 gethomeIndex() { // 获取首页
|
|
|
let that = this
|
|
|
try {
|
...
|
...
|
@@ -217,42 +137,7 @@ Page({ |
|
|
}
|
|
|
|
|
|
},
|
|
|
async getStarModel() { // 获取明星车型
|
|
|
let that = this
|
|
|
let bind_car = that.data.bind_car
|
|
|
if (bind_car == 1) {
|
|
|
try {
|
|
|
const {
|
|
|
data
|
|
|
} = await request({
|
|
|
url: 'api/index2/mingXing',
|
|
|
})
|
|
|
console.log(data);
|
|
|
if (data.code == 1) {
|
|
|
that.setData({
|
|
|
starModel: data.data,
|
|
|
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()
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
async getS4Info() { // 获取 4s店数据
|
|
|
async getS4Info() { // 获取4s店数据
|
|
|
let that = this
|
|
|
try {
|
|
|
const {
|
...
|
...
|
@@ -272,12 +157,9 @@ Page({ |
|
|
that.setData({
|
|
|
msg: data.msg,
|
|
|
bind_car: 0,
|
|
|
|
|
|
})
|
|
|
that.popTest()
|
|
|
}
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
that.setData({
|
...
|
...
|
@@ -311,11 +193,88 @@ Page({ |
|
|
})
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
if (err.code == 0) {
|
|
|
that.setData({
|
|
|
bind_car: 0,
|
|
|
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()
|
|
|
}
|
|
|
|
|
|
},
|
...
|
...
|
@@ -335,25 +294,15 @@ Page({ |
|
|
})
|
|
|
console.log(data);
|
|
|
if (data.code == 1) {
|
|
|
that.setData({
|
|
|
msg: data.msg
|
|
|
})
|
|
|
that.popSuccessTest()
|
|
|
} else {
|
|
|
that.setData({
|
|
|
msg: data.msg
|
|
|
})
|
|
|
that.popTest()
|
|
|
a.popSuccessTest(data.msg)
|
|
|
}
|
|
|
setTimeout(() => {
|
|
|
that.getSuccessPage()
|
|
|
setTimeout(() => { // 一旦有关注的店,就不显示推荐好店
|
|
|
// that.getSuccessPage()
|
|
|
that.getindexUser()
|
|
|
}, 500);
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
|
that.setData({
|
|
|
msg: err.msg
|
|
|
})
|
|
|
that.popTest()
|
|
|
a.popTest(err.msg)
|
|
|
}
|
|
|
} else {
|
|
|
that.goLogin()
|
...
|
...
|
|