realNameAuth.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <view class="page">
  3. <view class="authView">
  4. <!-- 头部识别窗口 -->
  5. <view class="uploadOCR dis j-s">
  6. <view class="view dis f-c a-c mr-2">
  7. <image :src="frontImg?frontImg:'/static/image/my/auth-bg1.png'" mode="" @click="frontChange">
  8. </image>
  9. <text>人像面</text>
  10. </view>
  11. <view class="view dis f-c a-c ">
  12. <image :src="backImg?backImg:'/static/image/my/auth-bg2.png'" mode="" @click="backChange"></image>
  13. <text>国徽面</text>
  14. </view>
  15. </view>
  16. <view class="mt-3 mb-2">
  17. <u-gap height="5" bgColor="#FAFAFA"></u-gap>
  18. </view>
  19. <!-- 表单区域 -->
  20. <u--form labelPosition="left" :model="ownerInfo" ref="ownerForm" labelWidth="80" errorType="message">
  21. <u-form-item label="姓名" prop="name" borderBottom>
  22. <u-input v-model="ownerInfo.name" border="none" clearable placeholder="请输入姓名"
  23. placeholderStyle="text-align:right;"></u-input>
  24. </u-form-item>
  25. <u-form-item label="身份证号" borderBottom>
  26. <u-input v-model="ownerInfo.identity" border="none" clearable placeholder="请输入证件号"
  27. placeholderStyle="text-align:right;"></u-input>
  28. </u-form-item>
  29. <u-form-item label="手机号" borderBottom>
  30. <u-input v-model="ownerInfo.mobile" border="none" clearable placeholder="请输入手机号" maxlength="11"
  31. placeholderStyle="text-align:right;"></u-input>
  32. </u-form-item>
  33. <u-form-item label="有效期始" borderBottom @click="identifyValidDateShow = true; ">
  34. <u--input v-model="ownerInfo.identityTimeStart" disabled disabledColor="#ffffff" clearable
  35. suffixIcon='calendar' suffixIconStyle="color:#333;font-size:40rpx" placeholder="请选择证件起期 "
  36. placeholderStyle="text-align:right;" border="none" style="pointer-events: none"></u--input>
  37. </u-form-item>
  38. <u-form-item label="有效期止" @click="identifyValidEndDateShow = true; ">
  39. <u--input v-model="ownerInfo.identityTimeEnd" disabled disabledColor="#ffffff" clearable
  40. suffixIcon='calendar' suffixIconStyle="color:#333;font-size:40rpx;margin-right:20px"
  41. placeholder="请选择证件止期 " placeholderStyle="text-align:right;" border="none"
  42. style="pointer-events: none">
  43. </u--input>
  44. <u-checkbox-group v-model="ownerlongTerm" iconPlacement="right" @change="ownerlongTermChange">
  45. <u-checkbox activeColor="#FDE935" iconColor="#333" labelSize="15px" shape="circle" label="长期有效"
  46. name="长期有效"></u-checkbox>
  47. </u-checkbox-group>
  48. </u-form-item>
  49. </u--form>
  50. <view class="btn dis a-c j-c " @click="authEnticate">
  51. 确定
  52. </view>
  53. </view>
  54. <view class="footer mt-2">
  55. <view class="header dis a-c j-s mb-4">
  56. <image class="line" src="/static/image/my/auth-line1.png" mode=""></image>
  57. <text>实名认证后 将获得以下权限</text>
  58. <image class="line" src="/static/image/my/auth-line2.png" mode=""></image>
  59. </view>
  60. <view class="cell">
  61. <view class="item dis f-c a-c " v-for="(item,index) in celllsit" :key="index">
  62. <image :src="item.icon" mode=""></image>
  63. <text>{{item.text}}</text>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 日期组件 -->
  68. <u-datetime-picker :show="identifyValidDateShow" v-model="identifyValidDatevalue" mode="date"
  69. :formatter="formatter" @cancel="identifyValidDateShow=false" @close="identifyValidDateShow=false"
  70. :closeOnClickOverlay="true" @confirm="identifyValidDateconfirm" confirmText="确定"></u-datetime-picker>
  71. <u-datetime-picker :show="identifyValidEndDateShow" mode="date" v-model="identifyValidEndDatevalue"
  72. :formatter="formatter" @cancel="identifyValidEndDateShow=false" @confirm="identifyValidEndDateconfirm"
  73. :closeOnClickOverlay="true" @close="identifyValidEndDateShow=false" confirmText="确定"></u-datetime-picker>
  74. </view>
  75. </template>
  76. <script>
  77. import {
  78. mapState,
  79. mapMutations
  80. } from "vuex"
  81. import store from '@/store';
  82. export default {
  83. data() {
  84. return {
  85. identifyValidDateShow: false,
  86. identifyValidEndDateShow: false,
  87. identifyValidDatevalue: Number(new Date()), //证件起期
  88. identifyValidEndDatevalue: Number(new Date()), //证件止期
  89. ownerInfo: {
  90. name: "",
  91. mobile: "",
  92. identity: "",
  93. identityTimeStart: "",
  94. identityTimeEnd: "",
  95. },
  96. ownerlongTerm: [], //车主长期
  97. celllsit: [{
  98. icon: "/static/image/my/auth-footer1.png",
  99. text: "车险报价"
  100. }, {
  101. icon: "/static/image/my/auth-footer2.png",
  102. text: "专属客服"
  103. }, {
  104. icon: "/static/image/my/auth-footer3.png",
  105. text: "出单佣金"
  106. }, {
  107. icon: "/static/image/my/auth-footer4.png",
  108. text: "积分权益"
  109. }],
  110. ImageListId: [], //图片id
  111. frontImg: null,
  112. backImg: null,
  113. }
  114. },
  115. onShow() {
  116. },
  117. onLoad() {
  118. if (this.userInfo.sysUser?.authStatus == 2) {
  119. this.authenticateInfoQuery();
  120. }
  121. },
  122. computed: {
  123. ...mapState(['userInfo']),
  124. },
  125. methods: {
  126. //认证信息查询
  127. async authenticateInfoQuery() {
  128. let res = await this.$http.get('/appUser/authInfoGet?id=' + this.userInfo.sysUser.id)
  129. if (res.code == 200) {
  130. this.ownerInfo = {
  131. name: res.data.name,
  132. mobile: res.data.mobile,
  133. identity: res.data.identity,
  134. identityTimeStart: res.data.identityTimeStart,
  135. identityTimeEnd: res.data.identityTimeEnd,
  136. }
  137. } else {
  138. uni.showToast({
  139. title: '查询失败',
  140. icon: "none"
  141. });
  142. }
  143. },
  144. //起始日期回调时事件
  145. identifyValidDateconfirm(e) {
  146. this.ownerInfo.identityTimeStart = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
  147. this.identifyValidDateShow = false;
  148. },
  149. identifyValidEndDateconfirm(e) {
  150. this.ownerInfo.identityTimeEnd = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
  151. this.identifyValidEndDateShow = false;
  152. },
  153. //日期格式化函数
  154. formatter(type, value) {
  155. if (type === 'year') {
  156. return `${value}年`
  157. }
  158. if (type === 'month') {
  159. return `${value}月`
  160. }
  161. if (type === 'day') {
  162. return `${value}日`
  163. }
  164. return value
  165. },
  166. //长期处理
  167. ownerlongTermChange(e) {
  168. if (e.length) {
  169. this.ownerInfo.identityTimeEnd = '9999-12-31';
  170. } else {
  171. this.ownerInfo.identityTimeEnd = '';
  172. }
  173. },
  174. //提交认证
  175. async authEnticate() {
  176. let res = await this.$http.post('/appUser/authInfoAdd', {
  177. userId: this.userInfo.sysUser.userId,
  178. fileList: this.ImageListId,
  179. ...this.ownerInfo
  180. })
  181. if (res.code == 200) {
  182. //调用认证接口
  183. uni.navigateTo({
  184. url: '/pages/my/authStatusPage',
  185. })
  186. } else {
  187. uni.showToast({
  188. title: res.msg,
  189. icon: "none"
  190. });
  191. }
  192. },
  193. //car正面
  194. async frontChange() {
  195. let [chooseImageErr, chooseImageRes] = await uni.chooseImage({
  196. count: 1,
  197. sizeType: ['compressed']
  198. });
  199. let size = chooseImageRes.tempFiles[0].size / 1024 / 1024 < 5;
  200. if (!size) {
  201. this.$refs.uToast.show({
  202. title: '上传图片大小不能超过 5MB!',
  203. type: 'error',
  204. })
  205. return false
  206. }
  207. if (chooseImageRes) {
  208. this.frontImg = chooseImageRes.tempFilePaths[0];
  209. uni.uploadFile({
  210. url: this.$base.baseUrl + '/file/upload',
  211. filePath: chooseImageRes.tempFilePaths[0],
  212. name: "file",
  213. formData: {
  214. 'type': 'image',
  215. },
  216. header: {
  217. Authorization: store.state.token,
  218. system_code: store.state.system_code ? store.state.system_code : ''
  219. },
  220. success: (imgRes) => {
  221. let data = JSON.parse(imgRes.data);
  222. if (data.code == '200') {
  223. if (this.ImageListId.some(v => v.fileType == 'sfz1')) {
  224. this.ImageListId.map(val => {
  225. if (val.fileType == 'sfz1') {
  226. val.fileId = data.data.id;
  227. }
  228. })
  229. } else {
  230. this.ImageListId.push({
  231. fileId: data.data.id,
  232. fileType: "sfz1",
  233. })
  234. }
  235. }
  236. }
  237. });
  238. } else {}
  239. },
  240. async backChange() {
  241. let [chooseImageErr, chooseImageRes] = await uni.chooseImage({
  242. count: 1,
  243. sizeType: ['compressed']
  244. });
  245. let size = chooseImageRes.tempFiles[0].size / 1024 / 1024 < 5;
  246. if (!size) {
  247. this.$refs.uToast.show({
  248. title: '上传图片大小不能超过 5MB!',
  249. type: 'error',
  250. })
  251. return false
  252. }
  253. if (chooseImageRes) {
  254. this.backImg = chooseImageRes.tempFilePaths[0];
  255. uni.uploadFile({
  256. url: this.$base.baseUrl + '/file/upload',
  257. filePath: chooseImageRes.tempFilePaths[0],
  258. name: "file",
  259. formData: {
  260. 'type': 'image',
  261. },
  262. header: {
  263. Authorization: store.state.token,
  264. system_code: store.state.system_code ? store.state.system_code : ''
  265. },
  266. success: (imgRes) => {
  267. let data = JSON.parse(imgRes.data);
  268. if (data.code == '200') {
  269. if (this.ImageListId.some(v => v.fileType == 'sfz2')) {
  270. this.ImageListId.map(val => {
  271. if (val.fileType == 'sfz2') {
  272. val.fileId = data.data.id;
  273. }
  274. })
  275. } else {
  276. this.ImageListId.push({
  277. fileId: data.data.id,
  278. fileType: "sfz2",
  279. })
  280. }
  281. }
  282. }
  283. });
  284. } else {}
  285. },
  286. }
  287. }
  288. </script>
  289. <style lang="scss" scoped>
  290. .page {
  291. background-color: #F8F8F8;
  292. height: 100vh;
  293. }
  294. ::v-deep {
  295. .uni-input-input {
  296. text-align: right !important;
  297. }
  298. .u-checkbox__icon-wrap {
  299. margin-left: 10rpx;
  300. }
  301. }
  302. .authView {
  303. padding: 30rpx 30rpx 60rpx;
  304. box-sizing: border-box;
  305. background: #fff;
  306. .uploadOCR {
  307. .view {
  308. flex: 1;
  309. image {
  310. width: 100%;
  311. height: 207rpx;
  312. }
  313. text {
  314. font-size: 28rpx;
  315. color: #333;
  316. margin-top: 10rpx;
  317. }
  318. }
  319. }
  320. .btn {
  321. height: 88rpx;
  322. margin: 60rpx 10rpx 0;
  323. padding: 20rpx;
  324. box-sizing: border-box;
  325. background: #FDE935;
  326. border-radius: 45rpx 45rpx 45rpx 45rpx;
  327. font-size: 36rpx;
  328. color: #1F1F1F;
  329. font-weight: bold;
  330. }
  331. }
  332. .footer {
  333. background: #fff;
  334. padding: 40rpx 54rpx;
  335. box-sizing: border-box;
  336. .header {
  337. .line {
  338. width: 110rpx;
  339. height: 18rpx;
  340. }
  341. text {
  342. font-size: 30rpx;
  343. color: #333;
  344. }
  345. }
  346. .cell {
  347. display: grid;
  348. /* 启用网格布局 */
  349. grid-template-columns: repeat(4, 1fr);
  350. /* 3 列,每列等宽 */
  351. grid-template-rows: auto;
  352. /* 只设置行间距(上下) */
  353. column-gap: 30rpx;
  354. /* 列间距设为 0(可选) */
  355. .item {
  356. image {
  357. width: 70rpx;
  358. height: 70rpx;
  359. margin-bottom: 14rpx;
  360. }
  361. text {
  362. font-size: 28rpx;
  363. color: #333;
  364. }
  365. }
  366. }
  367. }
  368. </style>