|
@@ -1,4 +1,5 @@
|
|
|
const pages = require('../../mixin/pages')
|
|
|
+const { postvideoGood, postVideoComment } = require('./api/index')
|
|
|
|
|
|
Page({
|
|
|
|
|
@@ -11,7 +12,11 @@ Page({
|
|
|
searchForm: {
|
|
|
'video_id': ''
|
|
|
},
|
|
|
- videoConfig: {}
|
|
|
+ videoConfig: {},
|
|
|
+ form: {
|
|
|
+ comment: ''
|
|
|
+ },
|
|
|
+ booLock: false
|
|
|
},
|
|
|
...pages.methods,
|
|
|
/**
|
|
@@ -80,5 +85,89 @@ Page({
|
|
|
},
|
|
|
bindCallBack() {
|
|
|
this.refreshOrderList()
|
|
|
+ },
|
|
|
+ onShareAppMessage(options) {
|
|
|
+ const { video_name, video_cover_url } = this.data.videoConfig
|
|
|
+
|
|
|
+ return {
|
|
|
+ title: video_name,
|
|
|
+ path: 'pages/mediaDetail/mediaDetail?videoConfig=' + JSON.stringify(this.data.videoConfig),
|
|
|
+ imageUrl: video_cover_url
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setComment(event) {
|
|
|
+ const { value } = event.detail
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ 'form.comment': value.trim()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 点赞
|
|
|
+ async addvideoGood() {
|
|
|
+ const { id } = this.data.videoConfig
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ booLock: true
|
|
|
+ })
|
|
|
+
|
|
|
+ try {
|
|
|
+ const { status, msg } = await postvideoGood(id)
|
|
|
+ if (status) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '点赞成功',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: msg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } catch (err) {}
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ booLock: false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 评论
|
|
|
+ async addVideoComment() {
|
|
|
+ const { id } = this.data.videoConfig
|
|
|
+ const { comment } = this.data.form
|
|
|
+
|
|
|
+ if (!comment) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '说点什么吧...',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ booLock: true
|
|
|
+ })
|
|
|
+
|
|
|
+ try {
|
|
|
+ const { status, msg } = await postVideoComment(id, comment)
|
|
|
+ if (status) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '评论成功',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ 'form.comment': ''
|
|
|
+ })
|
|
|
+ this.bindCallBack()
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: msg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } catch (err) {}
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ booLock: false
|
|
|
+ })
|
|
|
}
|
|
|
})
|