...
|
...
|
@@ -31,7 +31,39 @@ Page({ |
|
|
status2: '',
|
|
|
title2: '',
|
|
|
scrollTop:'',
|
|
|
pid:''
|
|
|
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
|
|
|
},
|
|
|
|
|
|
scroll(e) {
|
...
|
...
|
@@ -66,11 +98,11 @@ if( app.globalData.index==undefined){ |
|
|
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(this.data.pid){
|
|
|
// this.get_info(this.data.pid, 2);
|
|
|
// }else{
|
|
|
// this.get_info(0, 1);
|
|
|
// }
|
|
|
|
|
|
// 获取活动专区
|
|
|
this.getzhuanqulist();
|
...
|
...
|
@@ -83,9 +115,33 @@ if( app.globalData.index==undefined){ |
|
|
}
|
|
|
//控制显示隐藏
|
|
|
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
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 获取个人信息
|
|
|
getInfoFun() {
|
|
|
let that= this;
|
...
|
...
|
@@ -112,7 +168,7 @@ if( app.globalData.index==undefined){ |
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/register/register',
|
|
|
url: '/packageA/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
...
|
...
|
@@ -138,7 +194,7 @@ if( app.globalData.index==undefined){ |
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/login/login',
|
|
|
url: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
...
|
...
|
@@ -150,7 +206,7 @@ if( app.globalData.index==undefined){ |
|
|
|
|
|
}
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/xianshi/xianshi?title2='+this.data.title2,
|
|
|
url: '/packageA/pages/xianshi/xianshi?title2='+this.data.title2,
|
|
|
})
|
|
|
}
|
|
|
|
...
|
...
|
@@ -257,15 +313,15 @@ if( app.globalData.index==undefined){ |
|
|
//获取活动专区列表
|
|
|
getzhuanqulist() {
|
|
|
let that = this
|
|
|
let url = '/activity/get_all';
|
|
|
let url = '/activity/get_list';
|
|
|
let data = {
|
|
|
|
|
|
|
|
|
}
|
|
|
app.post(url, data, "POST").then((r) => {
|
|
|
app.postk(url, data, "POST").then((r) => {
|
|
|
console.log(r)
|
|
|
that.setData({
|
|
|
activity: r.msg
|
|
|
activity: r.data
|
|
|
})
|
|
|
|
|
|
console.log(that.data.activity)
|
...
|
...
|
@@ -289,7 +345,7 @@ if( app.globalData.index==undefined){ |
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/register/register',
|
|
|
url: '/packageA/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
...
|
...
|
@@ -306,7 +362,7 @@ if( app.globalData.index==undefined){ |
|
|
|
|
|
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/login/login',
|
|
|
url: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
...
|
...
|
@@ -316,7 +372,7 @@ if( app.globalData.index==undefined){ |
|
|
return false
|
|
|
}
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/zhuanqu/zhuanqu?id=' + id,
|
|
|
url: '/packageA/pages/zhuanqu/zhuanqu?id=' + id,
|
|
|
})
|
|
|
}
|
|
|
|
...
|
...
|
@@ -331,7 +387,7 @@ if( app.globalData.index==undefined){ |
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/register/register',
|
|
|
url: '/packageA/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
...
|
...
|
@@ -350,7 +406,7 @@ if( app.globalData.index==undefined){ |
|
|
|
|
|
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/login/login',
|
|
|
url: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
...
|
...
|
@@ -360,7 +416,7 @@ if( app.globalData.index==undefined){ |
|
|
return false
|
|
|
}
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/classify/classify',
|
|
|
url: '/packageA/pages/classify/classify',
|
|
|
})
|
|
|
},
|
|
|
//展示所有的小分类
|
...
|
...
|
@@ -379,7 +435,7 @@ if( app.globalData.index==undefined){ |
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/register/register',
|
|
|
url: '/packageA/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
...
|
...
|
@@ -396,7 +452,7 @@ if( app.globalData.index==undefined){ |
|
|
|
|
|
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/login/login',
|
|
|
url: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
...
|
...
|
@@ -405,12 +461,17 @@ if( app.globalData.index==undefined){ |
|
|
|
|
|
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: '/pages/search/search_result/search_result?title=' + title + "&index=" + index + '&pid=' + pid
|
|
|
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 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
|
|
|
// })
|
|
|
}
|
|
|
|
|
|
},
|
...
|
...
|
@@ -432,7 +493,7 @@ if( app.globalData.index==undefined){ |
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/register/register',
|
|
|
url: '/packageA/pages/register/register',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
...
|
...
|
@@ -447,7 +508,7 @@ if( app.globalData.index==undefined){ |
|
|
success(res) {
|
|
|
if (res.confirm) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/login/login',
|
|
|
url: '/packageA/pages/login/login',
|
|
|
})
|
|
|
} else if (res.cancel) {
|
|
|
}
|
...
|
...
|
@@ -458,12 +519,12 @@ if( app.globalData.index==undefined){ |
|
|
}
|
|
|
if (style == 2) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/outerChain/outerChain?src=' + e.currentTarget.dataset.src
|
|
|
url: '/packageA/pages/outerChain/outerChain?src=' + e.currentTarget.dataset.src
|
|
|
})
|
|
|
} else {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/shop_detail/shop_detail?id=' + id
|
|
|
})
|
|
|
// wx.navigateTo({
|
|
|
// url: '/packageA/pages/shop_detail/shop_detail?id=' + id
|
|
|
// })
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -475,67 +536,129 @@ if( app.globalData.index==undefined){ |
|
|
// 排序
|
|
|
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'
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
this.setData({
|
|
|
c_index: e.currentTarget.dataset.index,
|
|
|
page: 1,
|
|
|
page_type: false
|
|
|
that.setData({
|
|
|
page:1,
|
|
|
shop_arr:[]
|
|
|
})
|
|
|
//调用排序接口
|
|
|
this.good_list(this.data.pid, e.currentTarget.dataset.index)
|
|
|
},
|
|
|
|
|
|
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)
|
|
|
},
|
|
|
// 选择一级分类
|
|
|
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({
|
|
|
pid:id
|
|
|
})
|
|
|
|
|
|
this.setData({
|
|
|
scrollTop: 0
|
|
|
category_id1:id,
|
|
|
class_arr:newclass_arr,
|
|
|
nav_index:index
|
|
|
})
|
|
|
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' //销量排序方式
|
|
|
},
|
|
|
// 获取商品列表
|
|
|
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.get_info(id, 2)
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
|
|
|
// 轮播图
|
|
|
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
|
|
|
})
|
|
|
})
|
|
|
},
|
...
|
...
|
@@ -553,45 +676,45 @@ if( app.globalData.index==undefined){ |
|
|
})
|
|
|
},
|
|
|
//获取页面信息
|
|
|
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({
|
...
|
...
|
@@ -712,7 +835,9 @@ if( app.globalData.index==undefined){ |
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
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){
|
...
|
...
|
@@ -727,9 +852,9 @@ if( app.globalData.index==undefined){ |
|
|
this.getmessagelist();
|
|
|
console.log('998867',this.data.pid)
|
|
|
if(this.data.pid){
|
|
|
this.get_info(this.data.pid, 2);
|
|
|
// this.get_info(this.data.pid, 2);
|
|
|
}else{
|
|
|
this.get_info(0, 1);
|
|
|
// this.get_info(0, 1);
|
|
|
}
|
|
|
|
|
|
//控制显示隐藏
|
...
|
...
|
@@ -761,39 +886,46 @@ if( app.globalData.index==undefined){ |
|
|
|
|
|
},
|
|
|
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
|
|
|
let newpage=this.data.page;
|
|
|
newpage++;
|
|
|
this.setData({
|
|
|
page:newpage
|
|
|
})
|
|
|
that.good_list(that.data.pid, that.data.c_index)
|
|
|
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)
|
|
|
|
|
|
// 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)
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
|