index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <view class="feedback-container">
  3. <view class="item-box">
  4. <view class="title-box">
  5. <text>*</text>反馈类型
  6. </view>
  7. <view class="tab-box" v-if="tabList.length>0">
  8. <block v-for="(item,index) in tabList">
  9. <view class="tab-item" :key="index" :class="{'active':index == tabKey}"
  10. @click="bindTab(item,index)">{{item.cate_name}}</view>
  11. <!--<view class="tab-item" v-if="item.children && item.children.length > 0" :key="index" :class="{'active':index == tabKey}"
  12. @click="bindTab(item,index)">{{item.cate_name}}</view>-->
  13. </block>
  14. </view>
  15. <view class="picker" v-if="qsArray.length>0">
  16. <picker @change="bindPickerChange" :value="qsIndex" :range="qsArray" range-key="cate_name">
  17. <view class="picker-box">
  18. {{qsArray[qsIndex]['cate_name']}}
  19. <text class="iconfont icon-xiangxia"></text>
  20. </view>
  21. </picker>
  22. </view>
  23. </view>
  24. <view class="item-box">
  25. <view class="title-box">
  26. <text>*</text>反馈内容
  27. </view>
  28. <view class="textarea-box">
  29. <textarea maxlength="200" placeholder="请输入文字" v-model="con" />
  30. <view class="num">{{con.length}}/200字</view>
  31. </view>
  32. </view>
  33. <view class="item-box">
  34. <view class="title-box">
  35. <text>*</text>图片上传 <text class="des">(上传聊天截图或与问题描述相关的图片)</text>
  36. </view>
  37. <view class="upload-img">
  38. <view class="img-wrapper" v-if="uploadImg.length>0" v-for="(item,index) in uploadImg">
  39. <image :src="item"></image>
  40. <view class="iconfont icon-guanbi1" @click="deleteImg(index)"></view>
  41. </view>
  42. <view class="add-img" @click="uploadpic" v-if="isUpload">
  43. <text class="iconfont icon-xiangji"></text>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="item-box">
  48. <view class="title-box">
  49. <text>*</text>联系方式
  50. </view>
  51. <view class="input-box">
  52. <input type="text" placeholder="请填写您的姓名" v-model="name">
  53. <input type="text" placeholder="请填写您的电话或邮箱" v-model="phone">
  54. </view>
  55. </view>
  56. <view class="item-box">
  57. <view class="sub-btn" @click="bindSub">提交反馈</view>
  58. <navigator url="/pages/users/feedback/list" class="link" hover-class="none">反馈记录 <text class="iconfont icon-xiangyou"></text></navigator>
  59. </view>
  60. <view class="success" v-if="isShowbox">
  61. <view class="bg"></view>
  62. <view class="con">
  63. <image src="/static/images/success.png" mode=""></image>
  64. <view class="text">反馈提交成功</view>
  65. <view class="btn" @click="close">我知道了</view>
  66. </view>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. import {feedbackType,feedback} from '@/api/user.js'
  72. import { checkPhone,isEmailAvailable } from '@/utils/validate.js'
  73. export default {
  74. data() {
  75. return {
  76. // 反馈类型
  77. tabList: [],
  78. // 反馈类型key
  79. tabKey: 0,
  80. // 反馈列表
  81. qsArray: [],
  82. // 反馈index
  83. qsIndex:0,
  84. // 反馈内容
  85. con:'',
  86. uploadImg:[],
  87. name:'',
  88. phone:'',
  89. isShowbox:false,
  90. isUpload:true
  91. }
  92. },
  93. watch:{
  94. uploadImg(nVal,oVal){
  95. this.isUpload = nVal.length<6?true : false
  96. }
  97. },
  98. onLoad() {
  99. // 获取反馈类型
  100. feedbackType().then(({data})=>{
  101. this.tabList = data
  102. this.getFeedBack(data)
  103. console.log(this.tabKey)
  104. })
  105. },
  106. methods:{
  107. // 获取含有二级分类的反馈类型
  108. getFeedBack(data){
  109. let that = this;
  110. data.forEach(function(item,i) {
  111. if(item.children){
  112. that.tabKey = i;
  113. that.qsArray = data[that.tabKey].children
  114. return;
  115. }
  116. });
  117. },
  118. // 下拉选中
  119. bindPickerChange(e){
  120. this.qsIndex = e.target.value
  121. },
  122. // tab切换
  123. bindTab(item,index){
  124. this.tabKey = index
  125. this.qsIndex = 0
  126. this.qsArray = this.tabList[this.tabKey].children?this.tabList[this.tabKey].children:[]
  127. },
  128. /**
  129. * 上传文件
  130. *
  131. */
  132. uploadpic: function () {
  133. let that = this;
  134. that.$util.uploadImageOne('upload/image', function (res) {
  135. console.log(res,'回调')
  136. that.uploadImg.push(res.data.path);
  137. that.$set(that,'uploadImg',that.uploadImg);
  138. });
  139. },
  140. // 弹窗关闭
  141. close(){
  142. this.con = ''
  143. this.uploadImg = []
  144. this.name = ''
  145. this.phone = ''
  146. this.isShowbox = false
  147. },
  148. // 删除图片
  149. deleteImg(index){
  150. this.uploadImg.splice(index,1)
  151. },
  152. // 提交反馈
  153. bindSub(){
  154. if(!this.con){
  155. uni.showToast({
  156. title:'请输入反馈内容',
  157. icon:'none'
  158. })
  159. return
  160. }
  161. if(this.uploadImg.length == 0){
  162. uni.showToast({
  163. title:'请上传截图',
  164. icon:'none'
  165. })
  166. return
  167. }
  168. if(!this.name){
  169. uni.showToast({
  170. title:'请输入姓名',
  171. icon:'none'
  172. })
  173. return
  174. }
  175. if(!isEmailAvailable(this.phone) && !checkPhone(this.phone)){
  176. uni.showToast({
  177. title:'请输入电话或者邮箱',
  178. icon:'none'
  179. })
  180. return
  181. }
  182. feedback({
  183. type:this.qsArray[this.qsIndex].feedback_category_id,
  184. content:this.con,
  185. images:this.uploadImg,
  186. realname:this.name,
  187. contact:this.phone
  188. }).then(res=>{
  189. this.isShowbox = true
  190. }).catch(error=>{
  191. this.$util.Tips({
  192. title:error
  193. })
  194. })
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss">
  200. page {
  201. width: 100%;
  202. background-color: #fff;
  203. }
  204. .feedback-container {
  205. padding: 30rpx;
  206. .item-box {
  207. margin-bottom: 40rpx;
  208. .title-box {
  209. font-size: 28rpx;
  210. color: #222222;
  211. text {
  212. margin-right: 10rpx;
  213. color: $theme-color;
  214. }
  215. .des{
  216. margin-left: 10rpx;
  217. font-size: 22rpx;
  218. color: #999999;
  219. }
  220. }
  221. .tab-box {
  222. margin-top: 20rpx;
  223. display: flex;
  224. flex-wrap: wrap;
  225. .tab-item {
  226. overflow: hidden;
  227. display: -webkit-box;
  228. line-height: 28px;
  229. align-items: center;
  230. justify-content: center;
  231. width: 200rpx;
  232. height: 66rpx;
  233. margin-right: 20rpx;
  234. margin-bottom: 20rpx;
  235. border: 1px solid #BFBFBF;
  236. border-radius: 33px;
  237. font-size: 28rpx;
  238. text-align: center;
  239. &.active {
  240. background: $theme-color;
  241. color: #fff;
  242. border-color: $theme-color;
  243. }
  244. }
  245. }
  246. .picker{
  247. margin-top: 30rpx;
  248. .picker-box{
  249. position: relative;
  250. width: 100%;
  251. height: 90rpx;
  252. line-height: 90rpx;
  253. padding: 0 30rpx;
  254. background-color: #F5F5F5;
  255. border-radius:10rpx;
  256. .iconfont{
  257. position: absolute;
  258. right: 30rpx;
  259. top:50%;
  260. transform: translateY(-50%);
  261. font-size: 22rpx;
  262. color: #282828;
  263. }
  264. }
  265. }
  266. .textarea-box{
  267. background: #F5F5F5;
  268. border-radius:10rpx;
  269. textarea{
  270. width: 100%;
  271. height: 300rpx;
  272. margin-top: 30rpx;
  273. padding: 20rpx 20rpx 0;
  274. font-size: 28rpx;
  275. line-height: 1.5;
  276. }
  277. .num{
  278. color: #999;
  279. text-align: right;
  280. padding: 20rpx;
  281. }
  282. }
  283. .upload-img{
  284. display: flex;
  285. flex-wrap: wrap;
  286. .img-wrapper{
  287. position: relative;
  288. display: flex;
  289. flex-wrap: wrap;
  290. margin: 30rpx 90rpx 20rpx 0;
  291. image{
  292. width:158rpx;
  293. height: 158rpx;
  294. }
  295. .iconfont{
  296. position: absolute;
  297. right: -15rpx;
  298. top: -20rpx;
  299. font-size: 40rpx;
  300. color: $theme-color;
  301. }
  302. &:nth-child(3n){
  303. margin-right: 0;
  304. }
  305. }
  306. .add-img{
  307. display: flex;
  308. align-items: center;
  309. justify-content: center;
  310. width: 158rpx;
  311. height: 158rpx;
  312. background: #F5F5F5;
  313. border-radius:10rpx;
  314. margin-top: 20rpx;
  315. margin-bottom: 20rpx;
  316. .iconfont{
  317. color: #B5B5B5;
  318. font-size: 55rpx;
  319. }
  320. }
  321. }
  322. .input-box{
  323. input{
  324. display: block;
  325. width: 100%;
  326. height: 90rpx;
  327. margin-top: 20rpx;
  328. padding-left: 20rpx;
  329. background: #f5f5f5;
  330. border-radius:10rpx;
  331. font-size: 28rpx;
  332. }
  333. }
  334. .sub-btn{
  335. height: 90rpx;
  336. line-height: 90rpx;
  337. background: $theme-color;
  338. color: #fff;
  339. font-size: 32rpx;
  340. text-align: center;
  341. border-radius:45rpx;
  342. }
  343. .link{
  344. display: flex;
  345. align-items: center;
  346. justify-content: center;
  347. margin-top: 20rpx;
  348. .iconfont{
  349. margin-top: 6rpx;
  350. font-size: 22rpx;
  351. }
  352. }
  353. }
  354. .success{
  355. z-index: 10;
  356. position: fixed;
  357. left: 0;
  358. top: 0;
  359. width: 100%;
  360. height: 100%;
  361. .bg{
  362. position: absolute;
  363. left: 0;
  364. top: 0;
  365. width: 100%;
  366. height: 100%;
  367. background-color: rgba(0,0,0,.5);
  368. }
  369. .con{
  370. position: absolute;
  371. left: 50%;
  372. top: 50%;
  373. transform: translate(-50%,-50%);
  374. display: flex;
  375. flex-direction: column;
  376. align-items: center;
  377. justify-content: center;
  378. width:500rpx;
  379. height:540rpx;
  380. background:#fff;
  381. border-radius:10rpx;
  382. font-size: 34rpx;
  383. color: #282828;
  384. image{
  385. width: 149rpx;
  386. height: 230rpx;
  387. }
  388. .btn{
  389. width:340rpx;
  390. height:90rpx;
  391. line-height: 90rpx;
  392. margin-top: 38rpx;
  393. text-align: center;
  394. color: #fff;
  395. background:linear-gradient(-90deg,$bg-end 0%,$bg-star 100%);
  396. border-radius:45rpx;
  397. }
  398. }
  399. }
  400. }
  401. </style>