more.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view>
  3. <view style="padding: 8rpx;">
  4. <span style="font-size:40rpx; font-weight: bold">
  5. 活动详情
  6. </span>
  7. <hs-show label="活动类别" :data="data.eventType" labelSize="6" valueSize="18"></hs-show>
  8. <hs-show label="名称" :data="data.eventName" labelSize="4" valueSize="20"></hs-show>
  9. <hs-show label="地点" :data="data.eventPlaceSite" labelSize="4" valueSize="20"></hs-show>
  10. <hs-show label="社团群组" :data="data.clubName" labelSize="6" valueSize="18"></hs-show>
  11. <hs-show label="活动开始时间" :data="data.eventStartTime" labelSize="8" valueSize="16"></hs-show>
  12. <hs-show label="活动结束时间" :data="data.eventEndTime" labelSize="8" valueSize="16"></hs-show>
  13. <hs-show label="人数限制" :data="data.limitNum"></hs-show>
  14. </view>
  15. <view style="padding: 8rpx;">
  16. <span style="font-size:40rpx; font-weight: bold">
  17. 场地详情
  18. </span>
  19. <view v-html="data.placeMore" style="padding: 10rpx;">
  20. </view>
  21. </view>
  22. <view style="padding: 8rpx;">
  23. <uni-row>
  24. <uni-col :span="6">
  25. <span style="font-size:40rpx; font-weight: bold">
  26. 活动风采
  27. </span>
  28. </uni-col>
  29. <uni-col :span="18">
  30. </uni-col>
  31. </uni-row>
  32. <view style="padding: 30rpx;" v-if="!disabled">
  33. <view>
  34. <u-upload @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="999"
  35. uploadIcon="plus-circle">
  36. <image src="../static/img/upload.png" mode="widthFix" style="width: 150px;height: auto;">
  37. </image>
  38. </u-upload>
  39. </view>
  40. <view style="margin: 30rpx 0;overflow-y: auto;">
  41. <u-upload :fileList="fileList" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  42. :maxCount="999" width="120" height="120" uploadIcon="plus-circle" disabled>
  43. </u-upload>
  44. </view>
  45. </view>
  46. <view v-else v-html="imgData" style="padding: 5rpx;">
  47. </view>
  48. </view>
  49. <view style="height: 40rpx;">
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import hsShow from "../components/show.vue"
  55. export default {
  56. components: {
  57. hsShow
  58. },
  59. data() {
  60. return {
  61. id: uni.getStorageSync("eventId"),
  62. data: {},
  63. scrollTop: 0,
  64. imgData: '',
  65. imgHTML1: '<p><img src="',
  66. imgHTML2: '" style="max-width:100%;height:auto;"></p>',
  67. fileList: [],
  68. disabled: false
  69. }
  70. },
  71. onLoad() {
  72. if (uni.getStorageSync("isUpload") === 0) {
  73. this.disabled = true
  74. } else {
  75. this.disabled = false
  76. }
  77. },
  78. onShow() {
  79. this.submitMore()
  80. this.getMein()
  81. },
  82. onPageScroll(e) {
  83. this.scrollTop = e.scrollTop
  84. },
  85. methods: {
  86. async submitMore() {
  87. const {
  88. data: res
  89. } = await this.$httpRequest({
  90. url: '/app/more?eventId=' + this.id,
  91. method: 'get',
  92. urlType: this.$getUrlType()
  93. });
  94. if (res.code === 200) {
  95. this.data = res.data
  96. this.data.placeMore = this.data.placeMore.replace(/<img/g,
  97. "<img style='max-width:100%;height:auto;'");
  98. // this.data.mien = this.data.mien.replace(/<img/g,
  99. // "<img style='max-width:100%;height:auto;'");
  100. }
  101. },
  102. getMein() {
  103. this.$httpRequest({
  104. url: '/app/eventsImg?eventId=' + this.id,
  105. method: 'get',
  106. urlType: this.$getUrlType()
  107. }).then(res => {
  108. if (res.data.code === 200) {
  109. this.fileList = res.data.data
  110. this.fileList.forEach(item => {
  111. this.imgData += this.imgHTML1 + item.url + this.imgHTML2
  112. })
  113. }
  114. })
  115. },
  116. // 新增图片
  117. async afterRead(event) {
  118. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  119. let lists = [].concat(event.file)
  120. let fileListLen
  121. if (this.fileList) {
  122. fileListLen = this.fileList.length
  123. } else {
  124. this.fileList = []
  125. fileListLen = 0
  126. }
  127. lists.map((item) => {
  128. this.fileList.push({
  129. ...item,
  130. status: 'uploading',
  131. message: '上传中'
  132. })
  133. })
  134. for (let i = 0; i < lists.length; i++) {
  135. const result = await this.uploadFilePromise(lists[i].url)
  136. let item = this.fileList[fileListLen]
  137. this.fileList.splice(fileListLen, 1, result)
  138. fileListLen++
  139. }
  140. // uni.setStorageSync("listImg", this.fileList)
  141. console.log(this.fileList)
  142. },
  143. // 删除图片
  144. deletePic(event) {
  145. this.fileList.splice(event.index, 1)
  146. },
  147. uploadFilePromise(url) {
  148. return new Promise((resolve, reject) => {
  149. let header = {
  150. "Authorization": "Bearer " + uni.getStorageSync('token'),
  151. "eventId": this.id
  152. }
  153. let a = uni.uploadFile({
  154. url: this.$BASE_URL + '/app/eventImg/upload', // 仅为示例,非真实的接口地址
  155. filePath: url,
  156. name: 'file',
  157. header: header,
  158. success: (res) => {
  159. // console.log(JSON.parse(res.data).url);
  160. setTimeout(() => {
  161. resolve(JSON.parse(res.data))
  162. }, 1000)
  163. }
  164. });
  165. })
  166. }
  167. }
  168. }
  169. </script>
  170. <style scoped>
  171. image {
  172. padding: 0;
  173. margin: 0;
  174. /* max-width: 100%;
  175. height: auto; */
  176. }
  177. </style>