Commit d7221acf authored by lijiongliang's avatar lijiongliang

修改登录

parent e0091d5d
...@@ -8,3 +8,9 @@ export const loginByUsername = (params) => http.request({ ...@@ -8,3 +8,9 @@ export const loginByUsername = (params) => http.request({
method: 'POST', method: 'POST',
data: params data: params
}) })
export const loginByPhone = (params) => http.request({
url: $config.serveUrl + 'auth/web/LoginByMaCode',
method: 'POST',
data: params
})
\ No newline at end of file
...@@ -35,9 +35,20 @@ ...@@ -35,9 +35,20 @@
<user v-else /> <user v-else />
</view> </view>
<view class="home-btn" v-if="!token"> <view class="home-btn" v-if="!token">
<button type="primary" @click="clickLogin"><span> <!-- <button type="primary" @click="clickLogin">
<span>
<image src="@/static/home/wx_logo.png"> <image src="@/static/home/wx_logo.png">
</span>授权登录</button> </span>
授权登录
</button> -->
<button class="login__btn"
hover-class="none" type='primary'
open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
<span>
<image src="@/static/home/wx_logo.png">
</span>
授权登录
</button>
</view> </view>
<u-picker :show="selectShow" @cancel='cancel' @confirm="confirm" :columns="columns"></u-picker> <u-picker :show="selectShow" @cancel='cancel' @confirm="confirm" :columns="columns"></u-picker>
<!-- <button type="primary" open-type="share" @click="share">分享</button> --> <!-- <button type="primary" open-type="share" @click="share">分享</button> -->
...@@ -53,7 +64,7 @@ import { ...@@ -53,7 +64,7 @@ import {
login login
} from "@/kui/util/login.js"; } from "@/kui/util/login.js";
import { import {
loginByUsername, loginByUsername,loginByPhone
} from "@/kui/api/user.js"; } from "@/kui/api/user.js";
export default { export default {
components: { components: {
...@@ -149,10 +160,12 @@ export default { ...@@ -149,10 +160,12 @@ export default {
uni.getUserProfile({ uni.getUserProfile({
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => { success: (res) => {
console.log(res,11111)
console.log(this.config,11111)
this.config.userInfo = res.userInfo this.config.userInfo = res.userInfo
this.$store.state.userInfo = res.userInfo this.$store.state.userInfo = res.userInfo
uni.setStorageSync('userInfo', res.userInfo); uni.setStorageSync('userInfo', res.userInfo);
this.wxLogin(this.config) // this.wxLogin(this.config)
}, },
fail: (res) => { fail: (res) => {
console.log('--', res); console.log('--', res);
...@@ -160,6 +173,32 @@ export default { ...@@ -160,6 +173,32 @@ export default {
}) })
} }
}, },
//解析手机号
getPhoneNumber(e) {
uni.showLoading({
title: '加载中',
mask:true
});
let that = this
if (e.detail.errMsg == "getPhoneNumber:ok") {
uni.hideLoading()
this.decodePhoneLogin(e.detail)
} else {
uni.hideLoading()
console.log("用户点击了拒绝")
}
},
// 解密手机并且登录
decodePhoneLogin(detail){
let code = detail.code;
loginByPhone({code}).then(res => {
if (res.data.code == 0) {
this.$store.state.token = res.data.token
uni.setStorageSync('token', res.data.token);
}
});
},
} }
} }
</script> </script>
...@@ -178,7 +217,6 @@ export default { ...@@ -178,7 +217,6 @@ export default {
align-items: center; align-items: center;
bottom: 0; bottom: 0;
border-top: 1rpx solid #ddd; border-top: 1rpx solid #ddd;
button { button {
width: 600rpx; width: 600rpx;
height: 80rpx; height: 80rpx;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment