Browse Source

登录接口对接

master
主管理员 1 year ago
parent
commit
a63a9fb0ac
4 changed files with 239 additions and 4 deletions
  1. +6
    -0
      common/api.js
  2. +2
    -2
      common/config.js
  3. +5
    -2
      pages.json
  4. +226
    -0
      pages/login/login.vue

+ 6
- 0
common/api.js View File

@ -1,6 +1,12 @@
import request from './axios';
// 微信授权登录
export const wxLogin = (params, succCallback, errorCallback) => {
return request('/job-dev/house/applet/login',params,'POST', succCallback,errorCallback)
};
// 获取首页轮播图
export const getBannerList = (params, succCallback, errorCallback) => {
return request('/job-dev/house/applet/banner',params,'GET', succCallback,errorCallback)


+ 2
- 2
common/config.js View File

@ -1,4 +1,4 @@
const dev_baseUrl = "http://127.0.0.1:8091";
const dev_baseUrl = "http://aplet.xzaiyp.top";
const pro_baseUrl = "https://jobadmin.java996.icu";
const config = pro_baseUrl;
const config = dev_baseUrl;
export default config;

+ 5
- 2
pages.json View File

@ -10,14 +10,17 @@
},{
"path": "pages/index/icone"
},
{
"path": "pages/pusher/housea"
},{
"path": "pages/pusher/houseb"
},{
"path": "pages/pusher/article"
}],
},
{
"path": "pages/login/login"
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "兼兼街",


+ 226
- 0
pages/login/login.vue View File

@ -0,0 +1,226 @@
<template>
<view v-else class="login">
<view class="login-img flex align-center justify-center">
<view>
<image src="@/static/image/logo.jpg" mode=""></image>
</view>
</view>
<view class="login-title">找房租房尽在兼兼街</view>
<view>
<view>
<button type="primary" @click="login">授权登录</button>
</view>
</view>
<view class="tips flex align-center justify-between" @click="xieyiChoose = !xieyiChoose">
<view>
注册/登录即代表同意
<text class="xieyi">用户协议与隐私政策</text>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
xieyiChoose: true,
code: '',
did: '',
vid: '',
baomingStyle: {
fontSize: "30rpx",
fontWeight: "700",
height: "100rpx",
width: "480rpx"
},
baomingStyleQuxiao: {
fontSize: "30rpx",
fontWeight: "700",
height: "100rpx",
width: "480rpx",
marginTop: "40rpx"
}
}
},
onLoad(err) {
},
methods: {
//
login() {
uni.showLoading()
uni.getProvider({
service: 'oauth',
success: res => {
uni.hideLoading()
if (~res.provider.indexOf('weixin')) {
uni.login({
provider: 'weixin',
success: res => {
console.log("授权登录信息")
console.log(res)
this.code = res.code
uni.getUserInfo({
provider: 'weixin',
withCredentials: true,
success: info => {
this.getUserProfile(info, res.code)
},
fail: (err) => {
console.log(err)
uni.showToast({
title: '拒绝授权将无法使用',
icon: 'none'
})
}
})
},
fail: () => {
uni.hideLoading()
uni.showToast({
title: '微信登录授权失败',
icon: 'none'
})
}
})
} else {
uni.showToast({
title: '请先安装微信或升级版本',
icon: 'none'
})
}
},
fail: () => {
uni.hideLoading()
uni.showToast({
title: '拉取授权失败',
icon: 'none'
})
}
})
},
getUserProfile(user, code) {
uni.showModal({
title: '温馨提示',
content: '亲,请授权后获取您的',
success: res => {
if (res.confirm) {
uni.getUserProfile({
// desc: '',
desc: '获取你的昵称、头像、地区及性别',
lang: 'zh_CN',
success: val => {
// uni.showLoading()
let params = {
iv: user.iv,
code: code,
encryptedData: user.encryptedData,
signature: user.signature,
rawData: user.rawData,
nickName: val.userInfo.nickName
}
this.userInfo = val.userInfo
this.toLogin(params)
},
fail: error => {
console.log('getUserProfile error =>', error)
uni.hideLoading()
uni.showToast({
title: '微信登录授权失败',
icon: 'none'
})
}
})
}
}
})
},
//
toLogin(data) {
console.log("========data==")
console.log(data)
this.$request('/job-dev/house/applet/login', data, 'GET', (res) => {
console.log("登录成功")
console.log(res)
// uni.hideLoading()
// let {
// result,
// code,
// message
// } = res
// result?.token && this.$store.commit('set_userToken', result.token)
if (res.code == 200) {
console.log("登录成功")
uni.showToast({
title: "登录成功",
icon: 'none'
})
}else{
uni.showToast({
title: res.message,
icon: 'none'
})
}
})
.catch(err => {
uni.hideLoading()
uni.showToast({
title: err.message,
icon: 'none'
})
console.log(err)
})
}
}
}
</script>
<style lang="scss" scoped>
.login {
background-size: 100% 100%;
height: 70vh;
padding-top: 154rpx;
.login-title {
margin-top: 40rpx;
font-size: 34rpx;
font-weight: 700;
text-align: center;
padding-bottom: 30rpx;
}
.login-img {
image {
border-radius: 50%;
width: 248rpx;
height: 248rpx;
}
}
.btn-box {
margin-top: 136rpx;
}
.tips {
width: 500rpx;
position: fixed;
bottom: 52rpx;
left: 51%;
transform: translate(-50%, 0);
font-size: 24rpx;
color: #707070;
.xieyi {
color: #00CCFF;
}
}
}
</style>

Loading…
Cancel
Save