银花优选微信小程序修改后的最新版本代码
This commit is contained in:
133
pages/list/index.js
Normal file
133
pages/list/index.js
Normal file
@@ -0,0 +1,133 @@
|
||||
var app = getApp()
|
||||
var that = null
|
||||
Page({
|
||||
data: {
|
||||
products: [],
|
||||
categoryid: 0,
|
||||
keyword:"",
|
||||
Recount:0,
|
||||
Start: 0,
|
||||
t:0,
|
||||
onsearchHidden:true,
|
||||
loadingHidden:false,
|
||||
nodataHidden:true
|
||||
},
|
||||
onLoad: function(options) {
|
||||
that = this
|
||||
that.clearCache();//清本页缓存
|
||||
if(options.id&&options.title){
|
||||
that.setData({
|
||||
categoryid:options.id
|
||||
})
|
||||
wx.setNavigationBarTitle({
|
||||
title: options.title
|
||||
})
|
||||
}
|
||||
if(options.t){
|
||||
that.setData({
|
||||
t:options.t
|
||||
})
|
||||
}
|
||||
if(options.keyword){
|
||||
that.setData({
|
||||
keyword:options.keyword,
|
||||
onsearchHidden:false
|
||||
})
|
||||
wx.setNavigationBarTitle({
|
||||
title: "搜索商品"
|
||||
})
|
||||
}
|
||||
|
||||
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:"getwxshoplist",
|
||||
userId:(!userId?"":userId),
|
||||
LoginId:(!LoginId?"":LoginId),
|
||||
categoryid:that.data.categoryid,
|
||||
keyword:that.data.keyword,
|
||||
Start:that.data.Start
|
||||
},
|
||||
method:"GET",
|
||||
dataType:"json",
|
||||
header: {
|
||||
"content-type": "application/json" // 默认值
|
||||
},
|
||||
success (res) {
|
||||
var tmpArr = null;
|
||||
tmpArr = that.data.products;
|
||||
tmpArr.push.apply(tmpArr,res.data.productlist);
|
||||
that.setData({
|
||||
products: tmpArr,
|
||||
Start: that.data.Start+res.data.productlist.length,
|
||||
Recount:res.data.Recount,
|
||||
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();
|
||||
}
|
||||
}
|
||||
})
|
||||
},gotodetail: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"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
3
pages/list/index.json
Normal file
3
pages/list/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "分类列表"
|
||||
}
|
||||
37
pages/list/index.wxml
Normal file
37
pages/list/index.wxml
Normal file
@@ -0,0 +1,37 @@
|
||||
<view class="container">
|
||||
<view class="searchdata" hidden="{{onsearchHidden}}">共找到 “{{keyword}}” 相关的产品 {{Recount}} 条</view>
|
||||
<view>
|
||||
<view class="choice_box">
|
||||
<view class="choice_list">
|
||||
<block wx:for="{{products}}" wx:for-item="cell" wx:for-index="index0">
|
||||
<view class='block block0{{(index0%2)==1?" r":" l"}}' bindtap="gotodetail" data-id="{{cell._id}}">
|
||||
<view class='choice_item'>
|
||||
<image src="{{cell.image}}"/>
|
||||
<view class="title">{{cell.name}}</view>
|
||||
<view class="je">
|
||||
<view class="jeto">
|
||||
<view>零售价: </view>
|
||||
<view class="scje">¥{{cell.scje}}</view>
|
||||
</view>
|
||||
<view class="jeto">
|
||||
<view>会员价:</view>
|
||||
<view class="hyje">{{cell.hyje}}</view>
|
||||
</view>
|
||||
<view class="jeto">
|
||||
<view>可用补贴券:</view>
|
||||
<view class="hyje">{{cell.hyjf}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="nodata" hidden="{{nodataHidden}}">{{keyword==""?"暂无此类商品":""}}</view>
|
||||
|
||||
</view>
|
||||
<loading hidden="{{loadingHidden}}">
|
||||
加载中...
|
||||
</loading>
|
||||
122
pages/list/index.wxss
Normal file
122
pages/list/index.wxss
Normal file
@@ -0,0 +1,122 @@
|
||||
page{
|
||||
background: #ccc;
|
||||
}
|
||||
.container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-size: 14px;
|
||||
color: #000;
|
||||
}
|
||||
.container .nodata{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
line-height: 5em;
|
||||
}
|
||||
.container .searchdata{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
line-height: 5em;
|
||||
color: #939393;
|
||||
}
|
||||
|
||||
.choice_box {
|
||||
float: left;
|
||||
width:100%;
|
||||
padding:0;
|
||||
padding-top: 0.5em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.choice_box .choice_list .block{
|
||||
float: left;
|
||||
width: 100%;
|
||||
padding:0.5em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.choice_box .choice_list .block.block0{
|
||||
width: 50%;
|
||||
padding: 0.5em;
|
||||
padding-top: 0;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
.choice_box .choice_list .block.block0.l{
|
||||
padding-right: 0.25em;
|
||||
}
|
||||
.choice_box .choice_list .block.block0.r{
|
||||
padding-left: 0.25em;
|
||||
}
|
||||
.choice_box .choice_list .block .choice_item{
|
||||
float: left;
|
||||
width: 100%;
|
||||
padding:0;
|
||||
border:1px solid #f1f1f1;
|
||||
background-color: #f5f5f5;
|
||||
border-radius:0.5em;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
}
|
||||
.choice_box .choice_list .block image {
|
||||
width: 100%;
|
||||
height:90vw;
|
||||
}
|
||||
.choice_box .choice_list .block.block0 image {
|
||||
width: 100%;
|
||||
height:46vw;
|
||||
}
|
||||
|
||||
.choice_box .choice_list .title {
|
||||
float: left;
|
||||
padding:0 0.5em;
|
||||
font-weight: bold;
|
||||
text-align: left;
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
}
|
||||
.choice_box .choice_list .je {
|
||||
float: right;
|
||||
width:auto;
|
||||
display: flex;
|
||||
flex-direction:column;
|
||||
align-items:flex-end;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
color: #939393;
|
||||
padding:0 0.5em;
|
||||
padding-bottom: 0.5em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.choice_box .choice_list .je .jeto{
|
||||
display: flex;
|
||||
flex-direction:row;
|
||||
margin-top: 0.8em;
|
||||
background-color: #00B050;
|
||||
padding: 0.4em 0.4em;
|
||||
color:#fff;
|
||||
border-radius:0.5em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.choice_box .choice_list .je .jeto .scje{
|
||||
text-decoration:line-through;
|
||||
}
|
||||
|
||||
|
||||
.choice_box .choice_list .block.block0 .title{
|
||||
width:100%;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.choice_box .choice_list .block.block0 .je {
|
||||
float: left;
|
||||
width:100%;
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
.choice_box .choice_list .block.block0 .je .jeto .hyje{
|
||||
margin-top: 0.15em;
|
||||
}
|
||||
Reference in New Issue
Block a user