addFeed.vue 7.1 KB

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