「小程序JAVA實(shí)戰(zhàn)」小程序查看視頻發(fā)布者信息(64)

當(dāng)我們點(diǎn)擊右下角白色的小人,查看的是當(dāng)前登錄者的信息,如果我們點(diǎn)擊右上角視頻發(fā)布者,應(yīng)該可以跳轉(zhuǎn)到視頻發(fā)布者的信息詳情上,查看視頻發(fā)布者的信息。其實(shí)也沒必要登錄者和視頻發(fā)布者頁(yè)面不同,應(yīng)該在同一個(gè)頁(yè)面,如果來(lái)做呢。開始行動(dòng)把。源碼:https://github.com/limingios/wxProgram.git?中No.15

創(chuàng)新互聯(lián)建站致力于互聯(lián)網(wǎng)網(wǎng)站建設(shè)與網(wǎng)站營(yíng)銷,提供成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)、網(wǎng)站開發(fā)、seo優(yōu)化、網(wǎng)站排名、互聯(lián)網(wǎng)營(yíng)銷、小程序設(shè)計(jì)、公眾號(hào)商城、等建站開發(fā),創(chuàng)新互聯(lián)建站網(wǎng)站建設(shè)策劃專家,為不同類型的客戶提供良好的互聯(lián)網(wǎng)應(yīng)用定制解決方案,幫助客戶在新的全球化互聯(lián)網(wǎng)環(huán)境中保持優(yōu)勢(shì)。

「小程序JAVA實(shí)戰(zhàn)」小程序查看視頻發(fā)布者信息(64)

小程序修改

  • videoInfo.js

var?videoUtils?=?require('../../utils/videoUtils.js')const?app?=?getApp()
Page({??data:?{????cover:'cover',????videoContext:"",????videoInfo:{},????videId:'',????src:'',????userLikeVideo:false,????serverUrl:'',????publisher:[]
??},??

??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);????var?videoWidth?=?videoInfo.videoWidth;????var?videoHeight?=?videoInfo.videoHeight;????var?cover?=?'cover';????if?(videoWidth?>?videoHeight){
??????cover?=?'';
????}
????me.setData({??????videId:?videoInfo.id,??????src:?app.serverUrl?+?videoInfo.videoPath,??????videoInfo:?videoInfo,??????cover:?cover
????})????var?serverUrl?=?app.serverUrl;????var?user?=?app.getGlobalUserInfo();????var?loginUserId?=?"";????if?(user?!=?null?&&?user?!=?undefined?&&?user?!=?'')?{
??????loginUserId?=?user.id;
????}
????wx.request({??????url:?serverUrl?+?'/user/queryPublisher?loginUserId='?+?loginUserId?+?"&videoId="?+?videoInfo.id?+?"&publishUserId="?+?videoInfo.userId,??????method:?'POST',??????success:?function?(res)?{????????console.log(res.data);????????var?publisher?=?res.data.data.publisher;????????var?userLikeVideo?=?res.data.data.userLikeVideo;

????????me.setData({??????????serverUrl:?serverUrl,??????????publisher:?publisher,??????????userLikeVideo:?userLikeVideo
????????});
??????}
????})




??},??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(){?
????var?me?=?this;????var?userInfo?=?app.getGlobalUserInfo();????var?videoInfo?=?JSON.stringify(me.data.videoInfo);????var?realUrl?=?'../videoInfo/videoInfo#videoInfo@'?+?videoInfo;????if?(userInfo.id?==?''?||?userInfo.id?==?undefined)?{
??????wx.navigateTo({????????url:?'../userLogin/userLogin?realUrl='?+?realUrl,
??????})
????}?else?{
??????videoUtils.uploadVideo();
????}


??},??showMine:?function?()?{????var?me?=?this;????var?userInfo?=?app.getGlobalUserInfo();????var?videoInfo?=?JSON.parse????if?(userInfo.id?==?''?||?userInfo.id?==?undefined){
??????wx.navigateTo({????????url:?'../userLogin/userLogin',
??????})
????}else{
??????wx.navigateTo({????????url:?'../mine/mine',
??????})
????}
????
???
??},??likeVideoOrNot:?function?()?{????var?me?=?this;????var?userInfo?=?app.getGlobalUserInfo();????var?videoInfoStr?=?JSON.stringify(me.data.videoInfo);????var?realUrl?=?'../videoInfo/videoInfo#videoInfo@'?+?videoInfoStr;????if?(userInfo.id?==?''?||?userInfo.id?==?undefined)?{
??????wx.navigateTo({????????url:?'../userLogin/userLogin?realUrl='?+?realUrl,
??????})
????}?else?{??????var?videoInfo?=?me.data.videoInfo;??????var?userLikeVideo?=?me.data.userLikeVideo;??????var?url?=?"/video/userLike?userId="?+?userInfo.id?+?"&videoId="?+?videoInfo.id?+?"&videoCreaterId="?+?userLikeVideo.userId;??????if?(userLikeVideo){????????var?url?=?"/video/userUnLike?userId="?+?userInfo.id?+?"&videoId="?+?videoInfo.id?+?"&videoCreaterId="?+?userLikeVideo.userId;
??????}
??????wx.showLoading({????????title:?'....',
??????})
??????wx.request({????????url:?app.serverUrl?+?url,????????method:?"POST",????????header:?{??????????'content-type':?'application/json',?//?默認(rèn)值
??????????'headerUserId':?userInfo.id,??????????'headerUserToken':?userInfo.userToken
????????},????????success:?function?(res)?{
??????????wx.hideLoading();
??????????me.setData({????????????userLikeVideo:?!userLikeVideo,
??????????})
????????}
??????})

????}


??},??showPublisher:function(){????var?me?=?this;????var?userInfo?=?app.getGlobalUserInfo();????var?videoInfo?=?me.data.videoInfo;????var?realUrl?=?'../mine/mine#publisherId@'?+?videoInfo.userId;????if?(userInfo.id?==?''?||?userInfo.id?==?undefined)?{
??????wx.navigateTo({????????url:?'../userLogin/userLogin?realUrl='?+?realUrl,
??????})
????}?else?{
??????wx.navigateTo({????????url:?'../mine/mine?publisherId='?+?videoInfo.userId,
??????})

????}
??}
})

