银花优选微信小程序修改后的最新版本代码
This commit is contained in:
144
pages/articles/index.js
Normal file
144
pages/articles/index.js
Normal file
@@ -0,0 +1,144 @@
|
||||
var WxParse = null;
|
||||
var app = getApp()
|
||||
var that=null
|
||||
var that0=null
|
||||
var t=0
|
||||
Page( {
|
||||
data: {
|
||||
loadingHidden:false,
|
||||
nodataHidden:true,
|
||||
bodyHidden:true,
|
||||
Start: 0,
|
||||
articles:[]
|
||||
},
|
||||
onLoad: function(options) {
|
||||
that = this
|
||||
t=options.t
|
||||
if(t==0){
|
||||
wx.setNavigationBarTitle({
|
||||
title: "发图素材"
|
||||
})
|
||||
}else if(t==1){
|
||||
wx.setNavigationBarTitle({
|
||||
title: "健康知识"
|
||||
})
|
||||
}
|
||||
that.getlist(0);//第一次加载数据
|
||||
},
|
||||
|
||||
// 下拉刷新
|
||||
onPullDownRefresh: function () {
|
||||
that.clearCache();
|
||||
that.getlist(0);//第一次加载数据
|
||||
},
|
||||
|
||||
// 页面上拉触底事件(上拉加载更多)
|
||||
onReachBottom: function () {
|
||||
that.getlist(1);//后台获取新数据并追加渲染
|
||||
}, getlist: function (gp) {
|
||||
|
||||
var userId = wx.getStorageSync("userId")
|
||||
var LoginId = wx.getStorageSync("LoginId")
|
||||
wx.request({
|
||||
url: app.globalData.apiurl + "/xapiajax.ashx",
|
||||
data: {
|
||||
action:(t==1?"getjkzslist":"getftsclist"),
|
||||
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.articles;
|
||||
tmpArr.push.apply(tmpArr,res.data.data);
|
||||
that.setData({
|
||||
articles: 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
|
||||
})
|
||||
}else{
|
||||
that.setData({
|
||||
nodataHidden:true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
// 清缓存
|
||||
clearCache:function(){
|
||||
that.setData({
|
||||
articles: [],
|
||||
Start: 0,
|
||||
loadingHidden:false
|
||||
});
|
||||
},ondetail:function(e) {
|
||||
var id = e.currentTarget.dataset.id
|
||||
wx.navigateTo({
|
||||
url: "../articledetail/index?id="+id
|
||||
})
|
||||
/*that.setData({
|
||||
loadingHidden:false
|
||||
})
|
||||
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:"getnewdetail",
|
||||
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){
|
||||
WxParse.wxParse('body', 'html', res.data.content, that);
|
||||
that.setData({
|
||||
title:res.data.title,
|
||||
video:res.data.video,
|
||||
bodyHidden:false
|
||||
})
|
||||
|
||||
|
||||
}else{
|
||||
wx.showToast({
|
||||
title: res.data.msg,
|
||||
icon: "none",
|
||||
duration: 3000
|
||||
})
|
||||
}
|
||||
that.setData({
|
||||
loadingHidden:true
|
||||
})
|
||||
}
|
||||
})*/
|
||||
|
||||
},closeserver:function(e) {
|
||||
that.data.videoCtx.stop()
|
||||
that.setData({
|
||||
bodyHidden:true
|
||||
})
|
||||
},inserver :function(e) {
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
3
pages/articles/index.json
Normal file
3
pages/articles/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
38
pages/articles/index.wxml
Normal file
38
pages/articles/index.wxml
Normal file
@@ -0,0 +1,38 @@
|
||||
<import src="../../wxParse/wxParse.wxml"/>
|
||||
<view class="container">
|
||||
|
||||
<view class="news-box" >
|
||||
<view class="news-item" wx:for="{{articles}}" wx:for-item="cell">
|
||||
<view class="news-item-to" bindtap="ondetail" data-id="{{cell.id}}">
|
||||
<view class="pic"><image src="{{cell.pic}}"></image></view>
|
||||
<view class="title_time">
|
||||
<view class="title">{{cell.title}}</view>
|
||||
<view class="time">{{cell.createTime}}</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="nodata" hidden="{{nodataHidden}}">
|
||||
<image src="../../images/order-null.png"/>
|
||||
<view>暂无数据</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="Hidden_box" hidden="{{bodyHidden}}" bindtap="closeserver">
|
||||
<view class="Hidden_box_to" catchtap="inserver">
|
||||
<view class="close" bindtap="closeserver"><image src="../../images/close.png" /></view>
|
||||
|
||||
<view class="title">视频详情</view>
|
||||
<view class="body">
|
||||
<view class="title">{{title}}</view>
|
||||
<video id="myVideo" wx:if='{{video!=""}}' src="{{video}}" autoplay enable-danmu danmu-btn controls></video>
|
||||
<template is="wxParse" data="{{wxParseData:body.nodes}}"/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<loading hidden="{{loadingHidden}}">
|
||||
加载中...
|
||||
</loading>
|
||||
57
pages/articles/index.wxss
Normal file
57
pages/articles/index.wxss
Normal file
@@ -0,0 +1,57 @@
|
||||
page{
|
||||
background: #ccc;
|
||||
}
|
||||
.container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
font-size: 14px;
|
||||
color: #000;
|
||||
}
|
||||
.text{
|
||||
margin-top: 0;
|
||||
line-height: 2.5em;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
background-color: #fff;
|
||||
border-bottom:1px solid #f1f1f1;
|
||||
}
|
||||
.text .line_flag{
|
||||
margin-top: 0em;
|
||||
margin-left: 5px;
|
||||
margin-right: 0.5em;
|
||||
width:0.5em;
|
||||
height: 1.5em;
|
||||
line-height: 1.5em;
|
||||
background-color: #f0514d;
|
||||
border-radius:0.2em;
|
||||
}
|
||||
|
||||
.news-box{width:100%; padding:0;padding-top: 0.4em;padding-left:0.8em;box-sizing: border-box;}
|
||||
.news-item{position: relative; float:left; width:100%; margin:0; padding:0.8em; padding-top: 0; padding-left:0; box-sizing: border-box; text-align: left;}
|
||||
.news-item-to{ display: flex; flex-direction: row; position: relative; float:none; width:100%; margin:0; padding:0.8em; box-sizing: border-box; text-align: left; background-color: #fff; border-radius:0.5em;overflow: hidden;}
|
||||
.news-item .title_time{display: flex; flex-direction:column;flex-grow: 1; background-color:#fff; line-height:1.2em;padding-left:0.8em; box-sizing: border-box;
|
||||
overflow: hidden;}
|
||||
.news-item .title_time .title{height:4em;}
|
||||
.news-item .title_time .time{color:#848484; font-size: 0.85em;}
|
||||
.news-item .pic{width: 10em;padding: 0; box-sizing: border-box;}
|
||||
.news-item .pic image{width:100%;height:5em; border-radius:0.5em;}
|
||||
|
||||
.Hidden_box{ position: fixed;display: flex;align-items: center; justify-content: center; top:0; left:0; width:100%;height:100vh; background:rgba(0, 0, 0, 0.5);}
|
||||
.Hidden_box_to{position: relative; padding: 8px; width:95%;height:auto; background-color: #fff; box-sizing: border-box; border-radius:0.5em;}
|
||||
.Hidden_box_to.addcart_box{ position: absolute; bottom:0; width:100%;border-radius:0.5em 0.5em 0 0;}
|
||||
.Hidden_box_to .close{position: absolute; right:0.5em; 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;}
|
||||
.Hidden_box_to .close image{width:100%;height:100%;}
|
||||
.Hidden_box_to .title{ width:100%;height:2.5em;line-height: 2.5em; font-weight: 800; border-bottom:1px solid #f1f1f1;}
|
||||
.Hidden_box_to .body{line-height:1.5em; color:#939393;max-height:80vh; overflow-y: auto;}
|
||||
.Hidden_box_to .body .title{ width:100%;height:2.5em; line-height: 2.5em; text-align: center;}
|
||||
.Hidden_box_to .body img{max-width:100%;}
|
||||
.Hidden_box_to .body video{width:100%;height:15em;}
|
||||
.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