index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view>
  3. <!-- 签约页面 -->
  4. </view>
  5. </template>
  6. <script>
  7. // md5加密文件
  8. import md5 from '@/js_sdk/js-md5/src/md5.js';
  9. // base64加密文件
  10. import {
  11. Base64
  12. } from '@/js_sdk/js-base64/base64.js';
  13. export default {
  14. data() {
  15. return {
  16. newTime: ""
  17. }
  18. },
  19. onLoad() {
  20. this.getIdCard()
  21. },
  22. methods: {
  23. // 获取用户身份证
  24. getIdCard() {
  25. let idCard = sessionStorage.getItem("idCard")
  26. if (!idCard) {
  27. let idCard = this.getQueryString("idCard");
  28. if (!idCard) {
  29. window.location.href =
  30. `https://open.wecard.qq.com/connect/oauth/authorize?app_key=EE28EE2C93296F4E&response_type=code&scope=snsapi_base&ocode=1015730314&redirect_uri=https://jtishfw.ncjti.edu.cn/baoxiu/repairApi/wx/weixiao/auth&state=https://jtishfw.ncjti.edu.cn/baoxiu/repairApi/wx/weixiao/auth`;
  31. } else {
  32. sessionStorage.setItem("idCard", idCard)
  33. this.getName()
  34. }
  35. } else {
  36. this.getName()
  37. }
  38. },
  39. // 获取用户姓名
  40. getName() {
  41. let name = sessionStorage.getItem("name")
  42. if (!name) {
  43. let name = this.getQueryString("name");
  44. if (!name) {
  45. window.location.href =
  46. `https://open.wecard.qq.com/connect/oauth/authorize?app_key=EE28EE2C93296F4E&response_type=code&scope=snsapi_base&ocode=1015730314&redirect_uri=https://jtishfw.ncjti.edu.cn/baoxiu/repairApi/wx/weixiao/auth&state=https://jtishfw.ncjti.edu.cn/baoxiu/repairApi/wx/weixiao/auth`;
  47. } else {
  48. sessionStorage.setItem("name", name)
  49. this.getUrl()
  50. }
  51. } else {
  52. this.getUrl()
  53. }
  54. },
  55. // 获取跳转地址
  56. getUrl() {
  57. // md5加密 处理token参数
  58. this.getTime()
  59. let token = md5(md5("JANCJTISCHOOLSIGNING" + this.newTime))
  60. // base64加密 处理data参数
  61. let student_id = sessionStorage.getItem("idCard")
  62. let student_name = sessionStorage.getItem("name")
  63. let id_number = sessionStorage.getItem("idCard")
  64. // 收集参数
  65. let data = {
  66. student_id,
  67. student_name,
  68. id_number
  69. }
  70. // 把参数转换成JSON格式
  71. data = JSON.stringify(data)
  72. // 加密处理
  73. data = Base64.encode(encodeURIComponent(data))
  74. // // 获取授权签约地址
  75. let newUrl = `https://sa.jxnxs.com/SchoolAgreement/index?token=${token}&data=${data}`
  76. // // 跳转授权签约地址
  77. window.location.href = newUrl
  78. },
  79. // 获取当前时间
  80. getTime() {
  81. // 获取当前时间戳
  82. var date = new Date()
  83. // 获取年份
  84. var year = date.getFullYear()
  85. // 获取月份并补0
  86. var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
  87. // 获取日期并补0
  88. var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
  89. // 获取小时并补0
  90. var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
  91. // 拼接后赋值
  92. this.newTime = String(year) + String(month) + String(day) + String(hours) + "00" + "00"
  93. },
  94. //获取当前URL指定参数
  95. getQueryString(name) {
  96. // 获取URL
  97. let url = window.location.href;
  98. // 正则匹配URL
  99. let pattern = new RegExp("[?&]" + name + "=([^&]+)", "i");
  100. let matcher = pattern.exec(url);
  101. if (matcher == null || matcher.length < 1) {
  102. return false;
  103. }
  104. // 输出指定的参数值中文也可以
  105. return decodeURIComponent(matcher[1]);
  106. },
  107. }
  108. }
  109. </script>
  110. <style>
  111. </style>