videoCreate.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. <template>
  2. <div class="app-container">
  3. <div class="common-card basic-information-box">
  4. <div class="basic-information-title">基本信息</div>
  5. <div class="basic-information-form">
  6. <a-form
  7. :form="form"
  8. :label-col="{ span: 6 }"
  9. :wrapper-col="{ span: 18 }"
  10. style="width: 515px"
  11. @submit="handleSubmit"
  12. >
  13. <a-form-item label="文章标题">
  14. <a-input
  15. placeholder="请输入文章标题"
  16. :maxLength="100"
  17. v-decorator="[
  18. 'name',
  19. {
  20. rules: [{ required: true, message: '请输入文章标题' }],
  21. },
  22. ]"
  23. />
  24. </a-form-item>
  25. <!-- <a-form-item label="文章描述">
  26. <a-textarea
  27. placeholder="请输入文章描述"
  28. :auto-size="{ minRows: 3, maxRows: 5 }"
  29. :maxLength="100"
  30. v-decorator="[
  31. 'description',
  32. {
  33. rules: [{ message: '请输入文章描述' }],
  34. initialValue: description,
  35. },
  36. ]"
  37. />
  38. </a-form-item> -->
  39. <a-form-item label="文章分类">
  40. <!-- 文章分类父类 -->
  41. <a-select
  42. v-decorator="[
  43. 'articleParentClass',
  44. {
  45. rules: [
  46. {
  47. required: optionType == 'create',
  48. message: '请选择文章分类父类',
  49. },
  50. ],
  51. initialValue: articleParentClass.name,
  52. },
  53. ]"
  54. @change="articleClassParentChange"
  55. >
  56. <a-select-option
  57. v-for="(item, index) in articleParentClassArr"
  58. :key="index"
  59. >{{ articleParentClassArr[index].name }}</a-select-option
  60. >
  61. </a-select>
  62. </a-form-item>
  63. <a-form-item label="文章子类">
  64. <!-- 文章分类子类 -->
  65. <a-select
  66. v-decorator="[
  67. 'articleChildClass',
  68. {
  69. rules: [
  70. {
  71. required: optionType == 'create',
  72. message: '请选择文章分类子类',
  73. },
  74. ],
  75. initialValue: articleChildClass.name,
  76. },
  77. ]"
  78. :disabled="!articleChildClass || !articleChildClass.id"
  79. @change="articleClassChildChange"
  80. >
  81. <a-select-option
  82. v-for="(item, index) in articleChildClassArr"
  83. :key="index"
  84. >{{ articleChildClassArr[index].name }}</a-select-option
  85. >
  86. </a-select>
  87. </a-form-item>
  88. <a-form-item label="工种类别">
  89. <a-select
  90. v-decorator="[
  91. 'engineerType',
  92. {
  93. rules: [{ required: true, message: '请选择工种' }],
  94. initialValue: engineerType.name,
  95. },
  96. ]"
  97. @change="engineerTypeChange"
  98. >
  99. <a-select-option
  100. v-for="(item, index) in engineerTypeArray"
  101. :key="index"
  102. >{{ engineerTypeArray[index].name }}</a-select-option
  103. >
  104. </a-select>
  105. </a-form-item>
  106. <a-form-item label="必学日期:">
  107. <!-- <a-date-picker
  108. :defaultValue="learnDate"
  109. @change="learnDateChoose"
  110. style="width:100%;"
  111. />-->
  112. <a-date-picker
  113. placeholder="请选择日期"
  114. @change="learnDateChoose"
  115. v-decorator="[
  116. 'learnDate',
  117. {
  118. initialValue: learnDate,
  119. },
  120. ]"
  121. style="width: 100%"
  122. />
  123. </a-form-item>
  124. <a-form-item label="推荐:">
  125. <a-radio-group
  126. @change="recommendChange"
  127. v-decorator="[
  128. 'recommand',
  129. {
  130. initialValue: recommand,
  131. },
  132. ]"
  133. >
  134. <a-radio value="true"> 是 </a-radio>
  135. <a-radio value="false"> 否 </a-radio>
  136. </a-radio-group>
  137. </a-form-item>
  138. <a-form-item v-show="false" :wrapper-col="{ span: 20, offset: 10 }">
  139. <a-button id="articleCreateSubmit" type="primary" html-type="submit"
  140. >提交</a-button
  141. >
  142. </a-form-item>
  143. </a-form>
  144. </div>
  145. </div>
  146. <div class="common-card a-card-margin-top">
  147. <div class="information-title">视频内容</div>
  148. <div style="margin-bottom: 10px">上传视频</div>
  149. <!-- 截取视频第一帧用(太模糊了) -->
  150. <!-- <video
  151. v-if="defaultVideoFileList[0]"
  152. :src="defaultVideoFileList[0].url"
  153. width="400"
  154. height="300"
  155. crossOrigin="anonymous"
  156. controls="controls"
  157. id="videofile"
  158. ></video>
  159. <div id="output"></div>-->
  160. <div style="margin-bottom: 10px">
  161. <a-upload
  162. :customRequest="uploadOssVideoFile"
  163. list-type="picture"
  164. :file-list="defaultVideoFileList"
  165. :remove="removeOssVideoFile"
  166. class="upload-list-inline"
  167. >
  168. <a-button>
  169. <a-icon type="upload" />{{ isVideoUpload ? "上传中" : "点击上传" }}
  170. </a-button>
  171. </a-upload>
  172. </div>
  173. <div style="margin-bottom: 10px">上传封面</div>
  174. <div>
  175. <a-upload
  176. :customRequest="uploadOssImageFile"
  177. list-type="picture"
  178. :file-list="defaultImageFileList"
  179. :remove="removeOssImageFile"
  180. class="upload-list-inline"
  181. >
  182. <a-button> <a-icon type="upload" />点击上传 </a-button>
  183. </a-upload>
  184. </div>
  185. <div class="submit-row">
  186. <a-button type="primary" @click="handleSubmitBtnFun">提交</a-button>
  187. <a-button :style="{ marginLeft: '160px' }" @click="preview"
  188. >预览</a-button
  189. >
  190. </div>
  191. </div>
  192. <!-- 预览弹出框 -->
  193. <a-drawer
  194. title
  195. placement="left"
  196. :closable="true"
  197. :visible="previewVisible"
  198. :bodyStyle="bodyStyle"
  199. @close="closepreview"
  200. width="30%"
  201. >
  202. <video
  203. v-if="videoUrl"
  204. :poster="faceUrl"
  205. :src="videoUrl"
  206. controls="controls"
  207. >
  208. 您的浏览器不支持 video 标签。
  209. </video>
  210. <div v-else>暂未上传视频</div>
  211. </a-drawer>
  212. </div>
  213. </template>
  214. <script>
  215. const OSS = require("ali-oss");
  216. import {
  217. formatePathParams,
  218. formateStringDate,
  219. formateDateToString
  220. } from "@/filters";
  221. export default {
  222. name: "videoCreate",
  223. props: {},
  224. components: {},
  225. data() {
  226. return {
  227. previewVisible: false,
  228. videoUrl: "",
  229. faceUrl: "",
  230. content: "",
  231. form: this.$form.createForm(this, { name: "articleCreate" }),
  232. articleParentClassArr: [],
  233. articleChildClassArr: [],
  234. engineerTypeArray: [],
  235. articleParentClass: {},
  236. articleChildClass: {},
  237. engineerType: "",
  238. learnDate: "",
  239. recommand: "false",
  240. optionType: "",
  241. description: "",
  242. bodyStyle: {
  243. img: "{max-width:100%;width: auto;height: auto;}",
  244. video: "{max-width:100%;width: auto;height: auto;}",
  245. color: "red"
  246. },
  247. defaultVideoFileList: [],
  248. isVideoUpload: false,
  249. defaultImageFileList: []
  250. };
  251. },
  252. created() {
  253. this.initDataFun(); //初始化数据
  254. },
  255. mounted() {},
  256. beforeDestroy() {},
  257. watch: {},
  258. computed: {},
  259. methods: {
  260. //初始化数据
  261. async initDataFun() {
  262. await this.getArticleParentClass();
  263. await this.getEngineersWork();
  264. let type = this.$route.query.type;
  265. this.optionType = type ? type : "create";
  266. // 判断是新增文章还是编辑文章
  267. if ("edit" === type) {
  268. await this.getArticleContent();
  269. } else if ("create" === type) {
  270. console.log("---create---");
  271. }
  272. },
  273. // 查询文章分类父级
  274. getArticleParentClass() {
  275. this.$_http
  276. .get(this.$_API.INTERFACE_GET_CATEGORIES)
  277. .then(res => {
  278. this.articleParentClassArr = res.data;
  279. this.loading = false;
  280. })
  281. .catch(() => {
  282. this.loading = false;
  283. });
  284. },
  285. // 查询文章分类子集
  286. getArticleChildClass() {
  287. if (!this.articleParentClass.id) {
  288. return;
  289. }
  290. let pathParamsData = { categoryId: this.articleParentClass.id };
  291. this.$_http
  292. .get(
  293. formatePathParams(
  294. this.$_API.INTERFACE_GET_CATEGORIES_CATEGROYID,
  295. pathParamsData
  296. )
  297. )
  298. .then(res => {
  299. if (res && res.data.length !== 0) {
  300. this.articleChildClassArr = res.data;
  301. this.articleChildClass = this.articleChildClassArr[0];
  302. this.form.setFieldsValue({
  303. articleChildClass: this.articleChildClass.name
  304. });
  305. }
  306. this.loading = false;
  307. })
  308. .catch(() => {
  309. this.loading = false;
  310. });
  311. },
  312. // 查询工作类别
  313. async getEngineersWork() {
  314. await this.$_http
  315. .get(this.$_API.INTERFACE_GET_ENGINEERINGWORK_LIST)
  316. .then(res => {
  317. this.engineerTypeArray = [...res.data];
  318. this.engineerType = this.engineerTypeArray[0];
  319. });
  320. },
  321. // 文章分类父类变化
  322. articleClassParentChange(value) {
  323. this.articleParentClass = this.articleParentClassArr[value];
  324. // 子类选项清空
  325. this.articleChildClassArr = [];
  326. this.form.setFieldsValue({
  327. articleChildClass: ""
  328. });
  329. // 获取子类的值
  330. this.getArticleChildClass();
  331. },
  332. // 文章分类子类变化
  333. articleClassChildChange(value) {
  334. this.articleChildClass = this.articleChildClassArr[value];
  335. },
  336. // 工种变化
  337. engineerTypeChange(index) {
  338. this.engineerType = this.engineerTypeArray[index];
  339. },
  340. // 必学日期选择
  341. learnDateChoose(date, dateString) {
  342. this.learnDate = dateString;
  343. },
  344. // 推荐选择
  345. recommendChange(date) {
  346. this.recommand = date.target.value;
  347. console.log("------" + this.recommand);
  348. },
  349. handleSubmitBtnFun() {
  350. document.getElementById("articleCreateSubmit").click();
  351. },
  352. // 查询文章内容
  353. getArticleContent() {
  354. let pathParamsData = { materialId: this.$route.query.id };
  355. this.$_http
  356. .get(
  357. formatePathParams(this.$_API.INTERFACE_GET_MATERIALS, pathParamsData)
  358. )
  359. .then(res => {
  360. this.initEditArticleForm(res.data);
  361. this.loading = false;
  362. })
  363. .catch(() => {
  364. this.loading = false;
  365. });
  366. },
  367. initEditArticleForm(item) {
  368. // 文章标题
  369. this.form.setFieldsValue({
  370. name: item.name
  371. });
  372. // 文章描述
  373. this.description = item.description ? item.description : "";
  374. // 文章分类-父类:
  375. this.articleParentClass = item.rootMaterialCategory;
  376. this.getArticleChildClass(); // 获取子类列表的值
  377. // 文章分类-子类
  378. this.articleChildClass = item.materialCategory;
  379. // 选中工种
  380. if (item.engineerTypes.length !== 0) {
  381. let engineerId = item.engineerTypes[0];
  382. for (let i = 0; i < this.engineerTypeArray.length; i++) {
  383. let element = this.engineerTypeArray[i];
  384. if (element.id === engineerId) {
  385. this.engineerTypeChange(i);
  386. }
  387. }
  388. }
  389. let learnDate = item.tags.length > 0 ? item.tags[0] : null;
  390. // 必学日期
  391. this.learnDate = learnDate ? formateStringDate(learnDate) : null;
  392. console.log("编辑初始化时间为YYYY-MM-DD", this.learnDate, learnDate);
  393. // 推荐
  394. this.recommand = item.recommand + "";
  395. console.log("--推荐--" + item.recommand);
  396. // 文章内容
  397. this.content = item.contents;
  398. // 附件内容
  399. let contentObj = JSON.parse(this.content);
  400. console.log(contentObj);
  401. if (contentObj.videoUrl) {
  402. let videoFile = {
  403. uid: this.getUid(),
  404. name: this.getUrlName(contentObj.videoUrl),
  405. status: "done",
  406. url: contentObj.videoUrl
  407. };
  408. this.videoUrl = contentObj.videoUrl;
  409. this.defaultVideoFileList.push(videoFile);
  410. }
  411. if (contentObj.faceUrl) {
  412. let faceFile = {
  413. uid: this.getUid(),
  414. name: this.getUrlName(contentObj.faceUrl),
  415. status: "done",
  416. url: contentObj.faceUrl
  417. };
  418. this.faceUrl = contentObj.faceUrl;
  419. this.defaultImageFileList.push(faceFile);
  420. }
  421. },
  422. // 提交表单
  423. handleSubmit(e) {
  424. e.preventDefault();
  425. if ("create" === this.optionType) {
  426. console.log("创建文章");
  427. this.createArtical();
  428. } else if ("edit" === this.optionType) {
  429. console.log("更新文章");
  430. this.updateArtical();
  431. }
  432. },
  433. createArtical() {
  434. this.form.setFieldsValue({
  435. articleParentClass: this.articleParentClass.name
  436. });
  437. this.form.setFieldsValue({
  438. articleChildClass: this.articleChildClass.name
  439. });
  440. this.form.setFieldsValue({
  441. engineerType: this.engineerType.name
  442. });
  443. this.form.setFieldsValue({
  444. recommand: this.recommand
  445. });
  446. this.form.validateFields((err, values) => {
  447. if (!err) {
  448. // 新建文章
  449. let that = this;
  450. that.$confirm({
  451. title: "新建文章",
  452. content: `确认新建文章吗?`,
  453. okText: "确认",
  454. cancelText: "取消",
  455. onOk() {
  456. that.loading = true;
  457. let params = {
  458. categoryid: that.articleChildClass.id,
  459. engineertypeid: that.engineerType.id
  460. };
  461. let tag = formateDateToString(that.learnDate);
  462. let links = [];
  463. let contentObj = {
  464. faceUrl: that.faceUrl,
  465. videoUrl: that.videoUrl
  466. };
  467. let bodyParams = {
  468. name: values.name,
  469. description: values.description,
  470. type: "VIDEO",
  471. contents: JSON.stringify(contentObj),
  472. tags: tag ? [tag] : [],
  473. engineerTypes: [that.engineerType.id],
  474. links: links,
  475. recommand: eval(that.recommand.toLowerCase())
  476. };
  477. that.$_http
  478. .post(that.$_API.INTERFACE_POST_ADMIN_MATERIALS, bodyParams, {
  479. params
  480. })
  481. .then(() => {
  482. that.$message.success("新建文章成功");
  483. });
  484. },
  485. onCancel() {}
  486. });
  487. }
  488. });
  489. },
  490. updateArtical() {
  491. let pathParamsData = { materialId: this.$route.query.id };
  492. this.form.validateFields((err, values) => {
  493. if (!err) {
  494. // 更新文章
  495. let that = this;
  496. that.$confirm({
  497. title: "更新文章",
  498. content: `确认更新文章吗?`,
  499. okText: "确认",
  500. cancelText: "取消",
  501. onOk() {
  502. that.loading = true;
  503. let params = {
  504. categoryid: that.articleChildClass.id,
  505. engineertypeid: that.engineerType.id
  506. };
  507. let tag = formateDateToString(that.learnDate);
  508. let links = [];
  509. let contentObj = {
  510. faceUrl: that.faceUrl,
  511. videoUrl: that.videoUrl
  512. };
  513. let bodyParams = {
  514. id: that.$route.query.id,
  515. name: values.name,
  516. description: values.description,
  517. type: "VIDEO",
  518. contents: JSON.stringify(contentObj),
  519. tags: tag ? [tag] : [],
  520. engineerTypes: [that.engineerType.id],
  521. links: links,
  522. recommand: eval(that.recommand.toLowerCase())
  523. };
  524. console.log(
  525. "保存修改日期格式为YYYYMMDD",
  526. bodyParams.tags,
  527. that.learnDate
  528. );
  529. that.$_http
  530. .put(
  531. formatePathParams(
  532. that.$_API.INTERFACE_PUT_ADMIN_MATERIALS,
  533. pathParamsData
  534. ),
  535. bodyParams,
  536. {
  537. params
  538. }
  539. )
  540. .then(() => {
  541. that.$message.success("更新文章成功");
  542. });
  543. },
  544. onCancel() {}
  545. });
  546. }
  547. });
  548. },
  549. async uploadOssVideoFile(fileData) {
  550. console.log("-------fileData--------");
  551. console.log(fileData);
  552. let that = this;
  553. that.isVideoUpload = true;
  554. let file = fileData.file;
  555. var index = file.name.indexOf("."); //(考虑严谨用lastIndexOf(".")得到)得到"."在第几位
  556. var subfix = file.name.substring(index); //截断"."之前的,得到后缀
  557. if (subfix != ".mp4" && subfix != ".mov") {
  558. console.log(file);
  559. // console.log("--" + JSON.stringify(upFile));
  560. that.isVideoUpload = false;
  561. this.$message.error("只能上传mp4格式的文件");
  562. } else {
  563. let bucket = "jtxt-video-public";
  564. let ossPath = "file/";
  565. let res = await that.$_http.get(
  566. that.$_API.INTERFACE_GET_ASSUME_OSS_WRITER
  567. );
  568. console.log("--oss-writer--" + JSON.stringify(res));
  569. const client = new OSS({
  570. // yourRegion填写Bucket所在地域。以华东1(杭州)为例,Region填写为oss-cn-hangzhou。
  571. region: "oss-cn-beijing",
  572. // 从STS服务获取的临时访问密钥(AccessKey ID和AccessKey Secret)。
  573. accessKeyId: res.data.accessKeyId,
  574. accessKeySecret: res.data.accessKeySecret,
  575. // 从STS服务获取的安全令牌(SecurityToken)。
  576. stsToken: res.data.securityToken,
  577. // 填写Bucket名称。
  578. bucket: bucket
  579. });
  580. let fileName = new Date().getTime() + "_" + file.name;
  581. // 普通上传
  582. // try {
  583. // client.put(ossPath + fileName, file).then(res => {
  584. // console.log(res);
  585. // let upFile = {
  586. // uid: this.getUid(),
  587. // name: fileName,
  588. // status: "done",
  589. // url: res.url
  590. // };
  591. // that.videoUrl = res.url;
  592. // that.defaultVideoFileList.push(upFile);
  593. // // this.findvideocover(file);
  594. // fileData.onSuccess();
  595. // });
  596. // } catch (e) {
  597. // fileData.onError();
  598. // console.error(e);
  599. // }
  600. // 分片上传
  601. console.log("---upload-start--" + new Date().getTime());
  602. let options = {
  603. progress: function(p) {
  604. // 断点记录点。浏览器重启后无法直接继续上传,您需要手动触发上传操作。
  605. console.log("-----" + JSON.stringify(p));
  606. // console.log("-----" + JSON.stringify(checkpoint));
  607. },
  608. patrtSize: 1000 * 1024, // 设置分片大小
  609. timeout: 1000 * 60 * 10 // 超时时间
  610. };
  611. try {
  612. client
  613. .multipartUpload(ossPath + fileName, file, options)
  614. .then(res => {
  615. console.log("---upload-end--" + new Date().getTime());
  616. console.log(res);
  617. let fileUrl = res.res.requestUrls[0].split("?")[0];
  618. console.log(fileUrl);
  619. let upFile = {
  620. uid: this.getUid(),
  621. name: fileName,
  622. status: "done",
  623. url: fileUrl
  624. };
  625. that.videoUrl = fileUrl;
  626. that.defaultVideoFileList.push(upFile);
  627. fileData.onSuccess();
  628. that.isVideoUpload = false;
  629. });
  630. } catch (e) {
  631. fileData.onError();
  632. console.error("-aaaaaaaaaa---");
  633. console.error(e);
  634. that.isVideoUpload = false;
  635. }
  636. }
  637. },
  638. async uploadOssImageFile(fileData) {
  639. let that = this;
  640. let file = fileData.file;
  641. let bucket = "jtxt-video-public";
  642. let ossPath = "file/";
  643. let res = await that.$_http.get(
  644. that.$_API.INTERFACE_GET_ASSUME_OSS_WRITER
  645. );
  646. console.log("--oss-writer--" + JSON.stringify(res));
  647. const client = new OSS({
  648. // yourRegion填写Bucket所在地域。以华东1(杭州)为例,Region填写为oss-cn-hangzhou。
  649. region: "oss-cn-beijing",
  650. // 从STS服务获取的临时访问密钥(AccessKey ID和AccessKey Secret)。
  651. accessKeyId: res.data.accessKeyId,
  652. accessKeySecret: res.data.accessKeySecret,
  653. // 从STS服务获取的安全令牌(SecurityToken)。
  654. stsToken: res.data.securityToken,
  655. // 填写Bucket名称。
  656. bucket: bucket
  657. });
  658. let fileName = new Date().getTime() + "_" + file.name;
  659. console.log("---upload-start--" + new Date().getTime());
  660. let options = {
  661. progress: function(p) {
  662. // 断点记录点。浏览器重启后无法直接继续上传,您需要手动触发上传操作。
  663. console.log("-----" + JSON.stringify(p));
  664. // console.log("-----" + JSON.stringify(checkpoint));
  665. },
  666. patrtSize: 1000 * 1024, // 设置分片大小
  667. timeout: 1000 * 60 * 10 // 超时时间
  668. };
  669. try {
  670. client.multipartUpload(ossPath + fileName, file, options).then(res => {
  671. console.log(res);
  672. let fileUrl = res.res.requestUrls[0].split("?")[0];
  673. console.log(fileUrl);
  674. let upFile = {
  675. uid: this.getUid(),
  676. name: fileName,
  677. status: "done",
  678. url: fileUrl
  679. };
  680. that.faceUrl = fileUrl;
  681. that.defaultImageFileList.push(upFile);
  682. fileData.onSuccess();
  683. });
  684. } catch (e) {
  685. fileData.onError();
  686. console.error(e);
  687. }
  688. },
  689. // 截取路径名字
  690. getUrlName(url) {
  691. let strArr = url.split("/");
  692. console.log(strArr);
  693. let fileName = strArr[strArr.length - 1];
  694. console.log(fileName);
  695. fileName = decodeURIComponent(fileName);
  696. console.log(fileName);
  697. return fileName;
  698. },
  699. getUid() {
  700. let uid = "";
  701. for (let i = 0; i < 5; i++) {
  702. uid += Math.floor(Math.random() * 10);
  703. }
  704. return uid;
  705. },
  706. removeOssVideoFile(file) {
  707. for (let i = 0; i < this.defaultVideoFileList.length; i++) {
  708. let tmpFile = this.defaultVideoFileList[i];
  709. if (tmpFile.uid === file.uid) {
  710. this.defaultVideoFileList.splice(i, 1);
  711. return;
  712. }
  713. }
  714. },
  715. removeOssImageFile(file) {
  716. for (let i = 0; i < this.defaultImageFileList.length; i++) {
  717. let tmpFile = this.defaultImageFileList[i];
  718. if (tmpFile.uid === file.uid) {
  719. this.defaultImageFileList.splice(i, 1);
  720. return;
  721. }
  722. }
  723. },
  724. // // 截取视频第一帧
  725. // findvideocover(file) {
  726. // var fileReader = new FileReader();
  727. // fileReader.readAsDataURL(file);
  728. // var that = this;
  729. // fileReader.onload = function(e) {
  730. // that.videoSrc = e.currentTarget.result;
  731. // console.log(that.videoSrc, 11111);
  732. // const width = 400;
  733. // const height = 300;
  734. // var video = document.getElementById("videofile");
  735. // console.log(video, 66666);
  736. // video.currentTime = 5; //必须设置视频当前时长,要不然会黑屏
  737. // var output = document.getElementById("output");
  738. // // 创建画布准备截图
  739. // var canvas = document.createElement("canvas");
  740. // // 创建图片标签
  741. // var img = document.createElement("img");
  742. // // 获取视频的标签
  743. // video = document.getElementById("videofile");
  744. // video.setAttribute("crossOrigin", "anonymous");
  745. // // 设置画布的宽高
  746. // canvas.width = video.clientWidth;
  747. // canvas.height = video.clientHeight;
  748. // // 图片绘制
  749. // video.onloadeddata = () => {
  750. // canvas
  751. // .getContext("2d")
  752. // .drawImage(video, 0, 0, canvas.width, canvas.height);
  753. // var dataURL = canvas.toDataURL("image/jpeg");
  754. // img.src = dataURL;
  755. // img.width = width;
  756. // img.height = height;
  757. // // 添加到output盒子里面
  758. // output.appendChild(img);
  759. // console.log("--画图--");
  760. // console.log(img);
  761. // };
  762. // };
  763. // },
  764. // 预览
  765. preview() {
  766. this.previewVisible = true;
  767. },
  768. // 关闭预览
  769. closepreview() {
  770. this.previewVisible = false;
  771. }
  772. }
  773. };
  774. </script>
  775. <style lang="less">
  776. .p-content {
  777. max-width: 100%;
  778. img {
  779. max-width: 100%;
  780. width: auto;
  781. height: auto;
  782. }
  783. }
  784. /* tile uploaded pictures */
  785. .upload-list-inline .ant-upload-list-item {
  786. float: left;
  787. width: 200px;
  788. margin-right: 8px;
  789. }
  790. .upload-list-inline .ant-upload-animate-enter {
  791. animation-name: uploadAnimateInlineIn;
  792. }
  793. .upload-list-inline .ant-upload-animate-leave {
  794. animation-name: uploadAnimateInlineOut;
  795. }
  796. </style>
  797. <style lang="less" scoped>
  798. @import "~@/styles/common/variable.less";
  799. .app-container {
  800. .information-title {
  801. font-size: 18px;
  802. font-weight: bold;
  803. color: @mainColorBlack65;
  804. margin-bottom: @paddingMarginVal;
  805. }
  806. .submit-row {
  807. width: 100%;
  808. margin-top: 2 * @paddingMarginVal;
  809. padding: @paddingMarginVal 0 @navTopHight;
  810. display: flex;
  811. justify-content: center;
  812. }
  813. }
  814. </style>