index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <div :class="mobile ? 'mobileMain' : ''" :style="{
  3. marginTop: mainMarginTop,
  4. marginBottom: mobile ? '0px' : '30px !important'
  5. }">
  6. <div class="name-cert-container" v-if="!mobile && init">
  7. <!-- 待实名 -->
  8. <div class="name-cert-main" v-if="state == 'normal'">
  9. <div class="name-cert-title-area">
  10. <img class="name-cert-icon" :src="icon" />
  11. <h6 class="name-cert-title">实名认证</h6>
  12. <p class="name-cert-tips">请如实填写信息,客栈承诺保障用户的信息安</p>
  13. </div>
  14. <el-form ref="modalForm" :model="modalFormData" :rules="rules" size="medium" label-width="100px">
  15. <div class="name-cert-label">姓名</div>
  16. <el-form-item label-width="0" prop="cert_name">
  17. <el-input v-model="modalFormData.cert_name" placeholder="请输入真实姓名" clearable :style="{ width: '100%' }">
  18. </el-input>
  19. </el-form-item>
  20. <div class="name-cert-label">证件类型</div>
  21. <el-form-item label-width="0" prop="cert_type">
  22. <el-select v-model="modalFormData.cert_type" placeholder="请选择证件类型" clearable :style="{ width: '100%' }">
  23. <el-option v-for="(item, index) in cert_typeOptions" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
  24. </el-select>
  25. </el-form-item>
  26. <div class="name-cert-label">证件号</div>
  27. <el-form-item label-width="0" prop="cert_no">
  28. <el-input v-model="modalFormData.cert_no" placeholder="请输入证件号" clearable :style="{ width: '100%' }">
  29. </el-input>
  30. </el-form-item>
  31. <el-form-item size="large">
  32. <el-button type="primary" class='cert-btn' size="medium" @click="submitForm">支付宝实名认证</el-button>
  33. </el-form-item>
  34. </el-form>
  35. </div>
  36. <!-- 实名成功 -->
  37. <div class="name-cert-main" v-if="state == 'success'">
  38. <div class="name-cert-title-area">
  39. <img class="name-cert-icon" :src="iconSuccess" />
  40. <h6 class="name-cert-title">实名认证成功</h6>
  41. <p class="name-cert-tips">成为签约开发者,开启自由工作吧</p>
  42. <div class="name-cert-success-btn">
  43. <el-button type="primary" class='cert-btn' size="medium">去签约</el-button>
  44. </div>
  45. </div>
  46. </div>
  47. <!-- 实名失败 -->
  48. <div class="name-cert-main" v-if="state == 'fail'">
  49. <div class="name-cert-title-area">
  50. <img class="name-cert-icon" :src="iconFail" />
  51. <h6 class="name-cert-title">实名认证失败</h6>
  52. <div class="name-cert-fail-btn">
  53. <el-button type="primary" class='cert-btn' size="medium" @click="reset">重新认证</el-button>
  54. </div>
  55. <p class="name-cert-fail-tips">无法进行支付宝认证?<a href="">人工认证</a></p>
  56. </div>
  57. </div>
  58. </div>
  59. <el-dialog title="温馨提示" :visible.sync="centerDialogVisible" width="30%" center>
  60. <p class="qrcode-tips">请打开支付宝扫码以下二维码</p>
  61. <div class="qrcode-img">
  62. <img :src="qrcodeBase64" />
  63. </div>
  64. </el-dialog>
  65. </div>
  66. </template>
  67. <script>
  68. import {
  69. mapState
  70. } from "vuex";
  71. import qs from "qs";
  72. import icon from "@/assets/img/account/certicon@3x.png"
  73. import iconSuccess from "@/assets/img/account/cert_success_icon@3x.png"
  74. import iconFail from "@/assets/img/account/cert_fail_icon@3x.png"
  75. import QRCode from "qrcode"
  76. export default {
  77. name: "SeoLearnList",
  78. data() {
  79. return {
  80. baseUrl: "",
  81. mobile: false,
  82. isWeixinApp: true,
  83. icon,
  84. iconSuccess,
  85. iconFail,
  86. centerDialogVisible: false,
  87. url: "",
  88. certifyId: "",
  89. qrcodeBase64: '',
  90. timer: null,
  91. // normal 待实名 success 认证成功 fail 认证失败
  92. state: "normal",
  93. init: false,
  94. modalFormData: {
  95. cert_name: "",
  96. cert_type: 1,
  97. cert_no: ""
  98. },
  99. rules: {
  100. cert_name: [{
  101. required: true,
  102. message: "请输入真实姓名",
  103. trigger: "blur"
  104. }],
  105. cert_type: [{
  106. required: true,
  107. message: "请选择证件类型",
  108. trigger: "change"
  109. }],
  110. cert_no: [{
  111. required: true,
  112. message: "请输入证件号",
  113. trigger: "blur"
  114. }]
  115. },
  116. cert_typeOptions: [{
  117. label: "身份证",
  118. value: 1
  119. },
  120. {
  121. label: "港澳通行证",
  122. value: 2
  123. },
  124. {
  125. label: "台湾通行证",
  126. value: 3
  127. },
  128. {
  129. label: "港澳居住证",
  130. value: 4
  131. },
  132. {
  133. label: "台湾身份证",
  134. value: 5
  135. }
  136. ]
  137. };
  138. },
  139. head() {
  140. const {
  141. title = "",
  142. keyword = "",
  143. description = "",
  144. h1 = "",
  145. canonical = "",
  146. metaLocation
  147. } = this.head || {};
  148. let obj = {
  149. title: title,
  150. meta: [{
  151. name: "keywords",
  152. content: keyword
  153. },
  154. {
  155. name: "description",
  156. content: description
  157. },
  158. {
  159. name: "h1",
  160. content: h1
  161. }
  162. ],
  163. link: [{
  164. rel: "canonical",
  165. href: canonical
  166. }]
  167. };
  168. if (metaLocation) {
  169. obj.meta.push({
  170. name: "location",
  171. content: metaLocation
  172. });
  173. }
  174. return obj;
  175. },
  176. computed: {
  177. ...mapState(["deviceType"]),
  178. showWxHeader() {
  179. return (
  180. !this.deviceType.app &&
  181. !this.isWeixinApp &&
  182. (this.deviceType.android || this.deviceType.ios)
  183. );
  184. },
  185. mainMarginTop() {
  186. if (this.mobile && this.showWxHeader) {
  187. return "64px !important";
  188. } else if (this.mobile) {
  189. return "0px !important";
  190. } else {
  191. return "20px !important";
  192. }
  193. },
  194. userInfo() {
  195. return this.$store.state.userinfo;
  196. }
  197. },
  198. mounted() {
  199. this.home_page_type = this.userInfo.home_page_type;
  200. this.baseUrl = this.$store.state.domainConfig.siteUrl;
  201. this.isWeixinApp = navigator.userAgent.indexOf("miniProgram") > -1;
  202. this.checkNameIsCerted()
  203. },
  204. methods: {
  205. submitForm() {
  206. this.$refs["modalForm"].validate(valid => {
  207. if (!valid) return;
  208. this.submit()
  209. // TODO 提交表单
  210. });
  211. },
  212. resetForm() {
  213. this.$refs["modalForm"].resetFields();
  214. },
  215. async submit() {
  216. const {
  217. cert_name,
  218. cert_no,
  219. cert_type
  220. } = this.modalFormData
  221. // 测试用
  222. // let res = {
  223. // data: {
  224. // url: "http://www.baidu.com",
  225. // certifyId: "123123"
  226. // }
  227. // }
  228. let res = await this.$axios.$post("/uapi/zfb/certifyIdApp", {
  229. cert_name,
  230. cert_no,
  231. cert_type,
  232. from_type: 3
  233. });
  234. if (Number(res.status) !== 1) {
  235. this.$message.error(res.hqinfo);
  236. return
  237. }
  238. const {
  239. url,
  240. certifyId
  241. } = res.data
  242. this.url = url
  243. this.certifyId = certifyId
  244. this.centerDialogVisible = true;
  245. this.createQrCode()
  246. this.startTimer()
  247. },
  248. createQrCode() {
  249. this.$nextTick(() => {
  250. const text = this.url
  251. let that = this;
  252. QRCode.toDataURL(text, {
  253. errorCorrectionLevel: 'H'
  254. }, function (err, url) {
  255. that.qrcodeBase64 = url
  256. })
  257. })
  258. },
  259. startTimer() {
  260. // 启动定时器查询
  261. if (this.timer) {
  262. clearInterval(this.timer)
  263. this.timer = null
  264. }
  265. this.timer = setInterval(async () => {
  266. let res = await this.$axios.$post("/uapi/zfb/return", {
  267. });
  268. if (Number(res.status) !== 1) {
  269. this.$message.error(res.hqinfo);
  270. return
  271. }
  272. let {
  273. type
  274. } = res.data.type
  275. if (type == 1 || type == 4) {
  276. if (type == 1) {
  277. // 显示成功态
  278. this.state = 'success'
  279. } else if (type == 4) {
  280. // 显示失败态
  281. this.state = 'fail'
  282. }
  283. // 关闭弹层
  284. this.centerDialogVisible = false;
  285. clearInterval(this.timer);
  286. this.timer = null;
  287. }
  288. },5000)
  289. },
  290. async checkNameIsCerted() {
  291. let res = await this.$axios.$post("/uapi/zfb/return", {
  292. });
  293. if (Number(res.status) !== 1) {
  294. this.$message.error(res.hqinfo);
  295. return
  296. }
  297. const {
  298. type
  299. } = res.data.type;
  300. //type == 4
  301. if (type == 1) {
  302. this.state = 'success'
  303. }
  304. this.init = true;
  305. },
  306. reset(){
  307. this.modalFormData = {
  308. cert_name: "",
  309. cert_type: 1,
  310. cert_no: ""
  311. }
  312. this.state = "normal";
  313. }
  314. }
  315. };
  316. </script>
  317. <style lang="scss">
  318. body {
  319. background-color: #fff;
  320. }
  321. .main {
  322. position: relative;
  323. }
  324. .name-cert-container {
  325. position: absolute;
  326. top: 50%;
  327. left: 50%;
  328. transform: translate(-50%, -50%);
  329. display: flex;
  330. justify-content: center;
  331. align-items: center;
  332. }
  333. .name-cert-main {
  334. width: 328px;
  335. }
  336. .name-cert-label {
  337. font-size: 13px;
  338. font-family: PingFangSC-Regular, PingFang SC;
  339. font-weight: 400;
  340. color: #0b121a;
  341. line-height: 16px;
  342. margin-bottom: 8px;
  343. }
  344. .name-cert-title-area {
  345. text-align: center;
  346. margin-bottom: 40px;
  347. }
  348. .name-cert-icon {
  349. width: 70px;
  350. height: 70px;
  351. }
  352. .name-cert-title {
  353. margin-top: 4px;
  354. margin-bottom: 8px;
  355. font-size: 18px;
  356. font-family: PingFangSC-Medium, PingFang SC;
  357. font-weight: 500;
  358. color: #0B121A;
  359. line-height: 20px;
  360. text-align: center;
  361. }
  362. .name-cert-tips {
  363. text-align: center;
  364. font-size: 13px;
  365. font-family: PingFangSC-Regular, PingFang SC;
  366. font-weight: 400;
  367. color: #828C99;
  368. line-height: 16px
  369. }
  370. .qrcode-tips {
  371. text-align: center;
  372. }
  373. .qrcode-img {
  374. text-align: center;
  375. img {
  376. width: 80%
  377. }
  378. }
  379. .name-cert-success-btn {
  380. margin-top: 80px;
  381. }
  382. .name-cert-fail-btn {
  383. margin-top: 104px;
  384. }
  385. .name-cert-fail-tips {
  386. margin-top: 30px;
  387. font-size: 14px;
  388. font-family: PingFangSC-Regular, PingFang SC;
  389. font-weight: 400;
  390. color: #666666;
  391. line-height: 16px;
  392. }
  393. .cert-btn {
  394. width: 188px;
  395. }
  396. </style>