index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. <template>
  2. <view class="">
  3. <view class="btn" @click="takephotos">
  4. 点击保存
  5. </view>
  6. <view class="swiperBox">
  7. <swiper duration="100" :style="{height: swiperHeight+'px'}" @change='swiperChange' :current="current"
  8. :indicator-dots="false" :autoplay="false" :interval="3000" :duration="1000">
  9. <swiper-item v-for="(item,index) in list" :key="index">
  10. <view class="swiper-item swiper-itemcopy" :id='"copyswiperItem"+index'>
  11. <view class="titleBox" :style="{background: 'url('+BASE_URL+jt_bg1+')'}">
  12. <!-- <image :src="BASE_URL+item.qrimage" mode=""></image> -->
  13. <limeQrcodeVue ref="qrcodeRef" :value="BASE_URL1+'/h5/#/pages/deal/productInfo?id='+item.id" size="112rpx" ></limeQrcodeVue>
  14. <view class="title">
  15. <p>{{item.title1}}</p>
  16. <p>{{item.title2}}</p>
  17. <p class="warn">{{item.title3}}</p>
  18. </view>
  19. <!-- <image class="jtbj" src="../../static/logo.png" mode=""></image> -->
  20. </view>
  21. <view class="content" :style="{background: 'url('+BASE_URL+jt_bg2+')'}">
  22. <view class="" :id='"copycontent"+index'>
  23. </view>
  24. <view class="watermark"
  25. v-if="item.watermark_info&&item.watermark_info.type==1||item.watermark_info&&item.watermark_info.type==3">
  26. <view v-for="it in 9" class=""
  27. :style="{transform: 'rotate('+item.watermark_info.angle+'deg)',opacity:(100-item.watermark_info.opacity*1)*0.01,color:item.watermark_info.color,marginTop:item.watermark_info.hh+'px',marginBottom:item.watermark_info.hh+'px',marginLeft:item.watermark_info.ww+'px',marginRight:item.watermark_info.ww+'px',fontSize:item.watermark_info.text_font+'px',fontWeight:item.watermark_info.bold==1?'bold':'',fontFamily:item.watermark_info.typeface==1?'typeface1':item.watermark_info.typeface==2?'typeface2':item.watermark_info.typeface==3?'typeface3':item.watermark_info.typeface==4?'typeface4':item.watermark_info.typeface==5?'typeface5':item.watermark_info.typeface==6?'typeface6':''}">
  28. <image :src="BASE_URL+item.watermark_info.image" mode="" v-if="item.watermark_info.image&&item.watermark_info.type==1"></image>
  29. <text
  30. v-if="item.watermark_info.water_text&&item.watermark_info.type==3">{{item.watermark_info.water_text}}</text>
  31. </view>
  32. </view>
  33. <view class="watermark1"
  34. :style="{left:item.watermark_info.waterPos==0?0+item.watermark_info.xx+'px':item.watermark_info.waterPos==1?0+item.watermark_info.xx+'px':item.watermark_info.waterPos==4?0+item.watermark_info.voffset+'px':item.watermark_info.waterPos==7?0+item.watermark_info.xx+'px':item.watermark_info.waterPos==2?'calc( 40%'+' + '+item.watermark_info.xx+'px )':item.watermark_info.waterPos==5?'calc( 40%'+' + '+item.watermark_info.voffset+'px )':item.watermark_info.waterPos==8?'calc( 40%'+' + '+item.watermark_info.xx+'px )':'',top:item.watermark_info.waterPos==0?0+item.watermark_info.yy+'px':item.watermark_info.waterPos==1?0+item.watermark_info.yy+'px':item.watermark_info.waterPos==2?0+item.watermark_info.yy+'px':item.watermark_info.waterPos==3?0+item.watermark_info.yy+'px':item.watermark_info.waterPos==4?'40%':item.watermark_info.waterPos==5?'40%':item.watermark_info.waterPos==6?'40%':'',right:item.watermark_info.waterPos==3?0+item.watermark_info.xx+'px':item.watermark_info.waterPos==6?0+item.watermark_info.waterPos+'px':item.watermark_info.waterPos==9?0+item.watermark_info.xx+'px':'',bottom:item.watermark_info.waterPos==7?0+item.watermark_info.xx+'px':item.watermark_info.waterPos==8?0+item.watermark_info.ww+'px':item.watermark_info.waterPos==9?0+item.watermark_info.xx+'px':'',fontWeight:item.watermark_info.bold==1?'bold':'',fontFamily:item.watermark_info.typeface==1?'typeface1':item.watermark_info.typeface==2?'typeface2':item.watermark_info.typeface==3?'typeface3':item.watermark_info.typeface==4?'typeface4':item.watermark_info.typeface==5?'typeface5':item.watermark_info.typeface==6?'typeface6':''}"
  35. v-if="item.watermark_info&&item.watermark_info.type==2||item.watermark_info&&item.watermark_info.type==4">
  36. <view class=""
  37. :style="{transform: 'rotate('+item.watermark_info.angle+'deg)',color:`rgba(${hexToRgb(item.watermark_info.color).rgb},${(100-item.watermark_info.opacity*1)*0.01})`,fontSize:item.watermark_info.text_font+'px'}">
  38. <image :src="BASE_URL+item.watermark_info.image" mode=""
  39. v-if="item.watermark_info.image&&item.watermark_info.type==2"></image>
  40. <text
  41. v-if="item.watermark_info.water_text&&item.watermark_info.type==4">{{item.watermark_info.water_text}}</text>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="swiper-item" :id='"swiperItem"+index'>
  47. <view class="titleBox" :style="{background: 'url('+BASE_URL+jt_bg1+')'}">
  48. <!-- <view class="titleBox"> -->
  49. <!-- <image :src="BASE_URL+item.qrimage" mode=""></image> -->
  50. <limeQrcodeVue ref="qrcodeRef" :value="BASE_URL1+'/h5/#/pages/deal/productInfo?id='+item.id"
  51. size="112rpx"></limeQrcodeVue>
  52. <view class="title">
  53. <p>{{item.title1}}</p>
  54. <p>{{item.title2}}</p>
  55. <p class="warn">{{item.title3}}</p>
  56. </view>
  57. </view>
  58. <view class="content" v-if="item.detail" :style="{background: 'url('+BASE_URL+jt_bg2+')'}">
  59. <view class="" :id='"content"+index'>
  60. <u-parse :content="item.detail"></u-parse>
  61. </view>
  62. <view class="watermark"
  63. v-if="item.watermark_info&&item.watermark_info.type==1||item.watermark_info&&item.watermark_info.type==3">
  64. <view v-for="it in 100" class=""
  65. :style="{transform: 'rotate('+item.watermark_info.angle+'deg)',opacity:(100-item.watermark_info.opacity*1)*0.01,color:item.watermark_info.color,marginTop:item.watermark_info.hh+'px',marginBottom:item.watermark_info.hh+'px',marginLeft:item.watermark_info.ww+'px',marginRight:item.watermark_info.ww+'px',fontSize:item.watermark_info.text_font+'px',fontWeight:item.watermark_info.bold==1?'bold':'',fontFamily:item.watermark_info.typeface==1?'typeface1':item.watermark_info.typeface==2?'typeface2':item.watermark_info.typeface==3?'typeface3':item.watermark_info.typeface==4?'typeface4':item.watermark_info.typeface==5?'typeface5':item.watermark_info.typeface==6?'typeface6':''}">
  66. <image :src="BASE_URL+item.watermark_info.image" mode=""
  67. v-if="item.watermark_info.image&&item.watermark_info.type==1"></image>
  68. <text
  69. v-if="item.watermark_info.water_text&&item.watermark_info.type==3">{{item.watermark_info.water_text}}</text>
  70. </view>
  71. </view>
  72. <view class="watermark1"
  73. :style="{left:item.watermark_info.waterPos==0?0+item.watermark_info.xx+'px':item.watermark_info.waterPos==1?0+item.watermark_info.xx+'px':item.watermark_info.waterPos==4?0+item.watermark_info.voffset+'px':item.watermark_info.waterPos==7?0+item.watermark_info.xx+'px':item.watermark_info.waterPos==2?'calc( 40%'+' + '+item.watermark_info.xx+'px )':item.watermark_info.waterPos==5?'calc( 40%'+' + '+item.watermark_info.voffset+'px )':item.watermark_info.waterPos==8?'calc( 40%'+' + '+item.watermark_info.xx+'px )':'',top:item.watermark_info.waterPos==0?0+item.watermark_info.yy+'px':item.watermark_info.waterPos==1?0+item.watermark_info.yy+'px':item.watermark_info.waterPos==2?0+item.watermark_info.yy+'px':item.watermark_info.waterPos==3?0+item.watermark_info.yy+'px':item.watermark_info.waterPos==4?'40%':item.watermark_info.waterPos==5?'40%':item.watermark_info.waterPos==6?'40%':'',right:item.watermark_info.waterPos==3?0+item.watermark_info.xx+'px':item.watermark_info.waterPos==6?0+item.watermark_info.waterPos+'px':item.watermark_info.waterPos==9?0+item.watermark_info.xx+'px':'',bottom:item.watermark_info.waterPos==7?0+item.watermark_info.xx+'px':item.watermark_info.waterPos==8?0+item.watermark_info.ww+'px':item.watermark_info.waterPos==9?0+item.watermark_info.xx+'px':'',fontWeight:item.watermark_info.bold==1?'bold':'',fontFamily:item.watermark_info.typeface==1?'typeface1':item.watermark_info.typeface==2?'typeface2':item.watermark_info.typeface==3?'typeface3':item.watermark_info.typeface==4?'typeface4':item.watermark_info.typeface==5?'typeface5':item.watermark_info.typeface==6?'typeface6':''}"
  74. v-if="item.watermark_info&&item.watermark_info.type==2||item.watermark_info&&item.watermark_info.type==4">
  75. <view class=""
  76. :style="{transform: 'rotate('+item.watermark_info.angle+'deg)',color:`rgba(${hexToRgb(item.watermark_info.color).rgb},${(100-item.watermark_info.opacity*1)*0.01})`,fontSize:item.watermark_info.text_font+'px'}">
  77. <image :src="BASE_URL+item.watermark_info.image" mode=""
  78. v-if="item.watermark_info.image&&item.watermark_info.type==2"></image>
  79. <text
  80. v-if="item.watermark_info.water_text&&item.watermark_info.type==4">{{item.watermark_info.water_text}}</text>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </swiper-item>
  86. </swiper>
  87. </view>
  88. <u-overlay :show="show" @click="show = false">
  89. <view class="warp">
  90. <view class="rect" @tap.stop>
  91. <image :style="{height: swiperHeight+'px'}" :src="url" mode=""></image>
  92. <p>长按保存到本地</p>
  93. </view>
  94. </view>
  95. </u-overlay>
  96. <u-overlay :show="show2" @click="show2 = false" @touchstart="start" @touchend="end" @touchmove="move">
  97. <view class="warp">
  98. <view class="rect2">
  99. <image src="../../static/swiper1.png" mode=""></image>
  100. <p style="color: #fff;">{{alert2}}</p>
  101. </view>
  102. </view>
  103. </u-overlay>
  104. <u-overlay :show="show1" @click="show1 = false">
  105. <view class="warp">
  106. <view class="rect1" @tap.stop>
  107. <image src="../../static/warn.png" mode=""></image>
  108. <p>{{alert1}}</p>
  109. <u-button color="#A5CF49" type="success" shape="circle" text="确认收藏" @click="addFavorite"></u-button>
  110. </view>
  111. </view>
  112. </u-overlay>
  113. </view>
  114. </template>
  115. <script setup>
  116. import limeQrcodeVue from '../../uni_modules/lime-qrcode/components/l-qrcode/l-qrcode.vue';
  117. import html2canvas from 'html2canvas';
  118. import {
  119. BASE_URL,BASE_URL1
  120. } from '../../utils/http.js'
  121. import {
  122. onLoad,
  123. onShow,
  124. onPullDownRefresh
  125. } from "@dcloudio/uni-app";
  126. import {
  127. nextTick,
  128. ref
  129. } from "vue"
  130. import {
  131. getsimpleimages,
  132. getplatformeditor,getplatformmeun
  133. } from '@/utils/api.js'
  134. let isSave=ref(false)
  135. let show = ref(false)
  136. let show1 = ref(false)
  137. let show2 = ref(false)
  138. let startData=ref({clientX: '',clientY: '',})
  139. let moveX=ref(0)
  140. let touch=ref({})
  141. // let touch=(e)=>{
  142. // console.log(123,e)
  143. // current.value++
  144. // // show2.value = false
  145. // }
  146. // 触摸touch事件
  147. let start=(e)=>{ //@touchstart 触摸开始
  148. startData.value.clientX = e.changedTouches[0].clientX; //手指按下时的X坐标
  149. }
  150. let end=(e)=>{ //@touchend触摸结束
  151. moveX.value = 0; //触摸事件结束恢复原状
  152. console.log(123,touch.value.clientX-startData.value.clientX)
  153. if(touch.value.clientX-startData.value.clientX> 0) { //在事件结束时,判断滑动的距离是否达到出发需要执行事件的要求
  154. if(current.value!=0){
  155. current.value-=1
  156. }
  157. } else {
  158. current.value+=1
  159. // this.touch = {};
  160. }
  161. }
  162. let move=(event)=>{ //@touchmove触摸移动
  163. let touch1 = event.touches[0]; //滑动过程中,手指滑动的坐标信息 返回的是Objcet对象
  164. touch.value = touch1;
  165. let data = touch1.clientX - startData.value.clientX;
  166. if(touch1.clientX < startData.value.clientX) { //向左移动
  167. if(data<-250) {
  168. data = -250;
  169. }
  170. }
  171. if(touch1.clientX > startData.value.clientX) { //向右移动
  172. if(moveX.value == 0) {
  173. data = 0
  174. } else {
  175. if(data>50) {
  176. data = 50;
  177. }
  178. }
  179. }
  180. moveX.value = data;
  181. }
  182. let swiperChange = (e) => {
  183. current.value = e.detail.current
  184. var dom = document.getElementById('swiperItem' + current.value); // 获取dom元素
  185. if (dom && dom.children[1]) {
  186. swiperHeight.value = 67 + dom.children[1].clientHeight
  187. } else {
  188. swiperHeight.value = 67
  189. }
  190. if(current.value%10==0&&current.value!=0){
  191. page.value += 1
  192. getsimpleimages({
  193. page: page.value,
  194. page_num
  195. }).then(res => {
  196. list.value = [...list.value, ...res.data]
  197. list.value.forEach(item=>{
  198. // item.detail=getspan(item.detail)
  199. })
  200. })
  201. }
  202. }
  203. let page_num = 1
  204. let page = ref(1)
  205. let url = ref()
  206. let swiperHeight = ref(67)
  207. let current = ref(0)
  208. let list = ref([])
  209. let refList = ref([])
  210. let setBoxRef = (el) => {
  211. if (el) {
  212. refList.value.push(el)
  213. }
  214. }
  215. //收藏网站
  216. // 收藏本站
  217. let addFavorite = () => {
  218. var url = window.location;
  219. var title = '斑马交易平台';
  220. var ua = navigator.userAgent.toLowerCase();
  221. if (ua.indexOf("360se") > -1) {
  222. alert("您的浏览器不支持自动加入收藏,请手动设置!");
  223. } else if (ua.indexOf("msie 8") > -1) {
  224. window.external.AddToFavoritesBar(url, title); //IE8
  225. } else if (document.all) { //IE类浏览器
  226. try {
  227. window.external.addFavorite(url, title);
  228. } catch (e) {
  229. alert('您的浏览器不支持自动加入收藏,请手动设置!');
  230. }
  231. } else if (window.sidebar) { //firfox等浏览器;
  232. window.sidebar.addPanel(title, url, "");
  233. } else {
  234. alert('您的浏览器不支持自动加入收藏,请手动设置!');
  235. }
  236. show1.value = false
  237. }
  238. let takephotos = () => {
  239. // var dom = document.getElementById('swiperItem' + current.value); // 获取dom元素
  240. // // var dom1 = document.getElementById('swiperItem'); // 获取dom元素
  241. // if (dom && dom.children[1]) {
  242. // swiperHeight.value = 67 + dom.children[1].clientHeight
  243. // } else {
  244. // swiperHeight.value = 67
  245. // }
  246. // html2canvas(dom).then((canvas) => {
  247. // url.value = canvas.toDataURL("image/png").replace('image/png', 'image/octet-stream');
  248. // show.value = true
  249. // });
  250. var swiper = document.getElementById('copyswiperItem'+current.value); // 获取dom元素
  251. var dom = document.getElementById('content'+current.value); // 获取dom元素
  252. var dom1 = document.getElementById('copycontent'+current.value); // 获取dom元素
  253. dom1.innerHTML=dom.innerHTML
  254. let res = domTrans(dom1)
  255. let html = forFn(res)
  256. dom1.innerHTML=html
  257. html2canvas(swiper,{
  258. allowTaint: true,
  259. useCORS: true
  260. }).then((canvas) => {
  261. url.value = canvas.toDataURL("image/png").replace('image/png', 'image/octet-stream');
  262. show.value=true
  263. });
  264. }
  265. let alert1 = ref('')
  266. let alert2 = ref('')
  267. let jt_bg1=ref('')
  268. let jt_bg2=ref('')
  269. onLoad(() => {
  270. getplatformmeun().then(res=>{
  271. uni.setNavigationBarTitle({
  272. title: res.data.name
  273. });
  274. jt_bg1.value=res.data.jt_bg1
  275. jt_bg2.value=res.data.jt_bg2
  276. })
  277. getplatformeditor().then(res => {
  278. alert1.value = res.data.alert1
  279. alert2.value = res.data.alert2
  280. })
  281. getsimpleimages({
  282. page: page.value,
  283. page_num: 12
  284. }).then(res => {
  285. show2.value=true
  286. list.value = res.data
  287. // list.value.forEach(item=>{
  288. // item.detail=getspan(item.detail)
  289. // })
  290. setTimeout(()=>{
  291. var dom = document.getElementById('swiperItem' + current.value); // 获取dom元素
  292. if (dom && dom.children[1]) {
  293. swiperHeight.value = 67 + dom.children[1].clientHeight
  294. } else {
  295. swiperHeight.value = 67
  296. }
  297. })
  298. setTimeout(() => {
  299. show2.value = false
  300. }, 5000)
  301. })
  302. let flag = uni.getStorageSync('collect')
  303. if (!flag) {
  304. show1.value = true
  305. uni.setStorageSync('collect', true)
  306. }
  307. })
  308. onShow(() => {
  309. })
  310. function hexToRgb (val) { //HEX十六进制颜色值转换为RGB(A)颜色值
  311. // 16进制颜色值的正则
  312. var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  313. // 把颜色值变成小写
  314. var color = val.toLowerCase();
  315. var result = '';
  316. if (reg.test(color)) {
  317. // 如果只有三位的值,需变成六位,如:#fff => #ffffff
  318. if (color.length === 4) {
  319. var colorNew = "#";
  320. for (var i = 1; i < 4; i += 1) {
  321. colorNew += color.slice(i, i + 1).concat(color.slice(i, i + 1));
  322. }
  323. color = colorNew;
  324. }
  325. // 处理六位的颜色值,转为RGB
  326. var colorChange = [];
  327. for (var i = 1; i < 7; i += 2) {
  328. colorChange.push(parseInt("0x" + color.slice(i, i + 2)));
  329. }
  330. result = colorChange.join(",")
  331. return { rgb: result, r: colorChange[0], g: colorChange[1], b: colorChange[2] };
  332. } else {
  333. result = '无效';
  334. return { rgb: result };
  335. }
  336. }
  337. function getspan(str) {
  338. // let st=str.replace(new RegExp('font', 'g'), 'span')
  339. var list1 = str.split('</span>')
  340. var list2 = []
  341. list1.forEach(val => {
  342. if (val.indexOf("<span") > -1) {
  343. list2.push({
  344. isspan: true,
  345. arr: val.split("<span")
  346. })
  347. } else {
  348. list2.push({
  349. isspan: false,
  350. arr: val
  351. })
  352. }
  353. })
  354. var list3 = []
  355. list2.forEach(val => {
  356. if (val.isspan) {
  357. list3.push({
  358. ...val,
  359. style: val.arr[1].split('>')[0],
  360. span: val.arr[1].split('>')[1]
  361. })
  362. } else {
  363. list3.push({
  364. ...val
  365. })
  366. }
  367. })
  368. var html = ''
  369. list3.forEach(val => {
  370. if (val.isspan) {
  371. html = html + val.arr[0]
  372. var span = ''
  373. for (var a = 0; a < val.span.length; a++) {
  374. span = span + `<span${val.style}>${val.span[a]}</span>`
  375. }
  376. html = html + span
  377. } else {
  378. html = html + val.arr
  379. }
  380. })
  381. return html
  382. }
  383. onPullDownRefresh(() => {
  384. setTimeout(function() {
  385. uni.stopPullDownRefresh();
  386. }, 1000);
  387. })
  388. // 将DOM转换为js对象
  389. function domTrans(dom) {
  390. // 总dom树
  391. let tree = [];
  392. // 递归, node = 当前的节点,dataNode = 数据插入的节点
  393. const loop = (node, dataNode) => {
  394. // 当前节点的模板
  395. let temp = {
  396. type: node.nodeType,
  397. };
  398. // 如果是文本节点 或 单标签节点
  399. if (temp.type == 3 && node.nodeValue.match(/\S/)) {
  400. temp["content"] = node.nodeValue;
  401. temp["tag"] = node.nodeName;
  402. dataNode.push(temp);
  403. }
  404. // 元素节点
  405. if (temp.type == 1) {
  406. let attributes = getAttribute(node);
  407. // 如果没有属性,不添加 attributes
  408. if (attributes) temp["attributes"] = attributes;
  409. var newNode = node.childNodes
  410. var newNode2
  411. if (newNode[0] && newNode.length <= 1) {
  412. newNode2 = newNode[0].childNodes.length
  413. }
  414. // 当前节点下还有子节点
  415. if (node.childNodes.length > 1 || newNode2 > 0) {
  416. temp["children"] = [];
  417. temp["tag"] = node.nodeName.toLowerCase();
  418. for (let i = 0; i < node.childNodes.length; i++) {
  419. loop(node.childNodes[i], temp.children);
  420. }
  421. }
  422. // 当前节点下只有文本 或 单标签节点
  423. if (node.childNodes.length <= 1 && newNode2 == 0) {
  424. temp["content"] = node.innerHTML;
  425. temp["tag"] = node.nodeName.toLowerCase();
  426. }
  427. dataNode.push(temp);
  428. }
  429. };
  430. loop(dom, tree);
  431. return tree[0].children;
  432. }
  433. function forFn(arr) {
  434. let html = ``
  435. for (let i = 0; i < arr.length; i++) {
  436. let tArr = []
  437. if (arr[i].content) {
  438. tArr = arr[i].content.split("")
  439. }
  440. if (arr[i].type === 1) {
  441. if (arr[i].attributes) {
  442. if (arr[i].attributes.src) {
  443. html +=
  444. `<img class="${arr[i].attributes.class}" src="${arr[i].attributes.src}" style="${arr[i].attributes.style}">`
  445. } else {
  446. html += `<${arr[i].tag} class="${arr[i].attributes.class}" style="${arr[i].attributes.style}">`
  447. }
  448. } else {
  449. if (arr[i].tag == "img") {
  450. html += `<${arr[i].tag} style="${arr[i].attributes.style}">`
  451. } else {
  452. html += `<${arr[i].tag}>`
  453. }
  454. }
  455. if (arr[i].children) {
  456. html += forFn(arr[i].children)
  457. }
  458. html += `</${arr[i].tag}>`
  459. }
  460. tArr.forEach(el => {
  461. if (arr[i].tag === "#text") {
  462. html += `${el}`
  463. } else {
  464. if (arr[i].attributes) {
  465. if (arr[i].tag == "img") {
  466. html +=
  467. `<${arr[i].tag} class="${arr[i].attributes.class}" src="${arr[i].attributes.src}" style="${arr[i].attributes.style}">${el}</${arr[i].tag}>`
  468. } else {
  469. html +=
  470. `<${arr[i].tag} class="${arr[i].attributes.class}" style="${arr[i].attributes.style}">${el}</${arr[i].tag}>`
  471. }
  472. } else {
  473. if (arr[i].tag == "img") {
  474. html += `<${arr[i].tag} src="${arr[i].attributes.src}">${el}</${arr[i].tag}>`
  475. } else {
  476. html += `<${arr[i].tag}>${el}</${arr[i].tag}>`
  477. }
  478. }
  479. }
  480. });
  481. }
  482. // console.log(html,'====')
  483. return html
  484. }
  485. // 提取元素属性
  486. function getAttribute(dom) {
  487. let attributes = {};
  488. // let empty = true;
  489. Array.from(dom.attributes).map((item) => {
  490. attributes[item.nodeName] = item.nodeValue;
  491. // empty = false;
  492. });
  493. return attributes;
  494. }
  495. </script>
  496. <style lang="scss">
  497. .typeface1{
  498. font-family:typeface1;
  499. }
  500. .swiper-itemcopy{
  501. position: absolute;
  502. top: 999px;
  503. }
  504. .content {
  505. padding-left: 10rpx;
  506. padding-right: 10rpx;
  507. word-break: break-all;
  508. word-wrap: break-word;
  509. overflow: hidden;
  510. position: relative;
  511. .watermark {
  512. display: flex;
  513. flex-wrap: wrap;
  514. position: absolute;
  515. top: 0;
  516. left: 0;
  517. right: 0;
  518. // bottom: 0;
  519. image {
  520. width: 100rpx;
  521. height: 100rpx;
  522. }
  523. }
  524. .watermark1 {
  525. position: absolute;
  526. image {
  527. width: 100rpx;
  528. height: 100rpx;
  529. }
  530. }
  531. }
  532. .warp {
  533. padding: 0 28rpx;
  534. display: flex;
  535. align-items: center;
  536. justify-content: center;
  537. height: 100%;
  538. }
  539. .rect {
  540. display: flex;
  541. flex-direction: column;
  542. align-items: center;
  543. width: 694px;
  544. height: auto;
  545. image {
  546. width: 100%;
  547. }
  548. p {
  549. font-size: 48rpx;
  550. color: #fff;
  551. margin-top: 12rpx;
  552. }
  553. // background-color: #fff;
  554. }
  555. @keyframes example1 {
  556. 0% {
  557. transform:translate(0);
  558. }
  559. 50% {
  560. transform:translate(-40px);
  561. }
  562. 100% {
  563. transform:translate(-80px);
  564. }
  565. 0% {
  566. transform:translate(0);
  567. }
  568. }
  569. .rect2 {
  570. display: flex;
  571. flex-direction: column;
  572. align-items: center;
  573. image {
  574. width: 374rpx;
  575. height: 361rpx;
  576. }
  577. transform: translate(0);
  578. animation:example1 1s linear 0s backwards;
  579. animation-iteration-count:infinite;
  580. }
  581. .rect1 {
  582. padding: 60rpx 60rpx;
  583. display: flex;
  584. flex-direction: column;
  585. align-items: center;
  586. width: 558rpx;
  587. // height: 438rpx;
  588. background: #FFFFFF;
  589. border-radius: 20rpx;
  590. image {
  591. max-width: 96rpx;
  592. max-height: 96rpx;
  593. }
  594. p {
  595. font-size: 30rpx;
  596. margin: 62rpx 0 40rpx;
  597. }
  598. // background-color: #fff;
  599. }
  600. page {
  601. height: 100%;
  602. .btn {
  603. font-size: 35rpx;
  604. color: #fff;
  605. text-align: center;
  606. line-height: 90rpx;
  607. float: right;
  608. width: 200rpx;
  609. height: 90rpx;
  610. background: #A5CF49;
  611. border-radius: 0rpx 0rpx 0rpx 32rpx;
  612. }
  613. .swiperBox {
  614. width: 694rpx;
  615. position: fixed;
  616. top: 50%;
  617. left: 50%;
  618. transform: translate(-50%,-50%);
  619. .swiper-item {
  620. .titleBox {
  621. position: relative;
  622. font-size: 28rpx;
  623. color: #666666;
  624. padding: 6rpx;
  625. display: flex;
  626. align-items: flex-end;
  627. image {
  628. margin-right: 4rpx;
  629. width: 112rpx;
  630. height: 112rpx;
  631. }
  632. .jtbj{
  633. width: 100%;
  634. height: 100%;
  635. position: absolute;
  636. top: 0;
  637. left: 0;
  638. right: 0;
  639. bottom: 0;
  640. z-index: 0;
  641. }
  642. .warn {
  643. font-size: 32rpx;
  644. color: #FF2828;
  645. }
  646. .title {
  647. margin-left: 4rpx;
  648. }
  649. }
  650. }
  651. }
  652. }
  653. </style>