|
|
var app = getApp();
|
|
|
var animation = wx.createAnimation({
|
|
|
duration: 1000,
|
|
|
timingFunction: "ease",
|
|
|
})
|
|
|
Page({
|
|
|
data: {
|
|
|
winHeight: "",//窗口高度
|
|
|
currentTab: 0, //预设当前项的值
|
|
|
scrollLeft: 0, //tab标题的滚动条位置
|
|
|
expertList: [{}],
|
|
|
imgUrls: [],
|
|
|
indicatorDots: true,
|
|
|
autoplay: true,
|
|
|
interval: 3000,
|
|
|
duration: 1000,
|
|
|
// 筛选 ------------
|
|
|
winWidth: 0,
|
|
|
winHeight: 0,
|
|
|
// tab切换
|
|
|
currentTabT: 0,
|
|
|
// 筛选框状态
|
|
|
screenModel: false,
|
|
|
tabBarIndex: [],
|
|
|
// 动画状态
|
|
|
animation: false,
|
|
|
animations: false,
|
|
|
moudelOne: true,
|
|
|
authorization: false,
|
|
|
|
|
|
// 首页数据
|
|
|
allData: [],
|
|
|
// 自提点列表
|
|
|
sinceList: [],
|
|
|
// 堂食店铺列表
|
|
|
hallListh: [],
|
|
|
// 就近自提
|
|
|
nearest_spot: "",
|
|
|
// 到店堂食
|
|
|
nearest_store: "",
|
|
|
stateShop: false,
|
|
|
// 是否开启调研按钮
|
|
|
diaoyan: false,
|
|
|
|
|
|
// 判断设备活动快距离
|
|
|
rpx: 0,
|
|
|
// 递减cart_id
|
|
|
cart_id:null,
|
|
|
menu: false,
|
|
|
canaction: false //阻止快速点击事件
|
|
|
},
|
|
|
// 没有门口
|
|
|
sisi() {
|
|
|
wx.navigateTo({
|
|
|
url: '../expectLocation/expectLocation',
|
|
|
})
|
|
|
},
|
|
|
// 选择到店堂食
|
|
|
arriveShop(e) {
|
|
|
wx.showLoading({
|
|
|
title: '地址切换中。。。',
|
|
|
})
|
|
|
console.log(app.globalData.nearest_store)
|
|
|
var data = e.currentTarget.dataset.data;
|
|
|
var params = new Object;
|
|
|
params.store_id = data.store_id;
|
|
|
params.store_name = data.store_name + data.store_address + ",距您" + data.distance_text
|
|
|
app.globalData.nearest_store = params;
|
|
|
console.log(app.globalData.nearest_store)
|
|
|
this.setData({
|
|
|
moudelOne: true,
|
|
|
stateShop: true,
|
|
|
nearest_store: app.globalData.nearest_store
|
|
|
})
|
|
|
wx.showToast({
|
|
|
title: '切换完成',
|
|
|
icon: 'success',
|
|
|
duration: 2000
|
|
|
})
|
|
|
},
|
|
|
// 选择就近自提
|
|
|
setLocation(e) {
|
|
|
wx.showLoading({
|
|
|
title: '地址切换中。。。',
|
|
|
})
|
|
|
var spot_id = e.currentTarget.dataset.spot_id;
|
|
|
var spot_name = e.currentTarget.dataset.spot_name;
|
|
|
var distance_text = e.currentTarget.dataset.distance_text;
|
|
|
var params = new Object;
|
|
|
params.spot_id = spot_id;
|
|
|
params.spot_name = spot_name + distance_text;
|
|
|
app.globalData.nearest_spot = params;
|
|
|
console.log(app.globalData.nearest_spot)
|
|
|
this.setData({
|
|
|
screenModel: false,
|
|
|
nearest_spot: app.globalData.nearest_spot
|
|
|
})
|
|
|
wx.showToast({
|
|
|
title: '切换完成',
|
|
|
icon: 'success',
|
|
|
duration: 2000
|
|
|
})
|
|
|
},
|
|
|
// 判断是否新人能否领取优惠券
|
|
|
justy(){
|
|
|
app.ajax("Index/isFirst", {
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
if (res.statusCode == '200'){
|
|
|
this.setData({
|
|
|
card: res.data.status,
|
|
|
cardInfo: res.data.data
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
// 授权登陆
|
|
|
bindGetUserInfo(e) {
|
|
|
var that = this
|
|
|
console.log(e)
|
|
|
console.log(e.detail.userInfo)
|
|
|
app.globalData.userInfo = e.detail.userInfo
|
|
|
wx.login({
|
|
|
success: (res) => {
|
|
|
if (res.code) {
|
|
|
//发起网络请求
|
|
|
console.log(res)
|
|
|
app.ajax("Index/auth", {
|
|
|
code: res.code,
|
|
|
iv: e.detail.iv,
|
|
|
encryptedData: e.detail.encryptedData,
|
|
|
nickname: app.globalData.userInfo.nickName,
|
|
|
head_img: app.globalData.userInfo.avatarUrl,
|
|
|
}, (res) => {
|
|
|
this.onShow()
|
|
|
if (res.data.data.is_auth == 1) {
|
|
|
app.globalData.unique_id = res.data.data.unique_id
|
|
|
if (that.data.from) {
|
|
|
app.ajax("DiscountCoupon/shareGetCoupon", {
|
|
|
from: that.data.from,
|
|
|
to: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
})
|
|
|
}
|
|
|
this.setData({
|
|
|
authorization: false
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
console.log('获取用户登录态失败!' + res.errMsg)
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
},
|
|
|
hideCard(){
|
|
|
this.setData({
|
|
|
card: false
|
|
|
})
|
|
|
},
|
|
|
getCard(event){
|
|
|
let that = this
|
|
|
let info = this.data.cardInfo
|
|
|
var params = Object.assign({},info)
|
|
|
params.unique_id = app.globalData.unique_id
|
|
|
app.ajax("Index/receivePledge", params, (res) => {
|
|
|
console.log(res)
|
|
|
if(res.data.state == 'success'){
|
|
|
that.hideCard()
|
|
|
wx.showToast({
|
|
|
title: res.data.msg,
|
|
|
icon: 'success'
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
// 递增操作
|
|
|
addCount(e) {
|
|
|
wx.showLoading({
|
|
|
title: '加载中',
|
|
|
mask: true
|
|
|
})
|
|
|
var index = e.currentTarget.dataset.index;
|
|
|
var id = e.currentTarget.dataset.id;
|
|
|
var num = parseInt(e.currentTarget.dataset.num);
|
|
|
num++
|
|
|
app.ajax("Cart/add", {
|
|
|
unique_id: app.globalData.unique_id,
|
|
|
goods_id: id,
|
|
|
goods_num: 1,
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
wx.hideLoading()
|
|
|
if (res.data.status == true) {
|
|
|
var data = this.data.allData.goods_list;
|
|
|
data[index].chacke = true;
|
|
|
data[index].num = num;
|
|
|
this.setData({
|
|
|
"allData.goods_list": data
|
|
|
})
|
|
|
// 获取购物车数量
|
|
|
app.ajax("CountNum/countCart", {
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
if (res.data.status == true) {
|
|
|
app.globalData.tabBar[1].num = res.data.data[0].count
|
|
|
this.setData({
|
|
|
tabBarIndex: app.globalData.tabBar
|
|
|
})
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
}else{
|
|
|
wx.showToast({
|
|
|
title: res.data.msg,
|
|
|
icon: 'none'
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
// 递减操作
|
|
|
minusCount(e) {
|
|
|
wx.showLoading({
|
|
|
title: '加载中',
|
|
|
mask:true
|
|
|
})
|
|
|
var index = e.currentTarget.dataset.index;
|
|
|
var id = e.currentTarget.dataset.id;
|
|
|
var num = parseInt(e.currentTarget.dataset.num);
|
|
|
var cart_id = e.currentTarget.dataset.cart_id
|
|
|
if(num<=1){
|
|
|
app.ajax("Cart/del", {
|
|
|
cart_id: cart_id
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
if (res.data.status == true) {
|
|
|
// this.getShopCar()
|
|
|
var data = this.data.allData.goods_list;
|
|
|
data[index].chacke = false;
|
|
|
this.setData({
|
|
|
"allData.goods_list": data
|
|
|
})
|
|
|
// 获取购物车数量
|
|
|
app.ajax("CountNum/countCart", {
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
wx.hideLoading()
|
|
|
if (res.data.status == true) {
|
|
|
app.globalData.tabBar[1].num = res.data.data[0].count
|
|
|
this.setData({
|
|
|
tabBarIndex: app.globalData.tabBar
|
|
|
})
|
|
|
// console.log(res.data.data[0].count)
|
|
|
}
|
|
|
|
|
|
}, (res) => { })
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
}else{
|
|
|
num--
|
|
|
app.ajax("Cart/add", {
|
|
|
unique_id: app.globalData.unique_id,
|
|
|
goods_id: id,
|
|
|
goods_num: -1,
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
wx.hideLoading()
|
|
|
if (res.data.status == true) {
|
|
|
var data = this.data.allData.goods_list;
|
|
|
data[index].chacke = true;
|
|
|
data[index].num = num;
|
|
|
this.setData({
|
|
|
"allData.goods_list": data,
|
|
|
cart_id: res.data.cart_id
|
|
|
})
|
|
|
// 获取购物车数量
|
|
|
app.ajax("CountNum/countCart", {
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
if (res.data.status == true) {
|
|
|
app.globalData.tabBar[1].num = res.data.data[0].count
|
|
|
this.setData({
|
|
|
tabBarIndex: app.globalData.tabBar
|
|
|
})
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
// if (num < 1) {
|
|
|
|
|
|
// } else {
|
|
|
// num--
|
|
|
// app.ajax("Cart/editNum", {
|
|
|
// goods_num: -1
|
|
|
// }, (res) => {
|
|
|
// console.log(res)
|
|
|
// if (res.data.status == true) {
|
|
|
// this.getShopCar()
|
|
|
// // 获取购物车数量
|
|
|
// app.ajax("CountNum/countCart", {
|
|
|
// unique_id: app.globalData.unique_id
|
|
|
// }, (res) => {
|
|
|
// console.log(res)
|
|
|
// if (res.data.status == true) {
|
|
|
// if (parseInt(res.data.data[0].count) == 0) {
|
|
|
// wx.showModal({
|
|
|
// title: '提示',
|
|
|
// content: '是否删除该商品',
|
|
|
// success: (res) => {
|
|
|
// if (res.confirm) {
|
|
|
// console.log('用户点击确定')
|
|
|
// app.ajax("Cart/del", {
|
|
|
// cart_id: cart_id
|
|
|
// }, (res) => {
|
|
|
// console.log(res)
|
|
|
// if (res.data.status == true) {
|
|
|
// this.getShopCar()
|
|
|
// // 获取购物车数量
|
|
|
// app.ajax("CountNum/countCart", {
|
|
|
// unique_id: app.globalData.unique_id
|
|
|
// }, (res) => {
|
|
|
// console.log(res)
|
|
|
// if (res.data.status == true) {
|
|
|
// app.globalData.tabBar[1].num = res.data.data[0].count
|
|
|
// this.setData({
|
|
|
// tabBarIndex: app.globalData.tabBar
|
|
|
// })
|
|
|
// }
|
|
|
// }, (res) => { })
|
|
|
// }
|
|
|
// }, (res) => { })
|
|
|
// } else if (res.cancel) {
|
|
|
// console.log('用户点击取消')
|
|
|
// }
|
|
|
// }
|
|
|
// })
|
|
|
// }
|
|
|
// app.globalData.tabBar[1].num = res.data.data[0].count
|
|
|
// this.setData({
|
|
|
// tabBarIndex: app.globalData.tabBar
|
|
|
// })
|
|
|
// }
|
|
|
// }, (res) => { })
|
|
|
// }
|
|
|
// }, (res) => { })
|
|
|
// }
|
|
|
|
|
|
|
|
|
},
|
|
|
// 商品列表加入购物车
|
|
|
openShopCar(e) {
|
|
|
var index = e.currentTarget.dataset.index;
|
|
|
var id = e.currentTarget.dataset.id;
|
|
|
var num = e.currentTarget.dataset.num;
|
|
|
app.ajax("Cart/add", {
|
|
|
unique_id: app.globalData.unique_id,
|
|
|
goods_id: id,
|
|
|
goods_num: num,
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
if (res.data.status == true) {
|
|
|
var data = this.data.allData.goods_list;
|
|
|
data[index].chacke = true;
|
|
|
data[index].cart_id = res.data.cart_id
|
|
|
this.setData({
|
|
|
"allData.goods_list": data
|
|
|
})
|
|
|
|
|
|
// 获取购物车数量
|
|
|
app.ajax("CountNum/countCart", {
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
if (res.data.status == true) {
|
|
|
app.globalData.tabBar[1].num = res.data.data[0].count
|
|
|
this.setData({
|
|
|
tabBarIndex: app.globalData.tabBar
|
|
|
})
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
// 获取购物车
|
|
|
app.ajax("Cart/index", {
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log("获取购物车")
|
|
|
console.log(res)
|
|
|
if (res.data.status == true) {
|
|
|
app.globalData.shoppingCart = res.data.data
|
|
|
console.log(app.globalData.tabBar)
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
}else{
|
|
|
wx.showToast({
|
|
|
title: '库存不足',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
// 引导页
|
|
|
guidance() {
|
|
|
wx.navigateTo({
|
|
|
url: '../guidance/guidance',
|
|
|
})
|
|
|
},
|
|
|
// 门店详情
|
|
|
shopDetails(e) {
|
|
|
var store_id = e.currentTarget.dataset.store_id;
|
|
|
var store_name = e.currentTarget.dataset.store_name;
|
|
|
var open_start = e.currentTarget.dataset.open_start;
|
|
|
var open_end = e.currentTarget.dataset.open_end;
|
|
|
var store_address = e.currentTarget.dataset.store_address;
|
|
|
var distance_text = e.currentTarget.dataset.distance_text;
|
|
|
wx.navigateTo({
|
|
|
url: '../shopDetails/shopDetails?store_id=' + store_id + "&store_name=" + store_name + "&open_start=" + open_start + "&open_end=" + open_end + "&store_address=" + store_address + "&distance_text=" + distance_text,
|
|
|
})
|
|
|
},
|
|
|
// 下导航
|
|
|
tabBar(e) {
|
|
|
var index = e.currentTarget.dataset.index;
|
|
|
var tabBar = app.globalData.tabBar
|
|
|
for (let n in tabBar) {
|
|
|
tabBar[n].state = false
|
|
|
}
|
|
|
tabBar[index].state = !tabBar[index].state
|
|
|
app.globalData.tabBar = tabBar
|
|
|
wx.reLaunch({
|
|
|
url: tabBar[index].url,
|
|
|
})
|
|
|
},
|
|
|
// 列表详情
|
|
|
detailsGoods(e) {
|
|
|
var id = e.currentTarget.dataset.id;
|
|
|
wx.navigateTo({
|
|
|
url: '../detailsGoods/detailsGoods?id=' + id,
|
|
|
})
|
|
|
},
|
|
|
// 取货点详情
|
|
|
getGoodsDetails(e) {
|
|
|
let spot_id = e.currentTarget.dataset.spot_id;
|
|
|
wx.navigateTo({
|
|
|
url: '../getGoodsDetails/getGoodsDetails?spot_id=' + spot_id,
|
|
|
})
|
|
|
},
|
|
|
// 防止穿透
|
|
|
cat() { },
|
|
|
// 点击收起筛选
|
|
|
model() {
|
|
|
console.log(1)
|
|
|
this.setData({
|
|
|
screenModel: !this.data.screenModel
|
|
|
})
|
|
|
},
|
|
|
// 滚动切换标签样式
|
|
|
switchTab: function (e) {
|
|
|
this.setData({
|
|
|
currentTab: e.detail.current
|
|
|
});
|
|
|
this.checkCor();
|
|
|
},
|
|
|
// 点击标题切换当前页时改变样式
|
|
|
swichNav: function (e) {
|
|
|
console.log(e)
|
|
|
if (!this.data.canaction){
|
|
|
return false
|
|
|
}else{
|
|
|
this.setData({
|
|
|
canaction: false
|
|
|
})
|
|
|
var cur = e.target.dataset.current;
|
|
|
var t_id = e.currentTarget.dataset.t_id;
|
|
|
if (this.data.currentTaB == cur) {
|
|
|
return false;
|
|
|
}else {
|
|
|
this.setData({
|
|
|
currentTab: cur
|
|
|
})
|
|
|
}
|
|
|
wx.showLoading({
|
|
|
title: '加载中',
|
|
|
})
|
|
|
var params = new Object
|
|
|
if (cur == 0){
|
|
|
params.unique_id = app.globalData.unique_id
|
|
|
}else if(cur == '-1'){
|
|
|
params.unique_id = app.globalData.unique_id
|
|
|
app.ajax("Index/newGoodsList", params, (res) => {
|
|
|
wx.hideLoading()
|
|
|
if (res.statusCode == '200') {
|
|
|
var mes = res.data.data
|
|
|
var data = mes;
|
|
|
for (let n in data) {
|
|
|
data[n].chacke = false
|
|
|
data[n].num = 1
|
|
|
}
|
|
|
for (let n in data) {
|
|
|
if (data[n].goods_num != null) {
|
|
|
data[n].chacke = true
|
|
|
data[n].num = parseInt(data[n].goods_num)
|
|
|
}
|
|
|
}
|
|
|
this.setData({
|
|
|
'allData.goods_list': mes,
|
|
|
canaction: true
|
|
|
})
|
|
|
// this.setData({
|
|
|
// allData: res.data.data,
|
|
|
// imgUrls: res.data.data.banner
|
|
|
// })
|
|
|
} else {
|
|
|
wx.showLoading({
|
|
|
title: '暂无商品',
|
|
|
duration: 1000
|
|
|
})
|
|
|
this.setData({
|
|
|
"allData.goods_list": [],
|
|
|
canaction: true
|
|
|
})
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
|
|
|
return false
|
|
|
}else{
|
|
|
params.t_id = t_id
|
|
|
params.unique_id = app.globalData.unique_id
|
|
|
}
|
|
|
app.ajax("Index/index",params, (res) => {
|
|
|
wx.hideLoading()
|
|
|
console.log("获取首页数据")
|
|
|
console.log(res)
|
|
|
if (res.data.status == true) {
|
|
|
var mes = res.data.data
|
|
|
var data = mes.goods_list;
|
|
|
for (let n in data) {
|
|
|
data[n].chacke = false
|
|
|
data[n].num = 1
|
|
|
}
|
|
|
for (let n in data) {
|
|
|
if (data[n].goods_num != null) {
|
|
|
data[n].chacke = true
|
|
|
data[n].num = parseInt(data[n].goods_num)
|
|
|
}
|
|
|
}
|
|
|
app.globalData.nearest_spot = mes.nearest_spot
|
|
|
app.globalData.nearest_store = mes.nearest_store
|
|
|
this.setData({
|
|
|
allData: mes,
|
|
|
menu: true,
|
|
|
imgUrls: res.data.data.banner,
|
|
|
nearest_spot: app.globalData.nearest_spot,
|
|
|
nearest_store: app.globalData.nearest_store,
|
|
|
canaction: true
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
wx.showLoading({
|
|
|
title: '暂无商品',
|
|
|
duration: 1000
|
|
|
})
|
|
|
this.setData({
|
|
|
"allData.goods_list": [],
|
|
|
canaction: true
|
|
|
})
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
|
|
|
}
|
|
|
},
|
|
|
//判断当前滚动超过一屏时,设置tab标题滚动条。
|
|
|
checkCor: function () {
|
|
|
if (this.data.currentTab > 4) {
|
|
|
this.setData({
|
|
|
scrollLeft: 300
|
|
|
})
|
|
|
} else {
|
|
|
this.setData({
|
|
|
scrollLeft: 0
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
|
* 滑动切换tab
|
|
|
*/
|
|
|
bindChangeT: function (e) {
|
|
|
|
|
|
var that = this;
|
|
|
that.setData({ currentTabT: e.detail.current });
|
|
|
|
|
|
},
|
|
|
/**
|
|
|
* 点击tab切换
|
|
|
*/
|
|
|
swichNavT: function (e) {
|
|
|
|
|
|
var that = this;
|
|
|
|
|
|
if (this.data.currentTabT === e.target.dataset.current) {
|
|
|
return false;
|
|
|
} else {
|
|
|
that.setData({
|
|
|
currentTabT: e.target.dataset.current
|
|
|
})
|
|
|
}
|
|
|
var area_id = e.target.dataset.area_id;
|
|
|
|
|
|
app.ajax("Spot/index", {
|
|
|
area_id: area_id,
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log("获取自提点数据")
|
|
|
console.log(res)
|
|
|
if (res.data.status == true) {
|
|
|
this.setData({
|
|
|
sinceList: res.data.data
|
|
|
})
|
|
|
if (res.data.data.spot == null) {
|
|
|
wx.showLoading({
|
|
|
title: '空空如也',
|
|
|
duration: 1000,
|
|
|
mask: true
|
|
|
})
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
},
|
|
|
// 动画
|
|
|
animations(e) {
|
|
|
var state = e.currentTarget.dataset.state;
|
|
|
var type = e.currentTarget.dataset.type
|
|
|
console.log(this.data.animation)
|
|
|
console.log(state)
|
|
|
if (this.data.animations == false && state == false) {
|
|
|
console.log(1)
|
|
|
this.setData({
|
|
|
screenModel: !this.data.screenModel,
|
|
|
})
|
|
|
} else if (this.data.animations == true && state == true) {
|
|
|
if (this.data.moudelOne){
|
|
|
this.setData({
|
|
|
moudelOne: false
|
|
|
})
|
|
|
}else{
|
|
|
this.setData({
|
|
|
moudelOne: true
|
|
|
})
|
|
|
}
|
|
|
// this.setData({
|
|
|
// animation: true,
|
|
|
// stateShop: true
|
|
|
// })
|
|
|
} else if (this.data.animations == false && state == true) {
|
|
|
console.log(3)
|
|
|
console.log(this.data.rpx)
|
|
|
animation.translate((96 * 1.8) * this.data.rpx).step();
|
|
|
app.globalData.btnStart = false
|
|
|
this.setData({
|
|
|
animationData: animation.export(),
|
|
|
animations: true,
|
|
|
moudelOne: false,
|
|
|
stateShop: !this.data.stateShop,
|
|
|
screenModel: false
|
|
|
})
|
|
|
} else if (this.data.animations == true && state == false) {
|
|
|
console.log(4)
|
|
|
animation.translate(0).step();
|
|
|
app.globalData.btnStart = true
|
|
|
this.setData({
|
|
|
animationData: animation.export(),
|
|
|
animations: false,
|
|
|
moudelOne: true,
|
|
|
stateShop: !this.data.stateShop,
|
|
|
screenModel:true
|
|
|
})
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
onLoad: function (options) {
|
|
|
if (options.from) {
|
|
|
this.setData({
|
|
|
from: options.from
|
|
|
})
|
|
|
}
|
|
|
var that = this;
|
|
|
// 高度自适应
|
|
|
wx.getSystemInfo({
|
|
|
success: function (res) {
|
|
|
var clientHeight = res.windowHeight,
|
|
|
clientWidth = res.windowWidth,
|
|
|
rpxR = 750 / clientWidth;
|
|
|
var calc = clientHeight * rpxR - 180;
|
|
|
console.log(calc)
|
|
|
that.setData({
|
|
|
winHeight: calc
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
},
|
|
|
footerTap: app.footerTap,
|
|
|
onShow() {
|
|
|
let that = this
|
|
|
console.log(app.globalData.userInfo)
|
|
|
app.globalData.btnStart = true
|
|
|
|
|
|
wx.showLoading({
|
|
|
title: '加载中',
|
|
|
mask: true
|
|
|
})
|
|
|
|
|
|
// 设备判断滑动距离
|
|
|
wx.getSystemInfo({
|
|
|
success: (res) => {
|
|
|
let rpx = 1 * (res.windowWidth * res.pixelRatio) / (750 * res.pixelRatio);
|
|
|
this.setData({
|
|
|
rpx: rpx
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
// 获取用户是否需要授权
|
|
|
wx.login({
|
|
|
success: (res) => {
|
|
|
if (res.code) {
|
|
|
//发起网络请求
|
|
|
console.log(res)
|
|
|
app.ajax("Index/auth0", {
|
|
|
code: res.code
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
wx.hideLoading()
|
|
|
if (res.data.data.is_auth == 1) {
|
|
|
app.globalData.unique_id = res.data.data.unique_id
|
|
|
if (that.data.from){
|
|
|
app.ajax("DiscountCoupon/shareGetCoupon", {
|
|
|
from: that.data.from,
|
|
|
to: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
})
|
|
|
}
|
|
|
wx.getUserInfo({
|
|
|
success: function (res) {
|
|
|
var userInfo = res.userInfo
|
|
|
console.log(userInfo)
|
|
|
app.globalData.userInfo = userInfo
|
|
|
}
|
|
|
})
|
|
|
this.justy()
|
|
|
// 检测该用户是否参与了调研
|
|
|
app.ajax("Inquiry/isInquiry", {
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log("检测该用户是否参与了调研")
|
|
|
console.log(res)
|
|
|
if (res.data.data.is_inquiry != 1) {
|
|
|
// wx.navigateTo({
|
|
|
// url: '../guidance/guidance',
|
|
|
// })
|
|
|
this.setData({
|
|
|
diaoyan: true
|
|
|
})
|
|
|
} else {
|
|
|
this.setData({
|
|
|
diaoyan: false
|
|
|
})
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
// 获取堂食店铺列表
|
|
|
app.ajax("Store/storeList", {
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log("堂食店铺列表")
|
|
|
console.log(res)
|
|
|
if (res.data.status == true) {
|
|
|
this.setData({
|
|
|
hallListh: res.data.data
|
|
|
})
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
// 获取自提列表
|
|
|
app.ajax("Spot/index", {
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log("获取自提列表")
|
|
|
console.log(res)
|
|
|
if (res.data.status == true) {
|
|
|
this.setData({
|
|
|
sinceList: res.data.data
|
|
|
})
|
|
|
if (res.data.data.spot == null) {
|
|
|
wx.showLoading({
|
|
|
title: '空空如也',
|
|
|
duration: 1000,
|
|
|
mask: true
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
// 自提点列表
|
|
|
app.ajax("Spot/index", {
|
|
|
area_id: "",
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log("自提点列表")
|
|
|
console.log(res)
|
|
|
}, (res) => { })
|
|
|
// 首页数据
|
|
|
app.ajax("Index/index", {
|
|
|
t_id: "",
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log("获取首页数据")
|
|
|
console.log(res)
|
|
|
if (res.data.status == true) {
|
|
|
wx.hideLoading()
|
|
|
var mes = res.data.data
|
|
|
var data = mes.goods_list;
|
|
|
for (let n in data) {
|
|
|
data[n].chacke = false
|
|
|
data[n].num = 1
|
|
|
}
|
|
|
for (let n in data) {
|
|
|
if (data[n].goods_num != null) {
|
|
|
data[n].chacke = true
|
|
|
data[n].num = parseInt(data[n].goods_num)
|
|
|
}
|
|
|
}
|
|
|
app.globalData.nearest_spot = mes.nearest_spot
|
|
|
app.globalData.nearest_store = mes.nearest_store
|
|
|
this.setData({
|
|
|
allData: mes,
|
|
|
menu: true,
|
|
|
canaction: true,
|
|
|
imgUrls: res.data.data.banner,
|
|
|
nearest_spot: app.globalData.nearest_spot,
|
|
|
nearest_store: app.globalData.nearest_store
|
|
|
})
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
// 获取购物车数量
|
|
|
app.ajax("CountNum/countCart", {
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
if (res.data.status == true) {
|
|
|
app.globalData.tabBar[1].num = res.data.data[0].count
|
|
|
this.setData({
|
|
|
tabBarIndex: app.globalData.tabBar
|
|
|
})
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
// 获取购物车
|
|
|
app.ajax("Cart/index", {
|
|
|
unique_id: app.globalData.unique_id
|
|
|
}, (res) => {
|
|
|
console.log("获取购物车")
|
|
|
console.log(res)
|
|
|
if (res.data.status == true) {
|
|
|
var data = res.data.data
|
|
|
for (let n in data.cartList){
|
|
|
data.cartList[n].checked = true
|
|
|
}
|
|
|
app.globalData.shoppingCart = data
|
|
|
console.log(app.globalData.tabBar)
|
|
|
|
|
|
}
|
|
|
}, (res) => { })
|
|
|
} else if (res.data.data.is_auth == 0) {
|
|
|
this.setData({
|
|
|
authorization: true,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
})
|
|
|
} else {
|
|
|
console.log('获取用户登录态失败!' + res.errMsg)
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 获取经纬度
|
|
|
wx.getLocation({
|
|
|
type: 'wgs84',
|
|
|
success: (res) => {
|
|
|
var latitude = res.latitude
|
|
|
var longitude = res.longitude
|
|
|
app.ajax("Index/updateLatLng", {
|
|
|
unique_id: app.globalData.unique_id,
|
|
|
lat: latitude,
|
|
|
lng: longitude
|
|
|
}, (res) => {
|
|
|
console.log(res)
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|