银花优选微信小程序修改后的最新版本代码

This commit is contained in:
ss001
2026-02-07 16:22:31 +08:00
commit c00caf5744
516 changed files with 41796 additions and 0 deletions

166
pages/classify/index.js Normal file
View File

@@ -0,0 +1,166 @@
var app = getApp()
var that = null
Page({
data: {
navLeftItems: [],
navRightItems:[],
products: [],
Start: 0,
categoryid: 0,
categoryid0: 0,
navindex:0,
navindex0:-1,
loadingHidden:false
},
// 页面加载
onLoad: function () {
that = this
that.getlist(0);//第一次加载数据
},
// 下拉刷新
onPullDownRefresh: function () {
that.clearCache();
//在当前页面显示导航条加载动画
wx.showNavigationBarLoading();
//显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框
wx.showLoading({
title: '刷新中...',
})
that.getlist(1);//第一次加载数据
},
// 页面上拉触底事件(上拉加载更多)
onReachBottom: function () {
that.setData({
loadingHidden:false
});
that.getlist(2);//后台获取新数据并追加渲染
},
// 清缓存
clearCache:function(){
that.setData({
products: [],
Start: 0,
loadingHidden:false
});
},
getlist: function (gp) {
var userId = wx.getStorageSync("userId")
var LoginId = wx.getStorageSync("LoginId")
wx.request({
url: app.globalData.apiurl + "/xapiajax.ashx",
data: {
action:"getshopcategory",
categoryid:that.data.categoryid,
categoryid0:that.data.categoryid0,
Start:that.data.Start,
userId:(!userId?"":userId),
LoginId:(!LoginId?"":LoginId)
},
method:"GET",
dataType:"json",
header: {
"content-type": "application/json" // 默认值
},
success (res) {
if(that.data.Start==0){
var index=that.data.navindex;
var addlb=[{header:"全部分类",image:"",productlb:[],id:0}];
var productlb = null;
productlb = addlb;
if(productlb,res.data.productlb.length>0){
productlb.push.apply(productlb,res.data.productlb);
}
var productlb2=productlb[index].productlb;
that.setData({
navLeftItems: productlb,
navRightItems: productlb2,
navindex:index
})
}
var tmpArr = null;
tmpArr = that.data.products;
if(res.data.productlist.length>0){
tmpArr.push.apply(tmpArr,res.data.productlist);
}
that.setData({
products: tmpArr,
Start: that.data.Start+res.data.productlist.length,
loadingHidden:true
})
if(gp==0||gp==1){
if(res.data.productlist.length==0){
that.setData({
nodataHidden:false
})
}
}
if(gp==1){
//隐藏loading 提示框
wx.hideLoading();
//隐藏导航条加载动画
wx.hideNavigationBarLoading();
//停止下拉刷新
wx.stopPullDownRefresh();
}
}
})
},
//事件处理函数
switchRightTab: function(e) {
var index = e.target.dataset.id;
var categoryid=that.data.navLeftItems[index].id;
var productlb2=that.data.navLeftItems[index].productlb;
that.clearCache();
that.setData({
Start:0,
navindex:index,
navindex0:-1,
categoryid:categoryid,
categoryid0:0,
navRightItems: productlb2
})
that.getlist(1);
},
//事件处理函数
switchRightTab0: function(e) {
var index = e.target.dataset.id;
var categoryid0=0;
if(index>-1){
var productlb2=that.data.navLeftItems[that.data.navindex].productlb;
categoryid0=productlb2[index].id;
}
that.clearCache();
that.setData({
Start:0,
navindex0:index,
categoryid0: categoryid0
})
that.getlist(1);
},ondetail:function(e) {
var userId = wx.getStorageSync("userId")
var LoginId = wx.getStorageSync("LoginId")
if(userId&&LoginId){
var id = e.currentTarget.dataset.id
wx.navigateTo({
url: "../details/index?id="+id
})
}else{
wx.navigateTo({
url: "../login/index"
})
}
}
})

View File

@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "分类"
}

43
pages/classify/index.wxml Normal file
View File

@@ -0,0 +1,43 @@
<view class="container">
<view class="nav_left">
<block wx:for="{{navLeftItems}}" wx:for-index="index">
<view class="nav_left_items {{index==navindex?'active':''}}" bindtap="switchRightTab" data-id="{{index}}">{{item.header}}</view>
</block>
</view>
<view class="nav_right">
<view wx:if="{{categoryid>0&&navRightItems.length>0}}" style="width:100%;overflow-x: auto;">
<view style="width:200%;">
<view class="nav_right_item {{navindex0==-1?'active':''}}" bindtap="switchRightTab0" data-id="-1">
全部分类
</view>
<block wx:for="{{navRightItems}}" wx:for-index="index">
<view class="nav_right_item {{index==navindex0?'active':''}}" bindtap="switchRightTab0" data-id="{{index}}">
{{item.header}}
</view>
</block>
</view>
</view>
<view class="clear"></view>
<view wx:if="{{products}}">
<view wx:for="{{products}}" class="brand_item" bindtap="ondetail" data-id="{{item._id}}">
<image src="{{item.image}}" class="pic"></image>
<view class="brand_item_cont">
<text class="name">{{item.name}}</text>
<view class="price">
<!--<text class="marketprice">¥{{item.scje}}</text>-->
<text class="ourprice">¥{{item.hyje}}</text>
</view>
</view>
</view>
</view>
<view wx:else>暂无数据</view>
</view>
</view>

97
pages/classify/index.wxss Normal file
View File

@@ -0,0 +1,97 @@
page{
background: #ccc;
}
.container {
position: relative;
width: 100%;
height: 100%;
font-size: 14px;
color: #000;
}
.nav_left{
width: 25%;
height: 100vh;
background: #f5f5f5;
text-align: center;
overflow: hidden;
overflow-y: auto;
position: fixed;
left:0;
top:0;
}
.nav_left .nav_left_items{
height: 30px;
line-height: 30px;
padding: 6px 0;
border-bottom: 1px solid #dedede;
}
.nav_left .nav_left_items.active{
background: #fff;
}
.nav_right{
position: absolute;
right: 0;
top:0;
width: 75%;
min-height: 100vh;
margin: 0;
padding: 5px;
background: #fff;
box-sizing: border-box;
}
.nav_right .nav_right_item{
float: left;
width: auto;
text-align: center;
padding:5px;
box-sizing: border-box;
background: #ccc;
border: 1px solid #f1f1f1;
}
.nav_right .nav_right_item.active{
background: #fff;
border: 1px solid #f1f1f1;
}
.container .brand_item{
float: left;
width:50%;
margin:0;
padding:1em;
background-color: #fff;
border: 1px solid #f1f1f1;
box-sizing: border-box;
text-align: center;
overflow: hidden;
}
.container .brand_item .pic{
width: 6em;
height: 6em;
}
.container .brand_item .pic image{
width: 100%;
height: 100%;
}
.brand_item_cont{
width: 100%;
}
.brand_item_cont .name{
margin: 10px 0;
margin-bottom: 5px;
display: block;
width: 100%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.brand_item_cont .ourprice{
color: #ff4d00;
font-weight: bold;
}
.brand_item_cont .marketprice{
text-decoration: line-through;
color: #939393;
}