feedback.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view class="feedback">
  3. <view class="header-bg"></view>
  4. <view class="header">
  5. <view class="title">
  6. 意见反馈
  7. </view>
  8. </view>
  9. <view class="" style="margin: 0 20upx;">
  10. <view class="">
  11. <label class="label" for="">我要反馈</label>
  12. <view style="background: white;margin: 20upx 0;border-radius: 10upx;">
  13. <view>
  14. <textarea class="textarea" v-model="form.content" placeholder="" maxlength="300" />
  15. </view>
  16. <view class="tips">您还能输入{{300-form.content.length}}个字符</view>
  17. </view>
  18. </view>
  19. <view class="">
  20. <label class="label" for="">上传图片</label>
  21. <view style="background: white;border-radius: 10upx;margin-top: 20upx;">
  22. <view class="images-wrapper">
  23. <view class="image-item" v-for="(image,i) in mainImages">
  24. <view class="del" @tap="mainImages.splice(i,1)">删除</view>
  25. <image class="image" :src="image|imagesFilter" mode="aspectFill" @tap="replaceImage(i)">
  26. </image>
  27. </view>
  28. <view class="image-item" v-if="mainImagesLimit>mainImages.length">
  29. <view class="add" @tap="addImage">
  30. <uni-icons type="plusempty" size="40" color="#EEEEEE" style="font-weight: 500;">
  31. </uni-icons>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="" style="margin-top: 100upx;">
  38. <button type="default" class="btn submit-btn" @tap="submit">提交</button>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. mainImages: [],
  48. mainImagesLimit: 4,
  49. form: {
  50. content: ''
  51. }
  52. }
  53. },
  54. methods: {
  55. addImage() {
  56. this.chooseImage().then((res) => {
  57. console.log(res)
  58. for (let i in res.tempFilePaths) {
  59. this.$http.upload({
  60. file: res.tempFiles[i],
  61. filePath: res.tempFilePaths[i],
  62. name: 'file',
  63. success: (res) => {
  64. console.log(res.data.data)
  65. this.mainImages.push(res.data.data.url)
  66. }
  67. })
  68. }
  69. });
  70. },
  71. replaceImage(index) {
  72. console.log(index)
  73. this.chooseImage().then((res) => {
  74. this.$http.upload({
  75. file: res.tempFiles[0],
  76. filePath: res.tempFilePaths[0],
  77. name: 'file',
  78. success: (res) => {
  79. // this.mainImages[index] = res.data.data.url
  80. this.$set(this.mainImages, index, res.data.data.url)
  81. }
  82. })
  83. });
  84. },
  85. chooseImage() {
  86. return new Promise((resolve, reject) => {
  87. uni.chooseImage({
  88. count: this.mainImagesLimit - this.mainImages.length,
  89. extension: ['jpg', 'png', 'bmp', 'jpeg'],
  90. success(res) {
  91. resolve(res)
  92. },
  93. fail(err) {
  94. reject(err)
  95. }
  96. })
  97. })
  98. },
  99. submit() {
  100. if (this.$verified.required(this.form.content,"请输入反馈内容")) {
  101. this.$http.post({
  102. url: "/feedback/create",
  103. data: this.form,
  104. success: (res) => {
  105. console.log(res)
  106. uni.showModal({
  107. title: "意见反馈",
  108. content: "提交成功,平台将于三个工作日之内为您处理",
  109. success: (res) => {
  110. if (res.confirm) {
  111. uni.navigateBack()
  112. }
  113. }
  114. })
  115. }
  116. })
  117. }
  118. }
  119. }
  120. }
  121. </script>
  122. <style lang="scss" scoped>
  123. .feedback {
  124. position: relative;
  125. overflow: hidden;
  126. }
  127. .header-bg {
  128. background: $primary-color;
  129. height: 100upx;
  130. position: absolute;
  131. top: 0;
  132. width: 100%;
  133. z-index: 1;
  134. }
  135. .header {
  136. margin: 20upx;
  137. background: white;
  138. text-align: center;
  139. border-radius: 20upx;
  140. position: relative;
  141. z-index: 2;
  142. .title {
  143. height: 100upx;
  144. font-size: 32upx;
  145. line-height: 100upx;
  146. // font-weight: bold;
  147. }
  148. }
  149. .label {
  150. font-size: 30upx;
  151. }
  152. .tips {
  153. font-size: 28upx;
  154. text-align: right;
  155. padding: 10upx;
  156. color: #999999;
  157. }
  158. .textarea {
  159. padding: 20upx;
  160. font-size: 28upx;
  161. width: 100%;
  162. box-sizing: border-box;
  163. }
  164. .images-wrapper {
  165. padding: 0;
  166. padding-top: 40upx;
  167. display: flex;
  168. flex-wrap: wrap;
  169. // justify-content: space-between;
  170. .image-item {
  171. position: relative;
  172. width: 25%;
  173. text-align: center;
  174. margin-bottom: 40upx;
  175. .del {
  176. position: absolute;
  177. top: 0;
  178. right: 30upx;
  179. z-index: 1;
  180. font-size: 24upx;
  181. background-color: $primary-color;
  182. color: white;
  183. padding: 2upx 15upx;
  184. }
  185. }
  186. .image {
  187. width: 120upx;
  188. height: 120upx;
  189. background: #EEEEEE;
  190. flex: 0 0 150upx;
  191. }
  192. .add {
  193. width: 120upx;
  194. height: 120upx;
  195. display: inline-block;
  196. line-height: 110upx;
  197. border: 8upx #EEEEEE solid;
  198. box-sizing: border-box;
  199. }
  200. }
  201. .submit-btn {
  202. font-size: 30upx;
  203. line-height: 60upx;
  204. width: 250upx;
  205. background: $primary-color;
  206. color: white;
  207. }
  208. </style>