poster.vue 31 KB

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