123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <template>
- <view class="container">
- <u-navbar title="个人中心" @rightClick="rightClick" :autoBack="true">
- </u-navbar>
- <view class="box" v-if="userInfo">
- <view class="">
- 手机号:{{userInfo.mobile}}
- </view>
- <view class="">
- 唯一身份标识:{{userInfo.yige_open_id}}
- </view>
- <view class="">
- 姓名:{{userInfo.real_name}}
- </view>
- <view class="">
- 身份证号:{{userInfo.identity_card}}
- </view>
- <view class="">
- 昵称:{{userInfo.nickname}}
- </view>
- <view class="">
- 头像{{userInfo.head_photo}}
- </view>
- <block v-if="userInfo.current_ent">
- <view class="">
- 企业名称{{userInfo.current_ent.ent_name}}
- </view>
- <view class="">
- 统一社会信用代码{{userInfo.current_ent.credit_code}}
- </view>
- </block>
- </view>
- </view>
- </template>
- <script>
- import uniWeb from '../static/uni.webview.1.5.4.js'
- export default {
- data() {
- return {
- deviceType: "phone",
- loginType: 'account', //qywx account,
- form: {
- username: "",
- password: ""
- },
- yigeauth: false,
- userInfo: null
- }
- },
- onLoad(options) {
- console.log('options===>', options)
- this.yigeauth = options.yigeauth === 'true' ? true : false
- /**
- * 判断是否需要授权
- */
- if (this.yigeauth) {
- console.log(1111111)
- // 需要授权
- this.getYigeauth()
- } else if (options.yigeopenid) {
- console.log(222222)
- // 如果已经授权,并且返回了 openid,则通过 openid 去获取用户信息
- this.getUerByOpenId(options.yigeopenid)
- }
- },
- methods: {
- /**
- * app端通过 /auth/before/check 校验是否授权及相应返回参数
- *
- * redirect":"aHROcDoVLZE5Mi4xNjguMC4yNDYvcmVkaXJ1Y30uaHRtbA" 回调地址
- * redirect 带有 yigeauth参数 为 true 需要授权 不返回 yigeopenid 为 false 不需要授权 返回 yigeopenid
- * appId": "1738044695273148416
- * action": "auth"
- * back":"aHROcDovLZE5Mi4xNjguMC4yNDYvaw5kZXguaHRtbA"
- * 通过授权参数 yigeauth true 需要授权,false 不需要授权,通过 yigeopenid直接 获取信息
- */
- getYigeauth() {
- this.$http.get('/auth/build_auth').then(res => {
- console.log(res, 3333333333)
- try {
- uniWeb.webView.postMessage({
- data: res.data
- })
- } catch (err) {
- console.log('err==>', err)
- }
- })
- },
- getUerByOpenId(yigeopenid) {
- this.$http.post('/auth/getUserByOpenId', {
- yigeOpenId: yigeopenid
- }).then(res => {
- console.log(res, 4444444444)
- if (res.code == 200) {
- // 获取用户信息
- this.userInfo = res.data
- }
- })
- },
- }
- }
- </script>
- <style lang="scss">
- .container {
- width: 100vw;
- height: 100vh;
- overflow: hidden;
- // background: url('../static/img/loginBg.png');
- background-size: contain;
- position: relative;
- .box {
- padding: 30rpx;
- padding-top: 200rpx;
- word-break: break-all;
- }
- }
- </style>
|