feedback.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view class="container index">
  3. <nav-header :showback='true' :rightIcon="false" :rightText="'反馈列表'" :showright="true" @rightClick="rightClick">
  4. 意见反馈</nav-header>
  5. <textarea name="" v-model="content" id="textare" cols="30" rows="10" maxlength="500"
  6. placeholder="请输入您的意见(500字以内)"></textarea>
  7. <view class="contact">
  8. <view class="">
  9. 联系方式
  10. </view>
  11. <view class="">
  12. {{phone}}
  13. </view>
  14. </view>
  15. <!-- 上传图片部分 -->
  16. <view class="pic">
  17. <view class="">
  18. 上传图片
  19. </view>
  20. <view class="">
  21. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  22. :maxCount="10"></u-upload>
  23. </view>
  24. </view>
  25. <!-- 上传图片部分 结束-->
  26. <!-- 提交按钮 -->
  27. <view class="btn" @click="subcontent">
  28. 提交
  29. </view>
  30. <!-- 提交按钮 结束-->
  31. </view>
  32. </template>
  33. <script>
  34. import navHeader from "@/components/my/nav_header.vue"
  35. export default {
  36. components: {
  37. navHeader
  38. },
  39. data() {
  40. return {
  41. fileList1: [],
  42. uploadList1: [],
  43. content: "",
  44. phone: ""
  45. }
  46. },
  47. onLoad() {
  48. this.phone = uni.getStorageSync('user_info').phone
  49. },
  50. methods: {
  51. rightClick() {
  52. this.$api.to('/pages/my/feedback/Feedback/Feedback')
  53. },
  54. subcontent() {
  55. // console.log(this.uploadList1)
  56. this.api.feedback(this.uploadList1, this.content).then(res => {
  57. if (res.code == 1) {
  58. uni.showToast({
  59. title: "提交成功"
  60. })
  61. setTimeout(() => {
  62. this.fileList1 = []
  63. this.uploadList1 = []
  64. this.content = ''
  65. }, 500)
  66. }
  67. console.log(res)
  68. })
  69. },
  70. deletePic(event) {
  71. this[`fileList${event.name}`].splice(event.index, 1)
  72. this[`uploadList${event.name}`].splice(event.index, 1)
  73. },
  74. // 新增图片
  75. async afterRead(event) {
  76. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  77. let lists = [].concat(event.file)
  78. let fileListLen = this[`fileList${event.name}`].length
  79. lists.map((item) => {
  80. this[`fileList${event.name}`].push({
  81. ...item,
  82. status: 'uploading',
  83. message: '上传中'
  84. })
  85. })
  86. for (let i = 0; i < lists.length; i++) {
  87. const result = await this.uploadFilePromise(lists[i].url)
  88. let item = this[`fileList${event.name}`][fileListLen]
  89. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  90. status: 'success',
  91. message: '',
  92. url: result
  93. }))
  94. fileListLen++
  95. }
  96. },
  97. async uploadFilePromise(url) {
  98. this.$api.upload(url)
  99. console.log(await this.$api.upload(url))
  100. this.uploadList1.push(await this.$api.upload(url))
  101. },
  102. }
  103. }
  104. </script>
  105. <style scoped>
  106. .index {
  107. box-sizing: border-box;
  108. padding-top: 100rpx;
  109. display: flex;
  110. flex-direction: column;
  111. }
  112. #textare {
  113. width: 710rpx;
  114. height: 500rpx;
  115. background: #1D1F1E;
  116. border-radius: 16rpx;
  117. margin: 24rpx auto;
  118. box-sizing: border-box;
  119. padding: 20rpx;
  120. }
  121. .contact {
  122. width: 710rpx;
  123. height: 88rpx;
  124. border-radius: 16rpx;
  125. display: flex;
  126. justify-content: space-between;
  127. box-sizing: border-box;
  128. padding: 0 54rpx 0 30rpx;
  129. background: #1D1F1E;
  130. margin: 24rpx auto;
  131. line-height: 88rpx;
  132. font-size: 30rpx;
  133. }
  134. .pic {
  135. width: 710rpx;
  136. /* height: 250rpx; */
  137. background: #1D1F1E;
  138. border-radius: 16rpx;
  139. margin: 0 auto;
  140. box-sizing: border-box;
  141. padding: 30rpx;
  142. font-size: 28rpx;
  143. color: #999999;
  144. }
  145. .pic>view:nth-child(2) {
  146. margin-top: 16rpx;
  147. margin-right: 30rpx;
  148. }
  149. .btn {
  150. width: 710rpx;
  151. height: 88rpx;
  152. text-align: center;
  153. line-height: 88rpx;
  154. border-radius: 16rpx;
  155. background: linear-gradient(180deg, #69FF60 0%, #0C9D5B 100%);
  156. font-size: 32rpx;
  157. letter-spacing: 2rpx;
  158. font-weight: 400;
  159. color: #000;
  160. margin: 60rpx auto;
  161. }
  162. </style>