feedBack.vue 5.6 KB

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