homework.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="container">
  3. <!-- 返回按钮 -->
  4. <back text="作业详情"></back>
  5. <view class="detail-item">
  6. <view class="flex" style="width: 100%;height: 90rpx;">
  7. <view class="flex" style="margin: -30rpx 0 0 10rpx;">
  8. <view class="index" :style="{backgroundColor: singleDetail.work.progress === 'finish'? '#23b46c': '#ff8caf' }"></view>
  9. <view class="name">{{singleDetail.work.name}}</view>
  10. </view>
  11. <view class="t-icon t-icon-yiwancheng1" v-if="singleDetail.work.progress === 'finish'"
  12. style="margin-left: auto; width: 90rpx; height: 90rpx;"></view>
  13. <view class="t-icon t-icon-jinhangzhong-copy1" v-if="singleDetail.work.progress === 'going'"
  14. style="margin-left: auto; width: 90rpx; height: 90rpx;"></view>
  15. </view>
  16. <!-- 正文 -->
  17. <view class="content-box">
  18. <view class="flex-colum" style="padding: 0 30rpx;">
  19. <rich-text class="subtitle-info" style="margin-bottom: 15rpx;" :nodes="singleDetail.work.description"></rich-text>
  20. <view class="flex">
  21. <view class="subtitle">布置老师:</view>
  22. <view class="subtitle-info" style="margin-left: 10rpx;">{{singleDetail.work.creatorId}}</view>
  23. <view class="subtitle" style="margin-left: 20rpx;">截止时间:</view>
  24. <view class="subtitle-info" style="margin-left: 10rpx;">{{$timestampToTime(singleDetail.work.endTime)}}</view>
  25. </view>
  26. </view>
  27. <view class="content-detail-box" style="padding: 0 20rpx;">
  28. <view class="title-box" :style="{backgroundColor: singleDetail.work.progress === 'finish'? '#23b46c': '#ff8caf',top: -15 +'rpx' }">
  29. <view class="content-subtitle">作业附件</view>
  30. </view>
  31. <view v-for="(attachment,i) in singleDetail.work.attachments" :key="i" style="margin-bottom: 20rpx;">
  32. <view class="attachment-box" @click="openDocument(attachment.url)">
  33. <view v-if="attachment.type == 'word'" class="t-icon t-icon-WORD"></view>
  34. <view v-if="attachment.type == 'excel'" class="t-icon t-icon-ECEL"></view>
  35. <view v-if="attachment.type == 'pdf'" class="t-icon t-icon-PDF"></view>
  36. <view v-if="attachment.type == 'image'" class="t-icon t-icon-tupianziliao"></view>
  37. <view class="flex-colum" style="margin-left: 20rpx;">
  38. <view class="content-detail">文件名: {{attachment.name}}</view>
  39. <view class="content-subtitle" style="color: #aaa;">文件大小: {{fixNum(attachment.size/8/1024)}}KB</view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. mapState,
  51. mapMutations
  52. } from 'vuex'
  53. export default {
  54. computed: {
  55. ...mapState('m_children', ['singleDetail'])
  56. },
  57. data(){
  58. return{
  59. };
  60. },
  61. onLoad() {
  62. },
  63. methods:{
  64. fixNum(num){
  65. return num.toFixed(2)
  66. },
  67. openDocument(url) {
  68. //下载并打开文档
  69. uni.downloadFile({
  70. url: url,
  71. success: function(res) {
  72. var filePath = res.tempFilePath;
  73. uni.openDocument({
  74. filePath: filePath,
  75. success: function(res) {
  76. console.log('打开文档成功');
  77. }
  78. });
  79. }
  80. })
  81. },
  82. }
  83. }
  84. </script>
  85. <style lang="scss">
  86. @import '@/subpkg/common/detailpage.scss';
  87. .attachment-box{
  88. display: flex;
  89. align-items: center;
  90. padding: 15rpx 20rpx;
  91. background-color: #FFF;
  92. border-radius: 10rpx;
  93. }
  94. .flex-colum{
  95. display: flex;
  96. flex-direction: column;
  97. }
  98. </style>