目前直接展現的都是詳情頁面,如今須要完成經過詳情能夠直接跳轉到首頁,經過首頁點擊某個視頻,能夠跳轉到某個視頻詳情中。源碼github.com/limingios/w… 中No.15html
經過block 索引的方式找到點擊的對應視頻列表中的其中一個傳遞給詳情頁面ios
const app = getApp()
Page({
data: {
// 用於分頁的屬性
totalPage: 1,
page: 1,
videoList: [],
screenWidth: 350,
serverUrl: "",
searchValue:""
},
onLoad: function (params) {
var me = this;
var screenWidth = wx.getSystemInfoSync().screenWidth;
me.setData({
screenWidth: screenWidth,
});
var searchValue = params.searchValue;
var isSaveRecord = params.isSaveRecord;
if (isSaveRecord == null || isSaveRecord == "" || isSaveRecord == undefined){
isSaveRecord = 0;
}
me.setData({
searchValue: searchValue,
});
// 獲取當前的分頁數
var page = me.data.page;
me.getAllVideosList(page, isSaveRecord);
},
getAllVideosList: function (page, isSaveRecord){
var me = this;
var serverUrl = app.serverUrl;
wx.showLoading({
title: '請等待,加載中...',
});
wx.request({
url: serverUrl + '/video/showAll?page=' + page + "&isSaveRecord =" + isSaveRecord,
method: "POST",
data:{
videoDesc: me.data.searchValue
},
success: function (res) {
wx.hideLoading();
wx.hideNavigationBarLoading();
wx.stopPullDownRefresh();
console.log(res.data);
// 判斷當前頁page是不是第一頁,若是是第一頁,那麼設置videoList爲空
if (page === 1) {
me.setData({
videoList: []
});
}
var videoList = res.data.data.rows;
var newVideoList = me.data.videoList;
me.setData({
videoList: newVideoList.concat(videoList),
page: page,
totalPage: res.data.data.total,
serverUrl: serverUrl
});
}
})
},
onPullDownRefresh: function (params) {
var me = this;
wx.showNavigationBarLoading();
me.getAllVideosList(1,0);
},
onReachBottom: function (params){
var me = this;
var currentPage = me.data.page;
var totalPage = me.data.totalPage;
//判斷當前頁數和總頁數是否相等,若是相同已經無需請求
if (currentPage == totalPage){
wx.showToast({
title: '已經沒有視頻啦~',
icon:"none"
})
return;
}
var page = currentPage+1;
me.getAllVideosList(page,0);
},
showVideoInfo:function(e){
var me = this;
var videoList = me.data.videoList;
var arrIndex = e.target.dataset.arrindex;
var videoInfo = JSON.stringify(videoList[arrIndex]);
wx.redirectTo({
url: '../videoInfo/videoInfo?videoInfo=' + videoInfo,
})
}
})
複製代碼
var videoUtils = require('../../utils/videoUtils.js')
const app = getApp()
Page({
data: {
cover:'cover',
videoContext:"",
videoInfo:{},
videId:'',
src:''
},
showSearch:function(){
wx.navigateTo({
url: '../videoSearch/videoSearch',
})
},
onLoad:function(params){
var me = this;
me.videoContext = wx.createVideoContext('myVideo', me);
var videoInfo = JSON.parse(params.videoInfo);
me.setData({
videId: videoInfo.id,
src: app.serverUrl + videoInfo.videoPath,
videoInfo: videoInfo
})
},
showIndex:function(){
wx.redirectTo({
url: '../index/index',
})
},
onShow:function(){
var me = this;
me.videoContext.play();
},
onHide:function(){
var me = this;
me.videoContext.pause();
},
upload:function(){
videoUtils.uploadVideo();
}
})
複製代碼
PS: 頁面的跳轉傳值在html和jsp開發中也比較廣泛,千萬不要有老鐵經過緩存的方式傳值,能夠是能夠可是不清晰了。git