longPosterService.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view>
  3. <view class="poster" id="poster">
  4. <image class="poster-pic" :src="posterBg" mode="widthFix"></image>
  5. <view style="position: absolute;top: 912rpx;left: 50%;transform: translateX(-50%);">
  6. <view style="font-size: 36rpx;font-weight: bold;text-align: center;">合计理赔金额(元)</view>
  7. <view style="font-size: 90rpx;font-weight: bold;color: #FF5700;margin-top: 5rpx;line-height: 126rpx;text-align: center;">340895.2</view>
  8. <view style="font-size: 33rpx;font-weight: bold;margin-top: 78rpx;text-align: center;">理赔概况</view>
  9. <view style="width:522rpx;font-size: 26rpx;font-weight: 400;color: #333;line-height: 48rpx;margin: 17rpx auto 0;">
  10. 这里是理赔经过的概况描述文案这里是理赔经过的概况描述文案这里是理赔经过的概况描述文案这里是理赔经过的概况描述文案这里是理赔经过的概况描述文案这里是理赔经过的概况这里是理赔经过的概况描述文案
  11. </view>
  12. <view class="table-th ddflex">
  13. <view class="table-th-item fflex">赔付事件</view>
  14. <view class="table-th-item fflex">赔付金额</view>
  15. </view>
  16. <view>
  17. <view class="table-td" v-for="item,index in 10">
  18. <view class="ddflex">
  19. <view class="table-td-item fflex">L女士 32岁 福建人 甲状腺癌</view>
  20. <view class="table-td-item">14826元</view>
  21. </view>
  22. <view v-if="index!=10-1" class="table-td-item-border"></view>
  23. </view>
  24. </view>
  25. <view class="ddflex" style="margin-top: 40rpx;">
  26. <view class="flex">
  27. <view class="poster-title">杜平 | 18665676418</view>
  28. <view class="poster-note">扫码即可咨询理赔事宜</view>
  29. </view>
  30. <image class="poster-code" src="https://img.zhiqiyun.com/test/2023/08/23/d44ab2b86522a05ee6bd026cf04ec8bd.png"></image>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="ddflex" style="margin: 30rpx 0 10rpx;justify-content: space-between;">
  35. <view class="ddflex">
  36. <view class="option ddflex" @click="uploadImage">
  37. <image mode="aspectFit" src="../static/images/opt1.png"></image>
  38. 更换背景
  39. </view>
  40. <view class="line"></view>
  41. <view class="option ddflex" @click="jumpUrl('/library/longPosterContent/longPosterContent')">
  42. <image mode="aspectFit" src="../static/images/opt2.png"></image>
  43. 编辑内容
  44. </view>
  45. </view>
  46. <view class="option-btn" @click="toImg">发布</view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. const app = getApp();
  52. const req = require("../../utils/request.js");
  53. import html2canvas from '../static/html2canvas.min.js';
  54. export default {
  55. components: {},
  56. props: {},
  57. data() {
  58. return {
  59. systems: {},
  60. isTop:0,
  61. productLink:'',
  62. posterBg:'',
  63. base64:''
  64. }
  65. },
  66. onLoad(options) {
  67. this.posterBg = 'https://img.zhiqiyun.com/test/2023/08/23/e5705790f7614ebede4c06073b7abd50.png'
  68. },
  69. onShow() {
  70. },
  71. methods: {
  72. jumpUrl(url){
  73. uni.navigateTo({
  74. url:url
  75. })
  76. },
  77. creatCode(){
  78. },
  79. toImg() {
  80. // 使页面滑到顶部,避免顶部出现白边
  81. uni.pageScrollTo({
  82. scrollTop: 0,
  83. duration: 0
  84. })
  85. var dom = document.querySelector('#poster'); // 获取dom元素
  86. html2canvas(dom, {
  87. width: dom.clientWidth, //dom 原始宽度
  88. height: dom.clientHeight,
  89. scrollY: 0, // html2canvas默认绘制视图内的页面,需要把scrollY,scrollX设置为0
  90. scrollX: 0,
  91. useCORS: true, //支持跨域,但好像没什么用
  92. }).then((canvas) => {
  93. // 将生产的canvas转为base64图片
  94. this.base64 = canvas.toDataURL('image/png')
  95. console.log(this.base64)
  96. uni.downloadFile({
  97. url: this.base64, //仅为示例,并非真实的资源
  98. success: (res) => {
  99. console.log(res)
  100. if (res.statusCode === 200) {
  101. console.log('下载成功');
  102. var oA = document.createElement("a");
  103. oA.download = ''; // 设置下载的文件名,默认是'下载'
  104. oA.href = res.tempFilePath; //临时路径再保存到本地
  105. document.body.appendChild(oA);
  106. oA.click();
  107. oA.remove(); // 下载之后把创建的元素删除
  108. }
  109. }
  110. });
  111. });
  112. },
  113. uploadImage(){
  114. let that = this;
  115. let count = 1
  116. uni.chooseImage({
  117. count: count,
  118. sizeType: ['original', 'compressed'],
  119. sourceType: ['album', 'camera'],
  120. success: function({ tempFilePaths }) {
  121. var promise = Promise.all(
  122. tempFilePaths.map(tempFilePath => {
  123. return new Promise(function(resolve, reject) {
  124. req.uploadFile('/api/nocheck/upload', tempFilePath, res => {
  125. that.posterBg = res.src
  126. });
  127. });
  128. })
  129. );
  130. promise
  131. .then(function(results) {
  132. console.log(results);
  133. })
  134. .catch(function(err) {
  135. console.log(err);
  136. });
  137. }
  138. });
  139. },
  140. },
  141. mounted() {
  142. const systemInfo = uni.getSystemInfoSync();
  143. // px转换到rpx的比例
  144. let pxToRpxScale = 750 / systemInfo.windowWidth;
  145. let systems = {
  146. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  147. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  148. };
  149. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  150. this.systems = systems;
  151. },
  152. onPageScroll: function(e) {
  153. if (e.scrollTop > this.systems.barHeight) {
  154. this.isTop = 1;
  155. } else {
  156. this.isTop = 0;
  157. }
  158. }
  159. }
  160. </script>
  161. <style>
  162. @import "./longPosterService.css";
  163. </style>