feedBack.vue 5.6 KB

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