cread.vue 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  1. <template>
  2. <div class="CalligraphyMaster-cread">
  3. <Header />
  4. <div class="bg_main">
  5. <div class="main">
  6. <div class="main-top">
  7. <div class="left" v-if="1 == 2">
  8. <span>画布设置:</span>
  9. <div>
  10. <span>长度</span>
  11. <el-input
  12. :readonly="true"
  13. v-model="form.heightText"
  14. style="width: 60px"
  15. ></el-input>
  16. <div class="add_remove">
  17. <img
  18. @click="addCanvasWH('H')"
  19. src="../../assets/teacherdev/sfds-canvas-add.png"
  20. alt=""
  21. />
  22. <img
  23. @click="removeCanvasWH('H')"
  24. src="../../assets/teacherdev/sfds-canvas-remove.png"
  25. alt=""
  26. />
  27. </div>
  28. </div>
  29. <div>
  30. <img src="../../assets/teacherdev/sfds-canvas-line.png" alt="" />
  31. <span>宽度</span>
  32. <el-input
  33. :readonly="true"
  34. v-model="form.widthText"
  35. style="width: 60px"
  36. ></el-input>
  37. <div class="add_remove">
  38. <img
  39. @click="addCanvasWH('W')"
  40. src="../../assets/teacherdev/sfds-canvas-add.png"
  41. alt=""
  42. />
  43. <img
  44. @click="removeCanvasWH('W')"
  45. src="../../assets/teacherdev/sfds-canvas-remove.png"
  46. alt=""
  47. />
  48. </div>
  49. </div>
  50. <div>
  51. <span>背景颜色</span>
  52. <el-color-picker v-model="form.bg_color"></el-color-picker>
  53. </div>
  54. </div>
  55. <div class="right">
  56. <!-- <div>
  57. <img src="../../assets/teacherdev/word-save.png" alt="" />
  58. 保存
  59. </div>
  60. <div>
  61. <img src="../../assets/teacherdev/sfds-fb.png" alt="" />
  62. 发布
  63. </div> -->
  64. <div @click="downLoad">
  65. <img src="../../assets/teacherdev/word-download.png" alt="" />
  66. 下载
  67. </div>
  68. </div>
  69. </div>
  70. <div
  71. class="operation"
  72. v-if="changeType == 'text' || changeType == 'luminance'"
  73. >
  74. <template v-if="changeType == 'text'">
  75. <div class="text-operation">
  76. <div class="font_sele">
  77. <div
  78. class="font_sele_input"
  79. @click="FontFamilySele = !FontFamilySele"
  80. >
  81. <span>{{ fontForm.fontFamily }}</span>
  82. <img
  83. src="../../assets/teacherdev/font-sele-down.png"
  84. alt=""
  85. />
  86. </div>
  87. <div v-show="FontFamilySele" class="fontFamily_list">
  88. <div class="Boutque_font">
  89. <span class="one">精品字体</span>
  90. <span
  91. v-for="(item, index) in BoutiqueFontList"
  92. :key="index + 'BoutiqueFon'"
  93. >{{ item }}</span
  94. >
  95. <span class="more">更多...</span>
  96. </div>
  97. <div
  98. class="fontFamily_one"
  99. v-for="(item, index) in fontList"
  100. :key="index + 'font'"
  101. :value="item.fontFamily"
  102. >
  103. <div class="use" v-if="item.RecentUse">
  104. <span>最近使用</span>
  105. </div>
  106. <div class="fontFamily">{{ item.fontFamily }}</div>
  107. <div class="content">
  108. <span>{{ item.content }}</span>
  109. <img
  110. v-if="item.collect"
  111. src="../../assets/teacherdev/font-collect-sele.png"
  112. alt=""
  113. />
  114. <img
  115. v-else
  116. src="../../assets/teacherdev/font-collect.png"
  117. alt=""
  118. />
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. <el-select
  124. v-model="fontForm.fontSize"
  125. style="width: 60px; margin-left: 8px"
  126. >
  127. <el-option
  128. v-for="(item, i) in fontSizeList"
  129. :key="i + 'fontsize'"
  130. :value="item.value"
  131. :label="item.name"
  132. >
  133. </el-option>
  134. </el-select>
  135. <el-select
  136. v-model="fontForm.percent"
  137. style="width: 68px; height: 32px; margin-left: 8px"
  138. >
  139. <el-option
  140. v-for="i in 100"
  141. :key="i + 'fontsize'"
  142. :value="i"
  143. :label="i + '%'"
  144. >
  145. </el-option>
  146. </el-select>
  147. <div class="img_dv">
  148. <img src="../../assets/teacherdev/font-add.png" alt="" />
  149. <img src="../../assets/teacherdev/font-remove.png" alt="" />
  150. <img src="../../assets/teacherdev/font-blod.png" alt="" />
  151. <img src="../../assets/teacherdev/font-red.png" alt="" />
  152. </div>
  153. <el-color-picker
  154. v-model="fontForm.fontColor"
  155. style="margin-left: 8px; width: 60px"
  156. ></el-color-picker>
  157. <div class="img_dv" style="margin-left: 8px">
  158. <img src="../../assets/teacherdev/font-left.png" alt="" />
  159. <img src="../../assets/teacherdev/font-center.png" alt="" />
  160. <img src="../../assets/teacherdev/font-right.png" alt="" />
  161. </div>
  162. <div class="img_dv" style="margin-left: 8px">
  163. <img
  164. src="../../assets/teacherdev/font-line-left-right.png"
  165. alt=""
  166. />
  167. <img
  168. src="../../assets/teacherdev/font-line-top-bottom.png"
  169. alt=""
  170. />
  171. </div>
  172. <div class="img_dv" style="margin-left: 8px">
  173. <img src="../../assets/teacherdev/font-italic.png" alt="" />
  174. <img src="../../assets/teacherdev/font-blod2.png" alt="" />
  175. </div>
  176. </div>
  177. </template>
  178. <template v-else-if="changeType == 'luminance'">
  179. <div class="luminance-operation">
  180. <img
  181. :style="{ filter: `brightness(${changeluminanceNumber()})` }"
  182. src="../../assets/teacherdev/sun.png"
  183. alt=""
  184. />
  185. <div class="line-text">
  186. <div class="DragLine">
  187. <DragLine :min="-100" :max="100" v-model="luminanceNumber" />
  188. </div>
  189. <div class="text">
  190. <span>-100</span>
  191. <span>0</span>
  192. <span>+100</span>
  193. </div>
  194. </div>
  195. </div>
  196. </template>
  197. </div>
  198. <div class="canvas" style="margin-top: 16px">
  199. <div
  200. id="imgCanvas"
  201. ref="imgCanvas"
  202. :style="{
  203. width: form.width + 'px',
  204. height: form.height + 'px',
  205. background: form.bg_color,
  206. }"
  207. ></div>
  208. </div>
  209. <div class="bottom" v-if="1 == 2">
  210. <div @click="changeSize">
  211. <img src="../../assets/teacherdev/sfds-tailoring.png" alt="" />
  212. </div>
  213. <!-- <el-upload
  214. :accept="'.png,.jpg'"
  215. class="upload-demo"
  216. :show-file-list="false"
  217. :action="url"
  218. :on-preview="handlePreview"
  219. :on-remove="handleRemove"
  220. :multiple="true"
  221. :on-exceed="handleExceed"
  222. :on-success="handleSuccess"
  223. :file-list="fileList"
  224. :before-remove="beforeRemove"
  225. :limit="1"
  226. :before-upload="handlebeforeUplaod"
  227. >
  228. <div>
  229. <img src="../../assets/teacherdev/sfds-image.png" alt="" />
  230. </div>
  231. </el-upload> -->
  232. <div @click="addText">
  233. <img src="../../assets/teacherdev/sfds-text.png" alt="" />
  234. </div>
  235. <div @click="deleteImage">
  236. <img src="../../assets/teacherdev/sfds-delete.png" alt="" />
  237. </div>
  238. <div @click="changeluminance">
  239. <img src="../../assets/teacherdev/sfds-sun.png" alt="" />
  240. </div>
  241. </div>
  242. </div>
  243. </div>
  244. </div>
  245. </template>
  246. <script>
  247. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  248. //例如:import 《组件名称》from ‘《组件路径》';
  249. import Header from "@/components/Header";
  250. import DragLine from "@/components/DragLine";
  251. import { getToken, removeToken } from "@/utils/auth";
  252. import { WebFileDownload } from "@/api/api";
  253. import "tui-image-editor/dist/tui-image-editor.css";
  254. import "tui-color-picker/dist/tui-color-picker.css";
  255. import ImageEditor from "tui-image-editor";
  256. const locale_zh = {
  257. ZoomIn: "放大",
  258. ZoomOut: "缩小",
  259. Hand: "手掌",
  260. History: "历史",
  261. Resize: "调整宽高",
  262. Crop: "裁剪",
  263. DeleteAll: "全部删除",
  264. Delete: "删除",
  265. Undo: "撤销",
  266. Redo: "反撤销",
  267. Reset: "重置",
  268. Flip: "镜像",
  269. Rotate: "旋转",
  270. Draw: "画笔",
  271. Shape: "形状标注",
  272. Icon: "图标标注",
  273. Text: "文字标注",
  274. Mask: "上传图片",
  275. Filter: "滤镜",
  276. Bold: "加粗",
  277. Italic: "斜体",
  278. Underline: "下划线",
  279. Left: "左对齐",
  280. Center: "居中",
  281. Right: "右对齐",
  282. Color: "颜色",
  283. "Text size": "字体大小",
  284. Custom: "自定义",
  285. Square: "正方形",
  286. Apply: "应用",
  287. Cancel: "取消",
  288. "Flip X": "X 轴",
  289. "Flip Y": "Y 轴",
  290. Range: "区间",
  291. Stroke: "描边",
  292. Fill: "填充",
  293. Circle: "圆",
  294. Triangle: "三角",
  295. Rectangle: "矩形",
  296. Free: "曲线",
  297. Straight: "直线",
  298. Arrow: "箭头",
  299. "Arrow-2": "箭头2",
  300. "Arrow-3": "箭头3",
  301. "Star-1": "星星1",
  302. "Star-2": "星星2",
  303. Polygon: "多边形",
  304. Location: "定位",
  305. Heart: "心形",
  306. Bubble: "气泡",
  307. "Custom icon": "自定义图标",
  308. "Load Mask Image": "加载蒙层图片",
  309. Grayscale: "灰度",
  310. Blur: "模糊",
  311. Sharpen: "锐化",
  312. Emboss: "浮雕",
  313. "Remove White": "除去白色",
  314. Distance: "距离",
  315. Brightness: "亮度",
  316. Noise: "噪音",
  317. "Color Filter": "彩色滤镜",
  318. Sepia: "棕色",
  319. Sepia2: "棕色2",
  320. Invert: "负片",
  321. Pixelate: "像素化",
  322. Threshold: "阈值",
  323. Tint: "色调",
  324. Multiply: "正片叠底",
  325. Blend: "混合色",
  326. Width: "宽度",
  327. Height: "高度",
  328. "Lock Aspect Ratio": "锁定宽高比例",
  329. };
  330. const customTheme = {
  331. "common.bi.image": "", // 左上角logo图片
  332. "common.bisize.width": "0px",
  333. "common.bisize.height": "0px",
  334. "common.backgroundImage": "none",
  335. "common.backgroundColor": "#f3f4f6",
  336. "common.border": "1px solid #333",
  337. // header
  338. "header.backgroundImage": "none",
  339. "header.backgroundColor": "#f3f4f6",
  340. "header.border": "0px",
  341. // load button
  342. "loadButton.backgroundColor": "#fff",
  343. "loadButton.border": "1px solid #ddd",
  344. "loadButton.color": "#222",
  345. "loadButton.fontFamily": "NotoSans, sans-serif",
  346. "loadButton.fontSize": "12px",
  347. "loadButton.display": "none", // 隐藏
  348. // download button
  349. "downloadButton.backgroundColor": "#fdba3b",
  350. "downloadButton.border": "1px solid #fdba3b",
  351. "downloadButton.color": "#fff",
  352. "downloadButton.fontFamily": "NotoSans, sans-serif",
  353. "downloadButton.fontSize": "12px",
  354. "downloadButton.display": "none", // 隐藏
  355. // icons default
  356. "menu.normalIcon.color": "#8a8a8a",
  357. "menu.activeIcon.color": "#555555",
  358. "menu.disabledIcon.color": "#ccc",
  359. "menu.hoverIcon.color": "#e9e9e9",
  360. "submenu.normalIcon.color": "#8a8a8a",
  361. "submenu.activeIcon.color": "#e9e9e9",
  362. "menu.iconSize.width": "24px",
  363. "menu.iconSize.height": "24px",
  364. "submenu.iconSize.width": "32px",
  365. "submenu.iconSize.height": "32px",
  366. // submenu primary color
  367. "submenu.backgroundColor": "#1e1e1e",
  368. "submenu.partition.color": "#858585",
  369. // submenu labels
  370. "submenu.normalLabel.color": "#858585",
  371. "submenu.normalLabel.fontWeight": "lighter",
  372. "submenu.activeLabel.color": "#fff",
  373. "submenu.activeLabel.fontWeight": "lighter",
  374. // checkbox style
  375. "checkbox.border": "1px solid #ccc",
  376. "checkbox.backgroundColor": "#fff",
  377. // rango style
  378. "range.pointer.color": "#fff",
  379. "range.bar.color": "#666",
  380. "range.subbar.color": "#d1d1d1",
  381. "range.disabledPointer.color": "#414141",
  382. "range.disabledBar.color": "#282828",
  383. "range.disabledSubbar.color": "#414141",
  384. "range.value.color": "#fff",
  385. "range.value.fontWeight": "lighter",
  386. "range.value.fontSize": "11px",
  387. "range.value.border": "1px solid #353535",
  388. "range.value.backgroundColor": "#151515",
  389. "range.title.color": "#fff",
  390. "range.title.fontWeight": "lighter",
  391. // colorpicker style
  392. "colorpicker.button.border": "1px solid #1e1e1e",
  393. "colorpicker.title.color": "#fff",
  394. };
  395. export default {
  396. //import引入的组件需要注入到对象中才能使用
  397. components: {
  398. Header,
  399. DragLine,
  400. },
  401. props: {},
  402. data() {
  403. //这里存放数据
  404. return {
  405. form: {
  406. width: 500,
  407. widthText: "500mm",
  408. height: 500,
  409. heightText: "500mm",
  410. bg_color: "#FF3F3F",
  411. },
  412. BoutiqueFontList: [
  413. "水墨字体",
  414. "古风字体",
  415. "中国风字体",
  416. "书协专家字体",
  417. "电影海报字体",
  418. "国潮字体",
  419. ],
  420. fontSizeList: [
  421. {
  422. name: "5号",
  423. value: 5,
  424. },
  425. ],
  426. fontList: [
  427. {
  428. fontFamily: "方正颜真卿楷书",
  429. content: "忽如一夜春风来",
  430. collect: true,
  431. RecentUse: true,
  432. },
  433. {
  434. fontFamily: "方正颜真卿楷书",
  435. content: "忽如一夜春风来",
  436. collect: false,
  437. RecentUse: false,
  438. },
  439. {
  440. fontFamily: "方正颜真卿楷书",
  441. content: "忽如一夜春风来",
  442. collect: true,
  443. RecentUse: true,
  444. },
  445. {
  446. fontFamily: "方正颜真卿楷书",
  447. content: "忽如一夜春风来",
  448. collect: false,
  449. RecentUse: false,
  450. },
  451. {
  452. fontFamily: "方正颜真卿楷书",
  453. content: "忽如一夜春风来",
  454. collect: true,
  455. RecentUse: true,
  456. },
  457. {
  458. fontFamily: "方正颜真卿楷书",
  459. content: "忽如一夜春风来",
  460. collect: false,
  461. RecentUse: false,
  462. },
  463. {
  464. fontFamily: "方正颜真卿楷书",
  465. content: "忽如一夜春风来",
  466. collect: true,
  467. RecentUse: true,
  468. },
  469. {
  470. fontFamily: "方正颜真卿楷书",
  471. content: "忽如一夜春风来",
  472. collect: false,
  473. RecentUse: false,
  474. },
  475. {
  476. fontFamily: "方正颜真卿楷书",
  477. content: "忽如一夜春风来",
  478. collect: true,
  479. RecentUse: true,
  480. },
  481. {
  482. fontFamily: "方正颜真卿楷书",
  483. content: "忽如一夜春风来",
  484. collect: false,
  485. RecentUse: false,
  486. },
  487. ],
  488. luminanceNumber: 0,
  489. changeType: "",
  490. fontForm: {
  491. fontFamily: "方正颜真卿楷书",
  492. fontSize: 5,
  493. percent: 100,
  494. fontColor: "#FFFFFF",
  495. },
  496. FontFamilySele: false,
  497. loading: false,
  498. fileList: [],
  499. imgCtx: null,
  500. TUI_selectedItem: null,
  501. TUI_selectedFont: "",
  502. instance: null,
  503. imgUrl: "../../assets/login/bg-login.png",
  504. };
  505. },
  506. //计算属性 类似于data概念
  507. computed: {
  508. url() {
  509. let userInfor = JSON.parse(getToken());
  510. let UserCode = "",
  511. UserType = "",
  512. SessionID = "";
  513. if (userInfor) {
  514. UserCode = userInfor.user_code;
  515. UserType = userInfor.user_type;
  516. SessionID = userInfor.session_id;
  517. }
  518. return (
  519. process.env.VUE_APP_BASE_API +
  520. `/GCLSFileServer/WebFileUpload?UserCode=${UserCode}&UserType=${UserType}&SessionID=${SessionID}&SecurityLevel=Mid"`
  521. );
  522. },
  523. },
  524. //监控data中数据变化
  525. watch: {},
  526. //方法集合
  527. methods: {
  528. // 增加画布宽或高
  529. addCanvasWH(type) {
  530. if (type == "W") {
  531. if (this.form.width == 500) {
  532. this.$message.warning("已达到上限");
  533. return;
  534. }
  535. this.form.width++;
  536. this.form.widthText = this.form.width + "mm";
  537. } else {
  538. if (this.form.height == 500) {
  539. this.$message.warning("已达到上限");
  540. return;
  541. }
  542. this.form.height++;
  543. this.form.heightText = this.form.height + "mm";
  544. }
  545. },
  546. // 减少画布宽或高
  547. removeCanvasWH(type) {
  548. if (type == "W") {
  549. if (this.form.width == 0) {
  550. return;
  551. }
  552. this.form.width--;
  553. this.form.widthText = this.form.width + "mm";
  554. } else {
  555. if (this.form.height == 0) {
  556. return;
  557. }
  558. this.form.height--;
  559. this.form.heightText = this.form.height + "mm";
  560. }
  561. },
  562. // 添加文字
  563. addText() {
  564. this.changeType = "text";
  565. },
  566. // 修改亮度
  567. changeluminance() {
  568. this.changeType = "luminance";
  569. },
  570. // 计算css所需亮度
  571. changeluminanceNumber() {
  572. if (this.luminanceNumber == 0) {
  573. return 1;
  574. }
  575. if (this.luminanceNumber > 0) {
  576. return 1 + (this.luminanceNumber / 100) * 2;
  577. } else {
  578. return Math.abs(Math.abs(this.luminanceNumber) - 100) / 100;
  579. }
  580. },
  581. // 裁剪
  582. changeSize() {
  583. this.instance.ui._actions.crop.cancel();
  584. },
  585. initCanvasImage() {
  586. this.loading = this.$loading({
  587. lock: true,
  588. text: "Loading",
  589. spinner: "el-icon-loading",
  590. background: "rgba(0, 0, 0, 0.7)",
  591. });
  592. // const objectUrl = window.URL.createObjectURL("");
  593. this.instance = new ImageEditor(document.querySelector("#imgCanvas"), {
  594. includeUI: {
  595. loadImage: {
  596. path: "https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/c1d7a1feb60346449c1a64893888989a~tplv-k3u1fbpfcp-watermark.image", //"https://img2.baidu.com/it/u=1395980100,2999837177&fm=253&fmt=auto&app=120&f=JPEG?w=1200&h=675",
  597. name: "image",
  598. },
  599. menu: [
  600. "mask",
  601. "resize",
  602. "crop",
  603. "rotate",
  604. "draw",
  605. "shape",
  606. "icon",
  607. "text",
  608. // "filter",
  609. ], // 底部菜单按钮列表 隐藏镜像flip和遮罩mask
  610. //initMenu: "none", // 默认打开的菜单项
  611. menuBarPosition: "bottom", // 菜单所在的位置
  612. locale: locale_zh, // 本地化语言为中文
  613. theme: customTheme, // 自定义样式
  614. },
  615. cssMaxWidth: 500, //this.form.width, // canvas 最大宽度
  616. cssMaxHeight: 500, //this.form.height, // canvas 最大高度
  617. usageStatistics: false,
  618. });
  619. $(".tie-mask-apply").css("display", "none");
  620. let fontArray = [
  621. {
  622. value: 'FZLTH',
  623. img: require('../../assets/teacherdev/img1.png')
  624. },
  625. {
  626. value: 'FZJCGFKTK',
  627. img: require('../../assets/teacherdev/img2.png')
  628. },
  629. {
  630. value: 'sourceR',
  631. img: require('../../assets/teacherdev/img1.png')
  632. },
  633. {
  634. value: 'robot',
  635. img: require('../../assets/teacherdev/img2.png')
  636. },
  637. ]
  638. // let fontArray = [
  639. // "FZLTH",
  640. // "Arial",
  641. // "Arial Black",
  642. // "Caveat",
  643. // "Comic Sans MS",
  644. // "Courier New",
  645. // "Georgia1",
  646. // "Impact",
  647. // "Lobster Two",
  648. // "Lucida Console",
  649. // "Luckiest Guy",
  650. // "Open Sans",
  651. // "Pacifico",
  652. // "Palatino Linotype",
  653. // "Press Start 2P",
  654. // "Roboto",
  655. // "Tahoma",
  656. // "Tangerine",
  657. // "Times New Roman",
  658. // "Tourney",
  659. // "Ultra",
  660. // "Verdana",
  661. // "Symbol",
  662. // "Webdings",
  663. // "Wingdings",
  664. // ];
  665. let fontSelectHTML =
  666. '<div class="font-select-box"><input class="font-select-value" value="" /><ul #fontselect class="form-select font-selector font-select-list">';
  667. for (let i = 0; i < fontArray.length; i++) {
  668. fontSelectHTML +=
  669. '<li value="' +
  670. fontArray[i].value +
  671. '" ><img src="'+fontArray[i].img+'" /></li>';
  672. }
  673. fontSelectHTML += "</ul></div>";
  674. let textMenuAlign = document.querySelector(
  675. ".tui-image-editor-menu-text .tie-text-effect-button"
  676. );
  677. textMenuAlign.insertAdjacentHTML("afterbegin", fontSelectHTML);
  678. document
  679. .querySelector(".font-selector li")
  680. .addEventListener("click", (e) =>
  681. console.log($(this))
  682. // this.TUI_updateFontOnText($(".font-selector li:click").val())
  683. );
  684. this.instance.on("objectActivated", (props) => {
  685. this.TUI_selectedItem = props;
  686. this.TUI_updateFontSelected(props);
  687. console.log("TUI_selectedItem", props);
  688. });
  689. this.loading.close();
  690. },
  691. TUI_updateFontOnText(font) {
  692. console.log("TUI_updateFontOnText", font, this.TUI_selectedItem.id);
  693. if (font) {
  694. this.TUI_selectedFont = font;
  695. }
  696. if (font && this.TUI_selectedItem) {
  697. this.instance.changeTextStyle(this.TUI_selectedItem.id, {
  698. fontFamily: font,
  699. });
  700. }
  701. },
  702. TUI_updateFontSelected(layer) {
  703. console.log("TUI_updateFontSelected", layer);
  704. if (layer.fontFamily) {
  705. document.querySelector(".font-selector").value = layer.fontFamily;
  706. this.TUI_selectedFont = layer.fontFamily;
  707. }
  708. },
  709. // 删除上传的图片
  710. deleteImage() {
  711. this.fileList = [];
  712. },
  713. handlebeforeUplaod(file) {
  714. if (file.size > 20 * 1024 * 1024) {
  715. this.$message.warning("上传文件大小不能超过20M");
  716. return false; //必须返回false
  717. }
  718. this.loading = this.$loading({
  719. lock: true,
  720. text: "Loading",
  721. spinner: "el-icon-loading",
  722. background: "rgba(0, 0, 0, 0.7)",
  723. });
  724. },
  725. handleSuccess(response, file, fileList) {
  726. if (response.status == 1) {
  727. this.fileList = response.file_info_list;
  728. this.loading.close();
  729. this.initCanvasImage();
  730. } else if (response.status == -1) {
  731. this.loading.close();
  732. removeToken();
  733. this.$message.warning(response.error);
  734. this.$router.push("/login");
  735. } else {
  736. this.loading.close();
  737. }
  738. },
  739. handleRemove(file, fileList) {},
  740. handlePreview(file) {},
  741. handleExceed(files, fileList) {
  742. this.$message.warning(
  743. `当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
  744. files.length + fileList.length
  745. } 个文件`
  746. );
  747. },
  748. beforeRemove(file, filleList) {},
  749. downLoad() {
  750. let dataURL = this.instance.toDataURL();
  751. var base64 = dataURL.toString(); // imgSrc 就是base64哈
  752. var byteCharacters = atob(
  753. base64.replace(/^data:image\/(png|jpeg|jpg);base64,/, "")
  754. );
  755. var byteNumbers = new Array(byteCharacters.length);
  756. for (var i = 0; i < byteCharacters.length; i++) {
  757. byteNumbers[i] = byteCharacters.charCodeAt(i);
  758. }
  759. var byteArray = new Uint8Array(byteNumbers);
  760. var blob = new Blob([byteArray], {
  761. type: undefined,
  762. });
  763. var aLink = document.createElement("a");
  764. aLink.download = "图片名称.jpg"; //这里写保存时的图片名称
  765. aLink.href = URL.createObjectURL(blob);
  766. aLink.click();
  767. },
  768. },
  769. //生命周期 - 创建完成(可以访问当前this实例)
  770. created() {},
  771. //生命周期 - 挂载完成(可以访问DOM元素)
  772. mounted() {
  773. this.initCanvasImage();
  774. },
  775. //生命周期-创建之前
  776. beforeCreated() {},
  777. //生命周期-挂载之前
  778. beforeMount() {},
  779. //生命周期-更新之前
  780. beforUpdate() {},
  781. //生命周期-更新之后
  782. updated() {},
  783. //生命周期-销毁之前
  784. beforeDestory() {},
  785. //生命周期-销毁完成
  786. destoryed() {},
  787. //如果页面有keep-alive缓存功能,这个函数会触发
  788. activated() {},
  789. };
  790. </script>
  791. <style lang="scss" scoped>
  792. /* @import url(); 引入css类 */
  793. .CalligraphyMaster-cread {
  794. height: 100%;
  795. position: relative;
  796. .bg_main {
  797. background: #f7f7f7;
  798. min-height: 100%;
  799. padding-top: 24px;
  800. padding-bottom: 70px;
  801. .main {
  802. width: 968px;
  803. margin: 0 auto;
  804. padding: 16px;
  805. background: #ffffff;
  806. .main-top {
  807. display: flex;
  808. justify-content: flex-end;
  809. .left {
  810. display: flex;
  811. align-items: center;
  812. font-weight: 400;
  813. font-size: 14px;
  814. color: #000000;
  815. > div {
  816. display: flex;
  817. align-items: center;
  818. margin-right: 8px;
  819. > img {
  820. width: 16px;
  821. height: 16px;
  822. margin-right: 8px;
  823. }
  824. .add_remove {
  825. display: flex;
  826. flex-wrap: wrap;
  827. align-items: center;
  828. width: 10px;
  829. margin-left: 8px;
  830. img {
  831. width: 10px;
  832. height: 10px;
  833. cursor: pointer;
  834. }
  835. > :nth-child(1) {
  836. margin-bottom: 1px;
  837. }
  838. }
  839. }
  840. span {
  841. margin-right: 8px;
  842. }
  843. }
  844. .right {
  845. display: flex;
  846. div {
  847. margin-left: 16px;
  848. width: 96px;
  849. height: 40px;
  850. background: #ffffff;
  851. border: 1px solid rgba(0, 0, 0, 0.08);
  852. border-radius: 4px;
  853. display: flex;
  854. align-items: center;
  855. justify-content: center;
  856. cursor: pointer;
  857. img {
  858. width: 24px;
  859. height: 24px;
  860. margin-right: 8px;
  861. }
  862. }
  863. }
  864. }
  865. .operation {
  866. margin-top: 33px;
  867. }
  868. .text-operation {
  869. height: 48px;
  870. border: 1px solid rgba(0, 0, 0, 0.08);
  871. border-radius: 8px 8px 0px 0px;
  872. border-bottom: none;
  873. display: flex;
  874. align-items: center;
  875. padding: 0 16px;
  876. .font_sele {
  877. position: relative;
  878. .font_sele_input {
  879. width: 193px;
  880. height: 32px;
  881. padding: 0 6px;
  882. background: #ffffff;
  883. border: 1px solid rgba(0, 0, 0, 0.08);
  884. border-radius: 4px;
  885. display: flex;
  886. align-items: center;
  887. justify-content: space-between;
  888. cursor: pointer;
  889. > span {
  890. font-weight: 400;
  891. font-size: 14px;
  892. line-height: 20px;
  893. color: #000000;
  894. }
  895. > img {
  896. width: 16px;
  897. height: 16px;
  898. }
  899. }
  900. .fontFamily_list {
  901. position: absolute;
  902. top: 39px;
  903. left: 0;
  904. width: 468px;
  905. background: #ffffff;
  906. border-width: 0px 1px 1px 1px;
  907. border-style: solid;
  908. border-color: #dbdbdb;
  909. height: 520px;
  910. overflow: auto;
  911. .fontFamily_one {
  912. padding: 12px 24px 16px 32px;
  913. border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  914. position: relative;
  915. .use {
  916. width: 80px;
  917. height: 80px;
  918. background: url("../../assets/teacherdev/font-use.png");
  919. background-size: cover;
  920. position: absolute;
  921. left: -20px;
  922. top: -20px;
  923. -webkit-transform: scale(0.5);
  924. span {
  925. color: #ffffff;
  926. font-weight: 400;
  927. font-size: 16px;
  928. position: absolute;
  929. transform: translateX(-3px) translateY(20px) rotate(-45deg);
  930. }
  931. }
  932. .fontFamily {
  933. font-weight: 400;
  934. font-size: 14px;
  935. line-height: 20px;
  936. color: rgba(0, 0, 0, 0.5);
  937. }
  938. .content {
  939. margin-top: 8px;
  940. display: flex;
  941. justify-content: space-between;
  942. span {
  943. font-weight: 400;
  944. font-size: 32px;
  945. line-height: 150%;
  946. color: #000000;
  947. }
  948. img {
  949. width: 24px;
  950. height: 24px;
  951. cursor: pointer;
  952. }
  953. }
  954. }
  955. }
  956. }
  957. .Boutque_font {
  958. padding: 16px 12px 0 12px;
  959. background: #f0f0f0;
  960. font-weight: 400;
  961. font-size: 14px;
  962. line-height: 20px;
  963. color: rgba(0, 0, 0, 0.6);
  964. cursor: default;
  965. span {
  966. display: inline-block;
  967. margin: 0 12px 12px 12px;
  968. }
  969. .one {
  970. color: #000000;
  971. }
  972. .more {
  973. color: rgba(0, 0, 0, 0.35);
  974. cursor: pointer;
  975. }
  976. }
  977. .img_dv {
  978. img {
  979. width: 26px;
  980. height: 26px;
  981. cursor: pointer;
  982. margin-left: 8px;
  983. }
  984. }
  985. }
  986. .luminance-operation {
  987. width: 440px;
  988. margin: 0 auto;
  989. display: flex;
  990. > img {
  991. width: 24px;
  992. height: 24px;
  993. }
  994. .line-text {
  995. margin-left: 17px;
  996. .DragLine {
  997. margin-top: 7px;
  998. }
  999. .text {
  1000. margin-top: 8px;
  1001. display: flex;
  1002. justify-content: space-between;
  1003. font-weight: 400;
  1004. font-size: 12px;
  1005. line-height: 20px;
  1006. color: #919c9e;
  1007. }
  1008. }
  1009. }
  1010. .canvas {
  1011. height: 600px;
  1012. border: 1px solid rgba(0, 0, 0, 0.1);
  1013. display: flex;
  1014. justify-content: center;
  1015. align-items: center;
  1016. }
  1017. .bottom {
  1018. display: flex;
  1019. justify-content: center;
  1020. div {
  1021. width: 48px;
  1022. height: 40px;
  1023. background: #ffffff;
  1024. border: 1px solid rgba(0, 0, 0, 0.08);
  1025. border-radius: 4px;
  1026. display: flex;
  1027. align-items: center;
  1028. justify-content: center;
  1029. cursor: pointer;
  1030. margin: 0 16px;
  1031. img {
  1032. width: 32px;
  1033. height: 32px;
  1034. }
  1035. }
  1036. }
  1037. }
  1038. }
  1039. }
  1040. </style>
  1041. <style lang="scss">
  1042. .CalligraphyMaster-cread {
  1043. // 图片编辑器操作栏
  1044. //.tui-image-editor-controls {
  1045. // display: none;
  1046. //}
  1047. //.tui-image-editor-container .tui-image-editor-main-container {
  1048. //height: 100%;
  1049. //}
  1050. .main-top {
  1051. .left {
  1052. .el-input__inner {
  1053. padding: 0 5px;
  1054. }
  1055. .el-color-picker__color {
  1056. border: none;
  1057. }
  1058. .el-icon-close:before {
  1059. content: "";
  1060. }
  1061. .el-icon-arrow-down:before {
  1062. content: "";
  1063. }
  1064. .el-color-picker__color-inner {
  1065. position: absolute;
  1066. left: 3px;
  1067. top: 3px;
  1068. right: 0;
  1069. bottom: 0;
  1070. width: 24px;
  1071. height: 24px;
  1072. }
  1073. }
  1074. }
  1075. .text-operation {
  1076. .el-color-picker__trigger {
  1077. width: 60px;
  1078. height: 32px;
  1079. }
  1080. .el-color-picker__empty,
  1081. .el-color-picker__icon {
  1082. left: 72%;
  1083. }
  1084. .el-color-picker__color {
  1085. width: 28px;
  1086. }
  1087. .el-icon-close:before,
  1088. .el-icon-arrow-down:before {
  1089. color: gray;
  1090. }
  1091. .el-color-picker__color-inner {
  1092. position: absolute;
  1093. left: -1px;
  1094. top: -1px;
  1095. right: 0;
  1096. bottom: 0;
  1097. width: 100%;
  1098. height: 100%;
  1099. border: 1px solid rgba(0, 0, 0, 0.08);
  1100. border-radius: 2px;
  1101. }
  1102. .el-input__inner {
  1103. padding: 0 8px;
  1104. }
  1105. .el-input__inner,
  1106. .el-input__suffix {
  1107. height: 32px;
  1108. }
  1109. .el-input__icon {
  1110. line-height: 32px;
  1111. }
  1112. }
  1113. .font-select-box{
  1114. position: relative;
  1115. width: 100px;
  1116. input{
  1117. width: 100%;
  1118. height: 30px;
  1119. border: none;
  1120. }
  1121. }
  1122. .font-select-list{
  1123. display: flex;
  1124. width: 100px;
  1125. flex-flow: wrap;
  1126. li{
  1127. background: #ffffff;
  1128. font-size: 0;
  1129. padding: 10px 5px;
  1130. cursor: pointer;
  1131. img{
  1132. width: 100%;
  1133. }
  1134. }
  1135. }
  1136. }
  1137. </style>