123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <template>
- <div class="User-box">
-
- <div class="user-info">
- <img src="../assets/userImag/user.png" />
- <div class="info-name">
- <div>
- <span>旺旺旺</span>
- </div>
- <div>
- <span>18888888888</span>
- </div>
- </div>
- </div>
-
- <div class="button-box">
- <van-cell-group>
- <van-cell class="user-button" title="注册" @click="handLogin()" />
- </van-cell-group>
-
-
- </div>
- </div>
- </template>
-
- <script>
- export default {
- data() {
- return {
- code: ''
- }
- },
- created() {
-
- if (window.location.href.indexOf('CSDN_state') !== -1) {
-
- this.code = window.location.href.split('?')[1].split('=')[1].split('&')[0]
- this.$store.commit('SET_USER_INFO', { code: this.code })
- }
-
- if (this.$store.state.user.code) {
-
- this.handGetUserInfo(this.code)
- }
- },
- methods: {
- handLogin() {
- this.$store.commit('SET_USER_INFO', { code: this.code })
-
-
- if (process.env.NODE_ENV === 'development') {
- console.log(222)
- return
- }
-
-
-
-
-
-
-
-
-
- const hrefUrl = window.location.href
-
-
-
-
-
-
- if (this.code === '') {
- window.location.href = `
- https://open.weixin.qq.com/connect/oauth2/authorize
- ?appid=${this.$store.state.user.appid}
- &redirect_uri=${encodeURIComponent(hrefUrl)}
- &response_type=code
- &scope=snsapi_userinfo
- &state=Code_state#wechat_redirect
- `
- }
- },
- handGetUserInfo(code) {
- console.log(
- '🚀 ~ file: UserCenter.vue ~ line 44 ~ handGetUserInfo ~ code',
- code
- )
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
- }
- </script>
-
- <style lang="less" scoped>
- .User-box {
- width: 100%;
- height: 100%;
- .user-info {
- display: flex;
- height: 20%;
- padding-left: 24px;
- > img {
- width: 70px;
- height: 70px;
- border-radius: 50%;
- position: relative;
- top: 5vh;
- }
- .info-name {
- position: relative;
- font-size: 17px;
- height: 20%;
- font-weight: 700;
- top: 5vh;
- left: 6vw;
- > div {
- margin-top: 10px;
- }
- }
- }
- .button-box {
- width: 97%;
- margin: 0 auto;
- // box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
- .user-button {
- height: 50px;
- line-height: 30px;
-
- // box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
- }
- }
- }
- </style>
|