feedback.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="feedback">
  3. <view class="uni-form-item content">
  4. <view class="title">反馈内容</view>
  5. <textarea class="uni-textarea" placeholder="请输入留言内容" v-model="params.feedbackContext"/>
  6. </view>
  7. <view class="uni-form-item tel">
  8. <view class="title">如有需要,留下您的联系方式,方便我们联系您</view>
  9. <input class="uni-input" focus placeholder="邮箱/QQ/微信/手机号(可选)" v-model="params.tel" />
  10. </view>
  11. <view class="uni-form-item">
  12. <button type="primary" @click="postData">提交反馈</button>
  13. </view>
  14. <u-toast ref="uToast" />
  15. </view>
  16. </template>
  17. <script>
  18. export default{
  19. name:"feedback",
  20. components:{
  21. },
  22. data(){
  23. return{
  24. content:'',
  25. tel:'',
  26. message:'',
  27. messageType:'',
  28. params:{
  29. "fkCustomerId":'',
  30. "feedbackContext":'',
  31. "tel":''
  32. }
  33. }
  34. },
  35. mounted() {
  36. let u = uni.getStorageSync('userInfo');
  37. this.params.fkCustomerId = u.guid;
  38. },
  39. methods:{
  40. showToast() {
  41. this.$refs.uToast.show({
  42. title: this.message,
  43. type: this.messageType,
  44. icon:false,
  45. // url: '/pages/user/index'
  46. })
  47. },
  48. postData(data){
  49. if(!this.params.feedbackContext){
  50. this.messageType ="error";
  51. this.message = "请输入留言内容";
  52. this.showToast();
  53. return false;
  54. }else{
  55. var wxReg = new RegExp("^[a-zA-Z]([-_a-zA-Z0-9]{5,19})+$"); //微信号正则校验
  56. var qqReg = new RegExp("[1-9][0-9]{4,}"); //QQ号正则校验
  57. var phReg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; //手机号正则校验
  58. if(this.params.tel.length > 0){
  59. if(!wxReg.test(this.params.tel)&&!qqReg.test(this.params.tel)&&!phReg.test(this.params.tel)){
  60. this.messageType ="error";
  61. this.message = "邮箱/QQ/微信/手机号 输入不正确";
  62. this.$refs.uToast.show({
  63. title: this.message,
  64. type: 'error',
  65. // url: '/pages/user/index'
  66. });
  67. return false;
  68. }
  69. };
  70. this.$u.api.feedbackAdd(this.params).then(res => {
  71. console.log(res);
  72. if(res.retHead.errCode=='0'){
  73. this.messageType ="success";
  74. this.message = "留言成功";
  75. this.params.feedbackContext = '';
  76. this.params.tel = '';
  77. this.showToast();
  78. }else{
  79. this.$api.msg(res.retHead.errMsg)
  80. };
  81. // console.log(res);
  82. }).catch(err =>{
  83. console.log('articleFeedback err', err);
  84. })
  85. }
  86. }
  87. }
  88. }
  89. </script>
  90. <style scoped>
  91. .feedback{
  92. padding:0 40rpx;
  93. }
  94. .feedback .uni-form-item{
  95. margin-bottom:30rpx;
  96. }
  97. .feedback .content .title{
  98. font-size:34rpx;
  99. font-weight:500;
  100. color:rgba(102,102,102,1);
  101. padding:20rpx 0;
  102. }
  103. .feedback .content .uni-textarea{
  104. width:100%;
  105. height:500rpx;
  106. background:rgba(248,248,248,1);
  107. border-radius:28rpx;
  108. padding:20rpx;
  109. box-sizing: border-box;
  110. }
  111. .feedback .tel .title{
  112. font-size:28rpx;
  113. font-weight:400;
  114. color:rgba(153,153,153,1);
  115. line-height:40px;
  116. }
  117. .feedback .tel .uni-input{
  118. box-sizing: border-box;
  119. width:100%;
  120. height:110rpx;
  121. background:rgba(248,248,248,1);
  122. border-radius:24rpx;
  123. padding:3rpx 30rpx;
  124. }
  125. .feedback .tel .uni-input::-webkit-input-placeholder{color: #D4D4D4;}
  126. button{
  127. width: 400rpx;
  128. height: 88rpx;
  129. line-height: 88rpx;
  130. background-color: #65B74E;
  131. border-radius: 44rpx;
  132. }
  133. </style>