DDexemption.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view>
  3. hello
  4. <!-- <loading :loading='loading' /> -->
  5. </view>
  6. </template>
  7. <script>
  8. import loading from '@/components/loading.vue'
  9. import dd from '@/static/dd.js'
  10. export default {
  11. components: {
  12. loading
  13. },
  14. data() {
  15. return {
  16. loading: true,
  17. show_code : true,
  18. };
  19. },
  20. async mounted() {
  21. uni.navigateTo({
  22. url:"/pages/studentRanked/studentRanked"
  23. })
  24. return
  25. this.code = this.getUrlParam("code");
  26. if (!this.code) {
  27. this.show_code=true
  28. } else {
  29. this.$api.sendRequest({
  30. url: `/mobile/grantAuth?code=${this.code}`,
  31. success: res => {
  32. uni.setStorage({
  33. key: 'token',
  34. data: res.data.token
  35. });
  36. this.load()
  37. },
  38. error: res => {
  39. }
  40. })
  41. }
  42. dd.ready(() => {
  43. dd.runtime.permission.requestAuthCode({
  44. corpId: 'dinga5fb632b756d90fda1320dcb25e91351', // 替换为你的企业组织ID
  45. onSuccess: (result) => {
  46. this.$api.sendRequest({
  47. url: `/mobile/grantAuth?code=${result.code}`,
  48. success: res => {
  49. uni.setStorage({
  50. key: 'token',
  51. data: res.data.token
  52. });
  53. this.load()
  54. },
  55. error: res => {
  56. }
  57. })
  58. },
  59. onFail: function(err) {
  60. }
  61. });
  62. });
  63. },
  64. methods: {
  65. getUrlParam(name) {
  66. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  67. var r = window.location.search.substr(1).match(reg);
  68. if (r != null) return unescape(r[2]);
  69. return null;
  70. },
  71. wxLogin(){
  72. console.log(window.location);
  73. this.code = this.getUrlParam("code");
  74. let share_uid=this.getUrlParam("share_uid");
  75. if(process.env.NODE_ENV === 'development'){
  76. this.code="dasdadasdghtth111111tyfsf"
  77. }
  78. console.log("进来了吗");
  79. if (!this.code) {
  80. window.location.href=this.back_url
  81. } else {
  82. // let share_uid=uni.getStorageSync("share_uid")
  83. // if(!share_uid){
  84. // this.$toast('必须要分享人才可登录');
  85. // return false;
  86. // }
  87. this.$request({
  88. url: 'login/wechat_gzh_login',
  89. data: {
  90. code: this.code,
  91. share_uid : share_uid,
  92. _ajax : 1
  93. },
  94. onSuccess: res => {
  95. console.log(res,"ressss")
  96. if (res.token) {
  97. uni.setStorageSync('tokenid', res.token);
  98. this.$store.commit('setToken', res.token);
  99. uni.setStorageSync('share_uid', share_uid);
  100. }
  101. // this.$toast('登录成功');
  102. this.$store.commit('setUser', res.user);
  103. this.$getMallConf(user => {}, true);
  104. },
  105. });
  106. }
  107. },
  108. load() {
  109. this.$api.sendRequest({
  110. url: '/mobile/getRole',
  111. success: res => {
  112. let info = res.data[0]
  113. this.$store.commit('setInfo', info)
  114. uni.navigateTo({
  115. url: '/pages/home/home'
  116. })
  117. },
  118. error: res => {
  119. },
  120. })
  121. }
  122. },
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. </style>