login.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 if (options.yigeopenid) {
  51. // 如果已经授权,并且返回了 openid,则通过 openid 去获取用户信息
  52. this.getUerByOpenId(options.yigeopenid)
  53. }
  54. },
  55. methods: {
  56. /*
  57. *
  58. * yigeauth
  59. *
  60. */
  61. getYigeauth() {
  62. this.$http.get('/auth/build_auth').then(res => {
  63. try {
  64. uniWeb.webView.postMessage({
  65. data: res.data
  66. })
  67. } catch (err) {
  68. console.log('err==>', err)
  69. }
  70. })
  71. },
  72. getUerByOpenId(yigeopenid) {
  73. this.$http.post('/auth/getUserByOpenId', {
  74. yigeOpenId: yigeopenid
  75. }).then(res => {
  76. if (res.code == 200) {
  77. // 获取用户信息
  78. this.userInfo = res.data
  79. }
  80. })
  81. },
  82. }
  83. }
  84. </script>
  85. <style lang="scss">
  86. .container {
  87. width: 100vw;
  88. height: 100vh;
  89. overflow: hidden;
  90. // background: url('../static/img/loginBg.png');
  91. background-size: contain;
  92. position: relative;
  93. .box {
  94. padding: 30rpx;
  95. padding-top: 200rpx;
  96. word-break: break-all;
  97. }
  98. }
  99. </style>