RealNameCertification.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <div class="certification">
  3. <div class="container">
  4. <div class="content" v-show="goNextStep">
  5. <div class="content-top">
  6. <h3>实名认证</h3>
  7. <div class="step">
  8. <img src="/images/all/step01.png" alt=""/>
  9. <div class="step-item"><span class="active">认证申请</span><span>等待审核</span><span>审核结果</span></div>
  10. </div>
  11. </div>
  12. <div>
  13. <el-form :model="certification" :rules="rules" ref="certification" label-width="100px" class="demo-ruleForm">
  14. <el-form-item prop="realName">
  15. <el-input type="text" v-model="certification.realName"
  16. auto-complete="off"
  17. placeholder="真实姓名"></el-input>
  18. </el-form-item>
  19. <el-form-item prop="idCard">
  20. <el-input type="text" v-model="certification.idCard"
  21. auto-complete="off"
  22. v-bind:class="{ active: idCardHasCertification }"
  23. placeholder="身份证号"></el-input>
  24. <span class="tip" v-show="idCardHasCertification">身份已被认证,请确认。<a href="https://www.ubtob.com/contact">仍有问题?</a></span>
  25. </el-form-item>
  26. <el-form-item>
  27. <a class="btn finish"
  28. @click="submitRealName"
  29. :disabled="!checked || !realNameChecked || !idCardChecked">提交</a>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-checkbox name="type" v-model="checked" @click="checkboxIsChecked"></el-checkbox>
  33. <span class="agree">我已阅读并同意 <a href="/common/agreement">《优软云服务条款》</a></span>
  34. </el-form-item>
  35. </el-form>
  36. </div>
  37. </div>
  38. <div class="content" v-show="!goNextStep">
  39. <div class="content-top">
  40. <h3>实名认证</h3>
  41. <div class="step">
  42. <img src="/images/all/step02.png" alt=""/>
  43. <div class="step-item"><span class="active">认证申请</span><span class="active">等待审核</span><span>审核结果</span></div>
  44. </div>
  45. </div>
  46. <div class="content-bottom">
  47. <p><img src="/images/all/await.png" alt=""/>实名认证申请已提交,等待审核中</p>
  48. <span>我们会在1个工作日内审核您的资料,请耐心等待...</span>
  49. <div class="close-btn" @click="goCloudCenter">关闭</div>
  50. </div>
  51. </div>
  52. <div class="content" style="display: none">
  53. <div class="content-top">
  54. <h3>实名认证</h3>
  55. <div class="step">
  56. <img src="/images/all/step03.png" alt=""/>
  57. <div class="step-item"><span class="active">认证申请</span><span class="active">等待审核</span><span class="active">审核结果</span></div>
  58. </div>
  59. </div>
  60. <div class="content-bottom">
  61. <p class="pass"><img src="/images/all/times.png" alt=""/>审核不通过</p>
  62. <span>您好,您提交的实名认证资料未通过审核,请重新认证</span>
  63. <div class="close-btn">重新认证</div>
  64. </div>
  65. </div>
  66. <div class="content" style="display: none">
  67. <div class="content-top">
  68. <h3>实名认证</h3>
  69. <div class="step">
  70. <img src="/images/all/step03.png" alt=""/>
  71. <div class="step-item"><span class="active">认证申请</span><span class="active">等待审核</span><span class="active">审核结果</span></div>
  72. </div>
  73. </div>
  74. <div class="content-bottom">
  75. <p class="passed"><img src="/images/all/pass.png" alt=""/>审核通过</p>
  76. <span>恭喜您,您提交的实名认证申请通过审核了!</span>
  77. <div class="close-btn">关闭</div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </template>
  83. <script>
  84. export default {
  85. name: 'realNameCertification',
  86. data () {
  87. var validateRealName = (rule, value, callback) => {
  88. if (value === '') {
  89. callback(new Error('请填写您的真实姓名'))
  90. this.realNameChecked = false
  91. } else {
  92. if (this.certification.realName !== '') {
  93. if (value.length > 20) {
  94. callback(new Error('输入长度过长,20个字符以内'))
  95. this.realNameChecked = false
  96. } else {
  97. this.realNameChecked = true
  98. }
  99. }
  100. callback()
  101. }
  102. }
  103. var validateIdCard = (rule, value, callback) => {
  104. if (value === '') {
  105. callback(new Error('请填写您的身份证号'))
  106. this.idCardChecked = false
  107. this.idCardHasCertification = false
  108. } else {
  109. if (this.certification.idCard !== '') {
  110. var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
  111. if (reg.test(value)) {
  112. this.$http.get(`/api/user/idCard/valid`, {params: {idCard: this.certification.idCard}})
  113. .then(response => {
  114. if (response.data.content.isValid) {
  115. this.idCardChecked = false
  116. this.idCardHasCertification = true
  117. } else {
  118. this.idCardChecked = true
  119. this.idCardHasCertification = false
  120. return Promise.reject(response.data)
  121. }
  122. }).catch(err => {
  123. // this.$message.error(err.errMsg)
  124. console.log(err.content.isValid)
  125. })
  126. } else {
  127. callback(new Error('请填写正确的身份证号'))
  128. }
  129. }
  130. callback()
  131. }
  132. }
  133. return {
  134. goNextStep: true,
  135. showMsgTip: false,
  136. checked: true,
  137. certification: {
  138. realName: '',
  139. idCard: ''
  140. },
  141. realNameChecked: false,
  142. idCardChecked: false,
  143. idCardHasCertification: false,
  144. rules: {
  145. realName: [
  146. {validator: validateRealName, trigger: 'blur'}
  147. ],
  148. idCard: [
  149. {validator: validateIdCard, trigger: 'blur'}
  150. ]
  151. }
  152. }
  153. },
  154. computed: {
  155. logged () {
  156. return this.$store.state.option.isLogin.data.content
  157. }
  158. },
  159. mounted () {
  160. // 验证是否登录
  161. this.$nextTick(() => {
  162. this.isLogin()
  163. // 刷新统计信息
  164. setInterval(() => {
  165. this.isLogin()
  166. }, 10000)
  167. })
  168. },
  169. methods: {
  170. // 我同意是否被选中
  171. checkboxIsChecked () {
  172. this.checked = !this.checked
  173. },
  174. // 判断用户是否登录
  175. isLogin () {
  176. if (!this.logged.isLogin) {
  177. // 未登录跳到登录页面
  178. // window.location.href = '/'
  179. }
  180. },
  181. submitRealName () {
  182. if (this.checked && this.realNameChecked && this.idCardChecked) {
  183. let param = new FormData()
  184. param.append('realName', this.certification.realName)
  185. param.append('idCard', this.certification.idCard)
  186. let config = {
  187. headers: {'Content-Type': 'multipart/form-data'}
  188. }
  189. this.$http.post('/valid/user/identity/submit', param, config)
  190. .then(response => {
  191. if (response.data.success) {
  192. this.goNextStep = false
  193. } else {
  194. this.goNextStep = true
  195. return Promise.reject(response.data)
  196. }
  197. }).catch(err => {
  198. this.$message.error(err.errMsg)
  199. })
  200. }
  201. },
  202. // 跳转至个人中心页面
  203. goCloudCenter () {
  204. window.location.href = '/cloudcenter'
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss" scoped>
  210. .certification {
  211. margin: 0 auto;
  212. width: 100%;
  213. background: #eee;
  214. .container{
  215. padding-top: 50px;
  216. margin: 0 auto;
  217. width: 980px;
  218. text-align: center;
  219. .content{
  220. padding: 0 50px;
  221. margin: 50px auto 0;
  222. width: 100%;
  223. text-align: center;
  224. background: #fff;
  225. .content-top{
  226. height: 80px;
  227. line-height: 80px;
  228. h3{
  229. margin-bottom: 0;
  230. font-size: 24px;
  231. color: #000;
  232. border-bottom: 1px solid #dcdcdc;
  233. }
  234. .step{
  235. position: relative;
  236. margin-top: 10px;
  237. img{
  238. width: 315px;
  239. height: 46px;
  240. }
  241. .step-item{
  242. position: absolute;
  243. top: 45px;
  244. left: 265px;
  245. span{
  246. margin-right: 85px;
  247. font-size: 14px;
  248. color: #b4b4b4;
  249. }
  250. span.active {
  251. color: #0076ad;
  252. }
  253. }
  254. }
  255. }
  256. form {
  257. padding-bottom: 44px;
  258. margin-top: 152px;
  259. input{
  260. padding: 0 0 0 18px;
  261. width: 360px;
  262. height: 44px;
  263. line-height: 44px;
  264. font-size: 14px;
  265. color: #000;
  266. border-radius: 0;
  267. }
  268. span.tip{
  269. position: absolute;
  270. top: 0;
  271. right: -238px;
  272. font-size: 13px;
  273. color: #8c8c8c;
  274. a{
  275. font-size: 13px;
  276. color: #0076ad;
  277. }
  278. }
  279. i{
  280. position: absolute;
  281. top: 13px;
  282. left: 20px;
  283. font-size: 20px;
  284. color: #a0a0a0;
  285. }
  286. input[type='checkbox']{
  287. margin: 0 14px 0 55px;
  288. float: left;
  289. width: 16px;
  290. height: 16px;
  291. }
  292. span.agree{
  293. float: left;
  294. margin: 1px 0 0 10px;
  295. font-size: 14px;
  296. color: #8b8b8b;
  297. a{
  298. color: #0076ad;
  299. }
  300. }
  301. .form-group.agree{
  302. margin: 20px auto 0 !important;
  303. }
  304. .btn {
  305. margin: 34px 0 16px 0;
  306. width: 360px;
  307. height: 44px;
  308. line-height: 44px;
  309. font-size: 16px;
  310. color: #fff;
  311. background: #0076AD;
  312. border-radius: 3px;
  313. }
  314. }
  315. .content-bottom{
  316. margin-top: 155px;
  317. padding-bottom: 50px;
  318. p{
  319. font-size: 24px;
  320. color: #323232;
  321. img{
  322. margin-right: 20px;
  323. width: 30px;
  324. height: 28px;
  325. }
  326. }
  327. p.pass{
  328. font-size: 24px;
  329. color: #e77405;
  330. img{
  331. height: 30px;
  332. }
  333. }
  334. p.passed {
  335. color: #2ab300;
  336. img{
  337. height: 30px;
  338. }
  339. }
  340. span{
  341. display: inline-block;
  342. margin: 15px 0 140px 0;
  343. font-size: 14px;
  344. color: #8b8b8b;
  345. }
  346. .close-btn{
  347. margin: 0 auto;
  348. width: 200px;
  349. height: 36px;
  350. line-height: 36px;
  351. font-size: 14px;
  352. text-align: center;
  353. color: #323232;
  354. border: 1px solid #d2d2d2;
  355. border-radius: 3px;
  356. cursor: pointer ;
  357. }
  358. }
  359. }
  360. }
  361. }
  362. </style>