notice.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view class="notice">
  3. <!-- <custom-nav title="录取通知书"></custom-nav> -->
  4. <view class="canvas_container content">
  5. <!-- <image src="https://api.jiuweiyun.cn/public/uploads/icon/new_tzs.png" mode="" class="bg"></image> -->
  6. <canvas id="canvas" canvas-id="canvas" :style="{ width: canvasWidth + 'px', height: canvasHeight + 'px' }" />
  7. </view>
  8. <!-- <view class="save">(长按保存图片)</view> -->
  9. </view>
  10. </template>
  11. <script>
  12. import { userInfo } from 'os';
  13. import { mapState } from 'vuex';
  14. import userinfo from '../../store/modules/userinfo';
  15. import {
  16. _API_payment,
  17. _API_SearchStatus,
  18. GetEnrollInfo_online
  19. } from '@/apis/szy.js';
  20. export default {
  21. data() {
  22. return {
  23. canvasWidth: 0, //canvas 宽
  24. canvasHeight: 0, //canvas 高
  25. header: '',
  26. headerImg: '',
  27. Image: '../../static/zbs/online71.jpg',
  28. status: 0
  29. };
  30. },
  31. computed: {
  32. ...mapState(['userServerInfo'])
  33. // userServerInfo() {
  34. // return this.$store.state.userServerInfo
  35. // }
  36. },
  37. onShow() {
  38. this.initCanvas()
  39. },
  40. methods: {
  41. initCanvas(cb) {
  42. GetEnrollInfo_online().then(res => {
  43. // uni.hideLoading()
  44. if (res.code != 200) {
  45. uni.showModal({
  46. title: '提示',
  47. content: '检测到您还未报名',
  48. showCancel: false,
  49. success: (res) => {
  50. if (res.confirm) {
  51. uni.reLaunch({
  52. url: '/pages/payment/payment'
  53. });
  54. }
  55. }
  56. })
  57. return
  58. }else{
  59. if(!res.data.pay_status){
  60. uni.showModal({
  61. title: '提示',
  62. content: '检测到您还未报名',
  63. showCancel: false,
  64. success: (res) => {
  65. if (res.confirm) {
  66. uni.reLaunch({
  67. url: '/pages/payment/payment'
  68. });
  69. }
  70. }
  71. })
  72. return
  73. }
  74. }
  75. })
  76. const user = JSON.parse(uni.getStorageSync('userInfo'))
  77. const _this = this
  78. this.header = user.avatar
  79. // const nickname = uni.getStorageSync('nickName').slice(0,8)
  80. const nicknames = user.nickname
  81. // const nicknames = '啥的按'
  82. const nickname = nicknames.slice(0, 5);
  83. // const time = 1710206047000
  84. const time = Number(this.$route.query.time)
  85. // uni.showLoading({
  86. // title: '加载中',
  87. // mask: true
  88. // })
  89. uni.downloadFile({
  90. url: this.header,
  91. success: ({ statusCode, tempFilePath }) => {
  92. if (statusCode === 200) {
  93. this.headerImg = tempFilePath
  94. }
  95. },
  96. fail:(e) => {
  97. uni.showModal({
  98. content: JSON.stringify(e),
  99. showCancel: false
  100. })
  101. },
  102. complete: () => {
  103. // uni.getImageInfo({
  104. // src: this.Image,
  105. // success: res => {
  106. // }
  107. // })
  108. console.log(this.Image)
  109. uni.showLoading() //停止 loading
  110. _this.canvasWidth = uni.upx2px(690);
  111. _this.canvasHeight = uni.upx2px(1227);
  112. let ctx = uni.createCanvasContext('canvas');
  113. ctx.drawImage(this.Image, 0, 0, uni.upx2px(690), uni.upx2px(1227))
  114. ctx.save()
  115. ctx.beginPath()
  116. ctx.arc(uni.upx2px(353), uni.upx2px(574), uni.upx2px(150), 0, 2 * Math.PI, false)
  117. ctx.clip()
  118. ctx.drawImage(_this.headerImg, uni.upx2px(203), uni.upx2px(424), uni.upx2px(300), uni.upx2px(300))
  119. ctx.restore()
  120. ctx.setFontSize(uni.upx2px(120));
  121. ctx.setFillStyle("#0E2D84")
  122. ctx.font = 'normal bold 30px PingFang SC'
  123. ctx.textAlign = "center"
  124. ctx.fillText(nickname, uni.upx2px(350), uni.upx2px(782));
  125. ctx.draw();
  126. uni.hideLoading()
  127. }
  128. })
  129. }
  130. }
  131. };
  132. </script>
  133. <style scoped lang="scss">
  134. .notice {
  135. // @include page();
  136. width: 100%;
  137. height: 100%;
  138. min-height: 100%;
  139. // display: flex;
  140. // justify-content: space-between;
  141. // flex-direction: column;
  142. background-color: #ededed;
  143. .canvas_container {
  144. // flex: 1;
  145. padding: 50rpx 30rpx 0rpx 30rpx;
  146. position: relative;
  147. .bg {
  148. width: 690rpx;
  149. height: 1227rpx;
  150. }
  151. #canvas {
  152. width: 690rpx;
  153. height: 1227rpx;
  154. // position: absolute;
  155. // top: 169rpx;
  156. // bottom: 0;
  157. // left: 30rpx;
  158. // right: 0;
  159. }
  160. }
  161. }
  162. .save {
  163. width: 100%;
  164. text-align: center;
  165. margin-top:10rpx;
  166. }
  167. </style>