publish.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <div class="page">
  3. <div class="page-content">
  4. <el-form label-position="top" :model="formData" :rules="rules" ref="form">
  5. <el-form-item label="作品描述:" prop="title">
  6. <el-input
  7. type="textarea"
  8. rows="6"
  9. v-model="formData.title"
  10. placeholder="添加作品描述,能让更多的人看到..."
  11. maxlength="300"
  12. show-word-limit
  13. ></el-input>
  14. </el-form-item>
  15. <el-form-item label="上传视频:" prop="ossUrl">
  16. <SimpleOssUpload @success="onVideoUploadSuccess" :limit="1"></SimpleOssUpload>
  17. <el-input v-show="false" v-model="formData.ossUrl"></el-input>
  18. </el-form-item>
  19. <el-form-item label="抖音视频链接:" prop="linked">
  20. <el-input type="textarea" rows="3" v-model="formData.linked" placeholder="请添加抖音视频链接"></el-input>
  21. </el-form-item>
  22. </el-form>
  23. <div class="tip">
  24. <div class="title">温馨提示:</div>
  25. <div class="content">
  26. 视频文件大小不超过8G,时长在30分钟以内;分辨率为720p(720x1280)及以上; 支持常用视频格式,推荐使用mp4、webm
  27. </div>
  28. </div>
  29. <div class="control">
  30. <div class="button publish" @click="onPublish">提交</div>
  31. <div class="button cancel" @click="onBack">取消</div>
  32. </div>
  33. </div>
  34. <!-- 已上传视频列表 -->
  35. <div class="line"></div>
  36. <div class="video-container" v-if="videoList.length > 0">
  37. <div class="title"><span>已上传</span>({{ videoList.length }}个)</div>
  38. <div class="video-list">
  39. <div class="video" v-for="(item, index) in videoList" :key="index" @click="onPlay(item)">
  40. <div class="cover">
  41. <video :src="item.ossUrl"></video>
  42. <div class="name">
  43. <span>{{ item.title }}</span>
  44. </div>
  45. <div class="play"></div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. <!-- 提示框 -->
  51. <GeneralDialog
  52. v-model="promptDialog"
  53. title="提示"
  54. content="抱歉,最多只能上传3个视频!!"
  55. @confirm="promptDialog = false"
  56. ></GeneralDialog>
  57. <!-- 视频播放组件 -->
  58. <SimpleVideoPlayer :videoSrc="videoUrl" :description="description" ref="videoPlayer"></SimpleVideoPlayer>
  59. </div>
  60. </template>
  61. <script>
  62. import { mapGetters } from 'vuex'
  63. export default {
  64. layout: 'app-ross',
  65. data() {
  66. return {
  67. promptDialog: false,
  68. formData: {
  69. authUserId: '',
  70. authId: '',
  71. userName: '',
  72. title: '',
  73. ossName: '',
  74. cover: '',
  75. ossUrl: '',
  76. linked: '',
  77. },
  78. rules: {
  79. ossUrl: [{ required: true, message: '请上传视频', trigger: ['change'] }],
  80. linked: [{ required: true, message: '请填写抖音链接', trigger: ['blur'] }],
  81. },
  82. videoList: [],
  83. videoUrl: '',
  84. description: '',
  85. }
  86. },
  87. computed: {
  88. ...mapGetters(['routePrefix', 'userInfo', 'authUserId']),
  89. },
  90. created() {
  91. this.fetchVideoList()
  92. },
  93. methods: {
  94. // 获取当前机构已发布的视频列表
  95. async fetchVideoList() {
  96. try {
  97. const { clubUserId, mobile } = this.userInfo
  98. const res = await this.$http.api.fetchOwnerVideoList({ mobile: mobile, clubUserId: clubUserId })
  99. this.videoList = res.data
  100. } catch (error) {
  101. console.log(error)
  102. }
  103. },
  104. // 发布视频
  105. async onPublish() {
  106. if (this.videoList.length >= 3) {
  107. this.promptDialog = true
  108. return
  109. }
  110. try {
  111. await this.$refs.form.validate()
  112. this.publishVideoSave()
  113. } catch (error) {
  114. console.log(error)
  115. }
  116. },
  117. // 保存视频
  118. async publishVideoSave() {
  119. try {
  120. const { authId, mobile } = this.userInfo
  121. this.formData.authId = authId
  122. this.formData.userName = mobile
  123. this.formData.authUserId = this.authUserId
  124. await this.$http.api.publishVideo(this.formData)
  125. this.$router.replace(`${this.routePrefix}/activity/challenge/message`)
  126. } catch (error) {
  127. console.log(error)
  128. }
  129. },
  130. // 视频上传成功
  131. onVideoUploadSuccess({ file, fileList }) {
  132. this.formData.ossUrl = file.url
  133. this.formData.ossName = file.uuid
  134. },
  135. // 返回
  136. onBack() {
  137. this.$router.back()
  138. },
  139. // 播放视频
  140. onPlay(row) {
  141. this.videoUrl = row.ossUrl
  142. this.description = row.title
  143. this.$refs.videoPlayer.open()
  144. },
  145. },
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. @media screen and (min-width: 768px) {
  150. ::v-deep {
  151. .el-form-item__label {
  152. font-size: 16px;
  153. }
  154. .el-textarea .el-input__count {
  155. bottom: -32px;
  156. background: transparent;
  157. }
  158. }
  159. ::v-deep {
  160. .el-input.is-active .el-input__inner,
  161. .el-input__inner:focus,
  162. .el-textarea__inner:focus,
  163. .el-upload--picture-card:hover,
  164. .el-upload:focus {
  165. border-color: #f3920d;
  166. }
  167. }
  168. .page {
  169. background: #fff;
  170. padding: 40px 0;
  171. .video-container {
  172. width: 568px;
  173. margin: 0 auto;
  174. margin-top: 100px;
  175. .title {
  176. font-size: 16px;
  177. color: #282828;
  178. margin-bottom: 16px;
  179. }
  180. .video-list {
  181. display: grid;
  182. grid-template-columns: repeat(3, 1fr);
  183. grid-column-gap: 16px;
  184. grid-row-gap: 16px;
  185. .video {
  186. background: #fff;
  187. box-sizing: border-box;
  188. border: 1px solid #efefef;
  189. &:hover {
  190. .info {
  191. .club-name {
  192. color: #f3920d;
  193. }
  194. }
  195. }
  196. &:nth-child(4n) {
  197. margin-right: 0;
  198. }
  199. .cover {
  200. height: 248px;
  201. position: relative;
  202. video {
  203. display: block;
  204. width: 100%;
  205. height: 100%;
  206. background: #fff;
  207. }
  208. .play {
  209. position: absolute;
  210. z-index: 2;
  211. width: 32px;
  212. height: 32px;
  213. background: url(~assets/theme-images/common/pc-icon-play.png) no-repeat center;
  214. background-size: 32px;
  215. left: 50%;
  216. top: 50%;
  217. transform: translate(-50%, -50%);
  218. cursor: pointer;
  219. }
  220. .name {
  221. display: flex;
  222. align-items: flex-end;
  223. width: 100%;
  224. height: 75px;
  225. padding: 17px 16px;
  226. box-sizing: border-box;
  227. position: absolute;
  228. left: 0;
  229. bottom: 0;
  230. background: linear-gradient(180deg, rgba(51, 51, 51, 0) 0%, #333333 100%);
  231. span {
  232. color: #fff;
  233. font-size: 14px;
  234. line-height: 20px;
  235. max-height: 40px;
  236. @include ellipsis(2);
  237. }
  238. }
  239. }
  240. }
  241. }
  242. }
  243. .page-content {
  244. width: 568px;
  245. margin: 0 auto;
  246. .tip {
  247. margin: 60px 0;
  248. font-size: 14px;
  249. line-height: 1.8;
  250. .title {
  251. color: #666666;
  252. margin-bottom: 8px;
  253. }
  254. .content {
  255. color: #f94b4b;
  256. }
  257. }
  258. .control {
  259. .button {
  260. width: 295px;
  261. height: 50px;
  262. margin: 0 auto;
  263. border-radius: 4px;
  264. cursor: pointer;
  265. display: flex;
  266. justify-content: center;
  267. align-items: center;
  268. font-size: 16px;
  269. &.cancel {
  270. border: 1px solid #c2c2c2;
  271. color: #666666;
  272. margin-top: 16px;
  273. }
  274. &.publish {
  275. background: #f3920d;
  276. color: #fff;
  277. }
  278. }
  279. }
  280. }
  281. }
  282. }
  283. @media screen and (max-width: 768px) {
  284. ::v-deep {
  285. .el-form-item__label {
  286. font-size: 3.4vw;
  287. line-height: 4.6vw;
  288. }
  289. }
  290. .page {
  291. background: #fff;
  292. padding: 8vw 0;
  293. .line {
  294. width: 100%;
  295. height: 3.2vw;
  296. background: #f1f1f1;
  297. margin: 7.2vw 0;
  298. }
  299. .video-container {
  300. padding: 0 3.2vw;
  301. .title {
  302. font-size: 3.4vw;
  303. color: #282828;
  304. margin-bottom: 4vw;
  305. span {
  306. font-weight: bold;
  307. }
  308. }
  309. .video-list {
  310. display: grid;
  311. grid-template-columns: repeat(2, 1fr);
  312. grid-column-gap: 2.4vw;
  313. grid-row-gap: 2.4vw;
  314. .video {
  315. background: #fff;
  316. box-sizing: border-box;
  317. border: 0.1vw solid #efefef;
  318. &:hover {
  319. .info {
  320. .club-name {
  321. color: #f3920d;
  322. }
  323. }
  324. }
  325. &:nth-child(4n) {
  326. margin-right: 0;
  327. }
  328. .cover {
  329. height: 64.4vw;
  330. position: relative;
  331. video {
  332. display: block;
  333. width: 100%;
  334. height: 100%;
  335. background: #fff;
  336. }
  337. .play {
  338. position: absolute;
  339. z-index: 2;
  340. width: 7.2vw;
  341. height: 7.2vw;
  342. background: url(~assets/theme-images/common/h5-icon-play.png) no-repeat center;
  343. background-size: 7.2vw;
  344. left: 50%;
  345. top: 50%;
  346. transform: translate(-50%, -50%);
  347. cursor: pointer;
  348. }
  349. .name {
  350. display: flex;
  351. align-items: flex-end;
  352. width: 100%;
  353. height: 16vw;
  354. padding: 4.4vw 3vw;
  355. box-sizing: border-box;
  356. position: absolute;
  357. left: 0;
  358. bottom: 0;
  359. background: linear-gradient(180deg, rgba(51, 51, 51, 0) 0%, #333333 100%);
  360. span {
  361. color: #fff;
  362. font-size: 3vw;
  363. line-height: 3.6vw;
  364. max-height: 7.2vw;
  365. @include ellipsis(2);
  366. }
  367. }
  368. }
  369. }
  370. }
  371. }
  372. .page-content {
  373. padding: 0 3.2vw;
  374. .tip {
  375. margin: 20vw 0 12vw;
  376. font-size: 3vw;
  377. line-height: 1.8;
  378. .title {
  379. color: #666666;
  380. margin-bottom: 8px;
  381. }
  382. .content {
  383. color: #f94b4b;
  384. }
  385. }
  386. .control {
  387. .button {
  388. height: 12vw;
  389. cursor: pointer;
  390. display: flex;
  391. justify-content: center;
  392. align-items: center;
  393. font-size: 3.6vw;
  394. &.cancel {
  395. border: 0.1vw solid #c2c2c2;
  396. color: #666666;
  397. margin-top: 3.2vw;
  398. }
  399. &.publish {
  400. background: #f3920d;
  401. color: #fff;
  402. }
  403. }
  404. }
  405. }
  406. }
  407. }
  408. </style>