addFeed.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view class="index tn-safe-area-inset-bottom">
  3. <tn-nav-bar customBack>
  4. <view slot="back" class='tn-custom-nav-bar__back' @click="goBack()">
  5. <text class='icon tn-icon-left'></text>
  6. </view>
  7. <view slot="default" style="display: flex;">
  8. <view style="flex:1;margin-left:25px">
  9. <text>问题反馈</text>
  10. </view>
  11. <view @click="showHis">
  12. <text class='tn-icon-time'></text>
  13. 历史反馈
  14. </view>
  15. </view>
  16. </tn-nav-bar>
  17. <view :style="{paddingTop: vuex_custom_bar_height + 'px'}">
  18. <view style="display: flex;line-height: 37px;padding: 16px;">
  19. <view style="margin-right: 8px;">问题类型</view>
  20. <view style="flex:1"><uni-data-select :clear="false" v-model="typeValue" :localdata="range" @change="change"></uni-data-select></view>
  21. </view>
  22. <view class="tn-margin tn-bg-gray--light tn-padding" style="border-radius: 10rpx;">
  23. <textarea maxlength="500" v-model="contentValue" placeholder="请描述您遇到的问题..." placeholder-style="color:#AAAAAA"></textarea>
  24. </view>
  25. <view class="tn-margin-left tn-padding-top-xs">
  26. <uni-file-picker
  27. v-model="imgList" :limit="6" :auto-upload="false" @select="select" @success="success">
  28. </uni-file-picker>
  29. </view>
  30. <view style="display: flex;line-height: 37px;padding: 16px;">
  31. <view style="margin-right: 8px;">联系方式</view>
  32. <view style="flex:1">
  33. <uni-easyinput v-model="contactMethod" placeholder="请输入内容"></uni-easyinput>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="tn-flex tn-footerfixed">
  38. <view class="tn-flex-1 justify-content-item tn-margin-sm tn-text-center">
  39. <tn-button backgroundColor="#3668FC" padding="40rpx 0" width="60%" shadow fontBold @click="saveForm()">
  40. <!-- <text class="tn-icon-light tn-padding-right-xs tn-color-black"></text> -->
  41. <text class="tn-color-white">提交</text>
  42. <!-- <text class="tn-icon-camera tn-padding-left-xs tn-color-black"></text> -->
  43. </tn-button>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import request from '../../utils/request'
  50. export default {
  51. data() {
  52. return {
  53. imgList:[],
  54. fileDetailList:[],
  55. showHistory: false,
  56. content: [],
  57. contentValue:'',
  58. contactMethod:uni.getStorageSync('userInfo')?JSON.parse(uni.getStorageSync('userInfo')).userName:'',
  59. typeValue:1,
  60. range: [{
  61. value: 1,
  62. text: "汇报系统故障"
  63. },
  64. {
  65. value: 2,
  66. text: "平台问题"
  67. },
  68. {
  69. value: 3,
  70. text: "投诉"
  71. },
  72. ],
  73. showEmpty: false,
  74. }
  75. },
  76. filters: {
  77. formatDate(value) {
  78. if (!value) return '';
  79. const date = new Date(value);
  80. const today = new Date();
  81. const yesterday = new Date(today); // 昨天的日期
  82. yesterday.setDate(yesterday.getDate() - 1); // 将昨天的日期设置为前一天
  83. if (date.getFullYear() == today.getFullYear() && date.getMonth() == today.getMonth() && date.getDate() ==
  84. today.getDate()) {
  85. return '今天 ' + (date.getHours() > 9 ? '' : '0') + date.getHours() + ':' + (date
  86. .getMinutes() > 9 ? '' : '0') + date.getMinutes(); // 根据需要格式化日期
  87. }
  88. if (date.getFullYear() == yesterday.getFullYear() && date.getMonth() == yesterday.getMonth() && date
  89. .getDate() == yesterday.getDate()) {
  90. return '昨天 ' + (date.getHours() > 9 ? '' : '0') + date.getHours() + ':' + (date
  91. .getMinutes() > 9 ? '' : '0') + date.getMinutes(); // 根据需要格式化日期
  92. }
  93. return date.toLocaleDateString() + ' ' + (date.getHours() > 9 ? '' : '0') + date.getHours() + ':' + (date
  94. .getMinutes() > 9 ? '' : '0') + date.getMinutes(); // 根据需要格式化日期
  95. },
  96. },
  97. created() {
  98. // uni.navigateTo({
  99. // url:'/pages/mine/addFeed'
  100. // })
  101. },
  102. methods: {
  103. showHis(){
  104. uni.navigateTo({
  105. url:'/pages/mine/feedback'
  106. })
  107. },
  108. goBack() {
  109. uni.navigateBack();
  110. },
  111. select(e) {
  112. console.log('选择文件:', e)
  113. let tempFiles = e.tempFiles;
  114. for (let i in tempFiles) {
  115. this.upfile(tempFiles[i])
  116. }
  117. },
  118. upfile(file) {
  119. let that = this;
  120. console.warn(file);
  121. uni.uploadFile({
  122. url: 'http://slb-m.dev.ml1993.com/oss/upload/userFeedback', //仅为示例,非真实的接口地址
  123. filePath: file.url,
  124. name: 'file',
  125. success: (uploadFileRes) => {
  126. console.warn(JSON.parse(uploadFileRes.data));
  127. let resultMap = JSON.parse(uploadFileRes.data).resultMap;
  128. that.fileDetailList.push({
  129. name: file.name,
  130. fileName: file.name, // 原始文件名
  131. ftpUrl: resultMap.uploadUrl, // 文件访问url
  132. })
  133. }
  134. });
  135. },
  136. // 上传成功
  137. success(e) {
  138. console.log('上传成功')
  139. },
  140. saveForm(){
  141. let that = this;
  142. let params = {
  143. };
  144. if(!this.contentValue){
  145. uni.showToast({
  146. title: '请输入您遇到的问题',
  147. duration: 2000,
  148. icon:'none'
  149. });
  150. return false;
  151. }
  152. if(!this.contactMethod){
  153. uni.showToast({
  154. title: '请输入您的联系方式',
  155. duration: 2000,
  156. icon:'none'
  157. });
  158. return false;
  159. }
  160. uni.showToast({
  161. title: '提交中...',
  162. icon:'none'
  163. });
  164. params.slbFeedback = JSON.stringify({
  165. type:this.typeValue,
  166. content:this.contentValue,
  167. contactMethod:this.contactMethod,
  168. userNo:uni.getStorageSync('userNo'),
  169. });
  170. params.fileDetailList = JSON.stringify(this.fileDetailList);
  171. request.post('/slbFeedback/add', params).then(res => {
  172. if(res.success){
  173. uni.showToast({
  174. title:'已提交',
  175. icon:'none',
  176. success:()=>{
  177. setTimeout(()=>{
  178. uni.redirectTo({
  179. url:'/pages/mine/feedback'
  180. });
  181. },2000)
  182. }
  183. })
  184. }else{
  185. uni.showToast({
  186. title:res.msg,
  187. icon:'none'
  188. })
  189. }
  190. console.warn(res);
  191. })
  192. }
  193. },
  194. onLoad() {
  195. }
  196. }
  197. </script>
  198. <style lang="scss" scoped>
  199. /* 胶囊*/
  200. .tn-custom-nav-bar__back {
  201. width: 60%;
  202. height: 100%;
  203. position: relative;
  204. display: flex;
  205. justify-content: space-evenly;
  206. align-items: center;
  207. box-sizing: border-box;
  208. // background-color: rgba(0, 0, 0, 0.15);
  209. border-radius: 1000rpx;
  210. border: 1rpx solid rgba(255, 255, 255, 0.5);
  211. // color: #FFFFFF;
  212. font-size: 18px;
  213. .icon {
  214. display: block;
  215. flex: 1;
  216. margin: auto;
  217. text-align: center;
  218. }
  219. &:before {
  220. content: " ";
  221. width: 1rpx;
  222. height: 110%;
  223. position: absolute;
  224. top: 22.5%;
  225. left: 0;
  226. right: 0;
  227. margin: auto;
  228. transform: scale(0.5);
  229. transform-origin: 0 0;
  230. pointer-events: none;
  231. box-sizing: border-box;
  232. opacity: 0.7;
  233. background-color: #FFFFFF;
  234. }
  235. }
  236. </style>