| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <template>
- <view>
- <u-button @click="loginUse">点击登录</u-button>
- </view>
- </template>
- <script>
- export default {
- name: 'MyLogin',
- data() {
- return {
- infoData: {}
- }
- },
- methods: {
- loginUse() {
- wx.login({
- success: async (e) => {
- console.log('数据:', e)
- const result = await this.$request('post', '/miniLogin?tenantId=000000&code=' + e.code)
- console.log('登录成功:', result)
- // 处理响应数据
- if (!result) {
- console.log('登录成功:', result.data)
- var token = result.data.access_token;
- var haveOpenid = result.data.open_id;
- uni.setStorageSync("token", token);
- success: (result) => {
- console.log('登录成功:', result)
- uni.hideLoading()
- uni.navigateTo({
- url: `/pages/classify/classify`
- })
- };
- fail: (result) => {
- uni.hideLoading()
- }
- }
- }
- })
-
- // let that = this;
- // wx.login({
- // success: function(e) {
- // console.log('数据:', e)
- // uni.request({
- // url: 'http://36.137.224.81:8030/auth/miniLogin?tenantId=000000&code=' + e
- // .code,
- // header: {
- // "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", //
- // // "Content-Type": "application/json;charset=UTF-8", //
- // },
- // method: 'post',
- // success: res => {
- // console.log('登录成功:', res)
- // uni.hideLoading()
- // var token = res.data.data.access_token;
- // console.log('token:', token)
- // uni.setStorageSync("token", token);
- // uni.navigateTo({
- // url: `/pages/classify/classify`
- // })
- // // if (res.data.code == 200) {
- // // that.infoData = res.data.data
- // // }
- // },
- // fail: err => {
- // uni.hideLoading()
- // }
- // })
- // }
- // })
-
- }
- }
- }
- </script>
- <style>
- </style>
|