123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <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>
|