details.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <view class="container qualifications" :style="{ paddingBottom: isIphoneX ? '68rpx' : '0' }">
  3. <view class="remarks-content">
  4. <view class="list-view-title"> <view class="list-view-h1">文字备注</view> </view>
  5. <view class="remarks-textarea"> {{ remarksParams.remarks }} </view>
  6. <view class="list-view-title" v-if="remarksParams.imageList.length>0"> <view class="list-view-h1">图片</view> </view>
  7. <view class="list-view-upload clearfix" v-if="remarksParams.imageList.length>0">
  8. <view class="photo-item" v-for="(image, imageIndex) in remarksParams.imageList" :key="imageIndex">
  9. <image
  10. :src="image"
  11. mode="aspectFill"
  12. @click.stop="previewImg(remarksParams.imageList, imageIndex)"
  13. ></image>
  14. </view>
  15. </view>
  16. <view class="list-view-title" v-if="remarksParams.fileList.length>0"> <view class="list-view-h1">文件</view> </view>
  17. <view class="list-view" v-for="(file, fileIndex) in remarksParams.fileList" :key="fileIndex" v-if="remarksParams.fileList.length>0">
  18. <view class="list-view-text">
  19. <view class="input">{{ file.fileName }}</view>
  20. <view class="delbtn" @click.stop="previewFile(file)">预览</view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import { mapState, mapMutations } from 'vuex'
  28. import authorize from '@/common/config/authorize.js'
  29. import { uploadFileImage, uploadFilePdfDocDocx } from '@/services/public.js'
  30. var isPreviewImg
  31. export default {
  32. data() {
  33. return {
  34. isIphoneX: this.$store.state.isIphoneX,
  35. productActions: [],
  36. remarksParams: {},
  37. remarksId:0
  38. }
  39. },
  40. onLoad(option) {
  41. console.log(option)
  42. this.remarksId = option.remarksId
  43. this.getUserClubRemarksDetail()
  44. },
  45. methods: {
  46. ...mapMutations(['login']),
  47. getUserClubRemarksDetail() {
  48. //资料详情
  49. this.UserService.getUserClubRemarksDetail({
  50. remarksId: this.remarksId
  51. })
  52. .then(response => {
  53. this.remarksParams = response.data
  54. })
  55. .catch(error => {
  56. this.$util.msg(error.msg, 2000)
  57. })
  58. },
  59. previewImg(image, index) {
  60. //顶部商品图片预览
  61. isPreviewImg = true
  62. let previewUrls = image
  63. uni.previewImage({
  64. current: index, //图片索引
  65. urls: previewUrls, //必须是http图片,本地图片无效
  66. longPressActions: ''
  67. })
  68. },
  69. previewFile(file){//预览文件
  70. this.openDocument(file)
  71. },
  72. openDocument(file) {// 打开文档
  73. uni.showLoading({
  74. title:'加载中'
  75. })
  76. // 获取文件后缀
  77. const index = file.fileName.lastIndexOf('.')
  78. const suffix = file.fileName.substring(index + 1)
  79. // 下载文件
  80. uni.downloadFile({
  81. url: file.fileUrl,
  82. success(res) {
  83. const filePath = res.tempFilePath
  84. console.log(filePath)
  85. // 打开文件
  86. uni.openDocument({
  87. filePath: filePath,
  88. fileType: suffix,
  89. success(res) {
  90. uni.showToast({
  91. icon:'success',
  92. title:'打开成功',
  93. duration: 1200
  94. })
  95. uni.hideLoading()
  96. },
  97. fail(err) {
  98. if(err.errMsg.indexOf('fail filetype not supported')){
  99. uni.showModal({
  100. content: '不支持的文件预览',
  101. cancelColor: '#666',
  102. confirmColor: '#E15616'
  103. })
  104. }
  105. uni.hideLoading()
  106. }
  107. })
  108. },
  109. fail(err){
  110. uni.showToast({
  111. title: JSON.stringify(err),
  112. icon:'none',
  113. duration: 5000
  114. })
  115. uni.hideLoading()
  116. },
  117. })
  118. }
  119. },
  120. onShow() {}
  121. }
  122. </script>
  123. <style lang="scss">
  124. page {
  125. height: auto;
  126. background: #ffffff;
  127. }
  128. .remarks-content {
  129. width: 100%;
  130. height: auto;
  131. box-sizing: border-box;
  132. padding: 0 24rpx;
  133. padding-bottom: 80rpx;
  134. .list-view-title {
  135. width: 100%;
  136. height: auto;
  137. margin-bottom: 16rpx;
  138. margin-top: 40rpx;
  139. .list-view-h1 {
  140. line-height: 40rpx;
  141. font-size: $font-size-28;
  142. color: #333333;
  143. text-align: left;
  144. }
  145. }
  146. .remarks-textarea {
  147. width: 100%;
  148. height: 340rpx;
  149. padding: 16rpx;
  150. margin: 20rpx 0 0 0;
  151. border-radius: 6rpx;
  152. position: relative;
  153. border: 1px solid #b2b2b2;
  154. box-sizing: border-box;
  155. overflow-y: scroll;
  156. line-height: 38rpx;
  157. font-size: $font-size-26;
  158. color: #333333;
  159. }
  160. .list-view {
  161. width: 100%;
  162. height: auto;
  163. margin-top: 20rpx;
  164. .list-view-text {
  165. width: 100%;
  166. float: left;
  167. .input {
  168. width: 560rpx;
  169. height: 50rpx;
  170. box-sizing: border-box;
  171. line-height: 50rpx;
  172. color: #333333;
  173. text-overflow: ellipsis;
  174. overflow: hidden;
  175. display: -webkit-box;
  176. -webkit-line-clamp: 1;
  177. line-clamp: 1;
  178. -webkit-box-orient: vertical;
  179. float: left;
  180. font-size: 26rpx;
  181. }
  182. .delbtn{
  183. width: 96rpx;
  184. height: 44rpx;
  185. border-radius: 8rpx;
  186. background-color: #fff2ec;
  187. font-size: $font-size-24;
  188. color: #e15616;
  189. line-height: 44rpx;
  190. text-align: center;
  191. float: left;
  192. }
  193. }
  194. }
  195. .list-view-upload {
  196. width: 100%;
  197. height: auto;
  198. .photo-item {
  199. display: inline-block;
  200. width: 112rpx;
  201. height: 112rpx;
  202. margin: 10rpx 0;
  203. margin-right: 25rpx;
  204. border-radius: 10rpx;
  205. border: 1px solid #f5f5f5;
  206. position: relative;
  207. float: left;
  208. image {
  209. width: 112rpx;
  210. height: 112rpx;
  211. border-radius: 10rpx;
  212. }
  213. }
  214. .photo-list {
  215. width: 100%;
  216. height: 116rpx;
  217. overflow: hidden;
  218. white-space: nowrap;
  219. display: flex;
  220. align-items: flex-start;
  221. }
  222. }
  223. }
  224. </style>