MessageBoard.vue 19 KB

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