洛阳学员端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

224 lines
5.4 KiB

  1. <template>
  2. <view class="pageBgImg">
  3. <view class="videoBox">
  4. <view class="back">
  5. <topNavbar title=""></topNavbar>
  6. </view>
  7. <video :src="vdoDetail.videoUrl" :poster="vdoDetail.videoCover" v-if="vdoDetail.videoUrl"></video>
  8. </view>
  9. <view class="pad">
  10. <view class="card" style="margin: 28rpx 0 24rpx 0;">
  11. <view class="info">
  12. <view class="name">{{vdoDetail.title}}</view>
  13. <view class="date">{{ $u.timeFormat(vdoDetail.createTime, 'yyyy/mm/dd') }}</view>
  14. </view>
  15. </view>
  16. <view class="operate">
  17. <view class="operateWith">
  18. <view class="operateItem" @click="likeFn">
  19. <view class="icon">
  20. <image src="/static/images/index/dianzan_nor.png" mode="" v-if="!operateInfo.upvote"></image>
  21. <image src="/static/images/index/dianzan_cli.png" mode="" v-else></image>
  22. </view>
  23. <view class="txt">点赞</view>
  24. </view>
  25. </view>
  26. <view class="operateWith">
  27. <view class="operateItem" @click="createCollectFn">
  28. <view class="icon">
  29. <image src="/static/images/index/shoucang_nor.png" mode="" v-if="!operateInfo.collect"></image>
  30. <image src="/static/images/index/shoucang_cli.png" mode="" v-else></image>
  31. </view>
  32. <view class="txt">收藏</view>
  33. </view>
  34. </view>
  35. <view class="operateWith">
  36. <!-- #ifdef MP-WEIXIN -->
  37. <view class="operateItem">
  38. <button @click="onShareAppMessage" open-type="share"></button>
  39. <view class="icon">
  40. <image src="/static/images/index/fenxiang_nor.png" mode=""></image>
  41. </view>
  42. <view class="txt" >分享</view>
  43. </view>
  44. <!-- #endif -->
  45. </view>
  46. </view>
  47. <!-- <view class="videolist">
  48. <view class="flex-b">
  49. <view class="h1">相关推荐</view>
  50. <moreRight text="更多"></moreRight>
  51. </view>
  52. <view class="ul">
  53. <view class="li" v-for="(item,index) in 10" :key="index" @click="$goPage('/pages/indexEntry/publicVideo/videoDetail/videoDetail')">
  54. <videoItem></videoItem>
  55. </view>
  56. </view>
  57. </view> -->
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import videoItem from '../comp/videoItem'
  63. import { publicGetvideo, createUpvote, getlikesCollection, createCollect, createRetransmission, deleteUpvote, deleteRetransmission } from '@/config/api.js'
  64. export default {
  65. components: { videoItem },
  66. data() {
  67. return {
  68. operateInfo: {},
  69. id: '',
  70. vdoDetail: {},
  71. params: {}
  72. }
  73. },
  74. onLoad(options) {
  75. this.id = options.id
  76. this.params = {knowledge: this.id, mobile: this.vuex_userInfo.phone}
  77. this.publicGetvideoFn()
  78. },
  79. methods: {
  80. async publicGetvideoFn() {
  81. const {data: res} = await publicGetvideo({id: this.id})
  82. this.vdoDetail = res
  83. this.getlikesCollection()
  84. console.log(res)
  85. },
  86. // 查否点赞收藏
  87. async getlikesCollection() {
  88. const {data: res} = await getlikesCollection(this.params)
  89. this.operateInfo = res
  90. },
  91. // 点赞
  92. async likeFn() {
  93. if(this.operateInfo.upvote) {
  94. this.operateInfo.upvote = 0
  95. await deleteUpvote({upvoteId: this.operateInfo.upvoteId,mobile: this.vuex_userInfo.phone})
  96. }else {
  97. this.operateInfo.upvote = 1
  98. await createUpvote(this.params)
  99. }
  100. this.getlikesCollection()
  101. },
  102. // 收藏
  103. async createCollectFn() {
  104. if(this.operateInfo.collect) {
  105. this.operateInfo.collect = 0
  106. await deleteRetransmission({mobile: this.vuex_userInfo.phone, CollectId: this.operateInfo.collectId})
  107. }else {
  108. this.operateInfo.collect = 1
  109. await createCollect(this.params)
  110. }
  111. this.getlikesCollection()
  112. },
  113. // 转发
  114. async createRetransmissionFn() {
  115. const {data: res} = await createRetransmission(this.params)
  116. this.getlikesCollection()
  117. },
  118. onShareAppMessage(res) {
  119. this.createRetransmissionFn()
  120. if (res.from === 'button') {// 来自页面内分享按钮
  121. console.log(res.target)
  122. }
  123. return {
  124. title: this.vdoDetail.title,
  125. path: '/pages/indexEntry/publicVideo/videoDetail/videoDetail?id='+ this.id
  126. }
  127. }
  128. }
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. .h1 {
  133. line-height: 100rpx;
  134. }
  135. .info {
  136. padding: 28rpx;
  137. .name {
  138. font-size: 34rpx;
  139. color: #363A44;
  140. font-weight: 500;
  141. }
  142. .date {
  143. font-size: 28rpx;
  144. color: #686B73;
  145. margin-top: 4rpx;
  146. }
  147. }
  148. .operate {
  149. display: flex;
  150. // justify-content: space-between;
  151. .operateWith {
  152. flex: 1;
  153. }
  154. .operateItem {
  155. width: 188rpx;
  156. height: 132rpx;
  157. margin: 0 auto;
  158. background: #FFFFFF;
  159. border-radius: 16rpx;
  160. display: flex;
  161. flex-direction: column;
  162. align-items: center;
  163. justify-content: center;
  164. position: relative;
  165. button {
  166. display: block;
  167. width: 100%;
  168. height: 100%;
  169. position: absolute;
  170. left: 0;
  171. right: 0;
  172. opacity: 0;
  173. }
  174. .icon {
  175. width: 48rpx;
  176. height: 48rpx;
  177. }
  178. .txt {
  179. font-size: 24rpx;
  180. color: #333;
  181. font-weight: 500;
  182. }
  183. }
  184. }
  185. .videoBox {
  186. width: 100%;
  187. height: 492rpx;
  188. position: relative;
  189. .back {
  190. position: absolute;
  191. left: 0;
  192. top: 0;
  193. }
  194. video {
  195. width: 100%;
  196. height: 100%;
  197. display: block;
  198. }
  199. }
  200. .ul {
  201. width: 100%;
  202. display: flex;
  203. justify-content: space-between;
  204. flex-wrap: wrap;
  205. .li {
  206. width: 100%;
  207. width: 48%;
  208. height: 260rpx;
  209. background: #FFFFFF;
  210. box-shadow: 0px 8rpx 20rpx 0px rgba(0,0,0,0.04), 2rpx 2rpx 8rpx 0px rgba(0,0,0,0.06);
  211. border-radius: 16rpx;
  212. margin-bottom: 24rpx;
  213. padding: 16rpx;
  214. }
  215. }
  216. </style>