...
|
...
|
@@ -30,71 +30,241 @@ Page({ |
|
|
status1: '',
|
|
|
status2: '',
|
|
|
title2: '',
|
|
|
scrollTop:'',
|
|
|
pid:''
|
|
|
scrollTop: '',
|
|
|
pid: '',
|
|
|
logok: '',
|
|
|
selected: 0,
|
|
|
list: [{
|
|
|
pagePath: "/pages/index/index",
|
|
|
text: "商品",
|
|
|
iconPath: "/images/tabbar/icon_75.png",
|
|
|
selectedIconPath: "/images/tabbar/icon_68.png"
|
|
|
},
|
|
|
{
|
|
|
pagePath: "/pages/message/message",
|
|
|
text: "消息",
|
|
|
iconPath: "/images/tabbar/message.png",
|
|
|
selectedIconPath: "/images/tabbar/messageactive.png"
|
|
|
},
|
|
|
{
|
|
|
pagePath: "/pages/shop_cart/shop_cart",
|
|
|
text: "购物车",
|
|
|
iconPath: "/images/tabbar/icon_70.png",
|
|
|
selectedIconPath: "/images/tabbar/icon_73.png"
|
|
|
},
|
|
|
{
|
|
|
pagePath: "/pages/my/my",
|
|
|
text: "我的",
|
|
|
iconPath: "/images/tabbar/icon_71.png",
|
|
|
selectedIconPath: "/images/tabbar/icon_72.png"
|
|
|
}
|
|
|
],
|
|
|
category_id1: '',
|
|
|
sort: '',
|
|
|
keyword: '',
|
|
|
shop_arr: [],
|
|
|
pricesheng: false,
|
|
|
xiaoliang: false,
|
|
|
pinpailist: [],
|
|
|
seltui: 0,
|
|
|
isyouzhi:0
|
|
|
},
|
|
|
|
|
|
// 选择推荐列表
|
|
|
selitem(e) {
|
|
|
console.log(e)
|
|
|
let index = e.currentTarget.dataset.index;
|
|
|
this.setData({
|
|
|
seltui: index
|
|
|
})
|
|
|
},
|
|
|
// 进入商品列表
|
|
|
cityTap(e) {
|
|
|
console.log(e)
|
|
|
let id = e.currentTarget.dataset.id;
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/pinpaibox/pinpaibox?pinpaiid=' + id,
|
|
|
})
|
|
|
},
|
|
|
gopinpai() {
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token == '') {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请先登录',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/classify/classify?type=' + 2,
|
|
|
})
|
|
|
},
|
|
|
scroll(e) {
|
|
|
// console.log(e.detail.scrollTop)
|
|
|
// if (e.detail.scrollTop >300){
|
|
|
// console.log(8888)
|
|
|
// this.setData({
|
|
|
// stick:1
|
|
|
// })
|
|
|
// }else{
|
|
|
// this.setData({
|
|
|
// stick:0
|
|
|
// })
|
|
|
// }
|
|
|
console.log(e)
|
|
|
console.log(e.detail.scrollTop)
|
|
|
if (e.detail.scrollTop >600){
|
|
|
console.log(8888)
|
|
|
this.setData({
|
|
|
stick:1
|
|
|
})
|
|
|
}else{
|
|
|
this.setData({
|
|
|
stick:0
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// console.log(this.data.stick)
|
|
|
},
|
|
|
|
|
|
// 公告详情
|
|
|
noticedetail(e) {
|
|
|
let id = e.currentTarget.dataset.id;
|
|
|
wx.navigateTo({
|
|
|
url: '../notice/notice?notice_id=' + id,
|
|
|
})
|
|
|
},
|
|
|
|
|
|
onLoad: function(options) {
|
|
|
console.log( app.globalData.index)
|
|
|
if( app.globalData.index==undefined){
|
|
|
let that = this;
|
|
|
let token=wx.getStorageSync('token');
|
|
|
// 进入劳保商城
|
|
|
laobao() {
|
|
|
let token = wx.getStorageSync('token');
|
|
|
console.log(token)
|
|
|
if (token == '') {
|
|
|
wx.showToast({
|
|
|
title: '请先登录',
|
|
|
icon: 'none',
|
|
|
duration: 1300
|
|
|
})
|
|
|
setTimeout(function () {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/register/register',
|
|
|
})
|
|
|
}, 1300)
|
|
|
} else {
|
|
|
wx.setStorageSync('selecttype', 2)
|
|
|
wx.showLoading({
|
|
|
title: '加载中',
|
|
|
|
|
|
console.log('woshitoe',token);
|
|
|
if(token!=""){
|
|
|
console.log(9999)
|
|
|
this.getInfoFun()
|
|
|
}
|
|
|
this.get_notice()
|
|
|
this.get_shopnum()
|
|
|
this.getmessagelist();
|
|
|
console.log('998867',this.data.pid)
|
|
|
if(this.data.pid){
|
|
|
this.get_info(this.data.pid, 2);
|
|
|
}else{
|
|
|
this.get_info(0, 1);
|
|
|
}
|
|
|
})
|
|
|
setTimeout(function () {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/index/index',
|
|
|
})
|
|
|
}, 3000)
|
|
|
}
|
|
|
},
|
|
|
onLoad: function (options) {
|
|
|
console.log(app.globalData.index)
|
|
|
if (app.globalData.index == undefined) {
|
|
|
let that = this;
|
|
|
let token = wx.getStorageSync('token');
|
|
|
|
|
|
console.log('woshitoe', token);
|
|
|
if (token != "") {
|
|
|
console.log(9999)
|
|
|
this.getInfoFun()
|
|
|
}
|
|
|
this.get_notice()
|
|
|
this.get_shopnum()
|
|
|
this.getmessagelist();
|
|
|
console.log('998867', this.data.pid)
|
|
|
// if(this.data.pid){
|
|
|
// this.get_info(this.data.pid, 2);
|
|
|
// }else{
|
|
|
// this.get_info(0, 1);
|
|
|
// }
|
|
|
|
|
|
// 获取活动专区
|
|
|
this.getzhuanqulist();
|
|
|
this.getxianshi();
|
|
|
setTimeout(function () {
|
|
|
that.setData({
|
|
|
showtime: true
|
|
|
})
|
|
|
}, 990)
|
|
|
|
|
|
// 获取活动专区
|
|
|
this.getzhuanqulist();
|
|
|
this.getxianshi();
|
|
|
setTimeout(function() {
|
|
|
that.setData({
|
|
|
showtime: true
|
|
|
})
|
|
|
}, 990)
|
|
|
}
|
|
|
//控制显示隐藏
|
|
|
this.ishow()
|
|
|
this.getpinpailist()
|
|
|
}
|
|
|
//控制显示隐藏
|
|
|
this.ishow()
|
|
|
// 我写的项目
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
// 获取一级分类
|
|
|
getonkind() {
|
|
|
let that = this;
|
|
|
let url = "/sundry/get_category"
|
|
|
app.postk(url, {}).then((r) => {
|
|
|
console.log('商品分类', r)
|
|
|
let obj = {
|
|
|
name: '首页',
|
|
|
id: '',
|
|
|
description:"优质推荐"
|
|
|
}
|
|
|
r.data.unshift(obj)
|
|
|
r.data.forEach(function (value, index, array) {
|
|
|
if (value.description == '') {
|
|
|
value.description = '暂无描述'
|
|
|
}
|
|
|
})
|
|
|
that.setData({
|
|
|
nav_arr: r.data,
|
|
|
})
|
|
|
// 获取商品列表
|
|
|
that.getyouzhi()
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 获取优质推荐列表
|
|
|
getyouzhi() {
|
|
|
let that = this;
|
|
|
let url = '/activity/get_detail2'
|
|
|
let param = {
|
|
|
activity_id: '',
|
|
|
order: '',
|
|
|
page: this.data.page,
|
|
|
pageNum: 10
|
|
|
}
|
|
|
app.postk(url, param).then((res) => {
|
|
|
if (that.data.page > 1) {
|
|
|
if (res.data.length == 0) {
|
|
|
wx.showToast({
|
|
|
title: '没有更多了~',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
} else {
|
|
|
this.setData({
|
|
|
shop_arr: that.data.shop_arr.concat(res.data)
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
this.setData({
|
|
|
shop_arr: that.data.shop_arr.concat(res.data)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
console.log(that.data.shop_arr, '轮播图')
|
|
|
})
|
|
|
},
|
|
|
// 获取个人信息
|
|
|
getInfoFun() {
|
|
|
let that= this;
|
|
|
let that = this;
|
|
|
let u = app.interface.readteacher;
|
|
|
app.post(u, {}).then((r) => {
|
|
|
console.log('3489523498',r)
|
|
|
app.post(u, {}).then((r) => {
|
|
|
console.log('3489523498', r)
|
|
|
if (r.code == 200) {
|
|
|
|
|
|
app.globalData.login_new=r.msg.login_new;
|
|
|
app.globalData.login_new = r.msg.login_new;
|
|
|
app.globalData.status = r.msg.status;
|
|
|
console.log(app.globalData.status)
|
|
|
// t.setData({
|
...
|
...
|
@@ -114,43 +284,31 @@ if( app.globalData.index==undefined){ |
|
|
wx.navigateTo({
|
|
|
url: '/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
})
|
|
|
}else{
|
|
|
let login_new=wx.getStorageSync("login");
|
|
|
if(login_new==0){
|
|
|
// wx.showToast({
|
|
|
// title: '您还不是会员',
|
|
|
// icon:"none"
|
|
|
// })
|
|
|
// setTimeout(function(){
|
|
|
// wx.navigateTo({
|
|
|
// url: '/pages/login/login',
|
|
|
// })
|
|
|
// },1500)
|
|
|
// return false
|
|
|
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您还不是会员',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
}
|
|
|
} else {
|
|
|
let login_new = wx.getStorageSync("login");
|
|
|
// if(login_new==0){
|
|
|
// wx.showModal({
|
|
|
// title: '提示',
|
|
|
// content: '您还不是会员',
|
|
|
// success(res) {
|
|
|
// if (res.confirm) {
|
|
|
// wx.navigateTo({
|
|
|
// url: '/pages/login/login',
|
|
|
// })
|
|
|
// } else if (res.cancel) {
|
|
|
// }
|
|
|
// }
|
|
|
// })
|
|
|
|
|
|
// return false
|
|
|
|
|
|
|
|
|
// }
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/xianshi/xianshi?title2='+this.data.title2,
|
|
|
url: '/pages/xianshi/xianshi?title2=' + this.data.title2,
|
|
|
})
|
|
|
}
|
|
|
|
...
|
...
|
@@ -228,7 +386,7 @@ if( app.globalData.index==undefined){ |
|
|
var that = this;
|
|
|
console.log('999', that.data.endTime)
|
|
|
var time = that.data.endTime;
|
|
|
var interval = setInterval(function() {
|
|
|
var interval = setInterval(function () {
|
|
|
// 秒数
|
|
|
let day = parseInt(time / (60 * 60 * 24));
|
|
|
let hou = parseInt(time % (60 * 60 * 24) / 3600);
|
...
|
...
|
@@ -257,17 +415,13 @@ if( app.globalData.index==undefined){ |
|
|
//获取活动专区列表
|
|
|
getzhuanqulist() {
|
|
|
let that = this
|
|
|
let url = '/activity/get_all';
|
|
|
let data = {
|
|
|
|
|
|
|
|
|
}
|
|
|
app.post(url, data, "POST").then((r) => {
|
|
|
let url = '/activity/get_list';
|
|
|
let data = {}
|
|
|
app.postk(url, data, "POST").then((r) => {
|
|
|
console.log(r)
|
|
|
that.setData({
|
|
|
activity: r.msg
|
|
|
activity: r.data
|
|
|
})
|
|
|
|
|
|
console.log(that.data.activity)
|
|
|
// that.setData({
|
|
|
// messagelist: that.data.messagelist.concat(r.msg)
|
...
|
...
|
@@ -291,37 +445,52 @@ if( app.globalData.index==undefined){ |
|
|
wx.navigateTo({
|
|
|
url: '/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
}else{
|
|
|
let login_new=wx.getStorageSync('login');
|
|
|
if(login_new==0){
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您还不是会员',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
|
|
|
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
} else {
|
|
|
let login_new = wx.getStorageSync('login');
|
|
|
// if(login_new==0){
|
|
|
// wx.showModal({
|
|
|
// title: '提示',
|
|
|
// content: '您还不是会员',
|
|
|
// success(res) {
|
|
|
// if (res.confirm) {
|
|
|
|
|
|
|
|
|
// wx.navigateTo({
|
|
|
// url: '/pages/login/login',
|
|
|
// })
|
|
|
// } else if (res.cancel) {
|
|
|
// }
|
|
|
// }
|
|
|
// })
|
|
|
|
|
|
// return false
|
|
|
// }
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/zhuanqu/zhuanqu?id=' + id,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
// 获取品牌专区
|
|
|
getpinpailist() {
|
|
|
let that = this
|
|
|
let url = '/sundry/get_brand';
|
|
|
let data = {
|
|
|
page: 1
|
|
|
}
|
|
|
app.postk(url, data, "POST").then((r) => {
|
|
|
console.log(r)
|
|
|
that.setData({
|
|
|
pinpailist: r.data.slice(0, 4)
|
|
|
})
|
|
|
|
|
|
|
|
|
}).catch((err) => {})
|
|
|
},
|
|
|
more() {
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token == '') {
|
...
|
...
|
@@ -333,34 +502,15 @@ if( app.globalData.index==undefined){ |
|
|
wx.navigateTo({
|
|
|
url: '/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
let login_new=wx.getStorageSync('login');
|
|
|
if(login_new==0){
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您还不是会员',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
|
|
|
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
let login_new = wx.getStorageSync('login');
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/classify/classify',
|
|
|
url: '/pages/classify/classify?type=' + 1,
|
|
|
})
|
|
|
},
|
|
|
//展示所有的小分类
|
...
|
...
|
@@ -381,38 +531,42 @@ if( app.globalData.index==undefined){ |
|
|
wx.navigateTo({
|
|
|
url: '/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
})
|
|
|
}else{
|
|
|
let login_new=wx.getStorageSync('login');
|
|
|
if(login_new==0){
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您还不是会员',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
|
|
|
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
} else {
|
|
|
let login_new = wx.getStorageSync('login');
|
|
|
// if(login_new==0){
|
|
|
// wx.showModal({
|
|
|
// title: '提示',
|
|
|
// content: '您还不是会员',
|
|
|
// success(res) {
|
|
|
// if (res.confirm) {
|
|
|
|
|
|
|
|
|
// wx.navigateTo({
|
|
|
// url: '/pages/login/login',
|
|
|
// })
|
|
|
// } else if (res.cancel) {
|
|
|
// }
|
|
|
// }
|
|
|
// })
|
|
|
|
|
|
// return false
|
|
|
// }
|
|
|
let title = this.data.nav_arr[this.data.nav_index].name
|
|
|
let index = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
|
|
|
let pid = this.data.nav_arr[this.data.nav_index].id
|
|
|
let category_id2 = e.currentTarget.dataset.id;
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/search/search_result/search_result?title=' + title + "&index=" + index + '&pid=' + pid
|
|
|
url: '/pages/search/search_result/search_result?title=' + title + '&category_id2=' + category_id2
|
|
|
})
|
|
|
|
|
|
// let index = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
|
|
|
// let pid = this.data.nav_arr[this.data.nav_index].id
|
|
|
// wx.navigateTo({
|
|
|
// url: '/packageA/pages/search/search_result/search_result?title=' + title + "&index=" + index + '&pid=' + pid
|
|
|
// })
|
|
|
}
|
|
|
|
|
|
|
|
|
},
|
|
|
//监测轮播图变化
|
|
|
swiperChange(e) {
|
...
|
...
|
@@ -424,7 +578,8 @@ if( app.globalData.index==undefined){ |
|
|
look_more(e) {
|
|
|
let token = wx.getStorageSync("token")
|
|
|
let id = e.currentTarget.dataset.id
|
|
|
let style = e.currentTarget.dataset.style
|
|
|
let style = e.currentTarget.dataset.style;
|
|
|
console.log(style)
|
|
|
if (token == '') {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
...
|
...
|
@@ -434,28 +589,12 @@ if( app.globalData.index==undefined){ |
|
|
wx.navigateTo({
|
|
|
url: '/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
let login_new=wx.getStorageSync('login');
|
|
|
if(login_new==0){
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您还不是会员',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
let login_new = wx.getStorageSync('login');
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
if (style == 2) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/outerChain/outerChain?src=' + e.currentTarget.dataset.src
|
...
|
...
|
@@ -466,132 +605,205 @@ if( app.globalData.index==undefined){ |
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 排序
|
|
|
reorder(e) {
|
|
|
let that = this
|
|
|
let index = Number(e.currentTarget.dataset.index)
|
|
|
that.setData({
|
|
|
page: 1,
|
|
|
shop_arr: []
|
|
|
})
|
|
|
let index = Number(e.currentTarget.dataset.index);
|
|
|
that.setData({
|
|
|
c_index: index,
|
|
|
sort: index
|
|
|
})
|
|
|
if (index == 1) {
|
|
|
if (that.data.price == "price") {
|
|
|
that.setData({
|
|
|
price: 'price desc'
|
|
|
this.setData({
|
|
|
pricesheng: !this.data.pricesheng
|
|
|
})
|
|
|
if (this.data.pricesheng == true) {
|
|
|
this.setData({
|
|
|
sort: 1
|
|
|
})
|
|
|
} else {
|
|
|
that.setData({
|
|
|
price: 'price'
|
|
|
this.setData({
|
|
|
sort: 2
|
|
|
})
|
|
|
}
|
|
|
} else if (index == 2) {
|
|
|
if (that.data.paynum == "paynum") {
|
|
|
that.setData({
|
|
|
paynum: 'paynum desc'
|
|
|
}
|
|
|
if (index == 2) {
|
|
|
this.setData({
|
|
|
xiaoliang: !this.data.xiaoliang
|
|
|
})
|
|
|
if (this.data.xiaoliang == true) {
|
|
|
this.setData({
|
|
|
sort: 3
|
|
|
})
|
|
|
} else {
|
|
|
that.setData({
|
|
|
paynum: 'paynum'
|
|
|
this.setData({
|
|
|
sort: 4
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
this.setData({
|
|
|
c_index: e.currentTarget.dataset.index,
|
|
|
page: 1,
|
|
|
page_type: false
|
|
|
})
|
|
|
//调用排序接口
|
|
|
this.good_list(this.data.pid, e.currentTarget.dataset.index)
|
|
|
that.getgoodlist()
|
|
|
|
|
|
// let that = this
|
|
|
// let index = Number(e.currentTarget.dataset.index)
|
|
|
// if (index == 1) {
|
|
|
// if (that.data.price == "price") {
|
|
|
// that.setData({
|
|
|
// price: 'price desc'
|
|
|
// })
|
|
|
// } else {
|
|
|
// that.setData({
|
|
|
// price: 'price'
|
|
|
// })
|
|
|
// }
|
|
|
// } else if (index == 2) {
|
|
|
// if (that.data.paynum == "paynum") {
|
|
|
// that.setData({
|
|
|
// paynum: 'paynum desc'
|
|
|
// })
|
|
|
// } else {
|
|
|
// that.setData({
|
|
|
// paynum: 'paynum'
|
|
|
// })
|
|
|
// }
|
|
|
// }
|
|
|
// this.setData({
|
|
|
// c_index: e.currentTarget.dataset.index,
|
|
|
// page: 1,
|
|
|
// page_type: false
|
|
|
// })
|
|
|
// //调用排序接口
|
|
|
// this.good_list(this.data.pid, e.currentTarget.dataset.index)
|
|
|
},
|
|
|
|
|
|
// 选择一级分类
|
|
|
select_nav(e) {
|
|
|
let index = Number(e.currentTarget.dataset.index)
|
|
|
let id = e.currentTarget.dataset.id;
|
|
|
this.setData({
|
|
|
pid:id
|
|
|
seltui: index,
|
|
|
isyouzhi:1
|
|
|
})
|
|
|
|
|
|
let id = e.currentTarget.dataset.id;
|
|
|
let newclass_arr = this.data.nav_arr[index].child
|
|
|
this.setData({
|
|
|
scrollTop: 0
|
|
|
category_id1: id,
|
|
|
class_arr: newclass_arr,
|
|
|
nav_index: index,
|
|
|
page: 1,
|
|
|
shop_arr: []
|
|
|
})
|
|
|
if (index == this.data.nav_index) {
|
|
|
return
|
|
|
} else {
|
|
|
this.setData({
|
|
|
nav_index: index,
|
|
|
page: 1,
|
|
|
page_type: false,
|
|
|
c_index: 0, //筛选分类下标
|
|
|
price: 'price desc', //价格排序方式
|
|
|
paynum: 'paynum desc' //销量排序方式
|
|
|
})
|
|
|
this.get_info(id, 2)
|
|
|
if(index==0){
|
|
|
this.getyouzhi()
|
|
|
}else{
|
|
|
this.getgoodlist()
|
|
|
}
|
|
|
|
|
|
},
|
|
|
// 获取商品列表
|
|
|
getgoodlist() {
|
|
|
let that = this;
|
|
|
let url = '/goods/get_goods'
|
|
|
let param = {
|
|
|
category_id1: this.data.category_id1,
|
|
|
sort: this.data.sort,
|
|
|
keyword: this.data.keyword,
|
|
|
page: this.data.page,
|
|
|
pageNum: 10
|
|
|
}
|
|
|
app.postk(url, param).then((res) => {
|
|
|
if (that.data.page > 1) {
|
|
|
if (res.data.length == 0) {
|
|
|
wx.showToast({
|
|
|
title: '没有更多了~',
|
|
|
icon: 'none'
|
|
|
})
|
|
|
} else {
|
|
|
this.setData({
|
|
|
shop_arr: that.data.shop_arr.concat(res.data)
|
|
|
})
|
|
|
}
|
|
|
} else {
|
|
|
this.setData({
|
|
|
shop_arr: that.data.shop_arr.concat(res.data)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
console.log(that.data.shop_arr, '轮播图')
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 轮播图
|
|
|
get_banner() {
|
|
|
let url = app.interface.banner
|
|
|
app.post(url, {}).then((res) => {
|
|
|
let url = '/sundry/get_slide'
|
|
|
app.postk(url, {}).then((res) => {
|
|
|
console.log(res, '轮播图')
|
|
|
this.setData({
|
|
|
imgurl: res.msg
|
|
|
imgurl: res.data
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
//获取公告
|
|
|
get_notice() {
|
|
|
let that = this
|
|
|
let url = app.interface.notice
|
|
|
app.post(url, {}).then((res) => {
|
|
|
for (let obj of res.msg) {
|
|
|
let url = '/sundry/get_notice'
|
|
|
let param = {
|
|
|
page: 1,
|
|
|
pageNum: 2
|
|
|
}
|
|
|
app.postk(url, param).then((res) => {
|
|
|
for (let obj of res.data) {
|
|
|
obj.createtime = obj.createtime.substring(0, 10)
|
|
|
}
|
|
|
that.setData({
|
|
|
notice: res.msg
|
|
|
notice: res.data
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
//获取页面信息
|
|
|
get_info(pid, type) { //type 1为小标题 2为小标题下的小分类
|
|
|
wx.showLoading({
|
|
|
title: '加载中'
|
|
|
})
|
|
|
let that = this
|
|
|
let url = app.interface.index
|
|
|
let params = {
|
|
|
pid: pid
|
|
|
}
|
|
|
app.post(url, params).then((res) => {
|
|
|
console.log('88776654', res)
|
|
|
wx.hideLoading()
|
|
|
if (type == 1) {
|
|
|
let obj = {
|
|
|
name: '首页',
|
|
|
id: ''
|
|
|
}
|
|
|
res.msg.unshift(obj)
|
|
|
that.setData({
|
|
|
nav_arr: res.msg
|
|
|
})
|
|
|
that.get_info(res.msg[0].id, 2)
|
|
|
} else if (type == 2) {
|
|
|
console.log('666', res)
|
|
|
// let obj = {
|
|
|
// name: '全部',
|
|
|
// id: ''
|
|
|
// }
|
|
|
// res.msg.unshift(obj)
|
|
|
that.setData({
|
|
|
class_arr: res.msg,
|
|
|
cid: ''
|
|
|
})
|
|
|
that.good_list(pid, that.data.c_index)
|
|
|
}
|
|
|
}).catch((er) => {
|
|
|
wx.hideLoading()
|
|
|
})
|
|
|
},
|
|
|
// get_info(pid, type) { //type 1为小标题 2为小标题下的小分类
|
|
|
// wx.showLoading({
|
|
|
// title: '加载中'
|
|
|
// })
|
|
|
// let that = this
|
|
|
// let url = app.interface.index
|
|
|
// let params = {
|
|
|
// pid: pid
|
|
|
// }
|
|
|
// app.post(url, params).then((res) => {
|
|
|
// console.log('88776654', res)
|
|
|
// wx.hideLoading()
|
|
|
// if (type == 1) {
|
|
|
// let obj = {
|
|
|
// name: '首页',
|
|
|
// id: ''
|
|
|
// }
|
|
|
// res.msg.unshift(obj)
|
|
|
// that.setData({
|
|
|
// nav_arr: res.data
|
|
|
// })
|
|
|
// that.get_info(res.msg[0].id, 2)
|
|
|
// } else if (type == 2) {
|
|
|
// console.log('666', res)
|
|
|
// // let obj = {
|
|
|
// // name: '全部',
|
|
|
// // id: ''
|
|
|
// // }
|
|
|
// // res.msg.unshift(obj)
|
|
|
// that.setData({
|
|
|
// class_arr: res.data,
|
|
|
// cid: ''
|
|
|
// })
|
|
|
// that.good_list(pid, that.data.c_index)
|
|
|
// }
|
|
|
// }).catch((er) => {
|
|
|
// wx.hideLoading()
|
|
|
// })
|
|
|
// },
|
|
|
//获取商品列表
|
|
|
good_list(pid, c_index) {
|
|
|
wx.showLoading({
|
...
|
...
|
@@ -632,7 +844,7 @@ if( app.globalData.index==undefined){ |
|
|
})
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
...
|
...
|
@@ -645,7 +857,7 @@ if( app.globalData.index==undefined){ |
|
|
if (res.msg > 0) {
|
|
|
wx.showTabBarRedDot({
|
|
|
index: 2,
|
|
|
success: function(red) {
|
|
|
success: function (red) {
|
|
|
wx.setTabBarBadge({
|
|
|
index: 2,
|
|
|
text: res.msg.toString(),
|
...
|
...
|
@@ -675,7 +887,7 @@ if( app.globalData.index==undefined){ |
|
|
// })
|
|
|
|
|
|
let newlist = [];
|
|
|
r.msg.forEach(function(value, index, array) {
|
|
|
r.msg.forEach(function (value, index, array) {
|
|
|
console.log(newlist)
|
|
|
if (value.status == 1) {
|
|
|
newlist.push(value)
|
...
|
...
|
@@ -686,7 +898,7 @@ if( app.globalData.index==undefined){ |
|
|
if (newlist.length != 0) {
|
|
|
wx.showTabBarRedDot({
|
|
|
index: 1,
|
|
|
success: function(red) {
|
|
|
success: function (red) {
|
|
|
|
|
|
wx.setTabBarBadge({
|
|
|
index: 1,
|
...
|
...
|
@@ -700,106 +912,122 @@ if( app.globalData.index==undefined){ |
|
|
}).catch((err) => {})
|
|
|
},
|
|
|
// 获取个人信息
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady: function() {
|
|
|
onReady: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function() {
|
|
|
|
|
|
onShow: function () {
|
|
|
|
|
|
this.setData({
|
|
|
logok: app.globalData.baseUrlimg + "assets/img/cb2ad36a391388f19f5f912fa021f8f.png"
|
|
|
})
|
|
|
this.get_banner()
|
|
|
console.log(app.globalData.index)
|
|
|
if(app.globalData.index==0){
|
|
|
app.globalData.index=undefined
|
|
|
let token=wx.getStorageSync('token');
|
|
|
console.log('woshitoe',token)
|
|
|
if(token!=""){
|
|
|
this.getInfoFun()
|
|
|
}
|
|
|
this.get_notice()
|
|
|
this.get_shopnum()
|
|
|
this.getmessagelist();
|
|
|
console.log('998867',this.data.pid)
|
|
|
if(this.data.pid){
|
|
|
this.get_info(this.data.pid, 2);
|
|
|
}else{
|
|
|
this.get_info(0, 1);
|
|
|
if (app.globalData.index == 0) {
|
|
|
app.globalData.index = undefined
|
|
|
let token = wx.getStorageSync('token');
|
|
|
console.log('woshitoe', token)
|
|
|
if (token != "") {
|
|
|
this.getInfoFun()
|
|
|
}
|
|
|
this.get_notice()
|
|
|
this.get_shopnum()
|
|
|
this.getmessagelist();
|
|
|
console.log('998867', this.data.pid)
|
|
|
if (this.data.pid) {
|
|
|
// this.get_info(this.data.pid, 2);
|
|
|
} else {
|
|
|
// this.get_info(0, 1);
|
|
|
}
|
|
|
|
|
|
//控制显示隐藏
|
|
|
this.ishow()
|
|
|
}
|
|
|
// 获取一级分类
|
|
|
this.getonkind();
|
|
|
|
|
|
//控制显示隐藏
|
|
|
this.ishow()
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function() {
|
|
|
onHide: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: function() {
|
|
|
onUnload: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh: function() {
|
|
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
},
|
|
|
loadMore(e){
|
|
|
console.log(e)
|
|
|
let that = this
|
|
|
if (that.data.page_type) {
|
|
|
wx.showToast({
|
|
|
title: '暂无更多数据',
|
|
|
icon: 'none',
|
|
|
duration: 1000
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
that.setData({
|
|
|
page: that.data.page + 1
|
|
|
loadMore(e) {
|
|
|
let newpage = this.data.page;
|
|
|
newpage++;
|
|
|
this.setData({
|
|
|
page: newpage
|
|
|
})
|
|
|
that.good_list(that.data.pid, that.data.c_index)
|
|
|
if(this.data.isyouzhi==0){
|
|
|
this.getyouzhi()
|
|
|
}else{
|
|
|
this.getgoodlist()
|
|
|
}
|
|
|
|
|
|
// console.log(e)
|
|
|
// let that = this
|
|
|
// if (that.data.page_type) {
|
|
|
// wx.showToast({
|
|
|
// title: '暂无更多数据',
|
|
|
// icon: 'none',
|
|
|
// duration: 1000
|
|
|
// })
|
|
|
// return
|
|
|
// }
|
|
|
// that.setData({
|
|
|
// page: that.data.page + 1
|
|
|
// })
|
|
|
// that.good_list(that.data.pid, that.data.c_index)
|
|
|
},
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function() {
|
|
|
console.log(43898438493)
|
|
|
let that = this
|
|
|
if (that.data.page_type) {
|
|
|
wx.showToast({
|
|
|
title: '暂无更多数据',
|
|
|
icon: 'none',
|
|
|
duration: 1000
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
that.setData({
|
|
|
page: that.data.page + 1
|
|
|
})
|
|
|
that.good_list(that.data.pid, that.data.c_index)
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
// console.log(43898438493)
|
|
|
// let that = this
|
|
|
// if (that.data.page_type) {
|
|
|
// wx.showToast({
|
|
|
// title: '暂无更多数据',
|
|
|
// icon: 'none',
|
|
|
// duration: 1000
|
|
|
// })
|
|
|
// return
|
|
|
// }
|
|
|
// that.setData({
|
|
|
// page: that.data.page + 1
|
|
|
// })
|
|
|
// that.good_list(that.data.pid, that.data.c_index)
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: function() {
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
}
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|