twxt.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <template>
  2. <view class="border">
  3. <view class="" id="boxImage">
  4. </view>
  5. <view id="shareImage">
  6. <view class="top-border" >
  7. <image src="../../static/img/top.png" class="top">
  8. </image>
  9. <view class="top-content">
  10. <view class="text">
  11. <text class="name">吴根花</text><text>提醒您关注</text>
  12. </view>
  13. <view class="text1">
  14. 全国<text class="diqu">中高风险</text>地区
  15. </view>
  16. <image src="../../static/img/line.png" mode="" class="line"></image>
  17. <view class="text2">
  18. 买房卖房·童叟无欺·就找吴丹花
  19. </view>
  20. <view class="text3">
  21. 联系方式:15836692817
  22. </view>
  23. </view>
  24. </view>
  25. <view class="card">
  26. <view class="card-title">
  27. 统计截止:2020-01-22(全国疫情)
  28. </view>
  29. <view class="card-content">
  30. <view class="con-top">
  31. <view class="con-left">
  32. <view class="nums">
  33. <text class="num1">{{heighNum}}</text>个
  34. </view>
  35. <view class="text_1">
  36. <image src="../../static/img/heigh1.png" class="dian" mode=""></image>
  37. <text>高风险地区</text>
  38. </view>
  39. </view>
  40. <view class="con-left">
  41. <view class="nums">
  42. <text class="num2">{{middleNum}}</text>个
  43. </view>
  44. <view class="text_1">
  45. <image src="../../static/img/middle1.png" class="dian" mode=""></image>
  46. <text>中风险地区</text>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="card-tip">
  51. 其余未列出的均为低风险地区
  52. </view>
  53. </view>
  54. <view class="bt-tip">
  55. 由国家卫生健康委每日15时汇总各地疫情风险等级数据
  56. </view>
  57. </view>
  58. <view class="" @click="saveImage">>
  59. 下载
  60. </view>
  61. <view class="heigh_city" >
  62. <view class="city_title">
  63. <image class="icon" src="../../static/img/heigh.png" mode=""></image>高风险地区<text style="color: #FE0000;font-size: 48upx;">{{heighNum}}</text>个
  64. </view>
  65. <view class="time">
  66. 统计截至:2020-01-20
  67. </view>
  68. <view class="list" v-for="(item, index) in heighCity" :key='index'>
  69. <view class="list-left" style="color: #FE0000;background-color: #FFF4F3;">
  70. <text>{{item.province}}</text>
  71. </view>
  72. <view class="list-right">
  73. <view class="right-text" v-for="(item1,index1) in item.list" :key='index1'>
  74. <view class="text-left">
  75. <view>{{item1.detail}}</view>
  76. </view>
  77. <view class="text-right" style="color:#FE0000;">
  78. {{item1.risk}}
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="heigh_city">
  85. <view class="city_title">
  86. <image src="../../static/img/middle.png" class="icon" mode=""></image>中风险地区<text style="color: #FFB300;font-size: 48upx;">{{middleNum}}</text>个
  87. </view>
  88. <view class="time">
  89. 统计截至:2020-01-20
  90. </view>
  91. <view class="list" v-for="(item, index2) in middleCity" :key='index2'>
  92. <view class="list-left" style="color: #FF9100;background-color: #FCF2E4;">
  93. <text>{{item.province}}</text>
  94. </view>
  95. <view class="list-right">
  96. <view class="right-text" v-for="(item1,index3) in item.list" :key='index3'>
  97. <view class="text-left">
  98. <view>{{item1.detail}}</view>
  99. </view>
  100. <view class="text-right" style="color: #FF9100;">
  101. {{item1.risk}}
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. <view class="bt">
  108. <image src="../../static/html/img/erwei.jpg" mode=""></image>
  109. <view class="save">
  110. 长按图片发给朋友
  111. </view>
  112. <view class="source">
  113. 数据来源:国家卫生健康委提供
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. </template>
  119. <script>
  120. // import html2canvas from '@/static/html/js/test.js';
  121. import html2canvas from '@/static/html/js/html2canvas.js';
  122. export default {
  123. data() {
  124. return {
  125. heighCity: "",
  126. middleCity: "",
  127. heighNum: "",
  128. middleNum: ""
  129. }
  130. },
  131. onLoad() {
  132. uni.request({
  133. url: 'http://epidemic.site.ximengnaikang.com/api/v1/risk/city',
  134. method: 'GET',
  135. success: (res) => {
  136. console.log(res, 'res')
  137. this.heighCity = res.data.data.high.lists
  138. this.middleCity = res.data.data.middle.lists
  139. console.log(this.heighCity, 'heighCity')
  140. console.log(this.middleCity, 'this')
  141. this.heighNum = res.data.data.high_num
  142. this.middleNum = res.data.data.middle_num
  143. }
  144. })
  145. // var ua = window.navigator.userAgent.toLowerCase();
  146. // if (ua.match(/MicroMessenger/i) == 'micromessenger') {
  147. // uni.showLoading({
  148. // title: '图片生成中',
  149. // })
  150. // // this.status = 2
  151. // setTimeout(function() {
  152. // html2canvas(document.querySelector('#shareImage'), {
  153. // scale : 2,
  154. // x: 0, // x坐标
  155. // y: 0, // y坐标
  156. // foreignObjectRendering: true, // 是否在浏览器支持的情况下使用ForeignObject渲染
  157. // async: false, // 是否异步解析和呈现元素
  158. // background: "#ffffff", // 一定要添加背景颜色,否则出来的图片,背景全部都是透明的
  159. // // dpi: 300, // 处理模糊问题
  160. // useCORS: true,
  161. // }).then(imgDom => {
  162. // let previewFile = imgDom.toDataURL('image/png');
  163. // var image = new Image();
  164. // image.src = previewFile;
  165. // image.style.width = '100%';
  166. // document.getElementById('boxImage').appendChild(image);
  167. // });
  168. // uni.hideLoading()
  169. // uni.showToast({
  170. // title: '图片已生成'
  171. // })
  172. // that.isShow = false
  173. // }, 1000)
  174. // // this.drawImage()
  175. // // this.isShow = false
  176. // } else {
  177. // // this.status = 1
  178. // }
  179. },
  180. methods:{
  181. saveImage() {
  182. html2canvas(document.querySelector('#shareImage'), {
  183. useCORS: true,
  184. }).then(canvas => {
  185. let previewFile = canvas.toDataURL('image/png');
  186. this.download(previewFile)
  187. });
  188. },
  189. download(url) {
  190. var oA = document.createElement("a");
  191. oA.download = ''; // 设置下载的文件名,默认是'下载'
  192. oA.href = url;
  193. console.log(url, 'po')
  194. document.body.appendChild(oA);
  195. const event = document.createEvent('MouseEvents');
  196. oA.click();
  197. oA.remove(); // 下载之后把创建的元素删除
  198. }
  199. }
  200. }
  201. </script>
  202. <style>
  203. page {
  204. background-color: #F9F9FB;
  205. }
  206. .border {
  207. position: relative;
  208. z-index: 22;
  209. }
  210. .top-border {
  211. position: relative;
  212. }
  213. .top {
  214. width: 100%;
  215. height: 768upx;
  216. }
  217. .top-content {
  218. position: absolute;
  219. top: 0;
  220. left: 0;
  221. width: 100%;
  222. padding-left: 20upx;
  223. color: #FFFFFF;
  224. z-index: 888;
  225. }
  226. .text {
  227. margin-top: 100upx;
  228. font-size: 52upx;
  229. }
  230. .name {
  231. font-size: 92upx;
  232. color: #FFC86A;
  233. margin-right: 30upx;
  234. }
  235. .text1 {
  236. font-size: 66upx;
  237. margin-left: 20upx;
  238. }
  239. .diqu {
  240. color: #FFC86A;
  241. }
  242. .line {
  243. height: 21upx;
  244. width: 67%;
  245. margin-bottom: 10upx;
  246. margin-top: 10upx;
  247. margin-left: 20upx;
  248. }
  249. .text2 {
  250. font-size: 32upx;
  251. margin-bottom: 20upx;
  252. margin-left: 20upx;
  253. }
  254. .text3 {
  255. width: 70%;
  256. background-color: #FFFFFF;
  257. height: 60upx;
  258. line-height: 60upx;
  259. color: #0158E5;
  260. font-size: 36upx;
  261. margin-left: 10upx;
  262. padding-left: 20upx;
  263. }
  264. .card {
  265. position: relative;
  266. z-index: 10;
  267. background-color: #FFFFFF;
  268. margin: 0 30upx;
  269. background-color: #FFFFFF;
  270. margin-top: -250upx;
  271. border-radius: 15upx;
  272. padding: 30upx;
  273. }
  274. .card-title {
  275. height: 70upx;
  276. line-height: 70upx;
  277. font-size: 28upx;
  278. padding-bottom: 30upx;
  279. }
  280. .card-content {
  281. border-bottom: solid 2upx #EEEEEE;
  282. border-top: solid 2upx #EEEEEE;
  283. }
  284. .con-top {
  285. display: flex;
  286. }
  287. .con-left {
  288. flex: 1;
  289. text-align: center;
  290. }
  291. .nums {
  292. height: 100upx;
  293. line-height: 100upx;
  294. font-size: 36upx;
  295. }
  296. .num1 {
  297. font-size: 48upx;
  298. color: #FE0000;
  299. }
  300. .text_1 {
  301. font-size: 28upx;
  302. /* height: 50upx;
  303. line-height: 50upx; */
  304. }
  305. .dian1 {
  306. height: 24upx;
  307. width: 24upx;
  308. border-radius: 50%;
  309. background: #FE2400;
  310. display: inline-block;
  311. vertical-align: middle;
  312. margin-right: 10upx;
  313. }
  314. .dian2 {
  315. height: 24upx;
  316. width: 24upx;
  317. border-radius: 50%;
  318. background: #FFB300;
  319. display: inline-block;
  320. vertical-align: middle;
  321. margin-right: 10upx;
  322. }
  323. .card-tip {
  324. height: 100upx;
  325. font-size: 28upx;
  326. line-height: 100upx;
  327. text-align: center;
  328. }
  329. .bt-tip {
  330. text-align: center;
  331. font-size: 24upx;
  332. height: 80upx;
  333. line-height: 100upx;
  334. color: #999999;
  335. }
  336. .heigh_city {
  337. margin: 0 30upx;
  338. margin-top: 30upx;
  339. background-color: #FFFFFF;
  340. border-radius: 15upx;
  341. padding: 0 30upx;
  342. padding-bottom: 30upx;
  343. }
  344. .city_title {
  345. height: 100upx;
  346. line-height: 100upx;
  347. font-size: 36upx;
  348. font-weight: bold;
  349. }
  350. .time {
  351. font-size: 28upx;
  352. color: #999999;
  353. height: 50upx;
  354. line-height: 50upx;
  355. }
  356. .list {
  357. display: flex;
  358. margin-top: 40upx;
  359. }
  360. .list-left {
  361. flex: 0 0 72upx;
  362. font-size: 40upx;
  363. font-weight: bold;
  364. padding: 20upx 0;
  365. border-radius: 12upx;
  366. margin-right: 30upx;
  367. min-height: 200upx;
  368. /*文字居中*/
  369. text-align: center;
  370. display: flex;
  371. }
  372. .list-left text {
  373. /*文字竖排*/
  374. margin-left: 10upx;
  375. /* height: 100%; */
  376. writing-mode: vertical-lr;
  377. /*从左向右 从右向左是 writing-mode: vertical-rl;*/
  378. writing-mode: tb-lr;
  379. /*IE浏览器的从左向右 从右向左是 writing-mode: tb-rl;*/
  380. }
  381. .list-right {
  382. flex: 1;
  383. font-size: 28upx;
  384. }
  385. .right-text {
  386. display: flex;
  387. min-height: 60upx;
  388. line-height: 60upx;
  389. width: 100%;
  390. }
  391. .text-left {
  392. flex: 1;
  393. }
  394. .text-left view {
  395. }
  396. .text-right {
  397. flex: 0 0 110upx;
  398. /* background-color: #007AFF; */
  399. text-align: center;
  400. }
  401. .bt {
  402. min-height: 600upx;
  403. position: relative;
  404. margin-top: -200upx;
  405. width: 100%;
  406. z-index: -10;
  407. text-align: center;
  408. background: linear-gradient(180deg, #FFFFFF 0%, #0158E5 54%, #0158E5 100%);
  409. color: #FFFFFF;
  410. padding-bottom: 50upx;
  411. }
  412. .bt image {
  413. margin: 0 auto;
  414. margin-top: 300upx;
  415. height: 300upx;
  416. width: 300upx;
  417. }
  418. .save {
  419. font-size: 36upx;
  420. margin-top: 50upx;
  421. height: 50upx;
  422. line-height: 50upx;
  423. font-weight: bold;
  424. }
  425. .source {
  426. font-size: 28upx;
  427. height: 100upx;
  428. line-height: 100upx;
  429. font-weight: 500;
  430. }
  431. .icon {
  432. display: inline-block;
  433. /* vertical-align: middle; */
  434. height: 36upx;
  435. margin-right: 10upx;
  436. width: 40upx;
  437. }
  438. .dian {
  439. height: 24upx;
  440. width: 24upx;
  441. display: inline-block;
  442. margin-right: 20upx;
  443. }
  444. </style>