|
|
const app = getApp()
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
selected: 0,
|
|
|
autoplay: true,
|
|
|
interval: 5000,
|
|
|
duration: 500,
|
|
|
circular: true,
|
|
|
current: 0,
|
|
|
zcurrent: 0, //用来记录当前swiper对应的索引index
|
|
|
length_num: 9, //指定展示的小分类数量
|
|
|
nav_index: 0,
|
|
|
c_index: 0, //筛选分类下标
|
|
|
page: 1, //页数
|
|
|
price: 'price desc', //价格排序方式
|
|
|
paynum: 'paynum desc', //销量排序方式
|
|
|
stick: 0,
|
|
|
activity: [],
|
|
|
xianshilist: [{}],
|
|
|
day: '',
|
|
|
hou: '',
|
|
|
min: '',
|
|
|
sec: '',
|
|
|
endTime: '',
|
|
|
activitystatus: '',
|
|
|
showtime: false,
|
|
|
status1: '',
|
|
|
status2: '',
|
|
|
title2: '',
|
|
|
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){
|
|
|
// console.log(8888)
|
|
|
// this.setData({
|
|
|
// stick:1
|
|
|
// })
|
|
|
// }else{
|
|
|
// this.setData({
|
|
|
// stick:0
|
|
|
// })
|
|
|
// }
|
|
|
|
|
|
// console.log(this.data.stick)
|
|
|
},
|
|
|
|
|
|
|
|
|
onLoad: function (options) {
|
|
|
console.log(app.globalData.index)
|
|
|
if (wx.getStorageSync('entrance_type') == '2') {
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: '工会商城'
|
|
|
})
|
|
|
} else if (wx.getStorageSync('entrance_type') == '1') {
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: '劳保商城'
|
|
|
})
|
|
|
} else if (wx.getStorageSync('entrance_type') == '3') {
|
|
|
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 u = app.interface.readteacher;
|
|
|
app.post(u, {}).then((r) => {
|
|
|
console.log('3489523498', r)
|
|
|
if (r.code == 200) {
|
|
|
|
|
|
app.globalData.login_new = r.msg.login_new;
|
|
|
app.globalData.status = r.msg.status;
|
|
|
console.log(app.globalData.status)
|
|
|
// t.setData({
|
|
|
// obj: r.msg
|
|
|
// })
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
moremiao() {
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token == '') {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请先登录',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
selected: 0,
|
|
|
autoplay: true,
|
|
|
interval: 5000,
|
|
|
duration: 500,
|
|
|
circular: true,
|
|
|
current: 0,
|
|
|
zcurrent: 0, //用来记录当前swiper对应的索引index
|
|
|
length_num: 9, //指定展示的小分类数量
|
|
|
nav_index: 0,
|
|
|
c_index: 0, //筛选分类下标
|
|
|
page: 1, //页数
|
|
|
price: 'price desc', //价格排序方式
|
|
|
paynum: 'paynum desc', //销量排序方式
|
|
|
stick: 0,
|
|
|
activity: [],
|
|
|
xianshilist: [{}],
|
|
|
day: '',
|
|
|
hou: '',
|
|
|
min: '',
|
|
|
sec: '',
|
|
|
endTime: '',
|
|
|
activitystatus: '',
|
|
|
showtime: false,
|
|
|
status1: '',
|
|
|
status2: '',
|
|
|
title2: '',
|
|
|
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){
|
|
|
// console.log(8888)
|
|
|
// this.setData({
|
|
|
// stick:1
|
|
|
// })
|
|
|
// }else{
|
|
|
// this.setData({
|
|
|
// stick:0
|
|
|
// })
|
|
|
// }
|
|
|
// console.log(this.data.stick)
|
|
|
},
|
|
|
|
|
|
onLoad: function (options) {
|
|
|
if (options.token) {
|
|
|
wx.setStorageSync('token', options.token)
|
|
|
}
|
|
|
if (wx.getStorageSync('entrance_type') == '2') {
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: '工会商城'
|
|
|
})
|
|
|
} else if (wx.getStorageSync('entrance_type') == '1') {
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: '劳保商城'
|
|
|
})
|
|
|
} else if (wx.getStorageSync('entrance_type') == '3') {
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: '办公采办'
|
|
|
})
|
|
|
}
|
|
|
// if (app.globalData.index == undefined) {
|
|
|
// let that = this;
|
|
|
// let token = wx.getStorageSync('token');
|
|
|
// if (token != "") {
|
|
|
// this.getInfoFun()
|
|
|
// }
|
|
|
// this.get_notice()
|
|
|
// this.get_shopnum()
|
|
|
// this.getmessagelist();
|
|
|
// 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 u = app.interface.readteacher;
|
|
|
app.post(u, {}).then((r) => {
|
|
|
if (r.code == 200) {
|
|
|
app.globalData.login_new = r.msg.login_new;
|
|
|
app.globalData.status = r.msg.status;
|
|
|
}
|
|
|
}).catch({})
|
|
|
},
|
|
|
|
|
|
moremiao() {
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token == '') {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请先登录',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) { }
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
// 2023-10-19 需求是无需登录
|
|
|
// 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
|
|
|
// }
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/register/register',
|
|
|
url: '/packageA/pages/xianshi/xianshi?title2=' + this.data.title2,
|
|
|
})
|
|
|
} 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
|
|
|
},
|
|
|
|
|
|
// 控制活动专区和限时抢购显示隐藏
|
|
|
ishow() {
|
|
|
let that = this
|
|
|
let url = '//wb/wb';
|
|
|
let data = {}
|
|
|
app.post(url, data, "POST").then((r) => {
|
|
|
that.setData({
|
|
|
status1: r.msg.status1,
|
|
|
status2: r.msg.status2,
|
|
|
title2: r.msg.title2
|
|
|
})
|
|
|
}).catch((err) => { })
|
|
|
},
|
|
|
|
|
|
}
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/xianshi/xianshi?title2=' + this.data.title2,
|
|
|
})
|
|
|
}
|
|
|
// 限时抢购
|
|
|
getxianshi() {
|
|
|
let that = this
|
|
|
let url = '/special/get_all';
|
|
|
let data = {
|
|
|
page: 1,
|
|
|
pageNum: 6
|
|
|
}
|
|
|
app.post(url, data, "POST").then((r) => {
|
|
|
that.setData({
|
|
|
xianshilist: r.msg.list,
|
|
|
endTime: r.msg.residue_time,
|
|
|
activitystatus: r.msg.status
|
|
|
})
|
|
|
var time = that.date_format(r.msg.residue_time);
|
|
|
that.countDown()
|
|
|
// that.setData({
|
|
|
// messagelist: that.data.messagelist.concat(r.msg)
|
|
|
// })
|
|
|
// console.log(that.data.messagelist)
|
|
|
}).catch((err) => { })
|
|
|
},
|
|
|
|
|
|
},
|
|
|
date_format(micro_second) {
|
|
|
// 总秒数
|
|
|
var second = micro_second;
|
|
|
// var second = Math.floor(micro_second / 1000);
|
|
|
// 天数
|
|
|
var day = Math.floor(second / 3600 / 24);
|
|
|
// 小时
|
|
|
var hr = Math.floor(second / 3600 % 24);
|
|
|
// 分钟
|
|
|
var min = Math.floor(second / 60 % 60);
|
|
|
// 秒
|
|
|
var sec = Math.floor(second % 60);
|
|
|
return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
|
|
|
},
|
|
|
|
|
|
// 控制活动专区和限时抢购显示隐藏
|
|
|
ishow() {
|
|
|
let that = this
|
|
|
let url = '//wb/wb';
|
|
|
let data = {
|
|
|
// 倒计时
|
|
|
countDown() {
|
|
|
var that = this;
|
|
|
console.log('999', that.data.endTime)
|
|
|
var time = that.data.endTime;
|
|
|
var interval = setInterval(function () {
|
|
|
// 秒数
|
|
|
let day = parseInt(time / (60 * 60 * 24));
|
|
|
let hou = parseInt(time % (60 * 60 * 24) / 3600);
|
|
|
let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
|
|
|
let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
|
|
|
|
|
|
}
|
|
|
app.post(url, data, "POST").then((r) => {
|
|
|
console.log('4456789', r)
|
|
|
that.setData({
|
|
|
status1: r.msg.status1,
|
|
|
status2: r.msg.status2,
|
|
|
title2: r.msg.title2
|
|
|
})
|
|
|
that.setData({
|
|
|
day: that.timeFormat(day),
|
|
|
hou: that.timeFormat(hou),
|
|
|
min: that.timeFormat(min),
|
|
|
sec: that.timeFormat(sec)
|
|
|
})
|
|
|
|
|
|
time--;
|
|
|
if (time <= 0) {
|
|
|
clearInterval(interval);
|
|
|
|
|
|
}
|
|
|
}.bind(this), 1000);
|
|
|
},
|
|
|
|
|
|
}).catch((err) => { })
|
|
|
},
|
|
|
timeFormat(param) {
|
|
|
return param < 10 ? '0' + param : param;
|
|
|
},
|
|
|
|
|
|
// 限时抢购
|
|
|
getxianshi() {
|
|
|
let that = this
|
|
|
let url = '/special/get_all';
|
|
|
let data = {
|
|
|
page: 1,
|
|
|
pageNum: 6
|
|
|
//获取活动专区列表
|
|
|
getzhuanqulist() {
|
|
|
let that = this
|
|
|
let url = '/activity/get_all';
|
|
|
let data = {}
|
|
|
app.post(url, data, "POST").then((r) => {
|
|
|
console.log(r)
|
|
|
that.setData({
|
|
|
activity: r.msg
|
|
|
})
|
|
|
// that.setData({
|
|
|
// messagelist: that.data.messagelist.concat(r.msg)
|
|
|
// })
|
|
|
// console.log(that.data.messagelist)
|
|
|
}).catch((err) => { })
|
|
|
},
|
|
|
|
|
|
}
|
|
|
app.post(url, data, "POST").then((r) => {
|
|
|
console.log(r)
|
|
|
console.log(r.msg.residue_time)
|
|
|
that.setData({
|
|
|
xianshilist: r.msg.list,
|
|
|
endTime: r.msg.residue_time,
|
|
|
activitystatus: r.msg.status
|
|
|
})
|
|
|
var time = that.date_format(r.msg.residue_time);
|
|
|
console.log('9988776', that.data.activitystatus)
|
|
|
|
|
|
that.countDown()
|
|
|
|
|
|
console.log(that.data.xianshilist)
|
|
|
// that.setData({
|
|
|
// messagelist: that.data.messagelist.concat(r.msg)
|
|
|
// })
|
|
|
|
|
|
// console.log(that.data.messagelist)
|
|
|
|
|
|
}).catch((err) => { })
|
|
|
},
|
|
|
|
|
|
date_format(micro_second) {
|
|
|
// 总秒数
|
|
|
var second = micro_second;
|
|
|
// var second = Math.floor(micro_second / 1000);
|
|
|
// 天数
|
|
|
var day = Math.floor(second / 3600 / 24);
|
|
|
// 小时
|
|
|
var hr = Math.floor(second / 3600 % 24);
|
|
|
// 分钟
|
|
|
var min = Math.floor(second / 60 % 60);
|
|
|
// 秒
|
|
|
var sec = Math.floor(second % 60);
|
|
|
return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
|
|
|
},
|
|
|
|
|
|
// 倒计时
|
|
|
countDown() {
|
|
|
var that = this;
|
|
|
console.log('999', that.data.endTime)
|
|
|
var time = that.data.endTime;
|
|
|
var interval = setInterval(function () {
|
|
|
// 秒数
|
|
|
let day = parseInt(time / (60 * 60 * 24));
|
|
|
let hou = parseInt(time % (60 * 60 * 24) / 3600);
|
|
|
let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
|
|
|
let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
|
|
|
|
|
|
that.setData({
|
|
|
day: that.timeFormat(day),
|
|
|
hou: that.timeFormat(hou),
|
|
|
min: that.timeFormat(min),
|
|
|
sec: that.timeFormat(sec)
|
|
|
})
|
|
|
|
|
|
time--;
|
|
|
if (time <= 0) {
|
|
|
clearInterval(interval);
|
|
|
|
|
|
}
|
|
|
}.bind(this), 1000);
|
|
|
},
|
|
|
|
|
|
timeFormat(param) {
|
|
|
return param < 10 ? '0' + param : param;
|
|
|
},
|
|
|
|
|
|
//获取活动专区列表
|
|
|
getzhuanqulist() {
|
|
|
let that = this
|
|
|
let url = '/activity/get_all';
|
|
|
let data = {}
|
|
|
app.post(url, data, "POST").then((r) => {
|
|
|
console.log(r)
|
|
|
that.setData({
|
|
|
activity: r.msg
|
|
|
})
|
|
|
|
|
|
console.log(that.data.activity)
|
|
|
// that.setData({
|
|
|
// messagelist: that.data.messagelist.concat(r.msg)
|
|
|
// })
|
|
|
|
|
|
// console.log(that.data.messagelist)
|
|
|
|
|
|
}).catch((err) => { })
|
|
|
},
|
|
|
|
|
|
// 活动专区查看更多
|
|
|
seeactive(e) {
|
|
|
let id = e.currentTarget.dataset.id
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token == '') {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请先登录',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
// 活动专区查看更多
|
|
|
seeactive(e) {
|
|
|
let id = e.currentTarget.dataset.id
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token == '') {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请先登录',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) { }
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
// 2023-10-19 需求是无需登录
|
|
|
// 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) { }
|
|
|
// }
|
|
|
// })
|
|
|
// return false
|
|
|
// }
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/register/register',
|
|
|
url: '/packageA/pages/zhuanqu/zhuanqu?id=' + id,
|
|
|
})
|
|
|
} 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: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) { }
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/zhuanqu/zhuanqu?id=' + id,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
},
|
|
|
},
|
|
|
|
|
|
more() {
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token == '') {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请先登录',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/register/register',
|
|
|
more() {
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token == '') {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请先登录',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) { }
|
|
|
}
|
|
|
})
|
|
|
} else if (res.cancel) { }
|
|
|
return false
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
let login_new = wx.getStorageSync('login');
|
|
|
if (login_new == 0) {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '您还不是会员',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
|
|
|
|
|
|
// 2023-10-19 需求是无需登录
|
|
|
// 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) { }
|
|
|
// }
|
|
|
// })
|
|
|
// return false
|
|
|
// }
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/classify/classify',
|
|
|
})
|
|
|
},
|
|
|
//展示所有的小分类
|
|
|
show_all() {
|
|
|
this.setData({
|
|
|
length_num: this.data.length_num == 9 ? this.data.class_arr.length : 9
|
|
|
})
|
|
|
},
|
|
|
// 查看小分类
|
|
|
look_item(e) {
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token == '') {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请先登录',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) { }
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
// 2023-10-19 需求是无需登录
|
|
|
// let login_new = wx.getStorageSync('login');
|
|
|
// let gh_login = wx.getStorageSync('gh_login');
|
|
|
// let cb_login = wx.getStorageSync('cb_login');
|
|
|
// let loginType = wx.getStorageSync('entrance_type');
|
|
|
// if (loginType == 1) {
|
|
|
// if (login_new == 0) {
|
|
|
// wx.showModal({
|
|
|
// title: '提示',
|
|
|
// content: '请绑定账户后操作',
|
|
|
// success(res) {
|
|
|
// if (res.confirm) {
|
|
|
// wx.navigateTo({
|
|
|
// url: '/packageA/pages/login/login',
|
|
|
// })
|
|
|
// } else if (res.cancel) {
|
|
|
|
|
|
// }
|
|
|
// }
|
|
|
// })
|
|
|
|
|
|
// return false
|
|
|
// }
|
|
|
// } else if (loginType == 2) {
|
|
|
// if (gh_login == 0) {
|
|
|
// wx.showModal({
|
|
|
// title: '提示',
|
|
|
// content: '请绑定账户后操作',
|
|
|
// success(res) {
|
|
|
// if (res.confirm) {
|
|
|
// wx.navigateTo({
|
|
|
// url: '/packageA/pages/login/login',
|
|
|
// })
|
|
|
// } else if (res.cancel) {
|
|
|
|
|
|
// }
|
|
|
// }
|
|
|
// })
|
|
|
|
|
|
// return false
|
|
|
// }
|
|
|
// } else if (loginType == 3) {
|
|
|
// if (cb_login == 0) {
|
|
|
// wx.showModal({
|
|
|
// title: '提示',
|
|
|
// content: '请绑定账户后操作',
|
|
|
// success(res) {
|
|
|
// if (res.confirm) {
|
|
|
// wx.navigateTo({
|
|
|
// url: '/packageA/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
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/login/login',
|
|
|
url: '/packageA/pages/search/search_result/search_result?title=' + title + "&index=" + index + '&pid=' + pid
|
|
|
})
|
|
|
} else if (res.cancel) { }
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/classify/classify',
|
|
|
})
|
|
|
},
|
|
|
//展示所有的小分类
|
|
|
show_all() {
|
|
|
this.setData({
|
|
|
length_num: this.data.length_num == 9 ? this.data.class_arr.length : 9
|
|
|
})
|
|
|
},
|
|
|
// 查看小分类
|
|
|
look_item(e) {
|
|
|
let token = wx.getStorageSync("token")
|
|
|
if (token == '') {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请先登录',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/register/register',
|
|
|
},
|
|
|
//监测轮播图变化
|
|
|
swiperChange(e) {
|
|
|
this.setData({
|
|
|
zcurrent: e.detail.current
|
|
|
})
|
|
|
},
|
|
|
//轮播图
|
|
|
look_more(e) {
|
|
|
let token = wx.getStorageSync("token")
|
|
|
let id = e.currentTarget.dataset.id
|
|
|
let style = e.currentTarget.dataset.style
|
|
|
if (token == '') {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请先登录',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) { }
|
|
|
}
|
|
|
})
|
|
|
} else if (res.cancel) { }
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
let login_new = wx.getStorageSync('login');
|
|
|
let gh_login = wx.getStorageSync('gh_login');
|
|
|
let cb_login = wx.getStorageSync('cb_login');
|
|
|
let loginType = wx.getStorageSync('entrance_type');
|
|
|
if (loginType == 1) {
|
|
|
if (login_new == 0) {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请绑定账户后操作',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
} else {
|
|
|
// 2023-10-19 需求是无需登录
|
|
|
// 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) { }
|
|
|
// }
|
|
|
// })
|
|
|
// return false
|
|
|
// }
|
|
|
if (style == 2) {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/login/login',
|
|
|
url: '/packageA/pages/outerChain/outerChain?src=' + e.currentTarget.dataset.src
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
} else if(loginType == 2){
|
|
|
if (gh_login == 0) {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请绑定账户后操作',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
} else {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/login/login',
|
|
|
url: '/packageA/pages/shop_detail/shop_detail?id=' + id
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
return false
|
|
|
}
|
|
|
}else if(loginType == 3){
|
|
|
if (cb_login == 0) {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请绑定账户后操作',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
|
|
|
}
|
|
|
},
|
|
|
// 排序
|
|
|
reorder(e) {
|
|
|
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'
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
|
|
|
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
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/search/search_result/search_result?title=' + title + "&index=" + index + '&pid=' + pid
|
|
|
})
|
|
|
}
|
|
|
|
|
|
},
|
|
|
//监测轮播图变化
|
|
|
swiperChange(e) {
|
|
|
this.setData({
|
|
|
zcurrent: e.detail.current
|
|
|
})
|
|
|
},
|
|
|
//轮播图
|
|
|
look_more(e) {
|
|
|
let token = wx.getStorageSync("token")
|
|
|
let id = e.currentTarget.dataset.id
|
|
|
let style = e.currentTarget.dataset.style
|
|
|
if (token == '') {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content: '请先登录',
|
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/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: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) { }
|
|
|
}
|
|
|
})
|
|
|
return false
|
|
|
}
|
|
|
if (style == 2) {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/outerChain/outerChain?src=' + e.currentTarget.dataset.src
|
|
|
this.setData({
|
|
|
c_index: e.currentTarget.dataset.index,
|
|
|
page: 1,
|
|
|
page_type: false
|
|
|
})
|
|
|
} else {
|
|
|
wx.navigateTo({
|
|
|
url: '/packageA/pages/shop_detail/shop_detail?id=' + id
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
//调用排序接口
|
|
|
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
|
|
|
})
|
|
|
|
|
|
// 排序
|
|
|
reorder(e) {
|
|
|
let that = this
|
|
|
let index = Number(e.currentTarget.dataset.index)
|
|
|
if (index == 1) {
|
|
|
if (that.data.price == "price") {
|
|
|
that.setData({
|
|
|
price: 'price desc'
|
|
|
this.setData({
|
|
|
scrollTop: 0
|
|
|
})
|
|
|
} else {
|
|
|
that.setData({
|
|
|
price: 'price'
|
|
|
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 = app.interface.banner
|
|
|
app.post(url, {}).then((res) => {
|
|
|
this.setData({
|
|
|
imgurl: res.msg
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
} else if (index == 2) {
|
|
|
if (that.data.paynum == "paynum") {
|
|
|
that.setData({
|
|
|
paynum: 'paynum desc'
|
|
|
},
|
|
|
//获取公告
|
|
|
get_notice() {
|
|
|
let that = this
|
|
|
let url = app.interface.notice
|
|
|
app.post(url, {}).then((res) => {
|
|
|
for (let obj of res.msg) {
|
|
|
obj.createtime = obj.createtime.substring(0, 10)
|
|
|
}
|
|
|
that.setData({
|
|
|
notice: res.msg
|
|
|
})
|
|
|
})
|
|
|
} else {
|
|
|
that.setData({
|
|
|
paynum: 'paynum'
|
|
|
},
|
|
|
//获取页面信息
|
|
|
get_info(pid, type) { //type 1为小标题 2为小标题下的小分类
|
|
|
wx.showLoading({
|
|
|
title: '加载中',
|
|
|
mask: true
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
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
|
|
|
})
|
|
|
|
|
|
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 = app.interface.banner
|
|
|
app.post(url, {}).then((res) => {
|
|
|
this.setData({
|
|
|
imgurl: res.msg
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
//获取公告
|
|
|
get_notice() {
|
|
|
let that = this
|
|
|
let url = app.interface.notice
|
|
|
app.post(url, {}).then((res) => {
|
|
|
for (let obj of res.msg) {
|
|
|
obj.createtime = obj.createtime.substring(0, 10)
|
|
|
}
|
|
|
that.setData({
|
|
|
notice: res.msg
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
//获取页面信息
|
|
|
get_info(pid, type) { //type 1为小标题 2为小标题下的小分类
|
|
|
wx.showLoading({
|
|
|
title: '加载中',
|
|
|
mask: true
|
|
|
})
|
|
|
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: ''
|
|
|
let that = this
|
|
|
let url = app.interface.index
|
|
|
let params = {
|
|
|
pid: pid
|
|
|
}
|
|
|
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: ''
|
|
|
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()
|
|
|
})
|
|
|
that.good_list(pid, that.data.c_index)
|
|
|
}
|
|
|
}).catch((er) => {
|
|
|
wx.hideLoading()
|
|
|
})
|
|
|
},
|
|
|
//获取商品列表
|
|
|
good_list(pid, c_index) {
|
|
|
wx.showLoading({
|
|
|
title: '加载中',
|
|
|
mask: true
|
|
|
})
|
|
|
let that = this
|
|
|
let url = app.interface.good_list
|
|
|
let params = {
|
|
|
pid: pid,
|
|
|
page: that.data.page
|
|
|
}
|
|
|
if (c_index == 1) {
|
|
|
params.price = that.data.price
|
|
|
} else if (c_index == 2) {
|
|
|
params.paynum = that.data.paynum
|
|
|
}
|
|
|
app.post(url, params).then((res) => {
|
|
|
let list = res.msg;
|
|
|
for (let obj of list) {
|
|
|
obj.sales = obj.paynum
|
|
|
}
|
|
|
if (that.data.page == 1) {
|
|
|
wx.hideLoading()
|
|
|
|
|
|
that.setData({
|
|
|
shop_arr: list
|
|
|
},
|
|
|
//获取商品列表
|
|
|
good_list(pid, c_index) {
|
|
|
wx.showLoading({
|
|
|
title: '加载中',
|
|
|
mask: true
|
|
|
})
|
|
|
} else {
|
|
|
if (res.msg.length == 0) {
|
|
|
wx.hideLoading()
|
|
|
that.setData({
|
|
|
page_type: true
|
|
|
})
|
|
|
} else {
|
|
|
setTimeout(() => {
|
|
|
wx.hideLoading()
|
|
|
that.setData({
|
|
|
shop_arr: that.data.shop_arr.concat(list)
|
|
|
})
|
|
|
}, 1000)
|
|
|
let that = this
|
|
|
let url = app.interface.good_list
|
|
|
let params = {
|
|
|
pid: pid,
|
|
|
page: that.data.page
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
|
|
|
//获取购物车数量
|
|
|
get_shopnum() {
|
|
|
let that = this
|
|
|
let url = app.interface.shopcarNum
|
|
|
app.post(url, {}).then((res) => {
|
|
|
if (res.msg > 0) {
|
|
|
wx.showTabBarRedDot({
|
|
|
index: 2,
|
|
|
success: function (red) {
|
|
|
wx.setTabBarBadge({
|
|
|
index: 2,
|
|
|
text: res.msg.toString(),
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
wx.hideTabBarRedDot({
|
|
|
index: 2,
|
|
|
if (c_index == 1) {
|
|
|
params.price = that.data.price
|
|
|
} else if (c_index == 2) {
|
|
|
params.paynum = that.data.paynum
|
|
|
}
|
|
|
app.post(url, params).then((res) => {
|
|
|
let list = res.msg;
|
|
|
for (let obj of list) {
|
|
|
obj.sales = obj.paynum
|
|
|
}
|
|
|
if (that.data.page == 1) {
|
|
|
wx.hideLoading()
|
|
|
|
|
|
that.setData({
|
|
|
shop_arr: list
|
|
|
})
|
|
|
} else {
|
|
|
if (res.msg.length == 0) {
|
|
|
wx.hideLoading()
|
|
|
that.setData({
|
|
|
page_type: true
|
|
|
})
|
|
|
} else {
|
|
|
setTimeout(() => {
|
|
|
wx.hideLoading()
|
|
|
that.setData({
|
|
|
shop_arr: that.data.shop_arr.concat(list)
|
|
|
})
|
|
|
}, 1000)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
},
|
|
|
|
|
|
getmessagelist() {
|
|
|
let that = this
|
|
|
let url = '/information/get_all';
|
|
|
let data = {
|
|
|
page: 1,
|
|
|
pageNum: 10,
|
|
|
|
|
|
}
|
|
|
app.post(url, data, "POST").then((r) => {
|
|
|
// console.log(r)
|
|
|
// that.setData({
|
|
|
// messagelist: that.data.messagelist.concat(r.msg)
|
|
|
// })
|
|
|
|
|
|
let newlist = [];
|
|
|
r.msg.forEach(function (value, index, array) {
|
|
|
console.log(newlist)
|
|
|
if (value.status == 1) {
|
|
|
newlist.push(value)
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
|
|
|
//获取购物车数量
|
|
|
get_shopnum() {
|
|
|
let that = this
|
|
|
let url = app.interface.shopcarNum
|
|
|
app.post(url, {}).then((res) => {
|
|
|
if (res.msg > 0) {
|
|
|
wx.showTabBarRedDot({
|
|
|
index: 2,
|
|
|
success: function (red) {
|
|
|
wx.setTabBarBadge({
|
|
|
index: 2,
|
|
|
text: res.msg.toString(),
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
wx.hideTabBarRedDot({
|
|
|
index: 2,
|
|
|
})
|
|
|
}
|
|
|
}).catch(err => {})
|
|
|
},
|
|
|
|
|
|
getmessagelist() {
|
|
|
let that = this
|
|
|
let url = '/information/get_all';
|
|
|
let data = {
|
|
|
page: 1,
|
|
|
pageNum: 10,
|
|
|
}
|
|
|
})
|
|
|
app.post(url, data, "POST").then((r) => {
|
|
|
// console.log(r)
|
|
|
// that.setData({
|
|
|
// messagelist: that.data.messagelist.concat(r.msg)
|
|
|
// })
|
|
|
let newlist = [];
|
|
|
r.msg.forEach(function (value, index, array) {
|
|
|
if (value.status == 1) {
|
|
|
newlist.push(value)
|
|
|
}
|
|
|
})
|
|
|
if (newlist.length != 0) {
|
|
|
wx.showTabBarRedDot({
|
|
|
index: 1,
|
|
|
success: function (red) {
|
|
|
wx.setTabBarBadge({
|
|
|
index: 1,
|
|
|
text: newlist.length.toString(),
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
}).catch((err) => { })
|
|
|
},
|
|
|
// 获取个人信息
|
|
|
|
|
|
console.log('77889944556', newlist)
|
|
|
if (newlist.length != 0) {
|
|
|
wx.showTabBarRedDot({
|
|
|
index: 1,
|
|
|
success: function (red) {
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady: function () {
|
|
|
|
|
|
wx.setTabBarBadge({
|
|
|
index: 1,
|
|
|
text: newlist.length.toString(),
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
}).catch((err) => { })
|
|
|
},
|
|
|
// 获取个人信息
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
|
|
|
this.setData({
|
|
|
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);
|
|
|
}
|
|
|
|
|
|
//控制显示隐藏
|
|
|
this.ishow()
|
|
|
}
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
this.setData({
|
|
|
logok: app.globalData.baseUrlimg + "assets/img/cb2ad36a391388f19f5f912fa021f8f.png"
|
|
|
})
|
|
|
// this.logok=app.globalData.baseUrlimg+"assets/img/cb2ad36a391388f19f5f912fa021f8f.png''
|
|
|
this.get_banner()
|
|
|
// if (app.globalData.index == 0) {
|
|
|
// app.globalData.index = undefined
|
|
|
let token = wx.getStorageSync('token');
|
|
|
if (token != "") {
|
|
|
this.getInfoFun()
|
|
|
}
|
|
|
this.get_notice()
|
|
|
this.get_shopnum()
|
|
|
this.getmessagelist();
|
|
|
if (this.data.pid) {
|
|
|
this.get_info(this.data.pid, 2);
|
|
|
} else {
|
|
|
this.get_info(0, 1);
|
|
|
}
|
|
|
//控制显示隐藏
|
|
|
this.ishow()
|
|
|
// }
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function () {
|
|
|
|
|
|
},
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function () {
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: function () {
|
|
|
|
|
|
},
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: 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
|
|
|
})
|
|
|
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)
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh: function () {
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: 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
|
|
|
})
|
|
|
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 () {
|
|
|
|
|
|
}
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|