123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438 |
- const app = getApp();
- var utils = require("../../../utils/http"),
- page = 1;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl: app.globalData.imgUrl,
- videotext: '',
- videolist: [],
- leftlist: [],
- rightlist: [],
- titlist: [],
- secondtitlist: [],
- nowTagText:'',
- firsTitext:'',
- datashow:false,
- videotop:80,
- top:app.globalData.statusBarHeight,
- hgt:app.globalData.titleBarHeight,
- loginFlag:false,
- mobileflag:false,
- canIUseGetUserProfile: false,
- companyobj:{},
- showAction: false,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- wx.hideHomeButton()
- wx.showLoading({
- title: '加载中...',
- })
- if (wx.getUserProfile) {
- this.setData({
- canIUseGetUserProfile: true
- })
- }
- if(!!options.scene){
- options=unescape(options.scene);
- let arr=options.split('&');
- let obj={};
- for(let i=0;i<arr.length;i++){
- let arr1=arr[i].split('=');
- obj[arr1[0]]=arr1[1];
- }
- this.setData({
- firsTitext:obj.ftext,
- nowTagText:obj.nText
- })
- app.globalData.clientype=obj.ctp;
- app.globalData.shareuserid=obj.uid;
- }else{
- this.setData({
- firsTitext:options.ftext,
- nowTagText:options.nText
- })
- app.globalData.clientype=options.ctp;
- app.globalData.shareuserid=options.uid;
- }
- this.login();
- },
- sharecompany:function (){
- const that=this;
- utils.$post({
- url: app.globalData.webUrl + 'client/index/content_belong_company',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- client_type:app.globalData.clientype,
- uid: app.globalData.shareuserid
- },
- success: function (res) {
- if(res.data.code=='0'){
- app.globalData.companyobj=res.data.data;
- that.setData({
- companyobj:res.data.data
- })
- }
- },
- complete(res) {
- wx.hideLoading()
- }
- })
- },
- login: function () {
- var that = this;
- wx.login({
- success: function (data) {
- if (data.errMsg == 'login:ok') {
- utils.$post({
- url: app.globalData.webUrl + 'api/users/code2session',
- data: {
- code: data.code,
- share: app.globalData.shareuserid,
- client_type:app.globalData.clientype
- },
- success: function (r) {
- if (r.data.code == '0') {
- app.globalData.sharepersonobj = r.data.share?r.data.share:r.data.user;
-
- app.globalData.token = r.data.token;
- that.videotitfun();
- that.setData({
- shareobj:app.globalData.sharepersonobj
- })
- that.sharecompany();
- if (r.data.user != null&&(!!r.data.user.headimgurl&&r.data.user.headimgurl!=""||!!r.data.user.nickname&&r.data.user.nickname!=""&&r.data.user.nickname!='游客')) {
- app.globalData.sharename = !!r.data.share ? r.data.share.nickname : r.data.user.nickname;
- app.globalData.personMsg = r.data.user;
- app.globalData.userflag = false; //有个人信息
- var nickname = r.data.user.nickname;
- var phone = r.data.user.phone;
- app.globalData.phone = false; //没有手机号
- that.setData({
- loginFlag: false,
- employeeflag:(!!r.data.user.binded&&r.data.user.binded.state=='在职')?true:false
- })
- if (r.data.user.phone == '') {
- wx.hideLoading();
- app.globalData.phone = false; //没有手机号
- that.setData({
- phoneFlag: true,
- articlelogin: false
- })
- } else {
- app.globalData.phone = true; //有手机号
- that.setData({
- phoneFlag: false,
- })
- }
- that.videofun();
- } else {
- wx.hideLoading();
- that.setData({
- loginFlag: true,
- articlelogin: false
- })
- }
-
- }
- }
- })
- }
- }
- })
- },
- videofun:function(){
-
- this.videodata();
- },
- videotitfun: function () {
- var that = this;
- wx.showLoading({
- title: '加载中...',
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/video/type',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {},
- success: function (res) {
- wx.hideLoading();
- if (res.data.code == 0) {
- that.setData({
- titlist: res.data.data,
- })
- if(!!that.data.firsTitext){
- that.setData({
- videotop:'168',//顶部padding
- })
- for(let item of res.data.data){
- if(item.id==that.data.firsTitext){
- that.setData({
- secondtitlist:item.sonLabel
- })
- }
- }
- }
- }
- }
- })
- },
- videodata: function () {
- var that = this;
- that.setData({
- datashow: true,
- })
- page=1;
- utils.$post({
- url: app.globalData.webUrl + 'client/video/list',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- type: that.data.firsTitext,
- label: that.data.nowTagText,
- page: 1,
- limit: "10",
- keyword: ''
- },
- success: function (res) {
- if (res.data.code == 0) {
- that.setData({
- videolist: res.data.data,
- leftlist: [],
- rightlist: []
- })
- setTimeout(function () {
- that.videoimgload();
- }, 50)
- }
- setTimeout(function () {
- wx.hideLoading();
- }, 1000)
- }
- })
- },
- videoimgload:function(){
- var that=this;
-
- var leftlist=that.data.leftlist;
- var rightlist=that.data.rightlist;
- var videolist=that.data.videolist;
- if(videolist.length==0){
- return false;
- }
- let vidoemsg=videolist[0];
- if(!vidoemsg){
- that.setData({
- videolist:[],
- })
- return false;
- }
- if(leftlist.length==0){
- leftlist.push(vidoemsg);
- videolist.shift();
- that.setData({
- videolist:videolist,
- leftlist:leftlist,
- rightlist:rightlist
- })
- }else{
- var leftheight,rightheight;
- setTimeout(() => {
- wx.createSelectorQuery().select('.leftvideolistbox').boundingClientRect(function(res){
- leftheight=res.height;
- wx.createSelectorQuery().select('.rightvideolistbox').boundingClientRect(function(rs){
- leftlist=that.data.leftlist;
- rightlist=that.data.rightlist;
- rightheight=rs.height;
- if(leftheight<=rightheight){
- leftlist.push(vidoemsg);
- videolist.shift();
- }else{
- rightlist.push(vidoemsg);
- videolist.shift();
- }
- that.setData({
- videolist:videolist,
- leftlist:leftlist,
- rightlist:rightlist
- })
- }).exec();
- }).exec();
- },100)
- }
- },
- firsttap:function(e){
- var that=this;
- if(e.currentTarget.dataset.fid!=''){
- that.setData({
- firsTitext:e.currentTarget.dataset.fid,
- nowTagText:'',
- videotop:'168',//顶部padding
- secondtitlist:that.data.titlist[e.currentTarget.dataset.idx].sonLabel
- })
- }else{
- that.setData({
- firsTitext:e.currentTarget.dataset.fid,
- nowTagText:'',
- videotop:'80',//顶部padding
- secondtitlist:[]
- })
- }
- this.videodata()
- },
- childtypetap:function(e){
- this.setData({
- nowTagText:e.currentTarget.dataset.sid,
- })
- this.videodata();
- },
- videoTap:function(e){
- wx.navigateTo({
- url: "/share/pages/videoshare/videoshare?vid=" + e.currentTarget.dataset.vid+'&userid='+app.globalData.shareuserid+'&ctp='+app.globalData.clientype
- });
- },
- golastap:function(){
- wx.navigateBack()
- },
- goindextap:function(){
- wx.reLaunch({
- url: '/pages/index/index?state=1',
- })
- },
- toPageNameCard () {
- wx.navigateTo({
- url: '/share/pages/shareCard/shareCard?uid='+ app.globalData.shareuserid + '&empid=' + app.globalData.currentUserId + '&ctp=' + app.globalData.clientype + '&ftype=share',
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- var that = this;
- page=1;
- utils.$post({
- url: app.globalData.webUrl + 'client/video/list',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- type: that.data.firsTitext,
- label: that.data.nowTagText,
- page: 1,
- limit: "10",
- keyword: ''
- },
- success: function (res) {
- wx.stopPullDownRefresh()
- if (res.data.code == 0) {
- that.setData({
- videolist: res.data.data,
- leftlist: [],
- rightlist: []
- })
- setTimeout(function () {
- that.videoimgload();
- }, 50)
- }
- }
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- let that=this;
- page=page*1+1;
- wx.showLoading({
- title: '加载中...',
- })
- utils.$post({
- url: app.globalData.webUrl + 'client/video/list',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data: {
- type: that.data.firsTitext,
- label:that.data.nowTagText,
- page: page,
- limit: "10",
- user_id:app.globalData.personMsg.id
- },
- success: function (res) {
- setTimeout(function(){
- wx.hideLoading()
- },1200)
- if(res.data.code==0){
- var arr=res.data.data;
- var arrflag=false;
- var videolist=that.data.videolist;
- if(videolist.length!=0){
- arrflag=true;
- }
- for(var i=0;i<arr.length;i++){
- videolist.push(arr[i]);
- }
- that.setData({
- videolist:videolist,
- })
- if(!arrflag){
- that.videoimgload();
- }
- }
- }
- })
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- let that=this;
- return {
- title: app.globalData.personMsg.binded.name+"的视频素材",
- imageUrl:app.globalData.imgUrl+"xcx/videoposter.png",
- path: '/share/pages/videolist/videolist?uid='+app.globalData.personMsg.id+'&ftext='+that.data.firsTitext+'&nText='+that.data.nowTagText+'&ctp='+app.globalData.clientype
- }
- }
- })
|