login.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view class="container">
  3. <u-navbar title="个人中心" @rightClick="rightClick" :autoBack="true">
  4. </u-navbar>
  5. <view class="box" v-if="userInfo">
  6. <view class="">
  7. 手机号:{{userInfo.mobile}}
  8. </view>
  9. <view class="">
  10. 唯一身份标识:{{userInfo.yige_open_id}}
  11. </view>
  12. <view class="">
  13. 姓名:{{userInfo.real_name}}
  14. </view>
  15. <view class="">
  16. 身份证号:{{userInfo.identity_card}}
  17. </view>
  18. <view class="">
  19. 昵称:{{userInfo.nickname}}
  20. </view>
  21. <view class="">
  22. 头像{{userInfo.head_photo}}
  23. </view>
  24. <block v-if="userInfo.current_ent">
  25. <view class="">
  26. 企业名称{{userInfo.current_ent.ent_name}}
  27. </view>
  28. <view class="">
  29. 统一社会信用代码{{userInfo.current_ent.credit_code}}
  30. </view>
  31. </block>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import uniWeb from '../static/uni.webview.1.5.4.js'
  37. export default {
  38. data() {
  39. return {
  40. deviceType: "phone",
  41. loginType: 'account', //qywx account,
  42. form: {
  43. username: "",
  44. password: ""
  45. },
  46. yigeauth: false,
  47. userInfo: null
  48. }
  49. },
  50. onLoad(options) {
  51. console.log('options===>', options)
  52. this.yigeauth = options.yigeauth === 'true' ? true : false
  53. /**
  54. * 判断是否需要授权
  55. */
  56. if (this.yigeauth) {
  57. console.log(1111111)
  58. // 需要授权
  59. this.getYigeauth()
  60. } else if (options.yigeopenid) {
  61. console.log(222222)
  62. // 如果已经授权,并且返回了 openid,则通过 openid 去获取用户信息
  63. this.getUerByOpenId(options.yigeopenid)
  64. }
  65. },
  66. methods: {
  67. /**
  68. * app端通过 /auth/before/check 校验是否授权及相应返回参数
  69. *
  70. * redirect":"aHROcDoVLZE5Mi4xNjguMC4yNDYvcmVkaXJ1Y30uaHRtbA" 回调地址
  71. * redirect 带有 yigeauth参数 为 true 需要授权 不返回 yigeopenid 为 false 不需要授权 返回 yigeopenid
  72. * appId": "1738044695273148416
  73. * action": "auth"
  74. * back":"aHROcDovLZE5Mi4xNjguMC4yNDYvaw5kZXguaHRtbA"
  75. * 通过授权参数 yigeauth true 需要授权,false 不需要授权,通过 yigeopenid直接 获取信息
  76. */
  77. getYigeauth() {
  78. this.$http.get('/auth/build_auth').then(res => {
  79. console.log(res, 3333333333)
  80. try {
  81. uniWeb.webView.postMessage({
  82. data: res.data
  83. })
  84. } catch (err) {
  85. console.log('err==>', err)
  86. }
  87. })
  88. },
  89. getUerByOpenId(yigeopenid) {
  90. this.$http.post('/auth/getUserByOpenId', {
  91. yigeOpenId: yigeopenid
  92. }).then(res => {
  93. console.log(res, 4444444444)
  94. if (res.code == 200) {
  95. // 获取用户信息
  96. this.userInfo = res.data
  97. }
  98. })
  99. },
  100. }
  101. }
  102. </script>
  103. <style lang="scss">
  104. .container {
  105. width: 100vw;
  106. height: 100vh;
  107. overflow: hidden;
  108. // background: url('../static/img/loginBg.png');
  109. background-size: contain;
  110. position: relative;
  111. .box {
  112. padding: 30rpx;
  113. padding-top: 200rpx;
  114. word-break: break-all;
  115. }
  116. }
  117. </style>