addFeed.vue 6.7 KB

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