certificate.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="pages">
  3. <view class="container" id="wrapper">
  4. <view class="image-wrapper draw">
  5. <image :src="$getimg+'cqtanhui-cert.jpg'" class="draw page-bg" mode="scaleToFill"></image>
  6. </view>
  7. <view class="draw cart-no">证书编号:{{item.credentialNo}}</view>
  8. <view class="cart-text cart-name">
  9. 尊敬的 {{item.customerName}}:
  10. </view>
  11. <view class="cart-text">
  12. 感谢您对“碳汇+”生态产品价值实现的支持,您购买了{{item.year}}年度碳汇量{{item.carbonAmount}}kg,您购碳资金{{item.orderAmount}}元,已全额转入{{item.farmerName}}的银行账户。
  13. </view>
  14. <view class="cart-text">
  15. 该笔碳汇可用于抵消您的碳排放
  16. </view>
  17. <view class="cart-text">
  18. 感谢您为生态文明建设和全球应对气候变化所做出的贡献
  19. </view>
  20. <!-- <text class="title draw" data-text="Hello there">Hello there</text>
  21. <text class="info draw" data-text="小程序是一种新的开放能力,开发者可以快速地开发一个小程序。">
  22. 小程序是一种新的开放能力,开发者可以快速地开发一个小程序。
  23. </text>
  24. <view class="image-wrapper draw">
  25. <image class="draw" :src="$getimg + 'guide02.png'"/>
  26. <image class="draw" src="../../../../static/img/icon_use_active.png"/>
  27. </view> -->
  28. <!-- <button class="generate-btn" @click="drawCanvas">generate</button> -->
  29. </view>
  30. <canvas canvas-id="canvas" class="share-canvas"></canvas>
  31. </view>
  32. </template>
  33. <script>
  34. const wxml2canvas = require('@/utils/wxml2canvas.js');
  35. export default {
  36. data() {
  37. return {
  38. $getimg:this.$getimg,
  39. thetoken:'',
  40. orderid:'',
  41. item:[],
  42. params:{
  43. }
  44. }
  45. },
  46. onShow() {
  47. },
  48. onLoad(e) {
  49. this.thetoken = 'Bearer' + ' ' + this.$store.state.token;
  50. this.orderid = e.orderid;
  51. uni.showLoading({
  52. title: '正在获取证书信息'
  53. });
  54. this.$api.http.get(this.config.apiBaseurl + '/carbon-h5/wap/order/getCredentialByOrderId?orderId='+this.orderid,{
  55. header: {
  56. Accept:'application/json',
  57. Authorization: this.thetoken,
  58. },
  59. }).then(res => {
  60. uni.hideLoading();
  61. // this.info = Object.assign(this.info, data);
  62. // this.info.url = '/static/html2canvas/index.html?key=' + this.orderid;
  63. this.item = res.data.retBody;
  64. console.log('res',JSON.parse(JSON.stringify(res.data.retBody)));
  65. }).catch(err =>{
  66. console.log('err',err)
  67. });
  68. },
  69. methods: {
  70. drawCanvas: function() {
  71. const wrapperId = '#wrapper'
  72. const drawClassName = '.draw'
  73. const canvasId = 'canvas'
  74. wxml2canvas(wrapperId, drawClassName, canvasId).then(() => {
  75. uni.showLoading({
  76. title: '生成中'
  77. });
  78. uni.canvasToTempFilePath({
  79. x: 0,
  80. y: 0,
  81. // width: 500,
  82. // height: 500,
  83. // destWidth: 100,
  84. // destHeight: 100,
  85. canvasId: 'canvas',
  86. success: function(res) {
  87. uni.hideLoading();
  88. uni.showLoading({
  89. title: '保存中'
  90. });
  91. console.log(res.tempFilePath);
  92. uni.saveImageToPhotosAlbum({
  93. filePath:res.tempFilePath,
  94. success:function(res){
  95. uni.hideLoading();
  96. }
  97. })
  98. }
  99. })
  100. // canvas has been drawn
  101. // can save the image with wx.canvasToTempFilePath and wx.saveImageToPhotosAlbum
  102. })
  103. }
  104. }
  105. }
  106. </script>
  107. <style>
  108. @import url("./certificate.css");
  109. </style>