addFeed.vue 7.3 KB

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