index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <template>
  2. <view :style="viewColor">
  3. <view class="tips" v-if="is_open_service == 1 && service">
  4. <view class="tipBox" @click="toChat">
  5. <view class="left">
  6. <image :src="`${domain}/static/images/kefu.png`" mode=""></image>
  7. <view class="font">如需尽快解决问题,可直接联系在线客服</view>
  8. </view>
  9. <view><i class='iconfont icon-xiangyou' style="fontSize: 24rpx;"></i></view>
  10. </view>
  11. </view>
  12. <view class="feedback-container">
  13. <view class="item-box">
  14. <view class="title-box">
  15. <text>*</text>反馈类型
  16. </view>
  17. <view class="tab-box" v-if="tabList.length>0">
  18. <block v-for="(item,index) in tabList">
  19. <view class="tab-item" :key="index" :class="{'active':index == tabKey}"
  20. @click="bindTab(item,index)">{{item.cate_name}}</view>
  21. </block>
  22. </view>
  23. <view class="picker" v-if="qsArray.length>0">
  24. <picker @change="bindPickerChange" :value="qsIndex" :range="qsArray" range-key="cate_name">
  25. <view class="picker-box">
  26. {{qsArray[qsIndex]['cate_name']}}
  27. <text class="iconfont icon-xiangxia"></text>
  28. </view>
  29. </picker>
  30. </view>
  31. </view>
  32. <view class="item-box">
  33. <view class="title-box">
  34. <text>*</text>反馈内容
  35. </view>
  36. <view class="textarea-box">
  37. <textarea maxlength="200" placeholder="请输入文字" v-model="con" />
  38. <view class="num">{{con.length}}/200字</view>
  39. </view>
  40. </view>
  41. <view class="item-box">
  42. <view class="title-box">
  43. <text>*</text>图片上传 <text class="des">(上传聊天截图或与问题描述相关的图片)</text>
  44. </view>
  45. <view class="upload-img">
  46. <view class="img-wrapper" v-if="uploadImg.length>0" v-for="(item,index) in uploadImg">
  47. <image :src="item"></image>
  48. <view class="iconfont icon-guanbi1" @click="deleteImg(index)"></view>
  49. </view>
  50. <view class="add-img" @click="uploadpic" v-if="isUpload">
  51. <text class="iconfont icon-xiangji"></text>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="item-box">
  56. <view class="title-box">
  57. <text>*</text>联系方式
  58. </view>
  59. <view class="input-box">
  60. <input type="text" placeholder="请填写您的姓名" v-model="name">
  61. <input type="text" placeholder="请填写您的电话或邮箱" v-model="phone">
  62. </view>
  63. </view>
  64. <view class="item-box">
  65. <view class="sub-btn" @click="bindSub">提交反馈</view>
  66. <navigator url="/pages/users/feedback/list" class="link" hover-class="none">反馈记录 <text
  67. class="iconfont icon-xiangyou"></text></navigator>
  68. </view>
  69. <view class="success" v-if="isShowbox">
  70. <view class="bg"></view>
  71. <view class="con">
  72. <image :src="domain+'/static/diy/success'+keyColor+'.png'" mode=""></image>
  73. <view class="text">反馈提交成功</view>
  74. <view class="btn" @click="close">我知道了</view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. // +----------------------------------------------------------------------
  82. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  83. // +----------------------------------------------------------------------
  84. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  85. // +----------------------------------------------------------------------
  86. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  87. // +----------------------------------------------------------------------
  88. // | Author: CRMEB Team <admin@crmeb.com>
  89. // +----------------------------------------------------------------------
  90. import { feedbackType, feedback, hasServiceApi} from '@/api/user.js'
  91. import { checkPhone,isEmailAvailable } from '@/utils/validate.js'
  92. import { mapGetters } from "vuex";
  93. import { HTTP_REQUEST_URL } from '@/config/app';
  94. import { configMap } from '@/utils';
  95. export default {
  96. data() {
  97. return {
  98. domain: HTTP_REQUEST_URL,
  99. // 反馈类型
  100. tabList: [],
  101. // 反馈类型key
  102. tabKey: 0,
  103. // 反馈列表
  104. qsArray: [],
  105. // 反馈index
  106. qsIndex: 0,
  107. // 反馈内容
  108. con: '',
  109. uploadImg: [],
  110. name: '',
  111. phone: '',
  112. isShowbox: false,
  113. isUpload: true,
  114. service: false,
  115. }
  116. },
  117. computed:{
  118. ...configMap(['is_open_service'], mapGetters(['viewColor', 'keyColor']))
  119. },
  120. watch: {
  121. uploadImg(nVal, oVal) {
  122. this.isUpload = nVal.length < 6 ? true : false
  123. }
  124. },
  125. onLoad() {
  126. this.hasService()
  127. // 获取反馈类型
  128. feedbackType().then(({
  129. data
  130. }) => {
  131. this.tabList = data
  132. this.getFeedBack(data)
  133. })
  134. },
  135. methods: {
  136. toChat(){
  137. uni.navigateTo({
  138. url: `/pages/chat/customer_list/chat?mer_id=0`
  139. })
  140. },
  141. /*判断店铺是否有在线客服*/
  142. hasService(){
  143. hasServiceApi(0).then(res => {
  144. this.service = true;
  145. }).catch(err => {
  146. this.service = false;
  147. });
  148. },
  149. // 获取含有二级分类的反馈类型
  150. getFeedBack(data) {
  151. let that = this;
  152. data.forEach(function(item, i) {
  153. if (item.children) {
  154. that.tabKey = i;
  155. that.qsArray = data[that.tabKey].children
  156. return;
  157. }
  158. });
  159. },
  160. // 下拉选中
  161. bindPickerChange(e) {
  162. this.qsIndex = e.target.value
  163. },
  164. // tab切换
  165. bindTab(item, index) {
  166. this.tabKey = index
  167. this.qsIndex = 0
  168. this.qsArray = this.tabList[this.tabKey].children ? this.tabList[this.tabKey].children : []
  169. },
  170. /**
  171. * 上传文件
  172. *
  173. */
  174. uploadpic: function() {
  175. let that = this;
  176. that.$util.uploadImageOne('upload/image', function(res) {
  177. console.log(res, '回调')
  178. that.uploadImg.push(res.data.path);
  179. that.$set(that, 'uploadImg', that.uploadImg);
  180. });
  181. },
  182. // 弹窗关闭
  183. close() {
  184. this.con = ''
  185. this.uploadImg = []
  186. this.name = ''
  187. this.phone = ''
  188. this.isShowbox = false
  189. },
  190. // 删除图片
  191. deleteImg(index) {
  192. this.uploadImg.splice(index, 1)
  193. },
  194. // 提交反馈
  195. bindSub() {
  196. if (!this.con) {
  197. uni.showToast({
  198. title: '请输入反馈内容',
  199. icon: 'none'
  200. })
  201. return
  202. }
  203. if (this.uploadImg.length == 0) {
  204. uni.showToast({
  205. title: '请上传图片',
  206. icon: 'none'
  207. })
  208. return
  209. }
  210. if (!this.name) {
  211. uni.showToast({
  212. title: '请输入姓名',
  213. icon: 'none'
  214. })
  215. return
  216. }
  217. if (!this.phone) {
  218. uni.showToast({
  219. title: '请输入电话或者邮箱',
  220. icon: 'none'
  221. })
  222. return
  223. }
  224. if (!isEmailAvailable(this.phone) && !checkPhone(this.phone)) {
  225. uni.showToast({
  226. title: '请输入有效的电话或者邮箱',
  227. icon: 'none'
  228. })
  229. return
  230. }
  231. feedback({
  232. type: (this.qsArray[this.qsIndex] && this.qsArray[this.qsIndex].feedback_category_id) || 0,
  233. content: this.con,
  234. images: this.uploadImg,
  235. realname: this.name,
  236. contact: this.phone
  237. }).then(res => {
  238. this.isShowbox = true
  239. }).catch(error => {
  240. this.$util.Tips({
  241. title: error
  242. })
  243. })
  244. }
  245. }
  246. }
  247. </script>
  248. <style lang="scss">
  249. page {
  250. width: 100%;
  251. background-color: #fff;
  252. }
  253. .tips {
  254. background-color: #f1f1f1;
  255. padding: 20rpx;
  256. .tipBox {
  257. width: 100%;
  258. height: 100rpx;
  259. background: var(--view-minorColor);
  260. border-radius: 16rpx;
  261. line-height: 100rpx;
  262. display: flex;
  263. justify-content: space-between;
  264. font-size: 24rpx;
  265. font-weight: 400;
  266. color: var(--view-theme);
  267. padding: 0rpx 30rpx;
  268. .left {
  269. display: flex;
  270. image {
  271. width: 70rpx;
  272. height: 70rpx;
  273. background: #FFFFFF;
  274. border-radius: 50%;
  275. display: inline-block;
  276. margin-top: 15rpx;
  277. }
  278. .font {
  279. padding-left: 20rpx;
  280. }
  281. }
  282. }
  283. }
  284. .feedback-container {
  285. padding: 30rpx;
  286. .item-box {
  287. margin-bottom: 40rpx;
  288. .title-box {
  289. font-size: 28rpx;
  290. color: #222222;
  291. text {
  292. margin-right: 10rpx;
  293. color: var(--view-theme);
  294. }
  295. .des {
  296. margin-left: 10rpx;
  297. font-size: 22rpx;
  298. color: #999999;
  299. }
  300. }
  301. .tab-box {
  302. margin-top: 20rpx;
  303. display: flex;
  304. flex-wrap: wrap;
  305. .tab-item {
  306. line-height: 66rpx;
  307. align-items: center;
  308. justify-content: center;
  309. width: 200rpx;
  310. margin-right: 20rpx;
  311. margin-bottom: 20rpx;
  312. border: 1px solid #BFBFBF;
  313. border-radius: 33px;
  314. font-size: 28rpx;
  315. text-align: center;
  316. &.active {
  317. background: var(--view-theme);
  318. color: #fff;
  319. border-color: var(--view-theme);
  320. }
  321. }
  322. }
  323. .picker {
  324. margin-top: 30rpx;
  325. .picker-box {
  326. position: relative;
  327. width: 100%;
  328. height: 90rpx;
  329. line-height: 90rpx;
  330. padding: 0 30rpx;
  331. background-color: #F5F5F5;
  332. border-radius: 10rpx;
  333. .iconfont {
  334. position: absolute;
  335. right: 30rpx;
  336. top: 50%;
  337. transform: translateY(-50%);
  338. font-size: 22rpx;
  339. color: var(--view-theme);
  340. }
  341. }
  342. }
  343. .textarea-box {
  344. background: #F5F5F5;
  345. border-radius: 10rpx;
  346. textarea {
  347. width: 100%;
  348. height: 300rpx;
  349. margin-top: 30rpx;
  350. padding: 20rpx 20rpx 0;
  351. font-size: 28rpx;
  352. line-height: 1.5;
  353. }
  354. .num {
  355. color: #999;
  356. text-align: right;
  357. padding: 20rpx;
  358. }
  359. }
  360. .upload-img {
  361. display: flex;
  362. flex-wrap: wrap;
  363. .img-wrapper {
  364. position: relative;
  365. display: flex;
  366. flex-wrap: wrap;
  367. margin: 30rpx 20rpx 20rpx 0;
  368. width: 158rpx;
  369. height: 158rpx;
  370. image {
  371. width: 158rpx;
  372. height: 158rpx;
  373. }
  374. .iconfont {
  375. position: absolute;
  376. right: -15rpx;
  377. top: -20rpx;
  378. font-size: 40rpx;
  379. color: var(--view-theme);
  380. }
  381. &:nth-child(4n) {
  382. margin-right: 0;
  383. }
  384. }
  385. .add-img {
  386. display: flex;
  387. align-items: center;
  388. justify-content: center;
  389. width: 158rpx;
  390. height: 158rpx;
  391. background: #F5F5F5;
  392. border-radius: 10rpx;
  393. margin-top: 30rpx;
  394. margin-bottom: 20rpx;
  395. .iconfont {
  396. color: #B5B5B5;
  397. font-size: 55rpx;
  398. }
  399. }
  400. }
  401. .input-box {
  402. input {
  403. display: block;
  404. width: 100%;
  405. height: 90rpx;
  406. margin-top: 20rpx;
  407. padding-left: 20rpx;
  408. background: #f5f5f5;
  409. border-radius: 10rpx;
  410. font-size: 28rpx;
  411. }
  412. }
  413. .sub-btn {
  414. height: 90rpx;
  415. line-height: 90rpx;
  416. background: var(--view-theme);
  417. color: #fff;
  418. font-size: 32rpx;
  419. text-align: center;
  420. border-radius: 45rpx;
  421. }
  422. .link {
  423. display: flex;
  424. align-items: center;
  425. justify-content: center;
  426. margin-top: 20rpx;
  427. .iconfont {
  428. margin-top: 6rpx;
  429. font-size: 22rpx;
  430. }
  431. }
  432. }
  433. .success {
  434. z-index: 10;
  435. position: fixed;
  436. left: 0;
  437. top: 0;
  438. width: 100%;
  439. height: 100%;
  440. .bg {
  441. position: absolute;
  442. left: 0;
  443. top: 0;
  444. width: 100%;
  445. height: 100%;
  446. background-color: rgba(0, 0, 0, .5);
  447. }
  448. .con {
  449. position: absolute;
  450. left: 50%;
  451. top: 50%;
  452. transform: translate(-50%, -50%);
  453. display: flex;
  454. flex-direction: column;
  455. align-items: center;
  456. justify-content: center;
  457. width: 500rpx;
  458. height: 540rpx;
  459. background: #fff;
  460. border-radius: 10rpx;
  461. font-size: 34rpx;
  462. color: #282828;
  463. image {
  464. width: 149rpx;
  465. height: 230rpx;
  466. }
  467. .btn {
  468. width: 340rpx;
  469. height: 90rpx;
  470. line-height: 90rpx;
  471. margin-top: 38rpx;
  472. text-align: center;
  473. color: #fff;
  474. background-image: linear-gradient(-90deg, var(--view-bntColor21) 0%, var(--view-bntColor22) 100%);
  475. border-radius: 45rpx;
  476. }
  477. }
  478. }
  479. }
  480. </style>