index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="content">
  3. <view class="header"></view>
  4. <view class="form">
  5. <view class="form_title">
  6. 登记信息
  7. </view>
  8. <view class="form_item">
  9. 姓名<span class="icon">*</span>
  10. <uni-easyinput placeholder="请输入姓名" v-model="name"></uni-easyinput>
  11. </view>
  12. <view class="form_item">
  13. 手机号<span class="icon">*</span>
  14. <uni-easyinput type="number" placeholder="请输入手机号" v-model="phone"></uni-easyinput>
  15. </view>
  16. <view class="form_item">
  17. 单位名称<span class="icon">*</span>
  18. <uni-easyinput placeholder="请输入单位名称" v-model="company"></uni-easyinput>
  19. </view>
  20. <view class="form_item">
  21. 事件登记<span class="icon">*</span>
  22. <uni-easyinput type="textarea" :maxlength="-1" placeholder="请输入需要登记的事件" v-model="content">
  23. </uni-easyinput>
  24. </view>
  25. <button class="form_button" @click="handleSubmit">提交</button>
  26. </view>
  27. <view class="footer">
  28. 该系统由创海科技提供技术支持
  29. </view>
  30. </view>
  31. </template>
  32. <script setup>
  33. import {
  34. ref,
  35. onMounted
  36. } from 'vue'
  37. import {
  38. myRequest
  39. } from "../../util/api.js"
  40. onMounted(() => {
  41. const accredit = uni.getStorageSync('accredit')
  42. if (accredit) {
  43. submit()
  44. }
  45. })
  46. const name = ref(uni.getStorageSync('form_name') || '')
  47. const phone = ref(uni.getStorageSync('form_phone') || '')
  48. const company = ref(uni.getStorageSync('form_company') || '')
  49. const content = ref(uni.getStorageSync('form_content') || '')
  50. const wxPhone = ref(uni.getStorageSync('wxPhone') || '')
  51. const handleSubmit = () => {
  52. const reName = /^[\u4e00-\u9fa5]{2,4}$/
  53. const rePhone = /^[1][3,4,5,7,8,9][0-9]{9}$/
  54. if (name.value == '') {
  55. uni.showToast({
  56. title: '请输入姓名',
  57. icon: 'none'
  58. })
  59. return
  60. }
  61. if (!reName.test(name.value)) {
  62. uni.showToast({
  63. title: '姓名格式有误',
  64. icon: 'none'
  65. })
  66. return
  67. }
  68. if (phone.value == '') {
  69. uni.showToast({
  70. title: '请输入手机号',
  71. icon: 'none'
  72. })
  73. return
  74. }
  75. if (!rePhone.test(phone.value)) {
  76. uni.showToast({
  77. title: '手机格式有误',
  78. icon: 'none'
  79. })
  80. return
  81. }
  82. if (company.value == '') {
  83. uni.showToast({
  84. title: '请输入单位名称',
  85. icon: 'none'
  86. })
  87. return
  88. }
  89. if (!content.value) {
  90. uni.showToast({
  91. title: '请输入需要登记的事件',
  92. icon: 'none'
  93. })
  94. return
  95. }
  96. uni.setStorageSync('form_name', name.value);
  97. uni.setStorageSync('form_phone', phone.value);
  98. uni.setStorageSync('form_company', company.value);
  99. uni.setStorageSync('form_content', content.value);
  100. if (!wxPhone.value) {
  101. uni.showModal({
  102. title: '提示',
  103. content: '本次操作需要获取您的手机号码',
  104. success: (res) => {
  105. if (res.confirm) {
  106. uni.navigateTo({
  107. url: "/pages/authorization/authorization"
  108. })
  109. } else if (res.cancel) {
  110. }
  111. }
  112. });
  113. } else {
  114. uni.showModal({
  115. title: '提示',
  116. content: '确认提交吗',
  117. success: (res) => {
  118. if (res.confirm) {
  119. submit()
  120. } else if (res.cancel) {
  121. }
  122. }
  123. });
  124. }
  125. }
  126. const submit = async () => {
  127. const res = await myRequest({
  128. url: "/informationReporting/add",
  129. method: "post",
  130. data: {
  131. name: name.value,
  132. phone: phone.value,
  133. company: company.value,
  134. content: content.value,
  135. wxPhone: wxPhone.value,
  136. }
  137. })
  138. // console.log(res)
  139. if (res.success && res.code == 1) {
  140. uni.showToast({
  141. title: '提交成功',
  142. duration: 3000
  143. })
  144. content.value = ''
  145. uni.setStorageSync('form_content', '')
  146. uni.setStorageSync('accredit', false)
  147. } else {
  148. uni.showToast({
  149. title: res.message,
  150. icon: 'error'
  151. })
  152. }
  153. }
  154. </script>
  155. <style lang="scss" scoped>
  156. .content {
  157. width: 100vw;
  158. height: 100vh;
  159. background-color: #F2F2F2;
  160. .header {
  161. width: 750rpx;
  162. height: 300rpx;
  163. border-radius: 0 0 10% 10%;
  164. background-color: #1E7DFB;
  165. }
  166. .form {
  167. position: absolute;
  168. top: 42rpx;
  169. left: 30rpx;
  170. right: 30rpx;
  171. padding: 0 32rpx;
  172. height: 1055rpx;
  173. border-radius: 10rpx;
  174. background-color: #fff;
  175. .form_title {
  176. line-height: 105rpx;
  177. font-weight: bold;
  178. font-size: 34rpx;
  179. }
  180. .form_item {
  181. margin-bottom: 20rpx;
  182. font-size: 28rpx;
  183. .icon {
  184. color: #D43030;
  185. }
  186. :deep .uni-easyinput {
  187. margin-top: 10rpx;
  188. background-color: #F2F2F2;
  189. }
  190. }
  191. .form_button {
  192. margin-top: 65rpx;
  193. background-color: #1E7DFB;
  194. color: #fff;
  195. font-size: 28rpx;
  196. }
  197. }
  198. .footer {
  199. position: absolute;
  200. bottom: 44rpx;
  201. width: 100vw;
  202. text-align: center;
  203. font-size: 24rpx;
  204. color: #999999;
  205. }
  206. }
  207. </style>