share.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <view class="bt-tip">
  3. <view class="down" @click="drewImage">
  4. <view class="" >
  5. 保存图片
  6. </view>
  7. </view>
  8. <view id="shareImage" >
  9. <view class="border" :style="{'min-height':Height+'px'}">
  10. <view class="content">
  11. <view class="title_1" >
  12. <text>{{list.setCity}}</text>>>><text>{{list.reachCity}}</text>
  13. </view>
  14. <view class="title_2">
  15. {{list.title}}
  16. </view>
  17. <view class="text_1">
  18. <parse :content="list.body"></parse>
  19. <!-- 对于在湖北入境的人员,实施“14+14”的健康管理措施。即14天集中隔离医学观察,期间进行2次核酸检测和1次抗体检测;集中隔离医学观察期满后再实施14天居家医学观察,期间进行两次核酸检测。入境人员隔离点应在隔离对象隔离期满前3天,将隔离人员相关信息通知其地新冠肺炎疫情防控指挥部,以便当地落实居家医学观察。
  20. 天居家医学观察,期间进行两次核酸检测。入境人员隔离点应在隔离对象隔离期满前3天,将隔离人员相关信息通知其地新冠肺炎疫情防控指挥部,以便当地落实居家医学观察。 -->
  21. </view>
  22. <view class="tip_share">
  23. <view class="left_share">
  24. <image src="../../images/erwei.jpg" mode=""></image>
  25. </view>
  26. <view class="right_share">
  27. <view class="">
  28. 数据来源(可点击,数据来源列表)
  29. </view>
  30. <view class="">
  31. <text>xxxx</text>城市疫情防控指挥中心
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <image class="btimg" src="../../images/btimg.png" mode=""></image>
  37. <image src="../../images/icon6.png" mode="" class="icon"></image>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import html2canvas from '@/static/html/js/html2canvas.js';
  44. import parse from '../../uParse-master/src/wxParse.vue'
  45. export default {
  46. data() {
  47. return {
  48. list: "",
  49. Height:""
  50. }
  51. },
  52. onLoad(options) {
  53. this.list = JSON.parse(options.list)
  54. console.log(this.list, 'pppp')
  55. uni.getSystemInfo({
  56. success: (res) => {
  57. this.Height=res.windowHeight
  58. }
  59. })
  60. },
  61. components: {
  62. parse
  63. },
  64. methods: {
  65. drewImage() {
  66. html2canvas(document.querySelector('#shareImage'), {
  67. useCORS: true,
  68. }).then(canvas => {
  69. let previewFile = canvas.toDataURL('image/png');
  70. this.download(previewFile)
  71. });
  72. },
  73. download(url) {
  74. var oA = document.createElement("a");
  75. oA.download = ''; // 设置下载的文件名,默认是'下载'
  76. oA.href = url;
  77. document.body.appendChild(oA);
  78. oA.click();
  79. oA.remove(); // 下载之后把创建的元素删除
  80. },
  81. }
  82. }
  83. </script>
  84. <style>
  85. page {
  86. height: 100%;
  87. }
  88. #size {
  89. margin: 30px;
  90. background-color: #00BFFF;
  91. }
  92. .border {
  93. /* width: 100%; */
  94. position: relative;
  95. /* min-height:100vh; */
  96. padding: 0 15px;
  97. padding-top: 50px;
  98. padding-bottom: 40px;
  99. /* height: 600px; */
  100. background: linear-gradient(180deg, #1E37EB 0%, #0FC6A1 100%);
  101. }
  102. .down{
  103. position: fixed;
  104. bottom :0;
  105. height: 100upx;
  106. line-height: 100upx;
  107. width: 100vh;
  108. text-align: center;
  109. z-index: 9999999999999;
  110. }
  111. .down view{
  112. width: 20%;
  113. text-align: center;
  114. font-size: 30upx;
  115. height: 80upx;
  116. line-height: 80upx;
  117. margin-left: 15%;
  118. color: #FFFFFF;
  119. border-radius: 12upx;
  120. background-color: rgba(255,255,255,0.3);
  121. }
  122. .content {
  123. padding: 45px 17px;
  124. background-color: #FFFFFF;
  125. border-radius: 12px;
  126. margin-bottom: 170px;
  127. }
  128. .btimg {
  129. position: absolute;
  130. left: 0;
  131. bottom: 0;
  132. }
  133. .icon {
  134. position: absolute;
  135. top: 23px;
  136. right: 15px;
  137. height: 80px;
  138. width: 80px;
  139. }
  140. .title_1 {
  141. text-align: center;
  142. font-size: 26px;
  143. font-weight: bold;
  144. line-height: 88px;
  145. color: #23459D;
  146. opacity: 1;
  147. }
  148. .title_2 {
  149. text-align: center;
  150. font-size: 20px;
  151. font-weight: bold;
  152. line-height: 34px;
  153. color: #333333;
  154. opacity: 1;
  155. margin-top: 10px;
  156. margin-bottom: 20px;
  157. }
  158. .text_1 {
  159. font-size: 14px;
  160. font-weight: 400;
  161. line-height: 21px;
  162. color: #333333;
  163. opacity: 1;
  164. }
  165. .tip_share {
  166. display: flex;
  167. margin-top: 32px;
  168. }
  169. .left_share {
  170. flex: 1;
  171. }
  172. .left_share image {
  173. height: 60px;
  174. width: 60px;
  175. margin-left: 30px;
  176. /* right: 17px; */
  177. }
  178. .right_share {
  179. text-align: right;
  180. margin-top: 8px;
  181. font-size: 14px;
  182. font-weight: 400;
  183. line-height: 21px;
  184. color: #333333;
  185. opacity: 1;
  186. }
  187. </style>
  188. <!-- <template>
  189. <view class="border">
  190. <canvas style='width:100%; height:700px;' canvas-id="firstCanvas" id="firstCanvas"></canvas>
  191. </view>
  192. </template>
  193. <script>
  194. export default {
  195. data() {
  196. return{
  197. wHwidth:'',
  198. wHheight:''
  199. }
  200. },
  201. onReady: function(e) {
  202. uni.getSystemInfo({
  203. success: function (res) {
  204. console.log(res.model);
  205. console.log(res.pixelRatio);
  206. console.log(res.windowWidth);
  207. console.log(res.windowHeight);
  208. this.wHwidth=res.windowWidth
  209. this.wHheight=res.windowHeight
  210. console.log(res.language);
  211. console.log(res.version);
  212. console.log(res.platform);
  213. }
  214. });
  215. // context.fillText('郑州郑州回安阳过年需要隔离吗郑州回安阳过年需要隔离吗郑州回安阳过年需要隔离吗郑州回安阳过年需要隔离吗安阳', 50, 150)
  216. var str =
  217. "郑州郑州回安阳过年需要隔离吗郑州回安阳过年需要隔离吗郑州回安阳过年需要隔离吗郑州回安阳过年需要隔离吗安阳郑州郑州回安阳过年需要隔离吗郑州回安阳过年需要隔离吗郑州回安阳过年需要隔离吗郑州回安阳过年需要隔离吗安阳";
  218. // this.fenGeString(str, 25);
  219. let meber= str.length / 10
  220. let he=meber*20
  221. console.log(he,'he')
  222. var flag = 10;
  223. var arr = [];
  224. var count = 0;
  225. var context = uni.createCanvasContext('firstCanvas')
  226. context.setStrokeStyle("#00ff00")
  227. context.setLineWidth(2)
  228. context.rect(10, 10, 320, 700)
  229. context.stroke()
  230. context.drawImage('../../static/img/bg.png', 0,0 , this.wHwidth, he)
  231. context.drawImage('../../static/img/btimg.png', 0, 530, this.wHwidth, he) //底部图片
  232. context.beginPath()
  233. context.rect(40, 50, 300,he+150)
  234. context.setFillStyle('#FFFFFF')
  235. context.fill()
  236. context.setFontSize(28)
  237. context.setFillStyle('#23459D')
  238. // context.fillText('郑州>>安阳', 115, 100)
  239. context.fillText('郑州>>安阳', uni.upx2px(350) - context.measureText('郑州>>安阳').width / 2, 100)
  240. context.setFontSize(18)
  241. context.setFillStyle('#000000')
  242. context.fillText('郑州回安阳过年需要隔离吗', uni.upx2px(350) - context.measureText('郑州回安阳过年需要隔离吗').width / 2, 130)
  243. context.setFontSize(14)
  244. for (var i = 0, len = str.length / 10; i < len; i++) {
  245. var str1 = str.substr(0, 20);
  246. str = str.replace(str1, '');
  247. console.log(str1,'ppp')
  248. let height=i*25 + 170
  249. context.fillText(str1, 50, height)
  250. // return;
  251. }
  252. context.drawImage('../../static/img/erwei.jpg', 60, he+100, 70, 80)
  253. context.draw()
  254. },
  255. methods: {
  256. }
  257. // import html2convas from "../../static/html2canvas.js"
  258. // export default{
  259. // data(){
  260. // return{
  261. // }
  262. // },
  263. // onShow(){
  264. // console.log('ewewewe')
  265. // let dom = document.querySelector('shareImage');
  266. // new html2canvas(dom).then(canvas => {
  267. // // canvas为转换后的Canvas对象
  268. // let oImg = new Image();
  269. // oImg.src = canvas.toDataURL(); // 导出图片
  270. // document.body.appendChild(oImg); // 将生成的图片添加到body
  271. // console.log('ewewewe')
  272. // });
  273. // }
  274. // }
  275. }
  276. </script>
  277. <style>
  278. /* page {
  279. height: 100vh;
  280. }
  281. .body {
  282. position: relative;
  283. padding: 0 30upx;
  284. padding-top: 100upx;
  285. padding-bottom: 80upx;
  286. background: linear-gradient(180deg, #1E37EB 0%, #0FC6A1 100%);
  287. }
  288. .content {
  289. padding: 90upx 34upx;
  290. background-color: #FFFFFF;
  291. border-radius: 24upx;
  292. margin-bottom: 300upx;
  293. }
  294. .btimg {
  295. position: absolute;
  296. left: 0;
  297. bottom: 0;
  298. }
  299. .icon {
  300. position: absolute;
  301. top: 46upx;
  302. right: 30upx;
  303. height: 160upx;
  304. width: 160upx;
  305. }
  306. .title_1 {
  307. text-align: center;
  308. font-size: 52upx;
  309. font-weight: bold;
  310. line-height: 88upx;
  311. color: #23459D;
  312. opacity: 1;
  313. }
  314. .title_2 {
  315. text-align: center;
  316. font-size: 40upx;
  317. font-weight: bold;
  318. line-height: 68upx;
  319. color: #333333;
  320. opacity: 1;
  321. margin-top: 20upx;
  322. margin-bottom: 40upx;
  323. }
  324. .text_1 {
  325. font-size: 28upx;
  326. font-weight: 400;
  327. line-height: 42upx;
  328. color: #333333;
  329. opacity: 1;
  330. }
  331. .tip_share {
  332. display: flex;
  333. margin-top: 64upx;
  334. }
  335. .left_share {
  336. flex: 1;
  337. }
  338. .left_share image {
  339. height: 120upx;
  340. width: 120upx;
  341. margin-left: 106upx;
  342. right: 34upx;
  343. }
  344. .right_share {
  345. text-align: right;
  346. margin-top: 15upx;
  347. font-size: 28upx;
  348. font-weight: 400;
  349. line-height: 42upx;
  350. color: #333333;
  351. opacity: 1;
  352. } */
  353. </style>
  354. -->