index.vue 23 KB

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