authorizer.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <!-- @format -->
  2. <template>
  3. <view class="container">
  4. <view style="color: #3c9cff" class="informationTitle">填写个人信息</view>
  5. <view class="informationContent">
  6. <view class="contentItems">
  7. <u-form ref="uForm" labelWidth="140" :model="form" labelPosition="top">
  8. <view class="content">
  9. <u-form-item
  10. :required="true"
  11. style="border-bottom: 1px solid rgb(242, 242, 242)"
  12. label="身份证号"
  13. prop="idNum"
  14. >
  15. <u-input
  16. @blur="handleUpadteSync('idNum')"
  17. v-model="form.idNum"
  18. placeholder="请输入身份证号"
  19. ></u-input>
  20. </u-form-item>
  21. </view>
  22. <view class="content">
  23. <u-form-item
  24. :required="true"
  25. style="border-bottom: 1px solid rgb(242, 242, 242)"
  26. label="真实姓名"
  27. prop="name"
  28. >
  29. <u-input
  30. @blur="handleUpadteSync('name')"
  31. v-model="form.name"
  32. placeholder="请输入名字"
  33. ></u-input>
  34. </u-form-item>
  35. </view>
  36. <view class="content">
  37. <u-form-item
  38. :required="true"
  39. style="border-bottom: 1px solid rgb(242, 242, 242)"
  40. label="用户名"
  41. >
  42. <!-- <view class="message">{{
  43. formdData.personCardOrcResult.idNum
  44. }}</view> -->
  45. <u-input
  46. disabled
  47. :value="formdData.personCardOrcResult.idNum"
  48. ></u-input>
  49. </u-form-item>
  50. </view>
  51. <view class="content">
  52. <u-form-item
  53. :required="true"
  54. style="border-bottom: 1px solid rgb(242, 242, 242)"
  55. label="密码"
  56. prop="pwd"
  57. >
  58. <u-input
  59. type="password"
  60. @blur="handleUpadteSync('pwd')"
  61. v-model="form.pwd"
  62. placeholder="请输入密码"
  63. ></u-input>
  64. </u-form-item>
  65. </view>
  66. <view class="content">
  67. <u-form-item
  68. :required="true"
  69. style="border-bottom: 1px solid rgb(242, 242, 242)"
  70. label="确认密码"
  71. prop="pwdReset"
  72. >
  73. <u-input
  74. type="password"
  75. @blur="handleUpadteSync('pwdReset')"
  76. v-model="form.pwdReset"
  77. placeholder="保持两次密码一致"
  78. ></u-input>
  79. </u-form-item>
  80. </view>
  81. <view class="content">
  82. <u-form-item
  83. :required="true"
  84. style="border-bottom: 1px solid rgb(242, 242, 242)"
  85. label="手机号"
  86. prop="phone"
  87. >
  88. <u-input
  89. @blur="handleUpadteSync('phone')"
  90. v-model="form.phone"
  91. placeholder="请输入联系人手机号"
  92. ></u-input>
  93. </u-form-item>
  94. </view>
  95. </u-form>
  96. </view>
  97. </view>
  98. </view>
  99. </template>
  100. <script>
  101. import { idcardOCR } from "@/api/companiesRegistered";
  102. export default {
  103. data() {
  104. return {
  105. form: {
  106. pwd: "",
  107. pwdReset: "",
  108. phone: "",
  109. idNum: "",
  110. name: "",
  111. },
  112. rules: {
  113. name: [
  114. {
  115. required: true,
  116. message: "名字不能为空",
  117. trigger: "blur",
  118. },
  119. ],
  120. idNum: [
  121. {
  122. required: true,
  123. message: "身份证号不能为空",
  124. trigger: "blur",
  125. },
  126. {
  127. validator: (rule, value, callback) => {
  128. return uni.$u.test.idCard(value);
  129. },
  130. message: "身份证号不正确",
  131. // 触发器可以同时用blur和change
  132. trigger: ["change", "blur"],
  133. },
  134. ],
  135. pwd: [
  136. {
  137. required: true,
  138. message: "密码不能为空",
  139. trigger: "blur",
  140. },
  141. {
  142. validator: (rule, value, callback) => {
  143. if (value.trim().length < 8) {
  144. callback(new Error("密码长度不能低于8位"));
  145. } else {
  146. callback();
  147. }
  148. },
  149. trigger: "change",
  150. },
  151. ],
  152. pwdReset: [
  153. {
  154. // 自定义验证函数,见上说明
  155. validator: (rule, value, callback) => {
  156. if (value !== this.form.pwd) {
  157. callback(new Error("两次密码不一致"));
  158. } else {
  159. callback();
  160. }
  161. },
  162. trigger: ["blur", "change"],
  163. },
  164. ],
  165. phone: [
  166. {
  167. required: true,
  168. message: "手机号不能为空",
  169. trigger: "blur",
  170. },
  171. {
  172. // 自定义验证函数,见上说明
  173. validator: (rule, value, callback) => {
  174. return uni.$u.test.mobile(value);
  175. },
  176. message: "手机号码不正确",
  177. // 触发器可以同时用blur和change
  178. trigger: ["change", "blur"],
  179. },
  180. ],
  181. },
  182. };
  183. },
  184. props: {
  185. formdData: {
  186. type: Object,
  187. default: () => ({}),
  188. },
  189. authorizerRef: {},
  190. },
  191. onReady() {
  192. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  193. this.$refs.uForm.setRules(this.rules);
  194. this.$emit("update:authorizerRef", this.$refs.uForm);
  195. },
  196. created() {
  197. Object.keys(this.form).forEach((key) => {
  198. this.form[key] = this.formdData.personCardOrcResult[key];
  199. });
  200. },
  201. methods: {
  202. handleUpadteSync(key) {
  203. this.$emit("update:formdData", {
  204. ...this.formdData,
  205. personCardOrcResult: {
  206. ...this.formdData.personCardOrcResult,
  207. [key]: this.form[key],
  208. },
  209. });
  210. },
  211. },
  212. };
  213. </script>
  214. <style lang="scss">
  215. .topic {
  216. color: #909399;
  217. font-size: 24rpx;
  218. width: 400rpx;
  219. margin: 20rpx auto 0;
  220. font-family: "宋体";
  221. }
  222. .uploadTipcContent {
  223. width: 555rpx;
  224. height: 260rpx;
  225. padding: 30rpx;
  226. border: 1px dotted#909399;
  227. }
  228. .updateContent {
  229. display: flex;
  230. background: #fff;
  231. padding: 30rpx;
  232. }
  233. .informationTitle {
  234. margin-bottom: 30rpx;
  235. font-size: 30;
  236. }
  237. .contentItems {
  238. width: 100%;
  239. border-radius: 6px;
  240. background: #fff;
  241. margin: 0rpx auto 30rpx;
  242. padding: 20rpx 30rpx 20rpx;
  243. .content {
  244. border-bottom: 1px solid rgb(242, 242, 242);
  245. padding: 0rpx 0 10rpx;
  246. }
  247. .content:last-child {
  248. border-bottom: none;
  249. }
  250. .title {
  251. font-size: 30rpx;
  252. color: black;
  253. letter-spacing: 3rpx;
  254. }
  255. .message {
  256. margin-left: 14rpx;
  257. text-align: right;
  258. // width: 420rpx;
  259. font-size: 30rpx;
  260. color: rgb(146, 146, 146);
  261. // white-space: nowrap;
  262. // /* 禁止文本换行 */
  263. // overflow: hidden;
  264. // /* 隐藏超出容器的文本 */
  265. // text-overflow: ellipsis;
  266. /* 使用省略号表示被截断的文本 */
  267. }
  268. }
  269. </style>