certificate.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="content">
  3. <web-view v-if="info.url" class="web-view" :src="info.url"></web-view>
  4. <view class="btns">
  5. <!-- <button class="my-btn" @click="$api.goto('/pages/home/home', '', true)">首页</button> -->
  6. <!-- <button class="my-btn" type="gradient" @tap="$api.goto('/pages/usercenter/certificateList/certificateList')">我的证书</button> -->
  7. <!--#ifdef H5-->
  8. <!-- <button class="my-btn" type="gradient" @tap="share" v-show="$api.clientType.isWeiXin">分享证书</button> -->
  9. <!--#endif-->
  10. </view>
  11. <!--#ifdef H5-->
  12. <!-- <view v-show="showShare" class="share-bg" @tap="showShareFun"></view> -->
  13. <!--#endif-->
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. info: {
  21. url: ''
  22. },
  23. //#ifdef H5
  24. showShare:false,
  25. //#endif
  26. };
  27. },
  28. onLoad(e) {
  29. const data = this.$api.getE();
  30. this.info = Object.assign(this.info, data);
  31. //自定义证书ID字段 orderId
  32. //通过订单id获取证书信息
  33. uni.showLoading({
  34. title: '正在获取证书信息'
  35. });
  36. this.$api
  37. .$http({
  38. url: '/wap/order/getCredentialByOrderId',
  39. data: {
  40. orderId: data.orderId
  41. }
  42. })
  43. .then(res => {
  44. const info = res.data instanceof Object ? res.data : {};
  45. this.info = Object.assign(this.info, res.data);
  46. if (res.code == 0) {
  47. //更新缓存信息
  48. uni.setStorageSync(data.orderId, info);
  49. //调用生成
  50. this.info.url = '/static/html2canvas/index.html?key=' + data.orderId;
  51. } else {
  52. uni.hideLoading();
  53. }
  54. });
  55. },
  56. //标题栏按钮监听
  57. onNavigationBarButtonTap(e) {
  58. this.$api.gohome(e);
  59. },
  60. methods: {
  61. //#ifdef H5
  62. showShareFun(){
  63. this.showShare = !this.showShare;
  64. },
  65. share() {
  66. //显示菜单
  67. this.$wxApi.showMenu();
  68. this.showShareFun();
  69. //注册分享数据
  70. this.$wxApi.share({
  71. orderId: this.info.orderId
  72. });
  73. }
  74. //#endif
  75. }
  76. };
  77. </script>
  78. <style lang="scss">
  79. .content {
  80. .btns {
  81. position: absolute;
  82. top: 88%;
  83. width: 100%;
  84. display: flex;
  85. z-index: 1;
  86. button {
  87. flex: 1;
  88. margin: 0 10% 10% 10%;
  89. }
  90. }
  91. }
  92. .web-view {
  93. box-sizing: border-box;
  94. }
  95. .share-bg{
  96. position: fixed;
  97. z-index: 998;
  98. top: 0;
  99. bottom: 0;
  100. left: 0;
  101. right: 0;
  102. overflow: hidden;
  103. background: rgba(0,0,0,.7);
  104. box-sizing: border-box;
  105. &::after{
  106. content: "";
  107. position: absolute;
  108. top: 0;
  109. bottom: 0;
  110. left: 0;
  111. right: 0;
  112. // background: url(../../../../static/img/share-bg.png) no-repeat top right;
  113. background-size: 80% auto;
  114. }
  115. }
  116. </style>