...
|
...
|
@@ -5,6 +5,7 @@ Page({ |
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
selected: 0,
|
|
|
autoplay: true,
|
|
|
interval: 5000,
|
|
|
duration: 500,
|
...
|
...
|
@@ -30,42 +31,40 @@ Page({ |
|
|
status1: '',
|
|
|
status2: '',
|
|
|
title2: '',
|
|
|
scrollTop:'',
|
|
|
pid:'',
|
|
|
logok:'',
|
|
|
selected:0,
|
|
|
list:[{
|
|
|
pagePath: "/packageA/pages/index/index",
|
|
|
text: "商品",
|
|
|
iconPath: "/images/tabbar/icon_75.png",
|
|
|
selectedIconPath: "/images/tabbar/icon_68.png"
|
|
|
},
|
|
|
{
|
|
|
pagePath: "/packageA/pages/message/message",
|
|
|
text: "消息",
|
|
|
iconPath: "/images/tabbar/message.png",
|
|
|
selectedIconPath: "/images/tabbar/messageactive.png"
|
|
|
},
|
|
|
{
|
|
|
pagePath: "/packageA/pages/shop_cart/shop_cart",
|
|
|
text: "购物车",
|
|
|
iconPath: "/images/tabbar/icon_70.png",
|
|
|
selectedIconPath: "/images/tabbar/icon_73.png"
|
|
|
},
|
|
|
{
|
|
|
pagePath: "/packageA/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
|
|
|
scrollTop: '',
|
|
|
pid: '',
|
|
|
logok: '',
|
|
|
typename: 1,
|
|
|
list: [{
|
|
|
pagePath: "/packageA/pages/index/index",
|
|
|
text: "商品",
|
|
|
iconPath: "/images/tabbar/icon_75.png",
|
|
|
selectedIconPath: "/images/tabbar/icon_68.png"
|
|
|
},
|
|
|
{
|
|
|
pagePath: "/packageA/pages/message/message",
|
|
|
text: "消息",
|
|
|
iconPath: "/images/tabbar/message.png",
|
|
|
selectedIconPath: "/images/tabbar/messageactive.png"
|
|
|
},
|
|
|
{
|
|
|
pagePath: "/packageA/pages/shop_cart/shop_cart",
|
|
|
text: "购物车",
|
|
|
iconPath: "/images/tabbar/icon_70.png",
|
|
|
selectedIconPath: "/images/tabbar/icon_73.png"
|
|
|
},
|
|
|
{
|
|
|
pagePath: "/packageA/pages/my/my",
|
|
|
text: "我的",
|
|
|
iconPath: "/images/tabbar/icon_71.png",
|
|
|
selectedIconPath: "/images/tabbar/icon_72.png"
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scroll(e) {
|
|
|
// console.log(e.detail.scrollTop)
|
|
|
// if (e.detail.scrollTop >300){
|
...
|
...
|
@@ -81,76 +80,62 @@ Page({ |
|
|
|
|
|
// console.log(this.data.stick)
|
|
|
},
|
|
|
|
|
|
|
|
|
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.ishow()
|
|
|
// 我写的项目
|
|
|
// 获取一级分类
|
|
|
this.getonkind();
|
|
|
// 获取商品列表
|
|
|
this.getgoodlist()
|
|
|
|
|
|
},
|
|
|
|
|
|
// 获取一级分类
|
|
|
getonkind(){
|
|
|
let that= this;
|
|
|
let url="/sundry/get_category"
|
|
|
app.postk(url, {}).then((r) => {
|
|
|
console.log('商品分类',r)
|
|
|
let obj = {
|
|
|
name: '首页',
|
|
|
id: ''
|
|
|
}
|
|
|
r.data.unshift(obj)
|
|
|
that.setData({
|
|
|
nav_arr: r.data
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
onLoad: function (options) {
|
|
|
console.log(app.globalData.index)
|
|
|
if (wx.getStorageSync('entrance_type') == '2') {
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: '工会商城'
|
|
|
})
|
|
|
}else{
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: '劳保商城'
|
|
|
})
|
|
|
}
|
|
|
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.ishow()
|
|
|
|
|
|
},
|
|
|
|
|
|
// 获取个人信息
|
|
|
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({
|
...
|
...
|
@@ -170,43 +155,41 @@ this.getgoodlist() |
|
|
wx.navigateTo({
|
|
|
url: '/packageA/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: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} 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: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
}
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/xianshi/xianshi?title2='+this.data.title2,
|
|
|
url: '/packageA/pages/xianshi/xianshi?title2=' + this.data.title2,
|
|
|
})
|
|
|
}
|
|
|
|
...
|
...
|
@@ -284,7 +267,7 @@ this.getgoodlist() |
|
|
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);
|
...
|
...
|
@@ -313,15 +296,15 @@ this.getgoodlist() |
|
|
//获取活动专区列表
|
|
|
getzhuanqulist() {
|
|
|
let that = this
|
|
|
let url = '/activity/get_list';
|
|
|
let url = '/activity/get_all';
|
|
|
let data = {
|
|
|
|
|
|
|
|
|
}
|
|
|
app.postk(url, data, "POST").then((r) => {
|
|
|
app.post(url, data, "POST").then((r) => {
|
|
|
console.log(r)
|
|
|
that.setData({
|
|
|
activity: r.data
|
|
|
activity: r.msg
|
|
|
})
|
|
|
|
|
|
console.log(that.data.activity)
|
...
|
...
|
@@ -347,35 +330,33 @@ this.getgoodlist() |
|
|
wx.navigateTo({
|
|
|
url: '/packageA/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) {
|
|
|
} else {
|
|
|
let login_new = wx.getStorageSync('login');
|
|
|
if (login_new == 0) {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您还不是会员',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
|
|
|
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
return false
|
|
|
}
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/zhuanqu/zhuanqu?id=' + id,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
more() {
|
...
|
...
|
@@ -389,27 +370,25 @@ this.getgoodlist() |
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
let login_new=wx.getStorageSync('login');
|
|
|
if(login_new==0){
|
|
|
let login_new = wx.getStorageSync('login');
|
|
|
if (login_new == 0) {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您还不是会员',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
|
|
|
|
|
|
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
})
|
|
|
|
...
|
...
|
@@ -437,43 +416,36 @@ this.getgoodlist() |
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
})
|
|
|
}else{
|
|
|
let login_new=wx.getStorageSync('login');
|
|
|
if(login_new==0){
|
|
|
} else {
|
|
|
let login_new = wx.getStorageSync('login');
|
|
|
if (login_new == 0) {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您还不是会员',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
let title = this.data.nav_arr[this.data.nav_index].name
|
|
|
let category_id2=e.currentTarget.dataset.id;
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/search/search_result/search_result?title=' + title + '&category_id2=' + category_id2
|
|
|
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
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/search/search_result/search_result?title=' + title + "&index=" + index + '&pid=' + pid
|
|
|
})
|
|
|
|
|
|
// 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) {
|
...
|
...
|
@@ -495,13 +467,12 @@ this.getgoodlist() |
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
let login_new=wx.getStorageSync('login');
|
|
|
if(login_new==0){
|
|
|
let login_new = wx.getStorageSync('login');
|
|
|
if (login_new == 0) {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您还不是会员',
|
...
|
...
|
@@ -510,8 +481,7 @@ this.getgoodlist() |
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
|
|
} else if (res.cancel) {}
|
|
|
}
|
|
|
})
|
|
|
|
...
|
...
|
@@ -522,9 +492,9 @@ this.getgoodlist() |
|
|
url: '/packageA/pages/outerChain/outerChain?src=' + e.currentTarget.dataset.src
|
|
|
})
|
|
|
} else {
|
|
|
// wx.navigateTo({
|
|
|
// url: '/packageA/pages/shop_detail/shop_detail?id=' + id
|
|
|
// })
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/shop_detail/shop_detail?id=' + id
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -536,129 +506,67 @@ this.getgoodlist() |
|
|
// 排序
|
|
|
reorder(e) {
|
|
|
let that = this
|
|
|
that.setData({
|
|
|
page:1,
|
|
|
shop_arr:[]
|
|
|
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
|
|
|
})
|
|
|
let index = Number(e.currentTarget.dataset.index);
|
|
|
that.setData({
|
|
|
c_index:index,
|
|
|
sort:index
|
|
|
})
|
|
|
if(index==1){
|
|
|
this.setData({
|
|
|
pricesheng:!this.data.pricesheng
|
|
|
})
|
|
|
if(this.data.pricesheng==true){
|
|
|
this.setData({
|
|
|
sort:1
|
|
|
})
|
|
|
}else{
|
|
|
this.setData({
|
|
|
sort:2
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
if(this.data.index==2){
|
|
|
this.setData({
|
|
|
xiaoliang:!this.data.xiaoliang
|
|
|
})
|
|
|
if(this.data.xiaoliang==true){
|
|
|
this.setData({
|
|
|
sort:3
|
|
|
})
|
|
|
}else{
|
|
|
this.setData({
|
|
|
sort:4
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
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)
|
|
|
},
|
|
|
// 选择一级分类
|
|
|
//调用排序接口
|
|
|
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;
|
|
|
let newclass_arr=this.data.nav_arr[index].child
|
|
|
this.setData({
|
|
|
category_id1:id,
|
|
|
class_arr:newclass_arr,
|
|
|
nav_index:index
|
|
|
pid: id
|
|
|
})
|
|
|
},
|
|
|
// 获取商品列表
|
|
|
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,'轮播图')
|
|
|
|
|
|
this.setData({
|
|
|
scrollTop: 0
|
|
|
})
|
|
|
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)
|
|
|
}
|
|
|
},
|
|
|
// 轮播图
|
|
|
get_banner() {
|
|
|
let url = '/sundry/get_slide'
|
|
|
app.postk(url, {}).then((res) => {
|
|
|
console.log(res,'轮播图')
|
|
|
let url = app.interface.banner
|
|
|
app.post(url, {}).then((res) => {
|
|
|
this.setData({
|
|
|
imgurl: res.data
|
|
|
imgurl: res.msg
|
|
|
})
|
|
|
})
|
|
|
},
|
...
|
...
|
@@ -676,45 +584,45 @@ this.getgoodlist() |
|
|
})
|
|
|
},
|
|
|
//获取页面信息
|
|
|
// 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()
|
|
|
// })
|
|
|
// },
|
|
|
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()
|
|
|
})
|
|
|
},
|
|
|
//获取商品列表
|
|
|
good_list(pid, c_index) {
|
|
|
wx.showLoading({
|
...
|
...
|
@@ -755,7 +663,7 @@ this.getgoodlist() |
|
|
})
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
...
|
...
|
@@ -768,7 +676,7 @@ this.getgoodlist() |
|
|
if (res.msg > 0) {
|
|
|
wx.showTabBarRedDot({
|
|
|
index: 2,
|
|
|
success: function(red) {
|
|
|
success: function (red) {
|
|
|
wx.setTabBarBadge({
|
|
|
index: 2,
|
|
|
text: res.msg.toString(),
|
...
|
...
|
@@ -798,7 +706,7 @@ this.getgoodlist() |
|
|
// })
|
|
|
|
|
|
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)
|
...
|
...
|
@@ -809,7 +717,7 @@ this.getgoodlist() |
|
|
if (newlist.length != 0) {
|
|
|
wx.showTabBarRedDot({
|
|
|
index: 1,
|
|
|
success: function(red) {
|
|
|
success: function (red) {
|
|
|
|
|
|
wx.setTabBarBadge({
|
|
|
index: 1,
|
...
|
...
|
@@ -823,115 +731,111 @@ this.getgoodlist() |
|
|
}).catch((err) => {})
|
|
|
},
|
|
|
// 获取个人信息
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady: function() {
|
|
|
onReady: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function() {
|
|
|
onShow: function () {
|
|
|
|
|
|
this.setData({
|
|
|
logok:app.globalData.baseUrlimg+"assets/img/cb2ad36a391388f19f5f912fa021f8f.png"
|
|
|
logok: app.globalData.baseUrlimg + "assets/img/cb2ad36a391388f19f5f912fa021f8f.png"
|
|
|
})
|
|
|
console.log(this.data.logok)
|
|
|
// this.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.ishow()
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function() {
|
|
|
onHide: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: function() {
|
|
|
onUnload: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh: function() {
|
|
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
},
|
|
|
loadMore(e){
|
|
|
let newpage=this.data.page;
|
|
|
newpage++;
|
|
|
this.setData({
|
|
|
page:newpage
|
|
|
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
|
|
|
})
|
|
|
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)
|
|
|
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 |
...
|
...
|
|