MessageBoard.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <template>
  2. <div class="messageBoard container" v-if="isOpen">
  3. <div class="modal-header">
  4. <h3 class="modal-title f18">
  5. <span v-if="showHistory">留言板</span>
  6. <span v-if="!showHistory">留言记录</span>
  7. </h3>
  8. <a @click="isOpendMessage"><i class="fa fa-remove"></i></a>
  9. </div>
  10. <div class="modal-body msg-body">
  11. <div v-if="showHistory">
  12. <h3>亲爱的&nbsp;<span v-text="user.userName || '游客'">&nbsp;&nbsp;</span> ,您的意见对我们很重要!</h3>
  13. <div class="form-message">
  14. <div class="txtArea">
  15. <b class="first">*</b>
  16. <textarea @keyup="textareaLength" placeholder="请将您在使用当前页面遇到的任何问题、建议或意见反馈给我们。注意:不要输入您的隐私信息,如:账户密码等。" v-model="messageBoard.question" maxlength="500"></textarea>
  17. <span class="count_tip"><span v-text="txtVal"></span>/500</span>
  18. </div>
  19. <p><b>*</b>您的身份是:</p>
  20. <p class="radioCheck">
  21. <label for="buyer01" class="radioLabel">
  22. <input type="radio" name="role" value="buyer" v-model="messageBoard.role" id="buyer01"/>
  23. <label for="buyer01" class="txtContact"></label>
  24. <span>我是买家</span>
  25. </label>
  26. <label for="buyer02" class="radioLabel">
  27. <input type="radio" name="role" value="seller" v-model="messageBoard.role" id="buyer02" checked/>
  28. <label for="buyer02" class="txtContact"></label>
  29. <span>我是卖家</span>
  30. </label>
  31. </p>
  32. <p><b>*</b>您反馈的内容类型是:</p>
  33. <p class="radioCheck">
  34. <label for="contentType01" class="radioLabel">
  35. <input type="radio" name="type" value="展示效果" v-model="messageBoard.type" id="contentType01"/>
  36. <label for="contentType01" class="txtContact"></label>
  37. <span>展示效果</span>
  38. </label>
  39. <label for="contentType02" class="radioLabel">
  40. <input type="radio" name="type" value="页面功能" v-model="messageBoard.type" id="contentType02" checked/>
  41. <label for="contentType02" class="txtContact"></label>
  42. <span>页面功能</span>
  43. </label>
  44. <label for="contentType03" class="radioLabel">
  45. <input type="radio" name="type" value="异常报错" v-model="messageBoard.type" id="contentType03"/>
  46. <label for="contentType03" class="txtContact"></label>
  47. <span>异常报错</span>
  48. </label>
  49. <label for="contentType04" class="radioLabel">
  50. <input type="radio" name="type" value="其他方面" v-model="messageBoard.type" id="contentType04"/>
  51. <label for="contentType04" class="txtContact"></label>
  52. <span>其他方面</span>
  53. </label>
  54. </p>
  55. <p>&nbsp;&nbsp;&nbsp;添加图片:</p>
  56. <div class="img-warp">
  57. <div class="img-item">
  58. <upload @uploadAction="listenUpload($event, 0)"/>
  59. </div>
  60. <div class="img-item">
  61. <upload @uploadAction="listenUpload($event, 1)"/>
  62. </div>
  63. <div class="img-item">
  64. <upload @uploadAction="listenUpload($event, 2)"/>
  65. </div>
  66. <div class="img-item">
  67. <upload @uploadAction="listenUpload($event, 3)"/>
  68. </div>
  69. <div class="img-item">
  70. <upload @uploadAction="listenUpload($event, 4)"/>
  71. </div>
  72. </div>
  73. <p class="tip clearfix">提示:最多可上传五张图片,每张大小不超过500KB,仅支持JPG、PNG、GIF格式.</p>
  74. <div v-if="!user.userUU">
  75. <p><b>*</b>您当前尚未登录,请留下您的联系方式,我们会不定期发布一些有奖体验活动</p>
  76. <div class="msg-message" v-if="!user.userUU">
  77. <div class="msg-content">
  78. <label>手机:</label>
  79. <input type="text" name="userTel" v-model="messageBoard.userTel" autocomplete="off" @keyup="checkMobile"/>
  80. <span v-if="!isMobileValid"><i class="glyphicon glyphicon-info-sign x-icon-left"></i>请输入正确的号码</span>
  81. </div>
  82. </div>
  83. <div class="msg-message" v-if="!user.userUU">
  84. <div class="msg-content">
  85. <label>邮箱:</label>
  86. <input type="text" name="email" v-model="messageBoard.email" autocomplete="off" @keyup="checkEmail"/>
  87. <span v-if="!isEmail"><i class="glyphicon glyphicon-info-sign x-icon-left"></i>请输入正确的邮箱</span>
  88. </div>
  89. </div>
  90. </div>
  91. <button class="btn" @click="confirm">提交</button>
  92. </div>
  93. </div>
  94. <div class="msg-table" v-else-if="!showHistory && user.userUU">
  95. <div class="history" v-for="message in messageBoardCurrent.content">
  96. <div class="form-group row">
  97. <div class="col-xs-8">{{message.type}}</div>
  98. <div class="msgDate col-xs-4">{{message.createDate | date}}</div>
  99. </div>
  100. <div class="question">
  101. <span>问题:</span>
  102. <span style="word-break: break-all">{{message.question}}</span>
  103. </div>
  104. <div class="answer" v-show="message.answer" style="margin-bottom: 10px;">
  105. <span>回复:</span>
  106. <span style="word-break: break-all">{{message.answer}}</span>
  107. </div>
  108. </div>
  109. <div class="text-center" v-if="!messageBoardCurrent || messageBoardCurrent.length === 0">
  110. <div>无留言记录</div>
  111. </div>
  112. </div>
  113. <div class="page" v-if="!showHistory">
  114. <page :total="messageBoardCurrent.totalElements" :page-size="pageParams.count"
  115. :current="pageParams.page" @childEvent="listenPage"></page>
  116. </div>
  117. <div class="msg-slide1" @click="isOpenHistory" v-if="showHistory">
  118. <i class="fa fa-angle-left"></i><span>留言记录</span>
  119. </div>
  120. <div class="msg-slide2" @click="isHideHistory" v-if="!showHistory">
  121. <i class="fa fa-angle-right"></i><span>关闭记录</span>
  122. </div>
  123. </div>
  124. </div>
  125. </template>
  126. <script>
  127. import upload from '~components/common/upload/upload.vue'
  128. import Page from '~components/common/page/pageComponent.vue'
  129. export default {
  130. name: 'messageBoard',
  131. data () {
  132. return {
  133. pageParams: {
  134. page: 1,
  135. count: 3,
  136. currentPage: 1,
  137. dialogVisible: false
  138. },
  139. showHistory: true,
  140. isOpen: true,
  141. txtVal: 0,
  142. isMobileValid: true,
  143. isEmail: true,
  144. messageBoard: {},
  145. dialogImageUrl: [null, null, null, null, null]
  146. }
  147. },
  148. components: {
  149. Page,
  150. upload
  151. },
  152. computed: {
  153. messageBoardInfo () {
  154. return this.$store.state.messageBoard.information.data
  155. },
  156. logged () {
  157. return this.$store.state.option.user.logged
  158. },
  159. user () {
  160. return this.$store.state.option.user.data
  161. },
  162. isLogin () {
  163. return this.$store.state.option.user.logged
  164. },
  165. messageBoardCurrent () {
  166. return this.$store.state.messageBoardInformation.information.data
  167. }
  168. },
  169. filters: {
  170. date: function (num) {
  171. const d = new Date(num)
  172. const year = d.getFullYear()
  173. const month = d.getMonth() + 1 < 10 ? '0' + (d.getMonth() + 1) : '' + d.getMonth() + 1
  174. const day = d.getDate() < 10 ? '0' + d.getDate() : '' + d.getDate()
  175. return year + '-' + month + '-' + day
  176. }
  177. },
  178. methods: {
  179. listenUpload: function (url, index) {
  180. let imgUrl = {}
  181. imgUrl.img = url.url
  182. this.dialogImageUrl[index] = imgUrl
  183. },
  184. listenPage (page) {
  185. this.pageParams.page = page
  186. this.$emit('pageEvent', page)
  187. },
  188. isOpendMessage () {
  189. this.$emit('openBoardEvent', false)
  190. },
  191. isOpenHistory () {
  192. if (!this.isLogin) {
  193. this.login()
  194. } else {
  195. this.$store.dispatch('getMessageBoardInformation', {page: 1, count: 3})
  196. this.showHistory = !this.showHistory
  197. }
  198. },
  199. isHideHistory () {
  200. this.showHistory = !this.showHistory
  201. },
  202. textareaLength () {
  203. this.txtVal = this.messageBoard.question.length
  204. },
  205. // 判断手机号
  206. checkMobile () {
  207. this.isMobileValid = (/^[\d]{8,11}$/).test(this.messageBoard.userTel)
  208. },
  209. // 判断邮箱
  210. checkEmail () {
  211. this.isEmail = (/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/).test(this.messageBoard.email)
  212. },
  213. confirm () {
  214. let imgUrls = []
  215. this.dialogImageUrl.forEach(item => {
  216. if (item) {
  217. imgUrls.push(item)
  218. }
  219. })
  220. if (!this.logged) {
  221. if (!this.messageBoard.question) {
  222. this.$message.info('您还没有填写反馈内容')
  223. } else if (!this.messageBoard.role) {
  224. this.$message.info('请选择您的身份信息')
  225. } else if (!this.messageBoard.type) {
  226. this.$message.info('请选择一种反馈类型')
  227. } else if (!this.messageBoard.userTel && !this.messageBoard.email) {
  228. this.$message.info('请填写任意一种联系方式')
  229. } else {
  230. if (this.isMobileValid === false) {
  231. this.$message.info('请输入正确的手机号码')
  232. } else if (this.isEmail === false) {
  233. this.$message.info('请输入正确的邮箱')
  234. } else {
  235. this.$store.dispatch('uploadMessageBoardInformation', {
  236. question: this.messageBoard.question,
  237. role: this.messageBoard.role,
  238. submitTitle: '【优软商城】IC电子元器件现货采购交易平台商城',
  239. submitUrl: window.location.href,
  240. type: this.messageBoard.type,
  241. imgs: imgUrls,
  242. userTel: this.messageBoard.userTel ? this.messageBoard.userTel : '',
  243. email: this.messageBoard.email ? this.messageBoard.email : ''
  244. })
  245. this.isOpendMessage()
  246. this.$message.info('感谢您的宝贵意见')
  247. this.messageBoard = {}
  248. this.dialogImageUrl = [null, null, null, null, null]
  249. }
  250. }
  251. } else {
  252. if (!this.messageBoard.question) {
  253. this.$message.info('您还没有填写反馈内容')
  254. } else if (!this.messageBoard.role) {
  255. this.$message.info('请选择您的身份信息')
  256. } else if (!this.messageBoard.type) {
  257. this.$message.info('请选择一种反馈类型')
  258. } else {
  259. this.$store.dispatch('uploadMessageBoardInformation', {
  260. question: this.messageBoard.question,
  261. role: this.messageBoard.role,
  262. submitTitle: '【优软商城】IC电子元器件现货采购交易平台商城',
  263. submitUrl: window.location.href,
  264. type: this.messageBoard.type,
  265. imgs: imgUrls
  266. })
  267. this.isOpendMessage()
  268. this.$message.info('感谢您的宝贵意见')
  269. this.messageBoard = {}
  270. this.dialogImageUrl = [null, null, null, null, null]
  271. }
  272. }
  273. }
  274. }
  275. }
  276. </script>
  277. <style scoped>
  278. .messageBoard {
  279. width: 680px;
  280. font-size: 14px;
  281. background: #fff;
  282. }
  283. .messageBoard .modal-header {
  284. position: relative;
  285. background: url("/images/messageBoard/msg_nav.png") no-repeat left center;
  286. min-height: 0;
  287. padding: 11.5px;
  288. text-align: center;
  289. }
  290. .messageBoard .modal-header i{
  291. position: absolute;
  292. top: 5px;
  293. left: 650px;
  294. font-size: 20px;
  295. color: #fff;
  296. cursor: pointer;
  297. }
  298. .messageBoard .modal-header>h3{
  299. font-size: 18px;
  300. color: #000;
  301. }
  302. .messageBoard .modal-header .modal-title {
  303. margin-left: 30px;
  304. text-align: center;
  305. color: #fff;
  306. }
  307. .messageBoard .modal-header .modal-title span{
  308. vertical-align: middle;
  309. }
  310. .messageBoard .modal-body {
  311. padding: 10px;
  312. min-height: 445px;
  313. margin: 0 auto;
  314. width: 680px;
  315. }
  316. .messageBoard .modal-body h3{
  317. width: 680px;
  318. text-align: center;
  319. font-size: 14px;
  320. color: #333;
  321. margin: 0 0 10px 0;
  322. }
  323. .messageBoard .modal-body h3 span{
  324. color: #5078cb;
  325. }
  326. .messageBoard .modal-body .form-message{
  327. width: 680px;
  328. text-align: center;
  329. }
  330. .messageBoard .modal-body .form-message .txtArea{
  331. position: relative;
  332. }
  333. .messageBoard .modal-body .form-message textarea {
  334. padding: 10px 10px 20px 10px;
  335. width: 576px;
  336. height: 110px;
  337. color: #333;
  338. border: #c5c5c5 1px solid;
  339. font-size: 13px;
  340. letter-spacing: 1px;
  341. line-height: 18px;
  342. }
  343. .messageBoard .modal-body .form-message span.count_tip{
  344. position: absolute;
  345. bottom: 4px;
  346. right: 55px;
  347. display: inline-block;
  348. width: 564px;
  349. height: 20px;
  350. color: #979797;
  351. line-height: 20px;
  352. font-size: 12px;
  353. background: #fff;
  354. text-align: right;
  355. padding-right: 5px;
  356. }
  357. .messageBoard .modal-body .form-message p{
  358. padding-left: 40px;
  359. text-align: left;
  360. font-size: 14px;
  361. margin: 5px;
  362. color: #333;
  363. }
  364. .messageBoard .modal-body p.radioCheck{
  365. padding-left: 65px;
  366. }
  367. .messageBoard .modal-body .form-message input{
  368. padding: 0 10px;
  369. margin-left: 20px;
  370. height: 30px;
  371. width: 290px;
  372. font-size: 14px;
  373. color: #656565;
  374. border: #c5c5c5 1px solid;
  375. vertical-align: sub;
  376. }
  377. .messageBoard .modal-body .form-message label{
  378. margin-right: 25px;
  379. }
  380. /*查看图片*/
  381. .messageBoard .modal-body .form-message .img-warp{
  382. position: relative;
  383. overflow: hidden;
  384. width: 80%;
  385. margin: 0 auto;
  386. text-align: center;
  387. }
  388. .messageBoard .modal-body .form-message div.img-item{
  389. position: relative;
  390. float: left;
  391. margin-right: 23px;
  392. width: 82px;
  393. height: 70px;
  394. overflow: hidden;
  395. cursor: pointer;
  396. border: #C9C9C9 1px solid;
  397. font-size: 14px;
  398. }
  399. .messageBoard .modal-body .form-message div.img-item:last-child{
  400. margin-right: 0;
  401. }
  402. .messageBoard .modal-body .form-message div.img-item img{
  403. display: inline-block;
  404. max-width: 80px;
  405. max-height: 78px;
  406. z-index: 10;
  407. margin-top: 4px;
  408. }
  409. /*查看图片*/
  410. .messageBoard .modal-body .form-message p.tip{
  411. text-align: left;
  412. color: #999;
  413. font-size: 12px;
  414. padding-left: 68px;
  415. }
  416. .messageBoard .modal-body .form-message label{
  417. margin-bottom: 10px;
  418. font-size: 14px;
  419. font-weight: normal;
  420. }
  421. .messageBoard .modal-body .form-message input[type='text']{
  422. width: 295px;
  423. }
  424. .messageBoard .modal-body .form-message button{
  425. margin: 10px auto;
  426. width: 100px;
  427. height: 35px;
  428. background: #4777C6;
  429. color: #fff;
  430. border-radius: 0;
  431. text-align: center;
  432. }
  433. .messageBoard .modal-body .form-message .msg-message>label{
  434. font-size: 14px;
  435. }
  436. .messageBoard .modal-body .form-message .msg-message span{
  437. margin: 0 auto;
  438. font-size: 12px;
  439. margin-left: 5px;
  440. }
  441. .messageBoard .modal-body .form-message .input-style span{
  442. color: #666;
  443. }
  444. .messageBoard .modal-body .form-message .msg-message span i{
  445. padding-right: 5px;
  446. color: #4777C6;
  447. }
  448. .messageBoard .modal-body .form-message b{
  449. margin-right: 5px;
  450. font-weight: bold;
  451. color: #FF5A5C;
  452. }
  453. .messageBoard .modal-body .form-message b.first{
  454. position: relative;
  455. top: -95px;
  456. left: 2px;
  457. }
  458. .messageBoard .modal-body .history{
  459. border-collapse: collapse;
  460. margin: 10px auto;
  461. padding: 0 20px;
  462. width: 500px;
  463. min-height: 105px;
  464. font-size: 16px;
  465. color: #333;
  466. border-bottom: 1px dashed #c5c5c5;
  467. }
  468. .messageBoard .modal-body .msg-table{
  469. /*position: absolute;*/
  470. overflow: auto;
  471. height: 372px;
  472. width: 670px;
  473. margin-top: 10px;
  474. }
  475. .messageBoard .modal-body .msg-table .form-group{
  476. margin-bottom: 15px;
  477. }
  478. .messageBoard .modal-body .msgDate {
  479. padding-right: 55px;
  480. text-align: right;
  481. font-size: 13px;
  482. }
  483. .messageBoard .modal-body .question{
  484. margin-bottom: 10px;
  485. font-size: 12px;
  486. font-weight: normal;
  487. list-style-type: none;
  488. font-style: inherit;
  489. }
  490. .messageBoard .modal-body .answer{
  491. margin-bottom: 10px;
  492. color: #fa842d;
  493. font-size: 12px;
  494. font-weight: normal;
  495. list-style-type: none;
  496. font-style: inherit;
  497. }
  498. .messageBoard .msg-slide1{
  499. position: absolute;
  500. right: 0;
  501. top: 50%;
  502. width: 33px;
  503. height: 100px;
  504. margin-top: -50px;
  505. background: url("/images/messageBoard/circle-left.png") no-repeat top right;
  506. color: #fff;
  507. cursor: pointer;
  508. }
  509. .messageBoard .msg-slide1 span{
  510. display: inline-block;
  511. width: 20px;
  512. height: 40px;
  513. padding-top: 16px;
  514. margin-left: 13px;
  515. text-align: center;
  516. vertical-align: middle;
  517. }
  518. .messageBoard .msg-slide1 i{
  519. position: absolute;
  520. top: 50%;
  521. left: 2px;
  522. line-height: 20px;
  523. margin-top: -10px;
  524. font-size: 26px;
  525. }
  526. .messageBoard .msg-slide2{
  527. width: 33px;
  528. height: 100px;
  529. position: absolute;
  530. top: 50%;
  531. left: 0;
  532. margin-top: -50px;
  533. background: url("/images/messageBoard/circle-right.png") no-repeat top right;
  534. color: #fff;
  535. cursor: pointer;
  536. }
  537. .messageBoard .msg-slide2 span{
  538. display: inline-block;
  539. width: 20px;
  540. height: 40px;
  541. padding-top: 16px;
  542. margin-right: 13px;
  543. text-align: center;
  544. vertical-align: middle;
  545. }
  546. .messageBoard .msg-slide2 i{
  547. position: absolute;
  548. top: 50%;
  549. right: 2px;
  550. line-height: 20px;
  551. margin-top: -10px;
  552. font-size: 26px;
  553. }
  554. .msg-message{
  555. text-align: left;
  556. margin-bottom: 5px;
  557. height: 30px;
  558. line-height: 30px;
  559. }
  560. .msg-message .msg-content label{
  561. margin-left: 75px;
  562. margin-right: 0 !important;
  563. }
  564. .msg-message .modal-body div.txtArea{
  565. padding-left: 55px;
  566. }
  567. .messageBoard .modal-body .form-message p.radioLabel{
  568. margin-bottom: 10px;
  569. }
  570. .radioLabel {
  571. line-height: 20px;
  572. cursor: pointer;
  573. color: #666;
  574. }
  575. .radioLabel label{
  576. width: 16px;
  577. height: 16px;
  578. background: url("/images/messageBoard/radio.png");
  579. background-position: 0 -1px;
  580. margin-right: 2px;
  581. vertical-align: middle;
  582. margin-bottom: 0 !important;
  583. margin-right: 0 !important;
  584. }
  585. .radioLabel input[type="radio"]:checked + label {
  586. background-position: -19px -1px;
  587. }
  588. .radioLabel input[type="radio"] + label + span {
  589. margin-left: 5px;
  590. }
  591. .radioLabel input[type="radio"]:checked + label + span{
  592. color: #5078cb;
  593. }
  594. .radioLabel input[type="radio"]{
  595. display: none;
  596. }
  597. /*分页*/
  598. .page {
  599. text-align: center;
  600. }
  601. .page .page-wrap{
  602. float: none;
  603. }
  604. .page-wrap ul, .page-wrap div {
  605. float: none !important;
  606. display: inline-block;
  607. margin: 0;
  608. }
  609. </style>