银花优选微信小程序修改后的最新版本代码
This commit is contained in:
141
pages/myfavorite/index.js
Normal file
141
pages/myfavorite/index.js
Normal file
@@ -0,0 +1,141 @@
|
||||
var app = getApp()
|
||||
var that=null
|
||||
Page( {
|
||||
data: {
|
||||
loadingHidden:false,
|
||||
nodataHidden:true,
|
||||
Start: 0,
|
||||
myfavorites:[]
|
||||
},
|
||||
|
||||
onLoad: function() {
|
||||
that = this
|
||||
that.clearCache();//清本页缓存
|
||||
that.getlist(0);//第一次加载数据
|
||||
}, getlist: function (gp) {
|
||||
|
||||
var userId = wx.getStorageSync("userId")
|
||||
var LoginId = wx.getStorageSync("LoginId")
|
||||
wx.request({
|
||||
url: app.globalData.apiurl + "/xapiajax.ashx",
|
||||
data: {
|
||||
action:"getmyfavorite",
|
||||
userId:(!userId?"":userId),
|
||||
LoginId:(!LoginId?"":LoginId),
|
||||
Start:that.data.Start
|
||||
},
|
||||
method:"GET",
|
||||
dataType:"json",
|
||||
header: {
|
||||
"content-type": "application/json" // 默认值
|
||||
},
|
||||
success (res) {
|
||||
var tmpArr = null;
|
||||
tmpArr = that.data.myfavorites;
|
||||
tmpArr.push.apply(tmpArr,res.data.data);
|
||||
that.setData({
|
||||
myfavorites: tmpArr,
|
||||
Start: that.data.Start+res.data.data.length,
|
||||
loadingHidden:true
|
||||
})
|
||||
|
||||
if(gp==0||gp==1){
|
||||
if(res.data.data.length==0){
|
||||
that.setData({
|
||||
nodataHidden:false
|
||||
})
|
||||
}
|
||||
}
|
||||
if(gp==1){
|
||||
//隐藏loading 提示框
|
||||
wx.hideLoading();
|
||||
//隐藏导航条加载动画
|
||||
wx.hideNavigationBarLoading();
|
||||
//停止下拉刷新
|
||||
wx.stopPullDownRefresh();
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh: function () {
|
||||
//在当前页面显示导航条加载动画
|
||||
wx.showNavigationBarLoading();
|
||||
//显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框
|
||||
wx.showLoading({
|
||||
title: '刷新中...',
|
||||
})
|
||||
that.clearCache();
|
||||
that.getlist(1);//第一次加载数据
|
||||
},
|
||||
|
||||
// 页面上拉触底事件(上拉加载更多)
|
||||
onReachBottom: function () {
|
||||
that.setData({
|
||||
loadingHidden:false
|
||||
});
|
||||
that.getlist(2);//后台获取新数据并追加渲染
|
||||
},
|
||||
|
||||
// 清缓存
|
||||
clearCache:function(){
|
||||
that.setData({
|
||||
myfavorites: [],
|
||||
Start: 0,
|
||||
loadingHidden:false
|
||||
});
|
||||
},ondetail:function(e) {
|
||||
var id = e.currentTarget.dataset.id
|
||||
wx.navigateTo({
|
||||
url: "../details/index?id=" + id
|
||||
})
|
||||
},delete:function(e) {
|
||||
wx.showModal({
|
||||
title: '删除提示',
|
||||
content: '此操作不可恢复!您确认要删除吗?',
|
||||
success (res0) {
|
||||
if (res0.confirm) {
|
||||
var id = e.currentTarget.dataset.id
|
||||
var userId = wx.getStorageSync("userId")
|
||||
var LoginId = wx.getStorageSync("LoginId")
|
||||
wx.request({
|
||||
url: app.globalData.apiurl + "/xapiajax.ashx",
|
||||
data: {
|
||||
action:"delfavorite",
|
||||
userId:(!userId?"":userId),
|
||||
LoginId:(!LoginId?"":LoginId),
|
||||
id:id
|
||||
},
|
||||
method:"POST",
|
||||
dataType:"json",
|
||||
header: {
|
||||
"content-type": "application/x-www-form-urlencoded" // 默认值
|
||||
},
|
||||
success (res) {
|
||||
if(res.data.status==1){
|
||||
wx.showModal({
|
||||
title: "操作提示",
|
||||
content: res.data.msg,
|
||||
showCancel:false,
|
||||
success (res1) {
|
||||
if (res1.confirm) {
|
||||
that.clearCache();
|
||||
that.getlist(0);
|
||||
}
|
||||
}
|
||||
})
|
||||
}else{
|
||||
wx.showToast({
|
||||
title: res.data.msg,
|
||||
icon: "none",
|
||||
duration: 3000
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
3
pages/myfavorite/index.json
Normal file
3
pages/myfavorite/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "我的收藏"
|
||||
}
|
||||
26
pages/myfavorite/index.wxml
Normal file
26
pages/myfavorite/index.wxml
Normal file
@@ -0,0 +1,26 @@
|
||||
<view class="container">
|
||||
<view class="myfavorite-box" wx:for="{{myfavorites}}" >
|
||||
<view class="myfavorite-item" >
|
||||
<image src="{{item.image}}" bindtap="ondetail" data-id="{{item.ProductID}}"></image>
|
||||
<view class="myfavorite-box">
|
||||
<view class="name" bindtap="ondetail" data-id="{{item.ProductID}}">{{item.name}}</view>
|
||||
<view class="price">
|
||||
<text class="ourprice">¥{{item.hyje}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="icon" bindtap="delete" data-id="{{item.id}}"><image src="../../images/close.png" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="nodata" hidden="{{nodataHidden}}">
|
||||
<image src="../../images/order-null.png"/>
|
||||
<view>暂无数据</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
|
||||
<loading hidden="{{loadingHidden}}">
|
||||
加载中...
|
||||
</loading>
|
||||
34
pages/myfavorite/index.wxss
Normal file
34
pages/myfavorite/index.wxss
Normal file
@@ -0,0 +1,34 @@
|
||||
page{
|
||||
background: #ccc;
|
||||
}
|
||||
.container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-size: 14px;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.myfavorite-box{display: flex;flex-direction: column;align-items: center;justify-content: center;width:100%;padding:0.8em; box-sizing: border-box;}
|
||||
.myfavorite-item{position: relative; float:left; width:100%; margin-bottom:0.8em; padding:0.8em; box-sizing: border-box;border:1px solid #f1f1f1; background-color:#fff;border-radius:0.5em;}
|
||||
.myfavorite-item image{float:left;width:25%;height:5em; overflow: hidden;}
|
||||
|
||||
.myfavorite-item .myfavorite-box{float:left;width:75%;height:5em; padding:0 0.5em; overflow: hidden; box-sizing: border-box;}
|
||||
.myfavorite-item .myfavorite-box .ourprice{
|
||||
color: #ff4d00;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.myfavorite-item .myfavorite-box .marketprice{
|
||||
text-decoration: line-through;
|
||||
color: #939393;
|
||||
}
|
||||
.myfavorite-item .icon{position:absolute; right:0.8em; top:0.5em;width:1.5em; height:1.5em; padding:0.15em; background-color:#fff;border:1px solid #f1f1f1;border-radius:50%;box-sizing:border-box; overflow: hidden;}
|
||||
.myfavorite-item .icon image{width:100%;height:100%;}
|
||||
.nodata{padding-top:1em; text-align: center; line-height: 1.5em; color:#939393;}
|
||||
.nodata image {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user