recruitStudents.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <!-- 招生简章 -->
  2. <template>
  3. <view class="recruit">
  4. <!-- 导航栏 -->
  5. <u-navbar title="" :background="background" title-color="#fff" back-icon-color="#fff">
  6. <view class="navbar-right" slot="right" @click="downloadFile(info)" v-if="info.regulation_file">
  7. <u-image src="../../static/img/attachment.png" width="26" height="28" />
  8. <text>下载附件</text>
  9. </view>
  10. </u-navbar>
  11. <view class="recruit-content">
  12. <view class="recruit-content-name">{{ info.schoolName }}</view>
  13. <view class="recruit-content-box">
  14. <u-parse :html="info.content"></u-parse>
  15. </view>
  16. </view>
  17. <u-popup v-model="show" mode="center" :mask-close-able="false" border-radius="20" :closeable="closeable" width="300rpx" height="300rpx">
  18. <view class="progress">
  19. <u-circle-progress type="primary" :percent="downloadProgress" duration="100">
  20. <view>{{ downloadProgress }}%</view>
  21. </u-circle-progress>
  22. </view>
  23. </u-popup>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. background: {
  31. backgroundColor: '#496857'
  32. },
  33. info: {
  34. schoolName: '',
  35. content: '',
  36. regulation_file: ''
  37. },
  38. downloadProgress: 0,
  39. show: false,
  40. closeable: false
  41. }
  42. },
  43. onLoad(page) {
  44. if (page.id) {
  45. this.info.schoolName = page.name;
  46. this.getSchoolIntroduction(page.id);
  47. }
  48. },
  49. methods: {
  50. /**
  51. * @param {Object} id
  52. */
  53. getSchoolIntroduction(id) {
  54. this.$u.api.school.getSchoolIntroduction({ id }).then(res => {
  55. if (res.code === 200) {
  56. this.info.content = res.data.regulation
  57. this.info.regulation_file = res.data.regulation_file
  58. }
  59. })
  60. },
  61. downloadFile(info) {
  62. this.show = true
  63. this.closeable = false
  64. const downloadTask = uni.downloadFile({
  65. url: info.regulation_file,
  66. success: (e) => {
  67. if (e.statusCode === 200) {
  68. console.log('下载成功', e.tempFilePaths)
  69. this.closeable = true
  70. }
  71. },
  72. fail: (err) => {
  73. console.log(err)
  74. }
  75. });
  76. downloadTask.onProgressUpdate((res) => {
  77. console.log('下载进度' + res.progress);
  78. this.downloadProgress = res.progress
  79. console.log('已经下载的数据长度' + res.totalBytesWritten);
  80. console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
  81. });
  82. }
  83. }
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. @import './recruitStudents.scss';
  88. </style>