「小程序JAVA實(shí)戰(zhàn)」小程序查看視頻發(fā)布者信息(64)

image.png

  • mine.js

// pages/mine/mine.jsconst app = getApp()var videoUtils = require('../../utils/videoUtils.js')
Page({ ?/**
? * 頁(yè)面的初始數(shù)據(jù)
? */
?data: { ? ?faceImage: "../../resource/images/noneface.png", ? ?nickname: "昵稱", ? ?fansCounts: 0, ? ?followCounts: 0, ? ?receiveLikeCounts: 0,
?}, ?/**
? * 用戶注銷
? */
?logout: function(e) { ? ?var user = app.getGlobalUserInfo();
? ?wx.showLoading({ ? ? ?title: '正在注銷中。。。'
? ?});
? ?wx.request({ ? ? ?url: app.serverUrl + "/logout?userId=" + user.id, ? ? ?method: "POST", ? ? ?header: { ? ? ? ?'content-type': 'application/json' // 默認(rèn)值
? ? ?}, ? ? ?success: function(res) { ? ? ? ?console.log(res.data); ? ? ? ?var status = res.data.status;
? ? ? ?wx.hideLoading(); ? ? ? ?if (status == 200) {
? ? ? ? ?wx.showToast({ ? ? ? ? ? ?title: "用戶注銷成功~!", ? ? ? ? ? ?icon: 'none', ? ? ? ? ? ?duration: 3000
? ? ? ? ?}) ? ? ? ? ?// app.userInfo = null;
? ? ? ? ?wx.removeStorageSync("userInfo");
? ? ? ? ?wx.redirectTo({ ? ? ? ? ? ?url: '../userRegister/userRegister',
? ? ? ? ?})

? ? ? ?} else if (status == 500) {
? ? ? ? ?wx.showToast({ ? ? ? ? ? ?title: res.data.msg, ? ? ? ? ? ?icon: 'none', ? ? ? ? ? ?duration: 3000
? ? ? ? ?})
? ? ? ?}
? ? ?}
? ?})
?}, ?/**
? * 頭像上傳
? */
?uploadFace: function(e) { ? ?// var user = app.userInfo;
? ?var user = app.getGlobalUserInfo(); ? ?var me = this;
? ?wx.chooseImage({ ? ? ?count: 1, // 默認(rèn)9
? ? ?sizeType: ['compressed'], // 可以指定是原圖還是壓縮圖,默認(rèn)二者都有
? ? ?sourceType: ['album', 'camera'], // 可以指定來(lái)源是相冊(cè)還是相機(jī),默認(rèn)二者都有
? ? ?success: function(res) { ? ? ? ?// 返回選定照片的本地文件路徑列表,tempFilePath可以作為img標(biāo)簽的src屬性顯示圖片
? ? ? ?var tempFilePaths = res.tempFilePaths ? ? ? ?if (tempFilePaths.length > 0) { ? ? ? ? ?console.log(tempFilePaths[0]);
? ? ? ? ?wx.uploadFile({ ? ? ? ? ? ?url: app.serverUrl + "/user/uploadFace?userId=" + user.id, //僅為示例,非真實(shí)的接口地址
? ? ? ? ? ?filePath: tempFilePaths[0], ? ? ? ? ? ?name: 'file', ? ? ? ? ? ?success: function(res) { ? ? ? ? ? ? ?var data = JSON.parse(res.data); ? ? ? ? ? ? ?console.log(data);
? ? ? ? ? ? ?wx.hideLoading(); ? ? ? ? ? ? ?if (data.status == 200) {
? ? ? ? ? ? ? ?wx.showToast({ ? ? ? ? ? ? ? ? ?title: "用戶上傳成功~!", ? ? ? ? ? ? ? ? ?icon: 'none', ? ? ? ? ? ? ? ? ?duration: 3000
? ? ? ? ? ? ? ?})
? ? ? ? ? ? ? ?me.setData({ ? ? ? ? ? ? ? ? ?faceUrl: app.serverUrl + data.data
? ? ? ? ? ? ? ?})


? ? ? ? ? ? ?} else if (data.status == 500) {
? ? ? ? ? ? ? ?wx.showToast({ ? ? ? ? ? ? ? ? ?title: data.msg, ? ? ? ? ? ? ? ? ?icon: 'none', ? ? ? ? ? ? ? ? ?duration: 3000
? ? ? ? ? ? ? ?})
? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ? ?})
? ? ? ?}

? ? ?}
? ?})
?}, ?/**
? * 生命周期函數(shù)--監(jiān)聽頁(yè)面加載
? */
?onLoad: function(params) { ? ?var me = this; ? ?var userInfo = app.getGlobalUserInfo(); ? ?var publisherId = params.publisherId; ? ?var userId = userInfo.id; ? ?if (publisherId != null && publisherId != '' && publisherId!=undefined){
? ? ?userId = publisherId;
? ?}

?
? ?wx.showLoading({ ? ? ?title: '正在獲取用戶信息。。。'
? ?});
? ?wx.request({ ? ? ?url: app.serverUrl + "/user/queryByUserId?userId=" + userId, ? ? ?method: "POST", ? ? ?header: { ? ? ? ?'content-type': 'application/json', // 默認(rèn)值
? ? ? ?'headerUserId': userInfo.id, ? ? ? ?'headerUserToken': userInfo.userToken
? ? ?}, ? ? ?success: function(res) { ? ? ? ?console.log(res.data); ? ? ? ?var status = res.data.status; ? ? ? ?if (status == 200) { ? ? ? ? ?var userInfo = res.data.data;
? ? ? ? ?wx.hideLoading(); ? ? ? ? ?var faceImage = me.data.faceUrl; ? ? ? ? ?if (userInfo.faceImage != null && userInfo.faceImage != '' && userInfo.faceImage != undefined) {
? ? ? ? ? ?faceImage = app.serverUrl + userInfo.faceImage;
? ? ? ? ?}
? ? ? ? ?me.setData({ ? ? ? ? ? ?faceImage: faceImage, ? ? ? ? ? ?fansCounts: userInfo.fansCounts, ? ? ? ? ? ?followCounts: userInfo.followCounts, ? ? ? ? ? ?receiveLikeCounts: userInfo.receiveLikeCounts, ? ? ? ? ? ?nickname: userInfo.nickname
? ? ? ? ?})
? ? ? ?} else if (status == 502){
? ? ? ? ?wx.showToast({ ? ? ? ? ? ?title: res.data.msg, ? ? ? ? ? ?duration:3000, ? ? ? ? ? ?icon:'none', ? ? ? ? ? ?complete:function(){
? ? ? ? ? ? ?wx.removeStorageSync("userInfo");

? ? ? ? ? ? ?wx.navigateTo({ ? ? ? ? ? ? ? ?url: '../userLogin/userLogin',
? ? ? ? ? ? ?})
? ? ? ? ? ?}
? ? ? ? ?})
? ? ? ? ?
? ? ? ?}
? ? ?}
? ?})
?}, ?uploadVideo: function(e) {
? ?videoUtils.uploadVideo();
?}, ?/**
? * 生命周期函數(shù)--監(jiān)聽頁(yè)面初次渲染完成
? */
?onReady: function() {

?}, ?/**
? * 生命周期函數(shù)--監(jiān)聽頁(yè)面顯示
? */
?onShow: function() {

?}, ?/**
? * 生命周期函數(shù)--監(jiān)聽頁(yè)面隱藏
? */
?onHide: function() {

?}, ?/**
? * 生命周期函數(shù)--監(jiān)聽頁(yè)面卸載
? */
?onUnload: function() {

?}, ?/**
? * 頁(yè)面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動(dòng)作
? */
?onPullDownRefresh: function() {

?}, ?/**
? * 頁(yè)面上拉觸底事件的處理函數(shù)
? */
?onReachBottom: function() {

?}, ?/**
? * 用戶點(diǎn)擊右上角分享
? */
?onShareAppMessage: function() {

?}
})

「小程序JAVA實(shí)戰(zhàn)」小程序查看視頻發(fā)布者信息(64)

PS:現(xiàn)在發(fā)布人的界面和個(gè)人界面是一樣的,應(yīng)該根據(jù)判斷,發(fā)布人的里面只能有關(guān)注和視頻列表,而個(gè)人界面可以進(jìn)行注銷上傳視頻操作,下次我們繼續(xù)完成。

本文題目:「小程序JAVA實(shí)戰(zhàn)」小程序查看視頻發(fā)布者信息(64)
本文路徑:http://muchs.cn/article34/jpigse.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、企業(yè)網(wǎng)站制作、移動(dòng)網(wǎng)站建設(shè)、虛擬主機(jī)、面包屑導(dǎo)航、網(wǎng)站營(yíng)銷

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營(yíng)