合并 微信小程序登录获取用户详细信息功能
commit
879c9c2fc8
20
README.md
20
README.md
|
@ -20,7 +20,7 @@ Lilishop 是一款Java开发,基于SpringBoot的B2B2C多用户商城,前端
|
||||||
**产品文档**(需求、架构、使用、部署、开发):https://docs.pickmall.cn
|
**产品文档**(需求、架构、使用、部署、开发):https://docs.pickmall.cn
|
||||||
|
|
||||||
|
|
||||||
### 项目链接
|
### 项目链接(gitee)
|
||||||
|
|
||||||
**Java后台**:https://gitee.com/beijing_hongye_huicheng/lilishop.git
|
**Java后台**:https://gitee.com/beijing_hongye_huicheng/lilishop.git
|
||||||
|
|
||||||
|
@ -30,6 +30,16 @@ Lilishop 是一款Java开发,基于SpringBoot的B2B2C多用户商城,前端
|
||||||
|
|
||||||
**docker一键部署**:https://gitee.com/beijing_hongye_huicheng/docker.git
|
**docker一键部署**:https://gitee.com/beijing_hongye_huicheng/docker.git
|
||||||
|
|
||||||
|
### 项目链接(github)
|
||||||
|
|
||||||
|
**Java后台**:https://github.com/hongyehuicheng/lilishop.git
|
||||||
|
|
||||||
|
**Vue后台前端**: https://github.com/hongyehuicheng/lilishop-ui.git
|
||||||
|
|
||||||
|
**Uni-app**:https://github.com/hongyehuicheng/lilishop-uniapp.git
|
||||||
|
|
||||||
|
**docker一键部署**:https://github.com/hongyehuicheng/docker.git
|
||||||
|
|
||||||
### 演示地址
|
### 演示地址
|
||||||
|
|
||||||
**运营后台**:https://admin-b2b2c.pickmall.cn 账号:admin/123456
|
**运营后台**:https://admin-b2b2c.pickmall.cn 账号:admin/123456
|
||||||
|
@ -44,6 +54,8 @@ Lilishop 是一款Java开发,基于SpringBoot的B2B2C多用户商城,前端
|
||||||
|
|
||||||
### 3行命令搭建本地环境
|
### 3行命令搭建本地环境
|
||||||
|
|
||||||
|
温馨提示:由于服务较多,如果笔记本环境启动内存没有32g可能无法启动成功(macbookpro 2020 16g内存启动无法成功),台式机在16g内存、AMD 3700x 的ubuntu系统成功运行。
|
||||||
|
|
||||||
##### 下载docker脚本
|
##### 下载docker脚本
|
||||||
`git clone https://gitee.com/beijing_hongye_huicheng/docker.git `
|
`git clone https://gitee.com/beijing_hongye_huicheng/docker.git `
|
||||||
##### 部署基础环境
|
##### 部署基础环境
|
||||||
|
@ -51,6 +63,10 @@ Lilishop 是一款Java开发,基于SpringBoot的B2B2C多用户商城,前端
|
||||||
##### 部署应用
|
##### 部署应用
|
||||||
`docker-compose -f docker-compose-application.yml up -d`
|
`docker-compose -f docker-compose-application.yml up -d`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### 各个地址
|
||||||
|
|
||||||
| API | 地址 |
|
| API | 地址 |
|
||||||
| -------------- | --------------- |
|
| -------------- | --------------- |
|
||||||
| 买家api | http://127.0.0.1:8888 |
|
| 买家api | http://127.0.0.1:8888 |
|
||||||
|
@ -215,4 +231,4 @@ Lilishop 是一款Java开发,基于SpringBoot的B2B2C多用户商城,前端
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
### 授权
|
### 授权
|
||||||
Lilishop学习免费,限制商用,如果需要商业使用请联系我们。QQ3409056806
|
Lilishop学习免费,限制商用,如果需要商业使用请联系我们。QQ3409056806
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<u-modal v-model="showWxAuth" :title="projectName+'商城'" :show-confirm-button="false">
|
<u-modal v-model="phoneAuthPopup" :title="projectName+'商城'" :show-confirm-button="false">
|
||||||
|
|
||||||
<div class="tips">
|
<div class="tips">
|
||||||
为了更好地用户体验,需要您授权手机号
|
为了更好地用户体验,需要您授权手机号
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,15 +12,14 @@
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<view class="logo-info">
|
<view class="logo-info">
|
||||||
<text class="title">欢迎进入{{ projectName }}商城</text>
|
<text class="title">欢迎进入{{ projectName }}商城</text>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<view class="small-tips">
|
<view class="small-tips">
|
||||||
<view>为您提供优质服务,{{ projectName }}需要获取以下信息</view>
|
<view>为您提供优质服务,{{ projectName }}需要获取以下信息</view>
|
||||||
<view>您的公开信息(昵称、头像等)</view>
|
<view>您的公开信息(昵称、头像)</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="btns">
|
<view class="btns">
|
||||||
<button type="primary" open-type="getUserInfo" class="btn-auth"
|
<button type="primary" bindtap="getUserProfile" @click="getUserProfile()"
|
||||||
@getuserinfo="hidenWxAuth()">确认微信授权</button>
|
class="btn-auth">确认微信授权</button>
|
||||||
</view>
|
</view>
|
||||||
</div>
|
</div>
|
||||||
</view>
|
</view>
|
||||||
|
@ -40,9 +38,8 @@
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
show: true,
|
// 是否展示手机号码授权弹窗,默认第一步不展示,要先获取用户基础信息
|
||||||
// 默认不显示
|
phoneAuthPopup: false,
|
||||||
showWxAuth: false,
|
|
||||||
// 授权信息展示,商城名称
|
// 授权信息展示,商城名称
|
||||||
projectName: "LiLi",
|
projectName: "LiLi",
|
||||||
//微信返回信息,用于揭秘信息,获取sessionkey
|
//微信返回信息,用于揭秘信息,获取sessionkey
|
||||||
|
@ -53,40 +50,54 @@
|
||||||
image: '',
|
image: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
//微信小程序进入页面,先获取code,否则几率出现code和后续交互数据不对应情况
|
||||||
components: {},
|
mounted() {
|
||||||
props: {},
|
let that = this;
|
||||||
|
//获取code
|
||||||
|
uni.login({
|
||||||
|
success: (res) => {
|
||||||
|
that.code = res.code;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
hidenWxAuth() {
|
//获取用户信息
|
||||||
this.showWxAuth = true;
|
getUserProfile(e) {
|
||||||
let that = this;
|
let that = this;
|
||||||
//------执行Login---------
|
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
|
||||||
uni.login({
|
uni.getUserProfile({
|
||||||
success: (res) => {
|
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
|
||||||
that.code = res.code;
|
success: (res) => {
|
||||||
uni.getUserInfo({
|
that.nickName = res.userInfo.nickName;
|
||||||
provider: "weixin",
|
that.image = res.userInfo.avatarUrl;
|
||||||
success: function(infoRes) {
|
//展示手机号获取授权
|
||||||
that.nickName = infoRes.userInfo.nickName;
|
this.phoneAuthPopup = true;
|
||||||
that.image = infoRes.userInfo.avatarUrl;
|
},
|
||||||
},
|
fail: (res) => {
|
||||||
});
|
that.nickName = "微信用户";
|
||||||
},
|
that.image =
|
||||||
});
|
"https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132";
|
||||||
|
//展示手机号获取授权
|
||||||
|
this.phoneAuthPopup = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
//获取手机号授权
|
||||||
getPhoneNumber(e) {
|
getPhoneNumber(e) {
|
||||||
|
|
||||||
|
let that = this;
|
||||||
let iv = e.detail.iv;
|
let iv = e.detail.iv;
|
||||||
let encryptedData = e.detail.encryptedData;
|
let encryptedData = e.detail.encryptedData;
|
||||||
if (!e.detail.encryptedData) {
|
if (!e.detail.encryptedData) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "请授予手机号码获取权限!",
|
title: "请授予手机号码权限,手机号码会和会员系统用户绑定!",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let code = this.code;
|
|
||||||
let image = this.image;
|
let code = this.code;
|
||||||
|
let image = this.image;
|
||||||
let nickName = this.nickName;
|
let nickName = this.nickName;
|
||||||
mpAutoLogin({
|
mpAutoLogin({
|
||||||
encryptedData,
|
encryptedData,
|
||||||
|
@ -115,7 +126,6 @@
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue