details.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. .list-view-title {
  134. width: 100%;
  135. height: auto;
  136. margin-bottom: 16rpx;
  137. margin-top: 40rpx;
  138. .list-view-h1 {
  139. line-height: 40rpx;
  140. font-size: $font-size-28;
  141. color: #333333;
  142. text-align: left;
  143. }
  144. }
  145. .remarks-textarea {
  146. width: 100%;
  147. height: 340rpx;
  148. padding: 16rpx;
  149. margin: 20rpx 0 0 0;
  150. border-radius: 6rpx;
  151. position: relative;
  152. border: 1px solid #b2b2b2;
  153. box-sizing: border-box;
  154. overflow-y: scroll;
  155. line-height: 38rpx;
  156. font-size: $font-size-26;
  157. color: #333333;
  158. }
  159. .list-view {
  160. width: 100%;
  161. height: auto;
  162. margin-top: 20rpx;
  163. .list-view-text {
  164. width: 100%;
  165. float: left;
  166. .input {
  167. width: 560rpx;
  168. height: 50rpx;
  169. box-sizing: border-box;
  170. line-height: 50rpx;
  171. color: #333333;
  172. text-overflow: ellipsis;
  173. overflow: hidden;
  174. display: -webkit-box;
  175. -webkit-line-clamp: 1;
  176. line-clamp: 1;
  177. -webkit-box-orient: vertical;
  178. float: left;
  179. font-size: 26rpx;
  180. }
  181. .delbtn{
  182. width: 96rpx;
  183. height: 44rpx;
  184. border-radius: 8rpx;
  185. background-color: #fff2ec;
  186. font-size: $font-size-24;
  187. color: #e15616;
  188. line-height: 44rpx;
  189. text-align: center;
  190. float: left;
  191. }
  192. }
  193. }
  194. .list-view-upload {
  195. width: 100%;
  196. height: auto;
  197. .photo-item {
  198. display: inline-block;
  199. width: 112rpx;
  200. height: 112rpx;
  201. margin: 10rpx 0;
  202. margin-right: 25rpx;
  203. border-radius: 10rpx;
  204. border: 1px solid #f5f5f5;
  205. position: relative;
  206. float: left;
  207. image {
  208. width: 112rpx;
  209. height: 112rpx;
  210. border-radius: 10rpx;
  211. }
  212. }
  213. .photo-list {
  214. width: 100%;
  215. height: 116rpx;
  216. overflow: hidden;
  217. white-space: nowrap;
  218. display: flex;
  219. align-items: flex-start;
  220. }
  221. }
  222. }
  223. </style>