123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- // pages/playShow/playShow.js
- const app = getApp()
- const util = require("../../utils/util")
- const urlDef = require("../../utils/urls")
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- id: null,
- item: null,
- creator: null
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({ id: options.vid })
- this.loadInfo()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- return {
- title: '视频秀',
- path: '/pages/playShow/playShow?vid=' + this.data.id,
- image: this.data.item.imgUrl
- }
- },
- loadInfo: function () {
- const urls = urlDef.urls;
- let stu = wx.getStorageSync('student');
- this.setData({ curStu: stu })
- util.apiPost(urls.person_video_list + '&q.videoId=' + this.data.id).then((rs) => {
- if (rs && rs.length > 0) {
- let o = rs[0]
- o.viewsCount = this.formatCount(o.viewsCount)
- this.setData({ item: o })
- util.apiPost(urls.video_loadInfo + this.data.id).then((rs) => {
- o.imgUrl = rs.img
- o.playUrl = rs.url
- this.setData({ item: o })
- })
- let goodEntity = { videoId: this.data.id, personId: stu.studentId, personType: 1 };
- util.apiPost(urls.person_video_view_save, goodEntity, 'application/json').then(rs => {
- }).catch(e => {
- });
- }
- })
- util.apiPost(urls.query_video_creator + '&q.id=' + this.data.id).then((rs) => {
- let u = rs
- if (rs) {
- u.imageUrl = '/images/head.png'
- } else {
- u = {}
- u.imageUrl = urls.oss_file + 'image/' + u.imageUrl
- }
- this.setData({ creator: u })
- })
- },
- doThumbsUp: function () {
- let o = this.data.item
- const urls = urlDef.urls;
- let pid = this.data.curStu.studentId;
- let pt = o.personType;
- let vid = o.videoId;
- let entity = {
- videoId: vid,
- personId: pid,
- personType: pt,
- actionType: 1
- };
- util.apiPost(urls.person_video_view_save, entity, 'application/json').then(rs => {
- o.goodCount += 1
- this.setData({
- 'item': o
- })
- }).catch(e => {
- console.log(e);
- })
- },
- formatCount(n) {
- if (n >= 100000000) {
- return (n / 100000000).toFixed(2) + '亿';
- } else if (n >= 10000) {
- return (n / 10000).toFixed(2) + '万';
- } else if (n >= 1000) {
- return (n / 1000).toFixed(2) + '千';
- }
- return n;
- }
- })
|