feedBack.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <view class="content">
  3. <view class="main">
  4. <!-- 建议 -->
  5. <view class="firstView">
  6. <view class="title">您的问题或建议</view>
  7. <view>
  8. <textarea placeholder-style="color:#999999" placeholder="输入个人意见反馈" v-model="exeContent"
  9. class="textareaCont" maxlength="-1" auto-height="true" @confirm="feedDone" />
  10. </view>
  11. </view>
  12. <!-- 图片 -->
  13. <view class="secondView">
  14. <view class="title">上传图片</view>
  15. <view class="imgBox">
  16. <view class="imgLine" v-for="(img,imgindex) in imgArr">
  17. <image :class="{img4:(imgindex+1)%4==0}" :src="img" mode="" class="itemImg"></image>
  18. <image src="../../static/img/icon_del_red.png" mode="" class="delImg" @click="delimg(imgindex)">
  19. </image>
  20. </view>
  21. <view class="imgLine" @click="uploadImg">
  22. <image src="../../static/img/btn_pic.png" mode="" class="itemImg"></image>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="bottom">
  28. <view class="shoreDz" @click="submit">提交</view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. imgArr: [],
  37. exeContent: '',
  38. }
  39. },
  40. methods: {
  41. feedDone(e) {
  42. this.exeContent = e.target.value
  43. },
  44. uploadImg() {
  45. var that = this;
  46. var length = this.imgArr.length;
  47. var num = 9;
  48. if (length > 8) {
  49. uni.showToast({
  50. title: '最多上传9张',
  51. icon: 'none',
  52. duration: 2000,
  53. });
  54. return false;
  55. }
  56. uni.chooseImage({
  57. sourceType: ['album', 'camera'],
  58. count: num - length,
  59. success: (chooseImageRes) => {
  60. const tempFilePaths = chooseImageRes.tempFilePaths;
  61. /* uni.uploadFile({
  62. url: that.$request.baseUrl+'accompany/SuperCheckSheet/uploadFile', //仅为示例,非真实的接口地址
  63. filePath: tempFilePaths[0],
  64. name: 'file',
  65. formData: {
  66. 'user': 'test'
  67. },
  68. success: (uploadFileRes) => {
  69. console.log(JSON.parse(uploadFileRes.data).data );
  70. that.imgArr=that.imgArr.concat(JSON.parse(uploadFileRes.data).data) ;
  71. }
  72. }); */
  73. tempFilePaths.forEach(v => {
  74. console.log(that.$request.baseUrl + 'tuhuUploadFile');
  75. uni.uploadFile({
  76. url: that.$request.baseUrl + 'tuhuUploadFile',
  77. filePath: v,
  78. name: 'file',
  79. formData: {
  80. 'user': 'test'
  81. },
  82. success: (uploadFileRes) => {
  83. console.log(JSON.parse(uploadFileRes.data).data);
  84. that.imgArr = that.imgArr.concat(JSON.parse(
  85. uploadFileRes.data).data);
  86. }
  87. });
  88. })
  89. /* that.$http('accompany/SuperCheckSheet/uploadFile', tempFilePaths[0], 'POST').then(res => {
  90. }) */
  91. }
  92. });
  93. },
  94. delimg(index) {
  95. this.imgArr.splice(index, 1)
  96. },
  97. submit() {
  98. if (!this.exeContent) {
  99. uni.showToast({
  100. title: '请输入个人意见反馈',
  101. icon: 'none',
  102. duration: 2000,
  103. });
  104. return;
  105. }
  106. // if (this.imgArr.length == 0) {
  107. // uni.showToast({
  108. // title: '请上传图片',
  109. // icon: 'none',
  110. // duration: 2000,
  111. // });
  112. // return ;
  113. // }
  114. uni.showLoading({
  115. title: '保存中'
  116. })
  117. var exeImg = this.imgArr.join(',')
  118. this.$http('openmy/addTMemberSuggest', {
  119. contents: this.exeContent,
  120. img: exeImg
  121. }, 'GET').then(res => {
  122. //this.submitSuperCheckSheet()
  123. if (res.code == 0) {
  124. uni.showToast({
  125. title: '提交成功',
  126. icon: 'none',
  127. duration: 2000,
  128. });
  129. setTimeout(function() {
  130. uni.navigateBack({
  131. })
  132. }, 2000);
  133. } else {
  134. uni.showToast({
  135. title: '提交失败',
  136. icon: 'none',
  137. duration: 2000,
  138. });
  139. }
  140. })
  141. }
  142. }
  143. }
  144. </script>
  145. <style scoped>
  146. .content {
  147. background: #F4F5F7;
  148. min-height: 100vh;
  149. }
  150. /* #ifdef H5 */
  151. .content {
  152. background: #F4F5F7;
  153. min-height: calc(100vh - 44px);
  154. }
  155. /* #endif */
  156. .main {
  157. background: #F4F5F7;
  158. padding: 20rpx 24rpx;
  159. }
  160. .firstView,
  161. .secondView {
  162. background-color: #FFFFFF;
  163. border-radius: 10rpx;
  164. }
  165. .firstView {
  166. margin-bottom: 20rpx;
  167. }
  168. .title {
  169. font-size: 30rpx;
  170. color: #3C3C3C;
  171. padding: 20rpx;
  172. }
  173. .textareaCont {
  174. padding: 20rpx;
  175. min-height: 150rpx;
  176. width: 95%;
  177. }
  178. .imgBox {
  179. display: flex;
  180. flex-wrap: wrap;
  181. padding: 20rpx;
  182. }
  183. .imgLine {
  184. position: relative;
  185. margin-right: 10rpx;
  186. }
  187. .itemImg {
  188. width: 150rpx;
  189. height: 150rpx;
  190. margin-right: 5rpx;
  191. }
  192. /* .img4 {
  193. margin-right: 20rpx;
  194. } */
  195. .delImg {
  196. width: 32rpx;
  197. height: 32rpx;
  198. position: absolute;
  199. right: 0rpx;
  200. top: 0rpx;
  201. }
  202. .bottom {
  203. width: 750rpx;
  204. height: 120rpx;
  205. background: #FFFFFF;
  206. box-shadow: 0px -4px 8px 0px rgba(153, 153, 153, 0.08);
  207. position: fixed;
  208. left: 0;
  209. bottom: 0;
  210. display: flex;
  211. justify-content: space-around;
  212. padding-bottom: constant(safe-area-inset-bottom);
  213. padding-bottom: env(safe-area-inset-bottom);
  214. }
  215. .shoreDz {
  216. width: 702rpx;
  217. height: 74rpx;
  218. background: #D53533;
  219. border-radius: 37rpx;
  220. text-align: center;
  221. line-height: 74rpx;
  222. color: #FFFFFF;
  223. font-size: 30rpx;
  224. margin-top: 24rpx;
  225. }
  226. </style>