poster.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126
  1. <template>
  2. <view class="page">
  3. <view class="poster" v-if="!show_poster">
  4. <view class="canvas-content" style="text-align:center;position:relative;" :style='{background:(posterObj1.backgroundType=="rgb"? posterObj1.background:"url("+posterObj1.background+") no-repeat;background-size:100% 100%;"),borderRadius:posterObj1.borderRadius,padding:(check_idx==2?"80rpx 68rpx":"40rpx 36rpx 80rpx")}'>
  5. <image v-if='check_idx==1' style='position:absolute;width:103rpx;height:103rpx;bottom: 0;left: 0;' src="https://s.yun-live.com/images/20210201/d88d56843d43b917e2a28550b2a62723.png"></image>
  6. <image v-if='check_idx==1' style='position:absolute;width:56.4rpx;height:56.4rpx;right:0rpx;top:50%;' src="https://s.yun-live.com/images/20210201/247736ffd279276b891ec14db8ed0fd0.png"></image>
  7. <image :style='{width:posterObj1.width,height:posterObj1.height,borderRadius:posterObj1.imageBorderRadius}' :src="posterObj1.image"></image>
  8. <view :style='{fontSize:posterObj1.titleCssFontSize,fontWeight:posterObj1.titleCssFontWeight,color:posterObj1.titleCssColor,lineWeight:posterObj1.titleCssLineHeight
  9. }' class="title">{{posterObj1.title}}</view>
  10. <view class='flex justify-space-between' style='align-items: flex-start;margin-top:18rpx;'>
  11. <view style='text-align:left;margin-top:30rpx;'>
  12. <view :style='{fontSize:posterObj1.title1CssFontSize,fontWeight:posterObj1.title1CssFontWeight,color:posterObj1.title1CssColor,lineWeight:posterObj1.title1CssLineHeight
  13. }' class="title1">{{posterObj1.title1}}</view>
  14. <view :style='{fontSize:posterObj1.title2CssFontSize,color:posterObj1.title2CssColor,lineWeight:posterObj1.title2CssLineHeight
  15. }' class="title2">{{posterObj1.title2}}</view>
  16. </view>
  17. <view>
  18. <image :style='{width:posterObj1.qrcodeWidth,height:posterObj1.qrcodeHeight,}' :src="posterObj1.qrcode"></image>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="footer-btn">
  23. <view class="">
  24. 返回
  25. </view>
  26. <view class="save" @click="toSave">
  27. 保存
  28. </view>
  29. </view>
  30. </view>
  31. <view class="poster-btn">
  32. <view class='diy_image'>
  33. 上传图片
  34. <view>
  35. <u-radio-group @change='imagechange($event)' v-model="imageValue">
  36. <u-radio shape="square" name='自定义图片' label="自定义图片"></u-radio>
  37. <u-radio shape="square" name='选择名片' label="选择名片"></u-radio>
  38. </u-radio-group>
  39. </view>
  40. </view>
  41. <view style='color:red;font-size:24rpx;padding: 20rpx 20rpx 0;'>注:如勾选“选择名片”,其他用户扫描海报二维码后会自动与您交换名片。</view>
  42. <view class='diy_title'>
  43. 编辑内容
  44. <view>
  45. <u--input v-model="value" @focus='titleclick' placeholder="请输入内容" border="bottom" clearable></u--input></view>
  46. </view>
  47. <view class='check_bg'>
  48. <view style='font-size:28rpx'>定义背景</view>
  49. <view :class="{'is-check':check_idx==index}" v-for="(item,index) in footer_arr" :key="index" @click="toChoose(index)">
  50. <image :src="item" mode=""></image>
  51. <view v-if="check_idx==index"></view>
  52. </view>
  53. </view>
  54. </view>
  55. <!-- 生成的图片 -->
  56. <uni-popup type="center" ref="posterImg" :maskClick="false">
  57. <view class="poster-img">
  58. <text @click="closePopup"></text>
  59. <view style='overflow: scroll;width: 670rpx;height: 928rpx;'>
  60. <image :src="path" mode="widthFix" @click="previewImg"></image>
  61. </view>
  62. <!-- #ifdef H5 -->
  63. <view class="">
  64. 长按图片保存到手机
  65. </view>
  66. <!-- #endif -->
  67. <!-- #ifndef H5 -->
  68. <view class="">
  69. 点击图片保存到手机
  70. </view>
  71. <!-- #endif -->
  72. </view>
  73. </uni-popup>
  74. <u-popup :show="titleStatus" :round="10" mode="center" @close="close" @open="open">
  75. <view style='width:600rpx;padding:20rpx;'>
  76. <u--textarea v-model="value" maxlength='300' count placeholder="请输入内容" ></u--textarea>
  77. <view style='margin:20rpx 0rpx 0;'>
  78. <u-button @click='confirm' type="success" text="确定"></u-button>
  79. </view>
  80. </view>
  81. </u-popup>
  82. <u-picker :immediateChange="true" keyName="cardBusiness" confirmText='确定' title="选择名片" @cancel="show1=false"
  83. closeOnClickOverlay @confirm="cardConfirm" :show="show1" :columns="cardList"></u-picker>
  84. <poster :data="canvasData" background-color="#FFF" :width='948' :height='534' @on-success="posterSuccess"
  85. ref="poster" @on-error="posterError"></poster>
  86. <lPainter :board="posterObj" ref="painter"></lPainter>
  87. <canvas id="canvasId"
  88. :type="type"
  89. style="width:0;height:0;"></canvas>
  90. </view>
  91. </template>
  92. <script>
  93. var that;
  94. import uploadImage from '@/components/ossutil/uploadFile.js';
  95. import uniPopup from "@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue";
  96. import lPainter from '@/components/lime-painter/index.vue';
  97. import { Layout } from '@/components/lime-painter/layout';
  98. import Poster from '../../components/zhangyuhao-poster/Poster.vue';
  99. import { toPx, isNumber, getImageInfo, base64ToPath, compareVersion } from '@/components/lime-painter/utils'
  100. import { adaptor, expand } from '@/components/lime-painter/canvas';
  101. export default {
  102. components: {
  103. lPainter,
  104. uniPopup,
  105. Poster,
  106. },
  107. data() {
  108. return {
  109. imageValue:'',
  110. canvasData:{},
  111. value:'云现场 | 2020年 麓客城市 WO-LUNTEER创想礼·麓客共创之夜',
  112. show_poster:false,//显示海报
  113. path: '', //生成的图片地址
  114. image:'',
  115. show1:false,
  116. cardList: [],
  117. list:[],
  118. theight:0,
  119. poster:'',
  120. type:'2d',
  121. height:0,
  122. use2dCanvas:false,
  123. layout1: new Layout(),
  124. titleStatus:false,
  125. posterObj1:{
  126. background:'#fff',
  127. backgroundType:'rgb',
  128. borderRadius: '16rpx',
  129. image:'https://s.yun-live.com/images/20210201/eb694718fa6c7b90d60a2c250847a192.jpg',
  130. width: '606rpx',
  131. height: '341rpx',
  132. imageBorderRadius:'16rpx',
  133. title:'云现场 | 2020年 麓客城市 WO-LUNTEER创想礼·麓客共创之夜',
  134. titleCssFontSize: '32rpx',
  135. titleCssColor: '#1A2033',
  136. titleCssFontWeight: 'bold',
  137. titleCssLineHeight: '45rpx',
  138. title1:'厦门吴彦祖',
  139. title1CssFontSize: '28rpx',
  140. title1CssColor: '#1A2033',
  141. title1CssFontWeight: 'bold',
  142. title1CssLineHeight: '28rpx',
  143. title2:'扫描识别二维码',
  144. title2CssFontSize: '24rpx',
  145. title2CssColor: '#4070FF',
  146. title2CssLineHeight: '24rpx',
  147. qrcode:'../../static/imgs/qrcode.jpg',
  148. qrcodeWidth: '240rpx',
  149. qrcodeHeight: '240rpx',
  150. },
  151. posterObj: {
  152. width: '670rpx',
  153. height: '890rpx',
  154. background: '#fff',
  155. borderRadius: '16rpx',
  156. views: [
  157. // {
  158. // type: 'image',
  159. // src: 'https://s.yun-live.com/images/20210201/9a4e7df322dc5c9f30ea9b126d3269a6.png',
  160. // css: {
  161. // width: '128rpx',
  162. // height: '50rpx',
  163. // left: '542rpx',
  164. // top: '0rpx',
  165. // }
  166. // },
  167. // {
  168. // type: 'image',
  169. // src: 'https://s.yun-live.com/images/20210201/eb694718fa6c7b90d60a2c250847a192.jpg',
  170. // css: {
  171. // left: '32rpx',
  172. // top: '480rpx',
  173. // borderRadius: '50%',
  174. // width: '80rpx',
  175. // height: '80rpx'
  176. // }
  177. // },
  178. {
  179. type: 'text',
  180. text: '云现场 | 2020年 麓客城市 WO-LUNTEER创想礼·麓客共创之夜',
  181. use:'title',
  182. css: {
  183. fontSize: '32rpx',
  184. color: '#1A2033',
  185. fontWeight: 'bold',
  186. lineHeight: '45rpx',
  187. left: '32rpx',
  188. top: '400rpx',
  189. width: '606rpx'
  190. }
  191. },
  192. {
  193. type: 'text',
  194. text: '厦门吴彦祖',
  195. use:'title1',
  196. css: {
  197. fontSize: '28rpx',
  198. fontWeight: 'bold',
  199. color: '#1A2033',
  200. lineHeight: '28rpx',
  201. left: '32rpx',
  202. top: '515rpx'
  203. }
  204. },
  205. {
  206. type: 'text',
  207. text: '扫描识别二维码',
  208. use:'title2',
  209. css: {
  210. fontSize: '24rpx',
  211. color: '#4070FF',
  212. lineHeight: '24rpx',
  213. left: '32rpx',
  214. top: '559rpx'
  215. }
  216. },
  217. {
  218. type: 'image',
  219. src: 'https://s.yun-live.com/images/20210201/eb694718fa6c7b90d60a2c250847a192.jpg',
  220. use:'dt',
  221. css: {
  222. left: '32rpx',
  223. top: '34rpx',
  224. width: '606rpx',
  225. height: '341rpx',
  226. borderRadius: '16rpx'
  227. }
  228. },
  229. {
  230. type: 'qrcode',
  231. text: 'https://www.yun-live.com/',
  232. css: {
  233. left: '445rpx',
  234. top: '500rpx',
  235. width: '200rpx',
  236. height: '200rpx',
  237. }
  238. },
  239. // {
  240. // type: 'text',
  241. // text: '———— 由云现场提供技术支持 ————',
  242. // css: {
  243. // left: '0',
  244. // top: '863rpx',
  245. // width: '100%',
  246. // textAlign: 'center',
  247. // fontSize: '24rpx',
  248. // color: '#989FB3',
  249. // lineHeight: '33rpx'
  250. // }
  251. // }
  252. ]
  253. }, //画板数据
  254. footer_arr: [
  255. 'https://s.yun-live.com/images/20210201/d502979c734077930cee837739ee9285.png',
  256. 'https://s.yun-live.com/images/20210201/0289000561415e1f9f6e542a3553906d.png',
  257. 'https://s.yun-live.com/images/20210201/5d2e237728e1dd8727835ca95084721e.png',
  258. 'https://s.yun-live.com/images/20210201/15075d31c26cc446333d569b0d2346e8.png',
  259. 'https://s.yun-live.com/images/20210201/6e716c556d1a80e90ecb0260e0990add.png'
  260. ], //底部选项
  261. check_idx: 0, //底部选中的下标
  262. dtindex:0,
  263. titleindex:0,
  264. title1index:0,
  265. title2index:0,
  266. }
  267. },
  268. onLoad() {
  269. that = this
  270. },
  271. onShow(){
  272. // #ifdef MP-WEIXIN
  273. const {SDKVersion, version, platform} = uni.getSystemInfoSync()
  274. // ios wx7.0.20 createImage bug
  275. this.use2dCanvas = (this.type === '2d' && compareVersion(SDKVersion, '2.9.2') >= 0) && !(/ios/.test(platform) && /7.0.20/.test(version));
  276. // #endif
  277. this.posterObj1.title1=uni.getStorageSync("userInfo").nickname+'推荐给你'
  278. this.$request.baseRequest('admin.unimall.cardManagementInfo', 'list', {
  279. commonId: uni.getStorageSync("userInfo").id
  280. }, failres => {
  281. uni.hideLoading()
  282. uni.showToast({
  283. icon: "none",
  284. title: failres.errmsg,
  285. duration: 3000
  286. });
  287. }).then(res => {
  288. this.list = res.data.items
  289. this.cardList = [res.data.items]
  290. })
  291. },
  292. watch: {
  293. // check_idx(newVal,oldVal){
  294. // console.log(111,newVal);
  295. // console.log(222,oldVal);
  296. // }
  297. },
  298. methods: {
  299. confirm(e){
  300. this.titleStatus=false
  301. this.posterObj1.title=this.value
  302. },
  303. titleclick(){
  304. this.titleStatus=true
  305. },
  306. posterError(err) {
  307. console.log(err)
  308. uni.hideLoading()
  309. },
  310. posterSuccess(url) {
  311. console.log("hahahah", url)
  312. // 生成成功,会把临时路径在这里返回
  313. this.poster = url;
  314. this.posterObj1.image = url
  315. this.posterObj1.qrcode=this.currectData.qrCodeMyself
  316. console.log(url)
  317. this.show1 = false
  318. // this.show=false
  319. uni.hideLoading()
  320. },
  321. cardConfirm(e) {
  322. console.log(e)
  323. this.currectData = e.value[0]
  324. uni.showLoading({
  325. title: '加载中',
  326. mask: true
  327. })
  328. var data = [{
  329. type: 'image',
  330. path: this.currectData.currentBackground,
  331. use: 'bg',
  332. x: -24,
  333. y: -27,
  334. width: 1000,
  335. height: 600
  336. },
  337. {
  338. type: 'image',
  339. path: this.currectData.headSculpture ? this.currectData.headSculpture :
  340. '../../static/imgs/card/defaulthead.png',
  341. shape: 'circle',
  342. use: 'head',
  343. imageType: this.currectData.headSculpture ? 'wl' : 'bd',
  344. x: 60,
  345. y: 60,
  346. width: 150,
  347. height: 150
  348. },
  349. {
  350. type: 'text',
  351. text: this.currectData.name,
  352. use: 'name',
  353. x: 300,
  354. y: 80,
  355. size: 40,
  356. color: '#000'
  357. },
  358. {
  359. type: 'text',
  360. text: this.currectData.post,
  361. use: 'post',
  362. x: 440,
  363. y: 85,
  364. size: 32,
  365. color: '#666666'
  366. },
  367. {
  368. type: 'text',
  369. text: this.currectData.companyName,
  370. use: 'companyName',
  371. x: 300,
  372. y: 155,
  373. size: 32,
  374. color: '#000'
  375. },
  376. {
  377. type: 'image',
  378. path: '../../static/imgs/card/address1.png',
  379. use: 'address-icon',
  380. x: 300,
  381. y: 220,
  382. width: 30,
  383. height: 40
  384. },
  385. {
  386. type: 'textarea',
  387. text: this.currectData.province + this.currectData.city + this.currectData.area + this
  388. .currectData.detailedAddress,
  389. lineSpace: 1,
  390. width: 640,
  391. use: 'address',
  392. x: 345,
  393. y: 228,
  394. size: 28,
  395. color: '#000'
  396. },
  397. {
  398. type: 'image',
  399. path: '../../static/imgs/card/phone1.png',
  400. use: 'phone-icon',
  401. x: 300,
  402. y: 280,
  403. width: 32,
  404. height: 32
  405. },
  406. {
  407. type: 'text',
  408. text: this.currectData.phone,
  409. use: 'phone',
  410. x: 345,
  411. y: 284,
  412. size: 28,
  413. color: '#000'
  414. },
  415. {
  416. type: 'image',
  417. path: '../../static/imgs/card/remark1.png',
  418. use: 'remark-icon',
  419. x: 300,
  420. y: 340,
  421. width: 26,
  422. height: 32
  423. },
  424. {
  425. type: 'textarea',
  426. text: this.currectData.remark ? this.currectData.remark : '单击添加备注',
  427. use: 'remark',
  428. lineSpace: 2,
  429. width: 200,
  430. x: 345,
  431. y: 345,
  432. size: 26,
  433. color: '#000'
  434. },
  435. {
  436. type: 'image',
  437. path: '../../static/imgs/card/bg3.png',
  438. use: 'bg1',
  439. x: 0,
  440. y: 418,
  441. width: 687,
  442. height: 120
  443. },
  444. {
  445. type: 'image',
  446. path: '../../static/imgs/card/bg4.png',
  447. use: 'bg2',
  448. x: 647,
  449. y: 418,
  450. width: 305,
  451. height: 120
  452. },
  453. {
  454. type: 'image',
  455. path: '../../static/imgs/card/home.png',
  456. use: 'home',
  457. x: 65,
  458. y: 455,
  459. width: 55,
  460. height: 55
  461. },
  462. {
  463. type: 'text',
  464. text: this.currectData.classifyName ? this.currectData.classifyName : '默',
  465. use: 'classify',
  466. x: 245,
  467. y: 460,
  468. size: 54,
  469. color: '#fff'
  470. },
  471. {
  472. type: 'image',
  473. path: '../../static/imgs/card/share.png',
  474. use: 'share',
  475. x: 435,
  476. y: 453,
  477. width: 66,
  478. height: 52
  479. },
  480. ]
  481. console.log(this.currectData.cuttentTemplate, 111111)
  482. for (var i = 0; i < data.length; i++) {
  483. switch (this.currectData.cuttentTemplate) {
  484. case '2':
  485. if (data[i].use === 'name' ||
  486. data[i].use === 'companyName' ||
  487. data[i].use === 'address-icon' ||
  488. data[i].use === 'phone-icon' ||
  489. data[i].use === 'remark-icon') {
  490. data[i].x = 60
  491. }
  492. if (data[i].use === 'post') {
  493. data[i].x = 200
  494. }
  495. if (data[i].use === 'address' ||
  496. data[i].use === 'phone' ||
  497. data[i].use === 'remark') {
  498. data[i].x = 120
  499. }
  500. if (data[i].use == 'head') {
  501. data[i].x = 740
  502. }
  503. break;
  504. case '3':
  505. if (data[i].use === 'name') {
  506. data[i].x = 60
  507. data[i].y = 300
  508. }
  509. if (data[i].use === 'companyName') {
  510. data[i].x = 60
  511. data[i].y = 360
  512. }
  513. if (data[i].use === 'post') {
  514. data[i].x = 200
  515. data[i].y = 306
  516. }
  517. if (data[i].use === 'address-icon' ||
  518. data[i].use === 'phone-icon' ||
  519. data[i].use === 'remark-icon') {
  520. data[i].x = 340
  521. }
  522. if (data[i].use === 'address-icon') {
  523. data[i].y = 300
  524. }
  525. if (data[i].use === 'address') {
  526. data[i].y = 310;
  527. data[i].width = 300
  528. }
  529. if (data[i].use === 'phone-icon') {
  530. data[i].y = 360
  531. }
  532. if (data[i].use === 'phone') {
  533. data[i].y = 366
  534. }
  535. if (data[i].use === 'remark-icon') {
  536. data[i].y = 420
  537. }
  538. if (data[i].use === 'remark') {
  539. data[i].y = 424
  540. }
  541. if (data[i].use === 'address' ||
  542. data[i].use === 'phone' ||
  543. data[i].use === 'remark') {
  544. data[i].x = 380
  545. }
  546. break;
  547. case '4':
  548. if (data[i].use === 'name' ||
  549. data[i].use === 'companyName') {
  550. data[i].x = 60
  551. }
  552. if (data[i].use === 'companyName') {
  553. data[i].y = 180
  554. }
  555. if (data[i].use === 'post') {
  556. data[i].x = 200
  557. }
  558. if (data[i].use == 'head') {
  559. data[i].x = 45
  560. data[i].y = 240
  561. }
  562. if (data[i].use === 'address-icon' ||
  563. data[i].use === 'phone-icon' ||
  564. data[i].use === 'remark-icon') {
  565. data[i].x = 340
  566. }
  567. if (data[i].use === 'address') {
  568. data[i].width = 300
  569. }
  570. if (data[i].use === 'address' ||
  571. data[i].use === 'phone' ||
  572. data[i].use === 'remark') {
  573. data[i].x = 380
  574. }
  575. break;
  576. default:
  577. }
  578. }
  579. this.canvasData = {
  580. clicknum: this.clicknum++,
  581. list: data
  582. }
  583. },
  584. open() {
  585. // console.log('open');
  586. },
  587. close() {
  588. this.show = false
  589. // console.log('close');
  590. },
  591. imagechange(e){
  592. console.log(e,1111)
  593. if(e=='自定义图片'){
  594. uni.showActionSheet({
  595. itemList: ["拍照", "从手机相册选择"],
  596. success(res) {
  597. let sourceType = "camera";
  598. if (res.tapIndex == 0) {
  599. sourceType = "camera";
  600. } else if (res.tapIndex == 1) {
  601. sourceType = "album";
  602. }
  603. uni.chooseImage({
  604. count: 1, //最多可以选择的图片张数,默认9
  605. sizeType: ["original", "compressed"], //original 原图,compressed 压缩图,默认二者都有
  606. sourceType: [sourceType], //album 从相册选图,camera 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项
  607. success: function(res) {
  608. let tempFilePaths = res.tempFilePaths;
  609. that.posterObj1.image = tempFilePaths[0]
  610. this.posterObj1.qrcode = '../../static/imgs/qrcode.jpg'
  611. console.log(tempFilePaths)
  612. }
  613. });
  614. }
  615. });
  616. }else{
  617. if(this.list.length>0){
  618. this.show1=true
  619. }else{
  620. uni.showToast({
  621. icon: "none",
  622. title: '您还未创建名片',
  623. duration: 3000
  624. })
  625. }
  626. }
  627. },
  628. previewImg(){
  629. // #ifdef H5
  630. return;
  631. // #endif
  632. uni.previewImage({
  633. current:this.path,
  634. urls: [this.path]
  635. });
  636. },
  637. closePopup(){
  638. this.$refs.posterImg.close();
  639. this.show_poster=false;
  640. },
  641. async toSave() {
  642. var that = this
  643. //写个同步方法 把所谓 高度宽度 位置 都算好
  644. let query = wx.createSelectorQuery();
  645. await query.select('.canvas-content').boundingClientRect(rect=>{
  646. this.height = rect.height;
  647. }).exec()
  648. await query.select('.title').boundingClientRect(rect=>{
  649. this.theight = rect.height;
  650. }).exec()
  651. setTimeout(()=>{
  652. var posterObj = this.$request.makeCanvasData(this.check_idx,this.height,this.posterObj1,this.theight)
  653. uni.showLoading({
  654. title:'海报生成中',
  655. })
  656. this.posterObj = posterObj
  657. setTimeout(()=>{
  658. const painter = this.$refs.painter;
  659. console.log(painter)
  660. painter.canvasToTempFilePath().then(res => {
  661. console.log(res.tempFilePath,'path')
  662. this.path = res.tempFilePath;
  663. this.$refs.posterImg.open();
  664. this.show_poster=true;
  665. uni.hideLoading()
  666. });
  667. },4000)
  668. },1000)
  669. console.log(this.posterObj)
  670. console.log(this.check_idx)
  671. if (this.check_idx == 4) return;
  672. // switch (this.check_idx) {
  673. // case 0:
  674. // this.posterObj.background = '#fff';
  675. // this.posterObj.views=[
  676. // {
  677. // type: 'text',
  678. // text: this.posterObj1.title,
  679. // use:'title',
  680. // css: {
  681. // fontSize: '32rpx',
  682. // color: '#1A2033',
  683. // fontWeight: 'bold',
  684. // lineHeight: '45rpx',
  685. // left: '32rpx',
  686. // top: '400rpx',
  687. // width: '606rpx'
  688. // }
  689. // },
  690. // {
  691. // type: 'text',
  692. // text: this.posterObj1.title1,
  693. // use:'title1',
  694. // css: {
  695. // fontSize: '28rpx',
  696. // fontWeight: 'bold',
  697. // color: '#1A2033',
  698. // lineHeight: '28rpx',
  699. // left: '32rpx',
  700. // top: '515rpx'
  701. // }
  702. // },
  703. // {
  704. // type: 'text',
  705. // text: '长按或扫描识别二维码',
  706. // use:'title2',
  707. // css: {
  708. // fontSize: '24rpx',
  709. // color: '#4070FF',
  710. // lineHeight: '24rpx',
  711. // left: '32rpx',
  712. // top: '559rpx'
  713. // }
  714. // },
  715. // {
  716. // type: 'image',
  717. // src: 'https://s.yun-live.com/images/20210201/eb694718fa6c7b90d60a2c250847a192.jpg',
  718. // use:'dt',
  719. // css: {
  720. // left: '32rpx',
  721. // top: '34rpx',
  722. // width: '606rpx',
  723. // height: '341rpx',
  724. // borderRadius: '16rpx'
  725. // }
  726. // },
  727. // {
  728. // type: 'qrcode',
  729. // text: 'https://www.yun-live.com/',
  730. // css: {
  731. // left: '445rpx',
  732. // top: '500rpx',
  733. // width: '200rpx',
  734. // height: '200rpx',
  735. // }
  736. // },
  737. // // {
  738. // // type: 'text',
  739. // // text: '———— 由云现场提供技术支持 ————',
  740. // // css: {
  741. // // left: '0',
  742. // // top: '863rpx',
  743. // // width: '100%',
  744. // // textAlign: 'center',
  745. // // fontSize: '24rpx',
  746. // // color: '#989FB3',
  747. // // lineHeight: '33rpx'
  748. // // }
  749. // // }
  750. // ]
  751. // break;
  752. // case 1:
  753. // this.posterObj.height=(this.height*2)+'rpx'
  754. // this.posterObj.views=[{
  755. // type: 'image',
  756. // use:'bg',
  757. // src: 'https://s.yun-live.com/images/20210201/39ae4d9d8ad0b1acac7c224e845c641f.png',
  758. // css: {
  759. // left: '0',
  760. // top: '0',
  761. // width: '100%',
  762. // height: '100%'
  763. // }
  764. // },
  765. // {
  766. // type: 'image',
  767. // src: 'https://s.yun-live.com/images/20210201/eb694718fa6c7b90d60a2c250847a192.jpg',
  768. // css: {
  769. // left: '32rpx',
  770. // top: '34rpx',
  771. // width: '606rpx',
  772. // height: '341rpx',
  773. // borderRadius: '16rpx'
  774. // }
  775. // },
  776. // {
  777. // type: 'text',
  778. // text: this.posterObj1.title,
  779. // use:'title',
  780. // css: {
  781. // fontSize: '32rpx',
  782. // color: '#fff',
  783. // fontWeight: 'bold',
  784. // lineHeight: '45rpx',
  785. // left: '32rpx',
  786. // top: '400rpx',
  787. // width: '606rpx'
  788. // }
  789. // },
  790. // {
  791. // type: 'text',
  792. // text: this.posterObj1.title1,
  793. // use:'title1',
  794. // css: {
  795. // fontSize: '28rpx',
  796. // fontWeight: 'bold',
  797. // color: '#D8AB87',
  798. // lineHeight: '28rpx',
  799. // left: '32rpx',
  800. // top: '515rpx'
  801. // }
  802. // },
  803. // {
  804. // type: 'text',
  805. // text: '长按或扫描识别二维码',
  806. // use:'title2',
  807. // css: {
  808. // fontSize: '24rpx',
  809. // color: '#FFFFFF',
  810. // lineHeight: '24rpx',
  811. // left: '32rpx',
  812. // top: '559rpx'
  813. // }
  814. // },
  815. // {
  816. // type: 'image',
  817. // src: 'https://s.yun-live.com/images/20210201/d88d56843d43b917e2a28550b2a62723.png',
  818. // css: {
  819. // left: '551rpx',
  820. // top: '111rpx',
  821. // width: '103rpx',
  822. // height: '103rpx',
  823. // }
  824. // },
  825. // {
  826. // type: 'image',
  827. // src: 'https://s.yun-live.com/images/20210201/247736ffd279276b891ec14db8ed0fd0.png',
  828. // css: {
  829. // left: '43rpx',
  830. // top: '432rpx',
  831. // width: '56.4rpx',
  832. // height: '56.4rpx',
  833. // }
  834. // },
  835. // {
  836. // type: 'image',
  837. // src: 'https://s.yun-live.com/images/20210201/63a9b504fb745b43b9fe5c0adef8fddb.png',
  838. // css: {
  839. // left: '50%',
  840. // top: '750rpx',
  841. // transform: 'translate(-50%,0)',
  842. // width: '192rpx',
  843. // height: '78rpx',
  844. // }
  845. // },
  846. // {
  847. // type: 'view',
  848. // use:'qrcode-view',
  849. // css: {
  850. // left: '445rpx',
  851. // top: '500rpx',
  852. // width: '200rpx',
  853. // height: '200rpx',
  854. // background: '#fff',
  855. // }
  856. // },
  857. // {
  858. // type: 'image',
  859. // src:this.posterObj1.qrcode,
  860. // use:'qrcode',
  861. // css: {
  862. // left: '455rpx',
  863. // top: '510rpx',
  864. // // transform: 'translate(-50%,0)',
  865. // width: '180rpx',
  866. // height: '180rpx',
  867. // }
  868. // },
  869. // ]
  870. // break;
  871. // case 2:
  872. // this.posterObj1.backgroundType='image'
  873. // this.posterObj1.background='https://s.yun-live.com/images/20210201/78f227bd701da20676c9da9166ce3144.png';
  874. // this.posterObj1.width='540rpx',
  875. // this.posterObj1.height='303rpx',
  876. // this.posterObj1.titleCssColor='#1D1D25'
  877. // this.posterObj1.title1CssColor='#1D1D25'
  878. // this.posterObj1.title2CssColor='#6CB37A'
  879. // break;
  880. // case 3:
  881. // this.posterObj1.backgroundType='image'
  882. // this.posterObj1.background='https://s.yun-live.com/images/20210201/524ab6a41fe8c7eb57b35df9a547d388.png';
  883. // this.posterObj1.width='606rpx',
  884. // this.posterObj1.height='341rpx',
  885. // this.posterObj1.titleCssColor='#1D1D25'
  886. // this.posterObj1.title1CssColor='#1D1D25'
  887. // this.posterObj1.title2CssColor='#6CB37A'
  888. // break;
  889. // default:
  890. // break;
  891. // }
  892. // var node = await this.layout1.calcNode(this.posterObj)
  893. // console.log(node,'node')
  894. // if(node&&node.children.length===this.posterObj.views.length){
  895. // for(var i=0;i<node.children.length;i++){
  896. // if(node.children[i].use==='title'){
  897. // dth=node.children[i].layoutBox.height-48
  898. // }
  899. // if(node.children[i].use==='title'||node.children[i].use==='title1'||node.children[i].use==='title2'){
  900. // h+=node.children[i].layoutBox.height
  901. // }
  902. // }
  903. // console.log(h,h+780,'h打印')
  904. // for(var i=0;i<this.posterObj.views.length;i++){
  905. // if(this.posterObj.views[i].use==='title1'||this.posterObj.views[i].use==='title2'
  906. // ||this.posterObj.views[i].use==='qrcode-view'||this.posterObj.views[i].use==='qrcode'){
  907. // var top=this.posterObj.views[i].css.top.split('r')[0]
  908. // this.posterObj.views[i].css.top=(Number(top)+Number(dth*2))+'rpx'
  909. // }
  910. // }
  911. // this.posterObj.width='670rpx'
  912. // console.log(this.posterObj,'posterObj')
  913. // uni.showLoading({
  914. // title:'海报生成中',
  915. // })
  916. // const painter = this.$refs.painter;
  917. // setTimeout(()=>{
  918. // console.log(this.height*2,'height')
  919. // painter.canvasToTempFilePath().then(res => {
  920. // console.log(res.tempFilePath,'path')
  921. // this.path = res.tempFilePath;
  922. // this.$refs.posterImg.open();
  923. // this.show_poster=true;
  924. // uni.hideLoading()
  925. // });
  926. // },1000)
  927. // }
  928. },
  929. toChoose(index) {
  930. if (index == 4) return;
  931. this.check_idx = index;
  932. switch (index) {
  933. case 0:
  934. this.posterObj1.background='#fff';
  935. this.posterObj1.backgroundType='rgb'
  936. this.posterObj1.width='606rpx',
  937. this.posterObj1.height='341rpx',
  938. this.posterObj1.titleCssColor='#1A2033'
  939. this.posterObj1.title1CssColor='#1A2033'
  940. this.posterObj1.title2CssColor='#4070FF'
  941. break;
  942. case 1:
  943. this.posterObj1.backgroundType='image'
  944. this.posterObj1.background='https://s.yun-live.com/images/20210201/39ae4d9d8ad0b1acac7c224e845c641f.png';
  945. this.posterObj1.width='606rpx',
  946. this.posterObj1.height='341rpx',
  947. this.posterObj1.titleCssColor='#fff'
  948. this.posterObj1.title1CssColor='#D8AB87'
  949. this.posterObj1.title2CssColor='#fff'
  950. break;
  951. case 2:
  952. this.posterObj1.backgroundType='image'
  953. this.posterObj1.background='https://s.yun-live.com/images/20210201/78f227bd701da20676c9da9166ce3144.png';
  954. this.posterObj1.width='540rpx',
  955. this.posterObj1.height='303rpx',
  956. this.posterObj1.titleCssColor='#1D1D25'
  957. this.posterObj1.title1CssColor='#1D1D25'
  958. this.posterObj1.title2CssColor='#6CB37A'
  959. break;
  960. case 3:
  961. this.posterObj1.backgroundType='image'
  962. this.posterObj1.background='https://s.yun-live.com/images/20210201/524ab6a41fe8c7eb57b35df9a547d388.png';
  963. this.posterObj1.width='606rpx',
  964. this.posterObj1.height='341rpx',
  965. this.posterObj1.titleCssColor='#1D1D25'
  966. this.posterObj1.title1CssColor='#1D1D25'
  967. this.posterObj1.title2CssColor='#6CB37A'
  968. break;
  969. default:
  970. break;
  971. }
  972. },
  973. }
  974. }
  975. </script>
  976. <style lang="scss" scoped>
  977. page{
  978. background-color: #F2F4F8;
  979. }
  980. .page{
  981. /deep/ .uni-transition{
  982. background-color:rgba(0, 0, 0, 0.6)
  983. }
  984. .poster-img{
  985. width: 670rpx;
  986. height: 928rpx;
  987. position: relative;
  988. text{
  989. background: url('https://s.yun-live.com/images/20210201/5c4ef9d86bc5eec90f2f915683d9db08.png') no-repeat;
  990. background-size: 100% 100%;
  991. display: inline-block;
  992. width: 50rpx;
  993. height: 50rpx;
  994. position: absolute;
  995. top: -60rpx;
  996. right: 0;
  997. }
  998. image{
  999. width: 100%;
  1000. height: 100%;
  1001. }
  1002. view{
  1003. font-size: 32rpx;
  1004. font-family: PingFang-SC-Bold, PingFang-SC;
  1005. font-weight: bold;
  1006. color: #FFFFFF;
  1007. line-height: 32rpx;
  1008. text-align: center;
  1009. margin-top: 28rpx;
  1010. }
  1011. }
  1012. .poster{
  1013. padding: 24rpx 40rpx 410rpx;
  1014. .footer-btn{
  1015. margin-top: 24rpx;
  1016. display: flex;
  1017. align-items: center;
  1018. justify-content: space-between;
  1019. view{
  1020. width: 319rpx;
  1021. height: 66rpx;
  1022. border-radius: 40rpx;
  1023. border: 1px solid #4070FF;
  1024. font-size: 26rpx;
  1025. font-family: PingFangSC-Regular, PingFang SC;
  1026. font-weight: 400;
  1027. color: #4070FF;
  1028. line-height: 66rpx;
  1029. text-align: center;
  1030. }
  1031. .save{
  1032. background: #4070FF;
  1033. color: #FFFFFF;
  1034. }
  1035. }
  1036. }
  1037. .poster-btn{
  1038. position: fixed;
  1039. bottom: 0;
  1040. width: 100%;
  1041. height: 364rpx;
  1042. background: #FFFFFF;
  1043. border-radius: 32rpx 32rpx 0px 0px;
  1044. >.check_bg{
  1045. display: flex;
  1046. align-items: center;
  1047. justify-content: space-around;
  1048. padding-top:25rpx;
  1049. >view{
  1050. width: 80rpx;
  1051. height: 80rpx;
  1052. position: relative;
  1053. border-radius: 10rpx;
  1054. border: 4rpx solid #fff;
  1055. &.is-check{
  1056. border: 4rpx solid #4070FF;
  1057. }
  1058. image{
  1059. width: 100%;
  1060. height: 100%;
  1061. }
  1062. view{
  1063. width: 30rpx;
  1064. height: 30rpx;
  1065. position: absolute;
  1066. right: -15rpx;
  1067. bottom: -15rpx;
  1068. background: url('https://s.yun-live.com/images/20210201/311c01265c1aa508418f6bae10d67602.png') no-repeat;
  1069. background-size: 100% 100%;
  1070. }
  1071. }
  1072. }
  1073. /deep/.u-radio{
  1074. margin-left: 10px;
  1075. }
  1076. .diy_title,.diy_image{
  1077. display: flex;
  1078. align-items: center;
  1079. justify-content: space-between;
  1080. padding: 20rpx 20rpx 0;
  1081. font-size:28rpx;
  1082. }
  1083. .diy_title{
  1084. padding: 10rpx 20rpx 0;
  1085. }
  1086. }
  1087. }
  1088. .poster{
  1089. position:relative;
  1090. }
  1091. .poster .title{
  1092. text-align:left;
  1093. margin-top:20rpx;
  1094. word-break: break-word;
  1095. }
  1096. .poster .title1{
  1097. margin-bottom:10rpx;
  1098. }
  1099. </style>