index.vue 4.6 KB

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