feedBack.vue 5.5 KB

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