certificate.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="pages">
  3. <!-- <l-painter :board="base"/> 画板待调试 -->
  4. <view class="container" id="wrapper">
  5. <view class="image-wrapper draw">
  6. <image :src="$getimg+'cqtanhui-cert.jpg'" class="draw page-bg" mode="scaleToFill"></image>
  7. </view>
  8. <view class="draw cart-no">证书编号:{{item.credentialNo}}</view>
  9. <view class="cart-text cart-name">
  10. 尊敬的 {{item.customerName}}:
  11. </view>
  12. <view class="cart-text">
  13. 感谢您对“碳汇+”生态产品价值实现的支持,您购买了{{item.year}}年度碳汇量{{item.carbonAmount}}kg,您购碳资金{{item.orderAmount}}元,已全额转入{{item.farmerName}}的银行账户。
  14. </view>
  15. <view class="cart-text">
  16. 该笔碳汇可用于抵消您的碳排放
  17. </view>
  18. <view class="cart-text">
  19. 感谢您为生态文明建设和全球应对气候变化所做出的贡献
  20. </view>
  21. <!-- <text class="title draw" data-text="Hello there">Hello there</text>
  22. <text class="info draw" data-text="小程序是一种新的开放能力,开发者可以快速地开发一个小程序。">
  23. 小程序是一种新的开放能力,开发者可以快速地开发一个小程序。
  24. </text>
  25. <view class="image-wrapper draw">
  26. <image class="draw" :src="$getimg + 'guide02.png'"/>
  27. <image class="draw" src="../../../../static/img/icon_use_active.png"/>
  28. </view> -->
  29. <!-- <button class="generate-btn" @click="drawCanvas">generate</button> -->
  30. </view>
  31. <canvas canvas-id="canvas" class="share-canvas"></canvas>
  32. </view>
  33. </template>
  34. <script>
  35. import lPainter from '@/components/lime-painter/index.vue';
  36. export default {
  37. components:{
  38. lPainter
  39. },
  40. data() {
  41. return {
  42. $getimg:this.$getimg,
  43. thetoken:'',
  44. orderid:'',
  45. item:[],
  46. params:{
  47. },
  48. base: {
  49. width: '750rpx',
  50. height: '1130rpx',
  51. views: [
  52. {
  53. type: 'image',
  54. src: 'http://fqn.hongweisoft.com/cqcarbon/wxapp/cqtanhui-cert.jpg',
  55. css: {
  56. left: '0rpx',
  57. top: '0rpx',
  58. width: '100%',
  59. height: '1130rpx'
  60. }
  61. },
  62. {
  63. type: 'text',
  64. text: '左对齐,下划线\n无风才到地,有风还满空\n缘渠偏似雪,莫近鬓毛生',
  65. // 可以指定关键字颜色
  66. rules: {
  67. word: ['到地'],
  68. color: 'red'
  69. },
  70. css: {
  71. left: '0rpx',
  72. top: '10rpx',
  73. fontSize: '28rpx',
  74. lineHeight: '36rpx',
  75. textDecoration: 'underline'
  76. }
  77. },
  78. ]
  79. }
  80. }
  81. },
  82. onShow() {
  83. },
  84. onLoad(e) {
  85. this.thetoken = 'Bearer' + ' ' + this.$store.state.token;
  86. this.orderid = e.orderid;
  87. uni.showLoading({
  88. title: '正在获取证书信息'
  89. });
  90. this.$api.http.get(this.config.apiBaseurl + '/carbon-h5/wap/order/getCredentialByOrderId?orderId='+this.orderid,{
  91. header: {
  92. Accept:'application/json',
  93. Authorization: this.thetoken,
  94. },
  95. }).then(res => {
  96. uni.hideLoading();
  97. // this.info = Object.assign(this.info, data);
  98. // this.info.url = '/static/html2canvas/index.html?key=' + this.orderid;
  99. this.item = res.data.retBody;
  100. console.log('res',JSON.parse(JSON.stringify(res.data.retBody)));
  101. }).catch(err =>{
  102. console.log('err',err)
  103. });
  104. },
  105. methods: {
  106. drawCanvas: function() {
  107. const wrapperId = '#wrapper'
  108. const drawClassName = '.draw'
  109. const canvasId = 'canvas'
  110. wxml2canvas(wrapperId, drawClassName, canvasId).then(() => {
  111. uni.showLoading({
  112. title: '生成中'
  113. });
  114. uni.canvasToTempFilePath({
  115. x: 0,
  116. y: 0,
  117. // width: 500,
  118. // height: 500,
  119. // destWidth: 100,
  120. // destHeight: 100,
  121. canvasId: 'canvas',
  122. success: function(res) {
  123. uni.hideLoading();
  124. uni.showLoading({
  125. title: '保存中'
  126. });
  127. console.log(res.tempFilePath);
  128. uni.saveImageToPhotosAlbum({
  129. filePath:res.tempFilePath,
  130. success:function(res){
  131. uni.hideLoading();
  132. }
  133. })
  134. }
  135. })
  136. // canvas has been drawn
  137. // can save the image with wx.canvasToTempFilePath and wx.saveImageToPhotosAlbum
  138. })
  139. }
  140. }
  141. }
  142. </script>
  143. <style>
  144. @import url("./certificate.css");
  145. </style>