鸿宇研学生前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

399 lines
17 KiB

2 months ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
2 months ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 months ago
3 days ago
2 months ago
3 days ago
2 months ago
2 months ago
3 days ago
3 days ago
2 days ago
3 days ago
2 months ago
3 days ago
2 days ago
3 days ago
2 months ago
3 days ago
2 months ago
3 days ago
2 months ago
3 days ago
2 days ago
2 months ago
3 days ago
2 months ago
2 days ago
2 months ago
3 days ago
2 months ago
3 days ago
2 months ago
2 months ago
2 days ago
3 days ago
2 months ago
3 days ago
3 days ago
3 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
2 days ago
3 days ago
  1. <template>
  2. <div id="app" class="page__view">
  3. <div class="card">
  4. <div class="report" :style="style">
  5. <!-- 01 -->
  6. <view class="export">
  7. <img class="img fg" :src="configList.report_page_01" crossorigin=anonymous />
  8. </view>
  9. <!-- 02 -->
  10. <view class="export">
  11. <img class="img fg" :src="configList.report_page_02" crossorigin=anonymous />
  12. </view>
  13. <!-- 03 -->
  14. <view class="export">
  15. <img class="img" :src="configList.report_page_03" crossorigin=anonymous />
  16. <img class="img fg" style="top: 122rpx; left: 144rpx; width: 132rpx; height: 165rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  17. <div class="text" style="top: 128rpx; left: 330rpx;">姓名</div>
  18. <div class="text" style="top: 128rpx; left: 476rpx;">性别</div>
  19. <div class="text" style="top: 192rpx; left: 330rpx;">年龄</div>
  20. <div class="text" style="top: 192rpx; left: 476rpx;">学段</div>
  21. <div class="text" style="top: 256rpx; left: 330rpx;">学校</div>
  22. <div class="text" style="top: 300rpx; left: 190rpx;">城市</div>
  23. <div class="text" style="top: 344rpx; left: 220rpx;">出勤情况</div>
  24. </view>
  25. <!-- 04 -->
  26. <view class="export">
  27. <img class="img fg" style="top: 112rpx; left: 193rpx; width: 414rpx; height: 246rpx; border-radius: 12rpx; overflow: hidden;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  28. <img class="img fg" :src="configList.report_page_04" crossorigin=anonymous />
  29. </view>
  30. <!-- 05 -->
  31. <view class="export">
  32. <img class="img fg" style="top: 344rpx; left: 100rpx; width: 96rpx; height: 96rpx; transform: rotate(14deg);" src="@/static/image/temp-20.png" crossorigin=anonymous />
  33. <img class="img fg" style="top: 278rpx; left: 20rpx; width: 96rpx; height: 96rpx; transform: rotate(-7deg);" src="@/static/image/temp-14.png" crossorigin=anonymous />
  34. <img class="img fg" style="top: 49rpx; left: 92rpx; width: 118rpx; height: 118rpx; transform: rotate(15deg);" src="@/static/image/temp-20.png" crossorigin=anonymous />
  35. <img class="img fg" style="top: 134rpx; left: 138rpx; width: 118rpx; height: 118rpx; transform: rotate(-6deg);" src="@/static/image/temp-14.png" crossorigin=anonymous />
  36. <img class="img fg" style="top: 194rpx; left: 316rpx; width: 134rpx; height: 134rpx; transform: rotate(-14deg);" src="@/static/image/temp-20.png" crossorigin=anonymous />
  37. <img class="img fg" style="top: 280rpx; left: 430rpx; width: 134rpx; height: 134rpx; transform: rotate(14deg);" src="@/static/image/temp-14.png" crossorigin=anonymous />
  38. <img class="img fg" style="top: 40rpx; left: unset; right: -38rpx; width: 213rpx; height: 213rpx; transform: rotate(14deg);" src="@/static/image/temp-20.png" crossorigin=anonymous />
  39. <img class="img fg" :src="configList.report_page_05" crossorigin=anonymous />
  40. </view>
  41. <!-- 06 -->
  42. <view class="export">
  43. <img class="img fg" style="top: 190rpx; left: 146rpx; width: 126rpx; height: 80rpx; transform: skew(50deg, -34deg);" src="@/static/image/temp-20.png" crossorigin=anonymous />
  44. <img class="img fg" style="top: 176rpx; left: 390rpx; width: 110rpx; height: 96rpx; transform: skew(50deg, 317deg);" src="@/static/image/temp-20.png" crossorigin=anonymous />
  45. <img class="img fg" style="top: 120rpx; left: 276rpx; width: 110rpx; height: 74rpx; transform: skew(50deg, -34deg);" src="@/static/image/temp-14.png" crossorigin=anonymous />
  46. <img class="img fg" style="top: 280rpx; left: 260rpx; width: 148rpx; height: 96rpx; transform: skew(54deg, 324deg);" src="@/static/image/temp-14.png" crossorigin=anonymous />
  47. <img class="img fg" :src="configList.report_page_06" crossorigin=anonymous />
  48. </view>
  49. <!-- 07 -->
  50. <view class="export">
  51. <img class="img fg" style="top: 86rpx; left: 168rpx; width: 154rpx; height: 118rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  52. <img class="img fg" style="top: 86rpx; left: 326rpx; width: 154rpx; height: 118rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  53. <img class="img fg" style="top: 86rpx; left: 478rpx; width: 154rpx; height: 118rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  54. <img class="img fg" style="top: 244rpx; left: 138rpx; width: 226rpx; height: 154rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  55. <img class="img fg" style="top: 244rpx; left: 402rpx; width: 226rpx; height: 154rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  56. <img class="img fg" :src="configList.report_page_07" crossorigin=anonymous />
  57. </view>
  58. <!-- 08 -->
  59. <view class="export">
  60. <img class="img fg" style="top: 76rpx; left: 112rpx; width: 110rpx; height: 110rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  61. <img class="img fg" style="top: 194rpx; left: 112rpx; width: 110rpx; height: 110rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  62. <img class="img fg" style="top: 76rpx; left: 242rpx; width: 110rpx; height: 110rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  63. <img class="img fg" style="top: 194rpx; left: 242rpx; width: 110rpx; height: 110rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  64. <img class="img fg" style="top: 312rpx; left: 242rpx; width: 110rpx; height: 110rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  65. <img class="img fg" style="top: 138rpx; left: 372rpx; width: 110rpx; height: 110rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  66. <img class="img fg" style="top: 258rpx; left: 372rpx; width: 110rpx; height: 110rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  67. <img class="img fg" style="top: 194rpx; left: 504rpx; width: 110rpx; height: 110rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  68. <img class="img fg" style="top: 312rpx; left: 504rpx; width: 110rpx; height: 110rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  69. <img class="img fg" :src="configList.report_page_08" crossorigin=anonymous />
  70. </view>
  71. <!-- 09 -->
  72. <view class="export">
  73. <img class="img fg" style="top: 0; left: unset; right: 0; width: auto; height: 100%;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  74. <img class="img fg" style="width: 260rpx; height: 180rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  75. <img class="img img-08 fg" :src="configList.report_page_09" crossorigin=anonymous />
  76. </view>
  77. <!-- 10 -->
  78. <view class="export">
  79. <img class="img fg" style="top: 126rpx; left: 106rpx; width: 158rpx; height: 106rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  80. <img class="img fg" style="top: 132rpx; left: 450rpx; width: 148rpx; height: 100rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  81. <img class="img fg" style="top: 132rpx; left: 604rpx; width: 90rpx; height: 100rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  82. <img class="img fg" style="top: 238rpx; left: 54rpx; width: 210rpx; height: 140rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  83. <img class="img fg" style="top: 242rpx; left: 450rpx; width: 122rpx; height: 80rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  84. <img class="img fg" style="top: 242rpx; left: 576rpx; width: 120rpx; height: 200rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  85. <img class="img fg" style="top: 326rpx; left: 270rpx; width: 156rpx; height: 106rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  86. <img class="img fg" style="top: 68rpx; left: 274rpx; width: 170rpx; height: 256rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  87. <img class="img fg" :src="configList.report_page_10" crossorigin=anonymous />
  88. </view>
  89. <!-- 11 -->
  90. <view class="export">
  91. <img class="img fg" style="top: unset; bottom: 268rpx; left: 54rpx; width: 118rpx; height: 80rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  92. <img class="img fg" style="top: unset; bottom: 268rpx; left: 180rpx; width: 78rpx; height: 110rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  93. <img class="img fg" style="top: unset; bottom: 268rpx; left: 262rpx; width: 210rpx; height: 160rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  94. <img class="img fg" style="top: 240rpx; left: 54rpx; width: 170rpx; height: 142rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  95. <img class="img fg" style="top: 240rpx; left: 380rpx; width: 118rpx; height: 80rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  96. <img class="img fg" :src="configList.report_page_11" crossorigin=anonymous />
  97. </view>
  98. <!-- 12 -->
  99. <view class="export">
  100. <img class="img fg" style="top: 130rpx; left: 122rpx; width: 80rpx; height: 100rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  101. <img class="img fg" style="top: 130rpx; left: 224rpx; width: 80rpx; height: 100rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  102. <img class="img fg" style="top: 130rpx; left: 328rpx; width: 80rpx; height: 100rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  103. <img class="img fg" style="top: 130rpx; left: 432rpx; width: 80rpx; height: 100rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  104. <img class="img fg" style="top: 130rpx; left: 536rpx; width: 80rpx; height: 100rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  105. <img class="img fg" style="top: 264rpx; left: 122rpx; width: 80rpx; height: 100rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  106. <img class="img fg" style="top: 264rpx; left: 224rpx; width: 80rpx; height: 100rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  107. <img class="img fg" style="top: 264rpx; left: 328rpx; width: 80rpx; height: 100rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  108. <img class="img fg" style="top: 264rpx; left: 432rpx; width: 80rpx; height: 100rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  109. <img class="img fg" style="top: 264rpx; left: 536rpx; width: 80rpx; height: 100rpx;" src="@/static/image/temp-14.png" crossorigin=anonymous />
  110. <img class="img fg" :src="configList.report_page_12" crossorigin=anonymous />
  111. </view>
  112. <!-- 13 -->
  113. <view class="export">
  114. <img class="img" :src="configList.report_page_13" crossorigin=anonymous />
  115. <div class="text text-12" style="top: 134rpx; left: 160rpx;">技能01</div>
  116. <div class="text text-12" style="top: 134rpx; left: 260rpx;">技能01描述</div>
  117. <div class="text text-12" style="top: 182rpx; left: 160rpx;">技能02</div>
  118. <div class="text text-12" style="top: 182rpx; left: 260rpx;">技能02描述</div>
  119. <div class="text text-12" style="top: 232rpx; left: 160rpx;">技能03</div>
  120. <div class="text text-12" style="top: 232rpx; left: 260rpx;">技能03描述</div>
  121. <div class="text text-12" style="top: 282rpx; left: 160rpx;">技能04</div>
  122. <div class="text text-12" style="top: 282rpx; left: 260rpx;">技能04描述</div>
  123. <div class="text text-12" style="top: 330rpx; left: 160rpx;">技能05</div>
  124. <div class="text text-12" style="top: 330rpx; left: 260rpx;">技能05描述</div>
  125. </view>
  126. <!-- 14 -->
  127. <view class="export">
  128. <img class="img fg" :src="configList.report_page_14" crossorigin=anonymous />
  129. <div class="text text-13" style="top: 150rpx; left: 116rpx;">同学寄语同学寄语同学寄语同学寄语同学寄语同学寄语同学寄语同学寄语</div>
  130. <div class="text text-13" style="top: 260rpx; left: 400rpx;">导师寄语导师寄语导师寄语导师寄语导师寄语导师寄语导师寄语导师寄语导师寄语</div>
  131. </view>
  132. <!-- 15 -->
  133. <view class="export">
  134. <img class="img fg" style="top: 46rpx; left: unset; right: 30rpx; width: 506rpx; height: 390rpx;" src="@/static/image/temp-20.png" crossorigin=anonymous />
  135. <img class="img fg" :src="configList.report_page_15" crossorigin=anonymous />
  136. </view>
  137. <!-- 00 -->
  138. <view class="export">
  139. <img class="img fg" :src="configList.report_page_00" crossorigin=anonymous />
  140. </view>
  141. </div>
  142. </div>
  143. <img v-if="current > 0" class="img turn left" src="@/static/image/icon-left.png" @click="prev" />
  144. <img v-if="current < 15" class="img turn right" src="@/static/image/icon-right.png" @click="next" />
  145. <div class="flex bottom">
  146. <button class="btn" @click="createPdf">生成pdf</button>
  147. </div>
  148. </div>
  149. </template>
  150. <script>
  151. import html2canvas from 'html2canvas'
  152. import { jsPDF } from "jspdf";
  153. export default {
  154. data() {
  155. return {
  156. id: null,
  157. details: {},
  158. current: 0,
  159. }
  160. },
  161. computed: {
  162. style() {
  163. return `transform: translateX(calc(-${this.current}*(100vw - 24rpx * 2)))`
  164. },
  165. },
  166. onLoad(arg) {
  167. document.addEventListener('UniAppJSBridgeReady', function() {
  168. console.log('UniAppJSBridgeReady', uni)
  169. uni.getEnv(function(res) {
  170. console.log('当前环境:' + JSON.stringify(res));
  171. });
  172. })
  173. const { id, token } = arg
  174. token && uni.setStorageSync('token', token)
  175. this.id = id
  176. },
  177. mounted() {
  178. this.getData(this.id)
  179. },
  180. methods: {
  181. getData(id) {
  182. // todo
  183. },
  184. prev() {
  185. this.current -= 1
  186. },
  187. next() {
  188. this.current += 1
  189. },
  190. createPdf() {
  191. uni.showLoading({
  192. title: '生成中...'
  193. })
  194. console.log('createPdf')
  195. const fillPage = () => {
  196. // 设置背景色
  197. PDF.setFillColor(251, 254, 255); // 例如,红色背景
  198. // 绘制一个填充的矩形覆盖整个页面
  199. PDF.rect(0, 0, PDF.internal.pageSize.getWidth(), PDF.internal.pageSize.getHeight(), 'F'); // 'F'表示填充
  200. }
  201. let PDF = new jsPDF('l', 'pt', 'a4')
  202. console.log('PDF', PDF)
  203. console.log('size', PDF.internal.pageSize.getWidth(), PDF.internal.pageSize.getHeight())
  204. const WIDTH = PDF.internal.pageSize.getWidth() // 841.89
  205. const HEIGHT = PDF.internal.pageSize.getHeight() // 595.28
  206. let request = []
  207. let nodeList = document.querySelectorAll('.export')
  208. for(let i = 0; i < nodeList.length; i++) {
  209. request.push(html2canvas(nodeList[i], { allowTaint: true, useCORS: true, }))
  210. }
  211. return Promise.allSettled(request).then(res => {
  212. console.log('res', res)
  213. fillPage()
  214. res.forEach((item, index) => {
  215. if (index > 0) {
  216. PDF.addPage()
  217. fillPage()
  218. }
  219. const canvas = item.value
  220. let pageData = canvas.toDataURL('image/jpeg', 1.0)
  221. PDF.addImage(pageData, 'JPEG', 0, 0, WIDTH, HEIGHT)
  222. })
  223. // #ifdef H5
  224. console.log('env: h5')
  225. PDF.save('测试生成pdf' + '.pdf'); //h5在这就可以保存pdf
  226. // #endif
  227. return
  228. uni.postMessage({
  229. data: {
  230. imageData: PDF.output("datauristring"),
  231. }
  232. });
  233. // uni.navigateBack()
  234. uni.redirectTo({
  235. url: `/pages_order/thesis/createPdf?id=${this.id}`
  236. })
  237. }).catch(err => {
  238. console.log('err', err)
  239. }).finally(() => {
  240. uni.hideLoading()
  241. })
  242. },
  243. }
  244. }
  245. </script>
  246. <style lang="scss" scoped>
  247. $pages: 16;
  248. $w: calc(100vw - 24rpx * 2);
  249. $h: calc(#{$w} / 841.89 * 595.28);
  250. .page__view {
  251. width: 100vw;
  252. min-height: 100vh;
  253. background: #F7F8FA;
  254. position: relative;
  255. box-sizing: border-box;
  256. font-family: PingFang SC;
  257. font-weight: 400;
  258. line-height: 1.4;
  259. }
  260. .card {
  261. position: absolute;
  262. top: 50vh;
  263. transform: translateY(-50%);
  264. width: $w;
  265. margin: 0 24rpx;
  266. padding: 250rpx 0;
  267. overflow: hidden;
  268. background: #FFFFFF;
  269. }
  270. .report {
  271. width: calc(#{$pages}*#{$w});
  272. height: auto;
  273. overflow-x: visible;
  274. }
  275. .export {
  276. position: relative;
  277. display: inline-block;
  278. width: $w;
  279. min-height: $h;
  280. overflow: hidden;
  281. }
  282. .fg {
  283. position: absolute;
  284. top: 0;
  285. left: 0;
  286. }
  287. .img {
  288. display: block;
  289. width: $w;
  290. height: auto;
  291. &-08 {
  292. width: auto;
  293. height: $h;
  294. }
  295. }
  296. .text {
  297. position: absolute;
  298. font-size: 20rpx;
  299. font-weight: 600;
  300. color: #FFFFFF;
  301. &-12 {
  302. font-size: 14rpx;
  303. color: #000000;
  304. }
  305. &-13 {
  306. width: 206rpx;
  307. white-space: pre-wrap;
  308. font-size: 14rpx;
  309. color: #000000;
  310. }
  311. }
  312. // .export__view {
  313. // position: fixed;
  314. // top: 100vh;
  315. // }
  316. .turn {
  317. width: 80rpx;
  318. height: 80rpx;
  319. position: fixed;
  320. top: 50vh;
  321. transform: translateY(-50%);
  322. &.left {
  323. left: 0;
  324. }
  325. &.right {
  326. right: 0;
  327. }
  328. }
  329. .bottom {
  330. position: fixed;
  331. left: 0;
  332. bottom: 0;
  333. width: 100vw;
  334. background: #FFFFFF;
  335. box-sizing: border-box;
  336. padding: 32rpx 40rpx;
  337. padding-bottom: calc(env(safe-area-inset-bottom) + 32rpx);
  338. box-sizing: border-box;
  339. .btn {
  340. width: 100%;
  341. padding: 14rpx 0;
  342. font-family: PingFang SC;
  343. font-weight: 500;
  344. font-size: 36rpx;
  345. line-height: 1.4;
  346. color: #FFFFFF;
  347. background: linear-gradient(to right, #21FEEC, #019AF9);
  348. border: 2rpx solid #00A9FF;
  349. border-radius: 41rpx;
  350. }
  351. }
  352. </style>