addFeed.vue 7.0 KB

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