other.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="home">
  3. <view class="putWarp dffd">
  4. <view class="putin bb dfsb">
  5. <text class="fontmid flex1">姓名</text>
  6. <input type="text" v-model="name" placeholder="填写姓名" />
  7. </view>
  8. <view class="putin bb dfsb">
  9. <text class="fontmid flex1">学校</text>
  10. <input type="text" v-model="school" placeholder="填写学校" />
  11. </view>
  12. <view class="putin bb dfsb">
  13. <text class="fontmid flex1">电话</text>
  14. <input type="number" v-model="phone" placeholder="填写联系方式" />
  15. </view>
  16. <view class="putin spec ">
  17. <text class="fontmid flex1">留言内容</text>
  18. <textarea class="lyCon" maxlength="-1" v-model="content" placeholder="填写留言内容" />
  19. </view>
  20. </view>
  21. <u-button color="#ED742F" @click="clickHandle" throttleTime="2000" class="custom-style" text="提交"></u-button>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. name: '',
  29. phone: '',
  30. school: '',
  31. content: ''
  32. };
  33. },
  34. onLoad(opt) {},
  35. onShow() {},
  36. methods: {
  37. clickHandle() {
  38. let phoneReg = /^(1[3-9])\d{9}$/;
  39. if (!phoneReg.test(this.phone)) {
  40. return this.$api.toast('手机号码不合法!');
  41. }
  42. if (!this.phone) {
  43. return this.$api.toast('请输入手机号');
  44. }
  45. if (!this.name) {
  46. return this.$api.toast('请输入姓名');
  47. }
  48. if (!this.school) {
  49. return this.$api.toast('请输入学校');
  50. }
  51. if (!this.content) {
  52. return this.$api.toast('请输入留言内容');
  53. }
  54. this.$api
  55. .request('user/setMessage', {
  56. name: this.name,
  57. school: this.school,
  58. phone: this.phone,
  59. content: this.content,
  60. })
  61. .then(data => {
  62. if (data.code == '200') {
  63. this.$api.toast(data.msg);
  64. setTimeout(res => {
  65. uni.navigateBack({
  66. delta: 1
  67. });
  68. }, 300);
  69. } else {
  70. this.$api.toast(data.msg);
  71. }
  72. })
  73. }
  74. }
  75. };
  76. </script>
  77. <style lang="scss">
  78. .home {
  79. padding: 20rpx 0rpx 0;
  80. //yanzhengma
  81. .u-hairline-border[data-v-3bf2dba7]:after {
  82. border: 0;
  83. }
  84. .tips {
  85. padding: 0;
  86. color: $promain;
  87. font-size: 28rpx;
  88. line-height: 40rpx;
  89. height: 40rpx;
  90. }
  91. .putWarp {
  92. background-color: #fff;
  93. padding: 0rpx 32rpx;
  94. align-items: center;
  95. .putin {
  96. width: 100%;
  97. padding: 30rpx 0;
  98. &:nth-last-of-type(1) {
  99. border-bottom: 0px;
  100. }
  101. input {
  102. flex: 1;
  103. font-size: 28rpx;
  104. }
  105. .promain {
  106. border-left: 1px solid #dbdbdb;
  107. padding-left: 30rpx;
  108. }
  109. input {
  110. text-align: right;
  111. }
  112. }
  113. .spec {
  114. .lyCon {
  115. width: 100%;
  116. margin-top: 30rpx;
  117. height: 201rpx;
  118. padding: 24rpx;
  119. font-size: 22rpx;
  120. background: #f4f4f4;
  121. }
  122. }
  123. }
  124. .custom-style {
  125. background-color: #ED742E;
  126. color: #fff;
  127. width: 690rpx;
  128. margin-top: 200rpx;
  129. border-radius: 11rpx;
  130. }
  131. }
  132. </style>