login.vue 920 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <view>
  3. <u-button @click="loginUse">点击登录</u-button>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. infoData: {}
  11. }
  12. },
  13. methods: {
  14. loginUse() {
  15. let that = this;
  16. wx.login({
  17. success: function(e) {
  18. console.log('数据:', e)
  19. uni.request({
  20. url: 'http://36.137.224.81:8030/auth/miniLogin?tenantId=000000&code=' + e
  21. .code,
  22. header: {
  23. "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", //
  24. // "Content-Type": "application/json;charset=UTF-8", //
  25. },
  26. method: 'post',
  27. success: res => {
  28. console.log('登录成功:', res)
  29. uni.hideLoading()
  30. if (res.data.code == 200) {
  31. that.infoData = res.data.data
  32. }
  33. },
  34. fail: err => {
  35. uni.hideLoading()
  36. }
  37. })
  38. }
  39. })
  40. }
  41. }
  42. }
  43. </script>
  44. <style>
  45. </style>