login.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import uniWeb from '../static/uni.webview.1.5.4.js'
  29. export default {
  30. data() {
  31. return {
  32. deviceType: "phone",
  33. loginType: 'account', //qywx account,
  34. form: {
  35. username: "",
  36. password: ""
  37. },
  38. yigeauth: false,
  39. userInfo: null
  40. }
  41. },
  42. onLoad(options) {
  43. this.yigeauth = options.yigeauth === 'true' ? true : false
  44. /**
  45. * 判断是否需要授权
  46. */
  47. if (this.yigeauth) {
  48. // 需要授权
  49. this.getYigeauth()
  50. } else(options.yigeopenid) {
  51. // 如果已经授权,并且返回了 openid,则通过 openid 去获取用户信息
  52. this.getUerByOpenId(options.yigeopenid)
  53. }
  54. },
  55. methods: {
  56. /**
  57. * app端通过 /auth/before/check 校验是否授权及相应返回参数
  58. *
  59. * redirect":"aHROcDoVLZE5Mi4xNjguMC4yNDYvcmVkaXJ1Y30uaHRtbA" 回调地址
  60. * redirect 带有 yigeauth参数 为 true 需要授权 不返回 yigeopenid 为 false 不需要授权 返回 yigeopenid
  61. * appId": "1738044695273148416
  62. * action": "auth"
  63. * back":"aHROcDovLZE5Mi4xNjguMC4yNDYvaw5kZXguaHRtbA"
  64. * 通过授权参数 yigeauth true 需要授权,false 不需要授权,通过 yigeopenid直接 获取信息
  65. */
  66. getYigeauth() {
  67. this.$http.get('/auth/build_auth').then(res => {
  68. try {
  69. uniWeb.webView.postMessage({
  70. data: res.data
  71. })
  72. } catch (err) {
  73. console.log('err==>', err)
  74. }
  75. })
  76. },
  77. getUerByOpenId(yigeopenid) {
  78. this.$http.post('/auth/getUserByOpenId', {
  79. yigeOpenId: yigeopenid
  80. }).then(res => {
  81. if (res.code == 200) {
  82. // 获取用户信息
  83. this.userInfo = res.data
  84. }
  85. })
  86. },
  87. }
  88. }
  89. </script>
  90. <style lang="scss">
  91. .container {
  92. width: 100vw;
  93. height: 100vh;
  94. overflow: hidden;
  95. // background: url('../static/img/loginBg.png');
  96. background-size: contain;
  97. position: relative;
  98. .box {
  99. padding: 30rpx;
  100. padding-top: 200rpx;
  101. word-break: break-all;
  102. }
  103. }
  104. </style>