index.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  6. <link href="{__FRAME_PATH}css/font-awesome.min.css" rel="stylesheet">
  7. <script type="text/javascript" src="{__ADMIN_PATH}plug/umeditor/third-party/jquery.min.js"></script>
  8. <link rel="stylesheet" href="/static/plug/layui/css/layui.css">
  9. <script src="/static/plug/layui/layui.js"></script>
  10. <script src="{__PLUG_PATH}vue/dist/vue.min.js"></script>
  11. <script src="/static/plug/axios.min.js"></script>
  12. <script src="{__MODULE_PATH}widget/aliyun-oss-sdk-4.4.4.min.js"></script>
  13. <script src="{__MODULE_PATH}widget/cos-js-sdk-v5.min.js"></script>
  14. <script src="{__MODULE_PATH}widget/qiniu-js-sdk-2.5.5.js"></script>
  15. <script src="{__MODULE_PATH}widget/plupload.full.min.js"></script>
  16. <script src="{__MODULE_PATH}widget/videoUpload.js"></script>
  17. <style>
  18. .layui-form-item {
  19. margin-bottom: 0px;
  20. }
  21. .pictrueBox {
  22. display: inline-block !important;
  23. }
  24. .pictrue {
  25. width: 60px;
  26. height: 60px;
  27. border: 1px dotted rgba(0, 0, 0, 0.1);
  28. margin-right: 15px;
  29. display: inline-block;
  30. position: relative;
  31. cursor: pointer;
  32. }
  33. .pictrue img {
  34. width: 100%;
  35. height: 100%;
  36. }
  37. .upLoad {
  38. width: 58px;
  39. height: 58px;
  40. line-height: 58px;
  41. border: 1px dotted rgba(0, 0, 0, 0.1);
  42. border-radius: 4px;
  43. background: rgba(0, 0, 0, 0.02);
  44. cursor: pointer;
  45. display: flex;
  46. justify-content: center;
  47. align-items: center;
  48. }
  49. .rulesBox {
  50. display: flex;
  51. flex-wrap: wrap;
  52. margin-left: 10px;
  53. }
  54. .layui-tab-content {
  55. margin-top: 15px;
  56. }
  57. .ml110 {
  58. margin: 18px 0 4px 110px;
  59. }
  60. .rules {
  61. display: flex;
  62. }
  63. .rules-btn-sm {
  64. height: 30px;
  65. line-height: 30px;
  66. font-size: 12px;
  67. width: 109px;
  68. }
  69. .rules-btn-sm input {
  70. width: 79% !important;
  71. height: 84% !important;
  72. padding: 0 10px;
  73. }
  74. .ml10 {
  75. margin-left: 10px !important;
  76. }
  77. .ml40 {
  78. margin-left: 40px !important;
  79. }
  80. .closes {
  81. position: absolute;
  82. left: 86%;
  83. top: -18%;
  84. }
  85. .red {
  86. color: red;
  87. }
  88. .layui-input-block .layui-video-box {
  89. width: 64%;
  90. height: 180px;
  91. border-radius: 10px;
  92. background-color: #707070;
  93. margin-top: 10px;
  94. position: relative;
  95. overflow: hidden;
  96. }
  97. .layui-input-block .layui-video-box i {
  98. color: #fff;
  99. line-height: 180px;
  100. margin: 0 auto;
  101. width: 50px;
  102. height: 50px;
  103. display: inherit;
  104. font-size: 50px;
  105. }
  106. .layui-input-block .layui-video-box .mark {
  107. position: absolute;
  108. width: 100%;
  109. height: 30px;
  110. top: 0;
  111. background-color: rgba(0, 0, 0, .5);
  112. text-align: center;
  113. }
  114. </style>
  115. </head>
  116. <body>
  117. <div class="layui-fluid">
  118. <div class="layui-row layui-col-space15" id="app" v-cloak="">
  119. <div class="layui-card">
  120. <div class="layui-card-header">视频上传</div>
  121. <div class="layui-card-body" id="app">
  122. <div class="layui-form-item submit">
  123. <div class="layui-input-block" style="margin-left: 0;">
  124. <input type="text" name="link_key" v-model="videoLink"
  125. style="width:50%;display:inline-block;margin-right: 10px;" autocomplete="off"
  126. placeholder="请输入视频链接" class="layui-input">
  127. <button type="button" @click="uploadVideo" class="layui-btn layui-btn-sm layui-btn-normal">
  128. {{videoLink ? '确认添加' : '上传视频'}}
  129. </button>
  130. <input ref="filElem" type="file" style="display: none">
  131. </div>
  132. <div class="layui-input-block video_show" style="margin-top: 20px;margin-left: 0;width: 64%"
  133. v-if="upload.videoIng">
  134. <div class="layui-progress" style="margin-bottom: 10px">
  135. <div class="layui-progress-bar layui-bg-blue" :style="'width:'+progress+'%'"></div>
  136. </div>
  137. <button type="button" class="layui-btn layui-btn-sm layui-btn-danger percent">{{progress}}%
  138. </button>
  139. </div>
  140. <div class="layui-input-block" style="margin-left: 0;">
  141. <div class="layui-video-box" v-if="formData.video">
  142. <video style="width:100%;height: 100%!important;border-radius: 10px;" :src="formData.video"
  143. controls="controls">
  144. 您的浏览器不支持 video 标签。
  145. </video>
  146. <div class="mark" @click="delVideo">
  147. <span class="layui-icon layui-icon-delete"
  148. style="font-size: 30px; color: #1E9FFF;"></span>
  149. </div>
  150. </div>
  151. <div class="layui-video-box" v-else>
  152. <i class="layui-icon layui-icon-play"></i>
  153. </div>
  154. </div>
  155. <div class="layui-input-block" style="margin-left: 0;margin-top: 20px">
  156. <button class="layui-btn layui-btn-lg layui-btn-normal" type="button" @click="handleSubmit()">
  157. 确认
  158. </button>
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. </html>
  166. <script>
  167. var fodder = '{$fodder}';
  168. new Vue({
  169. el: '#app',
  170. data: {
  171. upload: {
  172. videoIng: false,
  173. },
  174. progress: 0,
  175. formData: {video: ''},
  176. videoLink: '',
  177. fodder: fodder,
  178. },
  179. methods: {
  180. requestPost: function (url, data) {
  181. return new Promise(function (resolve, reject) {
  182. axios.post(url, data).then(function (res) {
  183. if (res.status == 200 && res.data.code == 200) {
  184. resolve(res.data)
  185. } else {
  186. reject(res.data);
  187. }
  188. }).catch(function (err) {
  189. reject({msg: err})
  190. });
  191. })
  192. },
  193. U: function (opt) {
  194. var m = opt.m || 'admin', c = opt.c || window.controlle || '', a = opt.a || 'index', q = opt.q || '',
  195. p = opt.p || {};
  196. var params = Object.keys(p).map(function (key) {
  197. return key + '/' + p[key];
  198. }).join('/');
  199. var gets = Object.keys(q).map(function (key) {
  200. return key + '=' + q[key];
  201. }).join('&');
  202. return '/' + m + '/' + c + '/' + a + (params == '' ? '' : '/' + params) + (gets == '' ? '' : '?' + gets);
  203. },
  204. /**
  205. * 提示
  206. * */
  207. showMsg: function (msg, success) {
  208. layui.use(['layer'], function () {
  209. layui.layer.msg(msg, success);
  210. });
  211. },
  212. uploadVideo: function () {
  213. if (this.videoLink) {
  214. this.formData.video = this.videoLink;
  215. } else {
  216. $(this.$refs.filElem).click();
  217. }
  218. },
  219. delVideo: function () {
  220. var that = this;
  221. that.$set(that.formData, 'video', '');
  222. },
  223. handleSubmit: function () {
  224. if (!this.formData.video) {
  225. return this.showMsg('请上传后再确认添加');
  226. }
  227. parent.insertEditorVideo(this.formData.video);
  228. var index = parent.layer.getFrameIndex(window.name);
  229. parent.layer.close(index);
  230. }
  231. },
  232. mounted: function () {
  233. var that = this;
  234. $(that.$refs.filElem).change(function () {
  235. var inputFile = this.files[0];
  236. that.requestPost(that.U({c: "widget.video", a: 'get_signature'})).then(function (res) {
  237. AdminUpload.upload(res.data.uploadType, {
  238. token: res.data.uploadToken || '',
  239. file: inputFile,
  240. accessKeyId: res.data.accessKey || '',
  241. accessKeySecret: res.data.secretKey || '',
  242. bucketName: res.data.storageName || '',
  243. region: res.data.storageRegion || '',
  244. domain: res.data.domain || '',
  245. uploadIng: function (progress) {
  246. that.upload.videoIng = true;
  247. that.progress = progress;
  248. }
  249. }).then(function (res) {
  250. //成功
  251. that.$set(that.formData, 'video', res.url);
  252. that.progress = 0;
  253. that.upload.videoIng = false;
  254. return that.showMsg('上传成功');
  255. }).catch(function (err) {
  256. //失败
  257. console.log(err)
  258. return that.showMsg('上传失败');
  259. });
  260. }).catch(function (res) {
  261. return that.showMsg('获取密钥失败');
  262. });
  263. })
  264. }
  265. })
  266. </script>