<template> <view> hello <!-- <loading :loading='loading' /> --> </view> </template> <script> import loading from '@/components/loading.vue' import dd from '@/static/dd.js' export default { components: { loading }, data() { return { loading: true, show_code : true, }; }, async mounted() { uni.navigateTo({ url:"/pages/studentRanked/studentRanked" }) return this.code = this.getUrlParam("code"); if (!this.code) { this.show_code=true } else { this.$api.sendRequest({ url: `/mobile/grantAuth?code=${this.code}`, success: res => { uni.setStorage({ key: 'token', data: res.data.token }); this.load() }, error: res => { } }) } dd.ready(() => { dd.runtime.permission.requestAuthCode({ corpId: 'dinga5fb632b756d90fda1320dcb25e91351', // 替换为你的企业组织ID onSuccess: (result) => { this.$api.sendRequest({ url: `/mobile/grantAuth?code=${result.code}`, success: res => { uni.setStorage({ key: 'token', data: res.data.token }); this.load() }, error: res => { } }) }, onFail: function(err) { } }); }); }, methods: { getUrlParam(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; }, wxLogin(){ console.log(window.location); this.code = this.getUrlParam("code"); let share_uid=this.getUrlParam("share_uid"); if(process.env.NODE_ENV === 'development'){ this.code="dasdadasdghtth111111tyfsf" } console.log("进来了吗"); if (!this.code) { window.location.href=this.back_url } else { // let share_uid=uni.getStorageSync("share_uid") // if(!share_uid){ // this.$toast('必须要分享人才可登录'); // return false; // } this.$request({ url: 'login/wechat_gzh_login', data: { code: this.code, share_uid : share_uid, _ajax : 1 }, onSuccess: res => { console.log(res,"ressss") if (res.token) { uni.setStorageSync('tokenid', res.token); this.$store.commit('setToken', res.token); uni.setStorageSync('share_uid', share_uid); } // this.$toast('登录成功'); this.$store.commit('setUser', res.user); this.$getMallConf(user => {}, true); }, }); } }, load() { this.$api.sendRequest({ url: '/mobile/getRole', success: res => { let info = res.data[0] this.$store.commit('setInfo', info) uni.navigateTo({ url: '/pages/home/home' }) }, error: res => { }, }) } }, } </script> <style lang="scss" scoped> </style>