index.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043
  1. <template>
  2. <view class="">
  3. <view class="btn" @click="takephotos"> 点击保存 </view>
  4. <view class="swiperBox">
  5. <swiper
  6. duration="100"
  7. :style="{ height: swiperHeight + 'px' }"
  8. @change="swiperChange"
  9. :current="current"
  10. :indicator-dots="false"
  11. :autoplay="false"
  12. :interval="3000"
  13. :duration="1000"
  14. >
  15. <swiper-item v-for="(item, index) in list" :key="index">
  16. <view
  17. class="swiper-item swiper-itemcopy"
  18. :id="'copyswiperItem' + index"
  19. >
  20. <view
  21. class="titleBox"
  22. :style="{ background: 'url(' + BASE_URL + jt_bg1 + ')' }"
  23. >
  24. <!-- <image :src="BASE_URL+item.qrimage" mode=""></image> -->
  25. <limeQrcodeVue
  26. ref="qrcodeRef"
  27. :value="
  28. BASE_URL1 +
  29. `/h5/#/pages/deal/product_info?id=${item.id}&rand_num=${item.rand_num}`
  30. "
  31. size="112rpx"
  32. ></limeQrcodeVue>
  33. <view class="title">
  34. <p>{{ item.title1 }}</p>
  35. <p>{{ item.title2 }}</p>
  36. <p class="warn">{{ item.title3 }}</p>
  37. </view>
  38. <!-- <image class="jtbj" src="../../static/logo.png" mode=""></image> -->
  39. </view>
  40. <view
  41. class="content"
  42. :style="{ background: 'url(' + BASE_URL + jt_bg2 + ')' }"
  43. >
  44. <view class="" :id="'copycontent' + index"> </view>
  45. <view
  46. class="watermark"
  47. v-if="
  48. (item.watermark_info && item.watermark_info.type == 1) ||
  49. (item.watermark_info && item.watermark_info.type == 3)
  50. "
  51. >
  52. <view
  53. v-for="it in 9"
  54. class=""
  55. :style="{
  56. transform: 'rotate(' + item.watermark_info.angle + 'deg)',
  57. opacity: (100 - item.watermark_info.opacity * 1) * 0.01,
  58. color: item.watermark_info.color,
  59. marginTop: item.watermark_info.hh + 'px',
  60. marginBottom: item.watermark_info.hh + 'px',
  61. marginLeft: item.watermark_info.ww + 'px',
  62. marginRight: item.watermark_info.ww + 'px',
  63. fontSize: item.watermark_info.text_font + 'px',
  64. fontWeight: item.watermark_info.bold == 1 ? 'bold' : '',
  65. fontFamily:
  66. item.watermark_info.typeface == 1
  67. ? 'typeface1'
  68. : item.watermark_info.typeface == 2
  69. ? 'typeface2'
  70. : item.watermark_info.typeface == 3
  71. ? 'typeface3'
  72. : item.watermark_info.typeface == 4
  73. ? 'typeface4'
  74. : item.watermark_info.typeface == 5
  75. ? 'typeface5'
  76. : item.watermark_info.typeface == 6
  77. ? 'typeface6'
  78. : '',
  79. }"
  80. >
  81. <image
  82. :src="BASE_URL + item.watermark_info.image"
  83. mode=""
  84. v-if="
  85. item.watermark_info.image && item.watermark_info.type == 1
  86. "
  87. ></image>
  88. <text
  89. v-if="
  90. item.watermark_info.water_text &&
  91. item.watermark_info.type == 3
  92. "
  93. >{{ item.watermark_info.water_text }}</text
  94. >
  95. </view>
  96. </view>
  97. <view
  98. class="watermark1"
  99. :style="{
  100. left:
  101. item.watermark_info.waterPos == 0
  102. ? 0 + item.watermark_info.xx + 'px'
  103. : item.watermark_info.waterPos == 1
  104. ? 0 + item.watermark_info.xx + 'px'
  105. : item.watermark_info.waterPos == 4
  106. ? 0 + item.watermark_info.voffset + 'px'
  107. : item.watermark_info.waterPos == 7
  108. ? 0 + item.watermark_info.xx + 'px'
  109. : item.watermark_info.waterPos == 2
  110. ? 'calc( 40%' + ' + ' + item.watermark_info.xx + 'px )'
  111. : item.watermark_info.waterPos == 5
  112. ? 'calc( 40%' +
  113. ' + ' +
  114. item.watermark_info.voffset +
  115. 'px )'
  116. : item.watermark_info.waterPos == 8
  117. ? 'calc( 40%' + ' + ' + item.watermark_info.xx + 'px )'
  118. : '',
  119. top:
  120. item.watermark_info.waterPos == 0
  121. ? 0 + item.watermark_info.yy + 'px'
  122. : item.watermark_info.waterPos == 1
  123. ? 0 + item.watermark_info.yy + 'px'
  124. : item.watermark_info.waterPos == 2
  125. ? 0 + item.watermark_info.yy + 'px'
  126. : item.watermark_info.waterPos == 3
  127. ? 0 + item.watermark_info.yy + 'px'
  128. : item.watermark_info.waterPos == 4
  129. ? '40%'
  130. : item.watermark_info.waterPos == 5
  131. ? '40%'
  132. : item.watermark_info.waterPos == 6
  133. ? '40%'
  134. : '',
  135. right:
  136. item.watermark_info.waterPos == 3
  137. ? 0 + item.watermark_info.xx + 'px'
  138. : item.watermark_info.waterPos == 6
  139. ? 0 + item.watermark_info.waterPos + 'px'
  140. : item.watermark_info.waterPos == 9
  141. ? 0 + item.watermark_info.xx + 'px'
  142. : '',
  143. bottom:
  144. item.watermark_info.waterPos == 7
  145. ? 0 + item.watermark_info.xx + 'px'
  146. : item.watermark_info.waterPos == 8
  147. ? 0 + item.watermark_info.ww + 'px'
  148. : item.watermark_info.waterPos == 9
  149. ? 0 + item.watermark_info.xx + 'px'
  150. : '',
  151. fontWeight: item.watermark_info.bold == 1 ? 'bold' : '',
  152. fontFamily:
  153. item.watermark_info.typeface == 1
  154. ? 'typeface1'
  155. : item.watermark_info.typeface == 2
  156. ? 'typeface2'
  157. : item.watermark_info.typeface == 3
  158. ? 'typeface3'
  159. : item.watermark_info.typeface == 4
  160. ? 'typeface4'
  161. : item.watermark_info.typeface == 5
  162. ? 'typeface5'
  163. : item.watermark_info.typeface == 6
  164. ? 'typeface6'
  165. : '',
  166. }"
  167. v-if="
  168. (item.watermark_info && item.watermark_info.type == 2) ||
  169. (item.watermark_info && item.watermark_info.type == 4)
  170. "
  171. >
  172. <view
  173. class=""
  174. :style="{
  175. transform: 'rotate(' + item.watermark_info.angle + 'deg)',
  176. color: `rgba(${hexToRgb(item.watermark_info.color).rgb},${
  177. (100 - item.watermark_info.opacity * 1) * 0.01
  178. })`,
  179. fontSize: item.watermark_info.text_font + 'px',
  180. }"
  181. >
  182. <image
  183. :src="BASE_URL + item.watermark_info.image"
  184. mode=""
  185. v-if="
  186. item.watermark_info.image && item.watermark_info.type == 2
  187. "
  188. ></image>
  189. <text
  190. v-if="
  191. item.watermark_info.water_text &&
  192. item.watermark_info.type == 4
  193. "
  194. >{{ item.watermark_info.water_text }}</text
  195. >
  196. </view>
  197. </view>
  198. </view>
  199. </view>
  200. <view class="swiper-item" :id="'swiperItem' + index">
  201. <view
  202. class="titleBox"
  203. :style="{ background: 'url(' + BASE_URL + jt_bg1 + ')' }"
  204. >
  205. <!-- <view class="titleBox"> -->
  206. <!-- <image :src="BASE_URL+item.qrimage" mode=""></image> -->
  207. <limeQrcodeVue
  208. ref="qrcodeRef"
  209. :value="
  210. BASE_URL1 +
  211. `/h5/#/pages/deal/product_info?id=${item.id}&rand_num=${item.rand_num}`
  212. "
  213. size="112rpx"
  214. ></limeQrcodeVue>
  215. <view class="title">
  216. <p>{{ item.title1 }}</p>
  217. <p>{{ item.title2 }}</p>
  218. <p class="warn">{{ item.title3 }}</p>
  219. </view>
  220. </view>
  221. <view
  222. class="content"
  223. v-if="item.detail"
  224. :style="{ background: 'url(' + BASE_URL + jt_bg2 + ')' }"
  225. >
  226. <view class="" :id="'content' + index">
  227. <u-parse :content="item.detail"></u-parse>
  228. </view>
  229. <view
  230. class="watermark"
  231. v-if="
  232. (item.watermark_info && item.watermark_info.type == 1) ||
  233. (item.watermark_info && item.watermark_info.type == 3)
  234. "
  235. >
  236. <view
  237. v-for="it in 100"
  238. class=""
  239. :style="{
  240. transform: 'rotate(' + item.watermark_info.angle + 'deg)',
  241. opacity: (100 - item.watermark_info.opacity * 1) * 0.01,
  242. color: item.watermark_info.color,
  243. marginTop: item.watermark_info.hh + 'px',
  244. marginBottom: item.watermark_info.hh + 'px',
  245. marginLeft: item.watermark_info.ww + 'px',
  246. marginRight: item.watermark_info.ww + 'px',
  247. fontSize: item.watermark_info.text_font + 'px',
  248. fontWeight: item.watermark_info.bold == 1 ? 'bold' : '',
  249. fontFamily:
  250. item.watermark_info.typeface == 1
  251. ? 'typeface1'
  252. : item.watermark_info.typeface == 2
  253. ? 'typeface2'
  254. : item.watermark_info.typeface == 3
  255. ? 'typeface3'
  256. : item.watermark_info.typeface == 4
  257. ? 'typeface4'
  258. : item.watermark_info.typeface == 5
  259. ? 'typeface5'
  260. : item.watermark_info.typeface == 6
  261. ? 'typeface6'
  262. : '',
  263. }"
  264. >
  265. <image
  266. :src="BASE_URL + item.watermark_info.image"
  267. mode=""
  268. v-if="
  269. item.watermark_info.image && item.watermark_info.type == 1
  270. "
  271. ></image>
  272. <text
  273. v-if="
  274. item.watermark_info.water_text &&
  275. item.watermark_info.type == 3
  276. "
  277. >{{ item.watermark_info.water_text }}</text
  278. >
  279. </view>
  280. </view>
  281. <view
  282. class="watermark1"
  283. :style="{
  284. left:
  285. item.watermark_info.waterPos == 0
  286. ? 0 + item.watermark_info.xx + 'px'
  287. : item.watermark_info.waterPos == 1
  288. ? 0 + item.watermark_info.xx + 'px'
  289. : item.watermark_info.waterPos == 4
  290. ? 0 + item.watermark_info.voffset + 'px'
  291. : item.watermark_info.waterPos == 7
  292. ? 0 + item.watermark_info.xx + 'px'
  293. : item.watermark_info.waterPos == 2
  294. ? 'calc( 40%' + ' + ' + item.watermark_info.xx + 'px )'
  295. : item.watermark_info.waterPos == 5
  296. ? 'calc( 40%' +
  297. ' + ' +
  298. item.watermark_info.voffset +
  299. 'px )'
  300. : item.watermark_info.waterPos == 8
  301. ? 'calc( 40%' + ' + ' + item.watermark_info.xx + 'px )'
  302. : '',
  303. top:
  304. item.watermark_info.waterPos == 0
  305. ? 0 + item.watermark_info.yy + 'px'
  306. : item.watermark_info.waterPos == 1
  307. ? 0 + item.watermark_info.yy + 'px'
  308. : item.watermark_info.waterPos == 2
  309. ? 0 + item.watermark_info.yy + 'px'
  310. : item.watermark_info.waterPos == 3
  311. ? 0 + item.watermark_info.yy + 'px'
  312. : item.watermark_info.waterPos == 4
  313. ? '40%'
  314. : item.watermark_info.waterPos == 5
  315. ? '40%'
  316. : item.watermark_info.waterPos == 6
  317. ? '40%'
  318. : '',
  319. right:
  320. item.watermark_info.waterPos == 3
  321. ? 0 + item.watermark_info.xx + 'px'
  322. : item.watermark_info.waterPos == 6
  323. ? 0 + item.watermark_info.waterPos + 'px'
  324. : item.watermark_info.waterPos == 9
  325. ? 0 + item.watermark_info.xx + 'px'
  326. : '',
  327. bottom:
  328. item.watermark_info.waterPos == 7
  329. ? 0 + item.watermark_info.xx + 'px'
  330. : item.watermark_info.waterPos == 8
  331. ? 0 + item.watermark_info.ww + 'px'
  332. : item.watermark_info.waterPos == 9
  333. ? 0 + item.watermark_info.xx + 'px'
  334. : '',
  335. fontWeight: item.watermark_info.bold == 1 ? 'bold' : '',
  336. fontFamily:
  337. item.watermark_info.typeface == 1
  338. ? 'typeface1'
  339. : item.watermark_info.typeface == 2
  340. ? 'typeface2'
  341. : item.watermark_info.typeface == 3
  342. ? 'typeface3'
  343. : item.watermark_info.typeface == 4
  344. ? 'typeface4'
  345. : item.watermark_info.typeface == 5
  346. ? 'typeface5'
  347. : item.watermark_info.typeface == 6
  348. ? 'typeface6'
  349. : '',
  350. }"
  351. v-if="
  352. (item.watermark_info && item.watermark_info.type == 2) ||
  353. (item.watermark_info && item.watermark_info.type == 4)
  354. "
  355. >
  356. <view
  357. class=""
  358. :style="{
  359. transform: 'rotate(' + item.watermark_info.angle + 'deg)',
  360. color: `rgba(${hexToRgb(item.watermark_info.color).rgb},${
  361. (100 - item.watermark_info.opacity * 1) * 0.01
  362. })`,
  363. fontSize: item.watermark_info.text_font + 'px',
  364. }"
  365. >
  366. <image
  367. :src="BASE_URL + item.watermark_info.image"
  368. mode=""
  369. v-if="
  370. item.watermark_info.image && item.watermark_info.type == 2
  371. "
  372. ></image>
  373. <text
  374. v-if="
  375. item.watermark_info.water_text &&
  376. item.watermark_info.type == 4
  377. "
  378. >{{ item.watermark_info.water_text }}</text
  379. >
  380. </view>
  381. </view>
  382. </view>
  383. </view>
  384. </swiper-item>
  385. </swiper>
  386. </view>
  387. <u-overlay :show="show" @click="show = false">
  388. <view class="warp">
  389. <view class="rect" @tap.stop>
  390. <image
  391. :style="{ height: swiperHeight + 'px' }"
  392. :src="url"
  393. mode=""
  394. ></image>
  395. <p>长按保存到本地</p>
  396. </view>
  397. </view>
  398. </u-overlay>
  399. <u-overlay
  400. :show="show2"
  401. @click="show2 = false"
  402. @touchstart="start"
  403. @touchend="end"
  404. @touchmove="move"
  405. >
  406. <view class="warp">
  407. <view class="rect2">
  408. <image src="../../static/swiper1.png" mode=""></image>
  409. <p style="color: #fff">{{ alert2 }}</p>
  410. </view>
  411. </view>
  412. </u-overlay>
  413. <u-overlay :show="show1" @click="show1 = false">
  414. <view class="warp">
  415. <view class="rect1" @tap.stop>
  416. <image src="../../static/warn.png" mode=""></image>
  417. <p>{{ alert1 }}</p>
  418. <u-button
  419. color="#A5CF49"
  420. type="success"
  421. shape="circle"
  422. text="确认收藏"
  423. @click="addFavorite"
  424. ></u-button>
  425. </view>
  426. </view>
  427. </u-overlay>
  428. </view>
  429. </template>
  430. <script setup>
  431. import limeQrcodeVue from "../../uni_modules/lime-qrcode/components/l-qrcode/l-qrcode.vue";
  432. import html2canvas from "html2canvas";
  433. import { BASE_URL, BASE_URL1 } from "../../utils/http.js";
  434. import { onLoad, onShow, onPullDownRefresh } from "@dcloudio/uni-app";
  435. import { nextTick, ref } from "vue";
  436. import {
  437. getsimpleimages,
  438. getplatformeditor,
  439. getplatformmeun,
  440. } from "@/utils/api.js";
  441. let isSave = ref(false);
  442. let show = ref(false);
  443. let show1 = ref(false);
  444. let show2 = ref(false);
  445. let startData = ref({
  446. clientX: "",
  447. clientY: "",
  448. });
  449. let moveX = ref(0);
  450. let touch = ref({});
  451. // let touch=(e)=>{
  452. // console.log(123,e)
  453. // current.value++
  454. // // show2.value = false
  455. // }
  456. // 触摸touch事件
  457. let start = (e) => {
  458. //@touchstart 触摸开始
  459. startData.value.clientX = e.changedTouches[0].clientX; //手指按下时的X坐标
  460. };
  461. let end = (e) => {
  462. //@touchend触摸结束
  463. moveX.value = 0; //触摸事件结束恢复原状
  464. console.log(123, touch.value.clientX - startData.value.clientX);
  465. if (touch.value.clientX - startData.value.clientX > 0) {
  466. //在事件结束时,判断滑动的距离是否达到出发需要执行事件的要求
  467. if (current.value != 0) {
  468. current.value -= 1;
  469. }
  470. } else {
  471. current.value += 1;
  472. // this.touch = {};
  473. }
  474. };
  475. let move = (event) => {
  476. //@touchmove触摸移动
  477. let touch1 = event.touches[0]; //滑动过程中,手指滑动的坐标信息 返回的是Objcet对象
  478. touch.value = touch1;
  479. let data = touch1.clientX - startData.value.clientX;
  480. if (touch1.clientX < startData.value.clientX) {
  481. //向左移动
  482. if (data < -250) {
  483. data = -250;
  484. }
  485. }
  486. if (touch1.clientX > startData.value.clientX) {
  487. //向右移动
  488. if (moveX.value == 0) {
  489. data = 0;
  490. } else {
  491. if (data > 50) {
  492. data = 50;
  493. }
  494. }
  495. }
  496. moveX.value = data;
  497. };
  498. let swiperChange = (e) => {
  499. current.value = e.detail.current;
  500. var dom = document.getElementById("swiperItem" + current.value); // 获取dom元素
  501. if (dom && dom.children[1]) {
  502. swiperHeight.value = 67 + dom.children[1].clientHeight;
  503. } else {
  504. swiperHeight.value = 67;
  505. }
  506. if (current.value == list.value.length - 2) {
  507. page.value += 1;
  508. getsimpleimages({
  509. page: page.value,
  510. page_num: 12,
  511. }).then((res) => {
  512. res.data.forEach((item) => {
  513. item.detail = filterDetail(item.detail);
  514. });
  515. list.value = [...list.value, ...res.data];
  516. // list.value.forEach((item) => {
  517. // item.detail=getspan(item.detail)
  518. // });
  519. });
  520. }
  521. };
  522. let page_num = 1;
  523. let page = ref(1);
  524. let url = ref();
  525. let swiperHeight = ref(67);
  526. let current = ref(0);
  527. let list = ref([]);
  528. let refList = ref([]);
  529. let setBoxRef = (el) => {
  530. if (el) {
  531. refList.value.push(el);
  532. }
  533. };
  534. //收藏网站
  535. // 收藏本站
  536. let addFavorite = () => {
  537. var url = window.location;
  538. var title = "斑马交易平台";
  539. var ua = navigator.userAgent.toLowerCase();
  540. if (ua.indexOf("360se") > -1) {
  541. alert("您的浏览器不支持自动加入收藏,请手动设置!");
  542. } else if (ua.indexOf("msie 8") > -1) {
  543. window.external.AddToFavoritesBar(url, title); //IE8
  544. } else if (document.all) {
  545. //IE类浏览器
  546. try {
  547. window.external.addFavorite(url, title);
  548. } catch (e) {
  549. alert("您的浏览器不支持自动加入收藏,请手动设置!");
  550. }
  551. } else if (window.sidebar) {
  552. //firfox等浏览器;
  553. window.sidebar.addPanel(title, url, "");
  554. } else {
  555. alert("您的浏览器不支持自动加入收藏,请手动设置!");
  556. }
  557. show1.value = false;
  558. };
  559. function filterDetail(str) {
  560. let detail = str.split('<font style="">');
  561. detail = detail.map((item, index) => {
  562. return !index ? item : item.replace("</font>", "");
  563. });
  564. return detail.join("");
  565. }
  566. let takephotos = () => {
  567. var swiper = document.getElementById("copyswiperItem" + current.value); // 获取dom元素
  568. var dom = document.getElementById("content" + current.value); // 获取dom元素
  569. var dom1 = document.getElementById("copycontent" + current.value); // 获取dom元素
  570. dom1.innerHTML = dom.innerHTML;
  571. let res = domTrans(dom1);
  572. let html = forFn(res);
  573. dom1.innerHTML = html;
  574. html2canvas(swiper, {
  575. allowTaint: true,
  576. useCORS: true,
  577. ignoreElements: (e) => {
  578. if (e.contains(swiper) || swiper.contains(e)) {
  579. return false;
  580. }
  581. return true;
  582. },
  583. }).then((canvas) => {
  584. url.value = canvas
  585. .toDataURL("image/png")
  586. .replace("image/png", "image/octet-stream");
  587. show.value = true;
  588. });
  589. };
  590. let alert1 = ref("");
  591. let alert2 = ref("");
  592. let jt_bg1 = ref("");
  593. let jt_bg2 = ref("");
  594. onLoad(() => {
  595. getplatformmeun().then((res) => {
  596. uni.setNavigationBarTitle({
  597. title: res.data.name,
  598. });
  599. jt_bg1.value = res.data.jt_bg1;
  600. jt_bg2.value = res.data.jt_bg2;
  601. });
  602. getplatformeditor().then((res) => {
  603. alert1.value = res.data.alert1;
  604. alert2.value = res.data.alert2;
  605. });
  606. getsimpleimages({
  607. page: page.value,
  608. page_num: 12,
  609. }).then((res) => {
  610. show2.value = true;
  611. res.data.forEach((item) => {
  612. item.detail = filterDetail(item.detail);
  613. });
  614. list.value = res.data;
  615. // list.value.forEach(item=>{
  616. // item.detail=getspan(item.detail)
  617. // })
  618. setTimeout(() => {
  619. var dom = document.getElementById("swiperItem" + current.value); // 获取dom元素
  620. if (dom && dom.children[1]) {
  621. swiperHeight.value = 67 + dom.children[1].clientHeight;
  622. } else {
  623. swiperHeight.value = 67;
  624. }
  625. });
  626. setTimeout(() => {
  627. show2.value = false;
  628. }, 5000);
  629. });
  630. let flag = uni.getStorageSync("collect");
  631. if (!flag) {
  632. show1.value = true;
  633. uni.setStorageSync("collect", true);
  634. }
  635. });
  636. onShow(() => {});
  637. function hexToRgb(val) {
  638. //HEX十六进制颜色值转换为RGB(A)颜色值
  639. // 16进制颜色值的正则
  640. var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  641. // 把颜色值变成小写
  642. var color = val.toLowerCase();
  643. var result = "";
  644. if (reg.test(color)) {
  645. // 如果只有三位的值,需变成六位,如:#fff => #ffffff
  646. if (color.length === 4) {
  647. var colorNew = "#";
  648. for (var i = 1; i < 4; i += 1) {
  649. colorNew += color.slice(i, i + 1).concat(color.slice(i, i + 1));
  650. }
  651. color = colorNew;
  652. }
  653. // 处理六位的颜色值,转为RGB
  654. var colorChange = [];
  655. for (var i = 1; i < 7; i += 2) {
  656. colorChange.push(parseInt("0x" + color.slice(i, i + 2)));
  657. }
  658. result = colorChange.join(",");
  659. return {
  660. rgb: result,
  661. r: colorChange[0],
  662. g: colorChange[1],
  663. b: colorChange[2],
  664. };
  665. } else {
  666. result = "无效";
  667. return {
  668. rgb: result,
  669. };
  670. }
  671. }
  672. function getspan(str) {
  673. // let st=str.replace(new RegExp('font', 'g'), 'span')
  674. var list1 = str.split("</span>");
  675. var list2 = [];
  676. list1.forEach((val) => {
  677. if (val.indexOf("<span") > -1) {
  678. list2.push({
  679. isspan: true,
  680. arr: val.split("<span"),
  681. });
  682. } else {
  683. list2.push({
  684. isspan: false,
  685. arr: val,
  686. });
  687. }
  688. });
  689. var list3 = [];
  690. list2.forEach((val) => {
  691. if (val.isspan) {
  692. list3.push({
  693. ...val,
  694. style: val.arr[1].split(">")[0],
  695. span: val.arr[1].split(">")[1],
  696. });
  697. } else {
  698. list3.push({
  699. ...val,
  700. });
  701. }
  702. });
  703. var html = "";
  704. list3.forEach((val) => {
  705. if (val.isspan) {
  706. html = html + val.arr[0];
  707. var span = "";
  708. for (var a = 0; a < val.span.length; a++) {
  709. span = span + `<span${val.style}>${val.span[a]}</span>`;
  710. }
  711. html = html + span;
  712. } else {
  713. html = html + val.arr;
  714. }
  715. });
  716. return html;
  717. }
  718. onPullDownRefresh(() => {
  719. setTimeout(function () {
  720. uni.stopPullDownRefresh();
  721. }, 1000);
  722. });
  723. // 将DOM转换为js对象
  724. function domTrans(dom) {
  725. // 总dom树
  726. let tree = [];
  727. // 递归, node = 当前的节点,dataNode = 数据插入的节点
  728. const loop = (node, dataNode) => {
  729. // 当前节点的模板
  730. let temp = {
  731. type: node.nodeType,
  732. };
  733. // 如果是文本节点 或 单标签节点
  734. if (temp.type == 3 && node.nodeValue.match(/\S/)) {
  735. temp["content"] = node.nodeValue;
  736. temp["tag"] = node.nodeName;
  737. dataNode.push(temp);
  738. }
  739. // 元素节点
  740. if (temp.type == 1) {
  741. let attributes = getAttribute(node);
  742. // 如果没有属性,不添加 attributes
  743. if (attributes) temp["attributes"] = attributes;
  744. var newNode = node.childNodes;
  745. var newNode2;
  746. if (newNode[0] && newNode.length <= 1) {
  747. newNode2 = newNode[0].childNodes.length;
  748. }
  749. // 当前节点下还有子节点
  750. if (node.childNodes.length > 1 || newNode2 > 0) {
  751. temp["children"] = [];
  752. temp["tag"] = node.nodeName.toLowerCase();
  753. for (let i = 0; i < node.childNodes.length; i++) {
  754. loop(node.childNodes[i], temp.children);
  755. }
  756. }
  757. // 当前节点下只有文本 或 单标签节点
  758. if (node.childNodes.length <= 1 && newNode2 == 0) {
  759. temp["content"] = node.innerHTML;
  760. temp["tag"] = node.nodeName.toLowerCase();
  761. }
  762. dataNode.push(temp);
  763. }
  764. };
  765. loop(dom, tree);
  766. return tree[0].children;
  767. }
  768. function forFn(arr) {
  769. let html = ``;
  770. for (let i = 0; i < arr.length; i++) {
  771. let tArr = [];
  772. if (arr[i].content) {
  773. if (arr[i].content.includes("&nbsp;")) {
  774. let cArr = arr[i].content.split("&nbsp;").map((item) => item.split(""));
  775. let a = cArr.length - 1;
  776. for (let i = 0; i < a; i++) {
  777. cArr.splice(i + 2, 0, "&nbsp;");
  778. }
  779. tArr = cArr.flat();
  780. } else {
  781. tArr = arr[i].content.split("");
  782. }
  783. }
  784. if (arr[i].type === 1) {
  785. if (arr[i].attributes) {
  786. if (arr[i].attributes.src) {
  787. html += `<img class="${arr[i].attributes.class}" src="${arr[i].attributes.src}" style="${arr[i].attributes.style}">`;
  788. } else {
  789. html += `<${arr[i].tag} class="${arr[i].attributes.class}" style="${arr[i].attributes.style}">`;
  790. }
  791. } else {
  792. if (arr[i].tag == "img") {
  793. html += `<${arr[i].tag} style="${arr[i].attributes.style}">`;
  794. } else {
  795. html += `<${arr[i].tag}>`;
  796. }
  797. }
  798. if (arr[i].children) {
  799. html += forFn(arr[i].children);
  800. }
  801. html += `</${arr[i].tag}>`;
  802. }
  803. tArr.forEach((el) => {
  804. if (arr[i].tag === "#text") {
  805. html += `${el}`;
  806. } else {
  807. if (arr[i].attributes) {
  808. if (arr[i].tag == "img") {
  809. html += `<${arr[i].tag} class="${arr[i].attributes.class}" src="${arr[i].attributes.src}" style="${arr[i].attributes.style}">${el}</${arr[i].tag}>`;
  810. } else {
  811. html += `<${arr[i].tag} class="${arr[i].attributes.class}" style="${arr[i].attributes.style}">${el}</${arr[i].tag}>`;
  812. }
  813. } else {
  814. if (arr[i].tag == "img") {
  815. html += `<${arr[i].tag} src="${arr[i].attributes.src}">${el}</${arr[i].tag}>`;
  816. } else {
  817. html += `<${arr[i].tag}>${el}</${arr[i].tag}>`;
  818. }
  819. }
  820. }
  821. });
  822. }
  823. // console.log(html,'====')
  824. return html;
  825. }
  826. // 提取元素属性
  827. function getAttribute(dom) {
  828. let attributes = {};
  829. // let empty = true;
  830. Array.from(dom.attributes).map((item) => {
  831. attributes[item.nodeName] = item.nodeValue;
  832. // empty = false;
  833. });
  834. return attributes;
  835. }
  836. </script>
  837. <style lang="scss">
  838. .typeface1 {
  839. font-family: typeface1;
  840. }
  841. .swiper-itemcopy {
  842. position: absolute;
  843. top: 999px;
  844. }
  845. .content {
  846. padding-left: 10rpx;
  847. padding-right: 10rpx;
  848. word-break: break-all;
  849. word-wrap: break-word;
  850. overflow: hidden;
  851. position: relative;
  852. .watermark {
  853. display: flex;
  854. flex-wrap: wrap;
  855. position: absolute;
  856. top: 0;
  857. left: 0;
  858. right: 0;
  859. // bottom: 0;
  860. image {
  861. width: 100rpx;
  862. height: 100rpx;
  863. }
  864. }
  865. .watermark1 {
  866. position: absolute;
  867. image {
  868. width: 100rpx;
  869. height: 100rpx;
  870. }
  871. }
  872. }
  873. .warp {
  874. padding: 0 28rpx;
  875. display: flex;
  876. align-items: center;
  877. justify-content: center;
  878. height: 100%;
  879. }
  880. .rect {
  881. display: flex;
  882. flex-direction: column;
  883. align-items: center;
  884. width: 694px;
  885. height: auto;
  886. image {
  887. width: 100%;
  888. }
  889. p {
  890. font-size: 48rpx;
  891. color: #fff;
  892. margin-top: 12rpx;
  893. }
  894. // background-color: #fff;
  895. }
  896. @keyframes example1 {
  897. 0% {
  898. transform: translate(0);
  899. }
  900. 50% {
  901. transform: translate(-40px);
  902. }
  903. 100% {
  904. transform: translate(-80px);
  905. }
  906. 0% {
  907. transform: translate(0);
  908. }
  909. }
  910. .rect2 {
  911. display: flex;
  912. flex-direction: column;
  913. align-items: center;
  914. image {
  915. width: 374rpx;
  916. height: 361rpx;
  917. }
  918. transform: translate(0);
  919. animation: example1 1s linear 0s backwards;
  920. animation-iteration-count: infinite;
  921. }
  922. .rect1 {
  923. padding: 60rpx 60rpx;
  924. display: flex;
  925. flex-direction: column;
  926. align-items: center;
  927. width: 558rpx;
  928. // height: 438rpx;
  929. background: #ffffff;
  930. border-radius: 20rpx;
  931. image {
  932. max-width: 96rpx;
  933. max-height: 96rpx;
  934. }
  935. p {
  936. font-size: 30rpx;
  937. margin: 62rpx 0 40rpx;
  938. }
  939. // background-color: #fff;
  940. }
  941. page {
  942. height: 100%;
  943. .btn {
  944. font-size: 35rpx;
  945. color: #fff;
  946. text-align: center;
  947. line-height: 90rpx;
  948. float: right;
  949. width: 200rpx;
  950. height: 90rpx;
  951. background: #a5cf49;
  952. border-radius: 0rpx 0rpx 0rpx 32rpx;
  953. }
  954. .swiperBox {
  955. width: 694rpx;
  956. position: fixed;
  957. top: 50%;
  958. left: 50%;
  959. transform: translate(-50%, -50%);
  960. .swiper-item {
  961. .titleBox {
  962. position: relative;
  963. font-size: 28rpx;
  964. color: #666666;
  965. padding: 6rpx;
  966. display: flex;
  967. align-items: flex-end;
  968. image {
  969. margin-right: 4rpx;
  970. width: 112rpx;
  971. height: 112rpx;
  972. }
  973. .jtbj {
  974. width: 100%;
  975. height: 100%;
  976. position: absolute;
  977. top: 0;
  978. left: 0;
  979. right: 0;
  980. bottom: 0;
  981. z-index: 0;
  982. }
  983. .warn {
  984. font-size: 32rpx;
  985. color: #ff2828;
  986. }
  987. .title {
  988. margin-left: 4rpx;
  989. }
  990. }
  991. }
  992. }
  993. }
  994. </style>