Skip to content

Commit

Permalink
修正了授权登录功能和readme
Browse files Browse the repository at this point in the history
  • Loading branch information
darkSheep404 committed Feb 22, 2021
1 parent 7760165 commit 643fd52
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 57 deletions.
36 changes: 29 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
# 云开发 quickstart
# 汉服查山正微信小程序

这是云开发的快速启动指引,其中演示了如何上手使用云开发的三大基础能力:
**Hi!同袍~欢迎使用[查山正]小程序!**

- 数据库:一个既可在小程序前端操作,也能在云函数中读写的 JSON 文档型数据库
- 文件存储:在小程序前端直接上传/下载云端文件,在云开发控制台可视化管理
- 云函数:在云端运行的代码,微信私有协议天然鉴权,开发者只需编写业务逻辑代码
​ 该项目是我个人开发的汉服查山正微信小程序

​ 官方QQ群是737117630

​ 有什么想法建议或者想来聊聊天都十分欢迎(✪ω✪)\n

​ 如果补充或者纠正店铺信息,可以点击主页的纠正或者提交

现在是2021年2月22日,数据库当前收录了547家店铺

我会继续搜集店铺信息来补充数据库,如果您有总结的汉服店铺山正信息也欢迎向我们提交\n

小程序后续会展示贡献店铺信息的袍子列表来感谢大家的帮助(✪ω✪)



如果这个小程序有帮到你,或者你想表扬一下孩子,可以点击赞赏支持

给孩子买只冰激凌或者请孩子恰一顿饭(๑❛ᴗ❛๑)۶

![image-20210222223708736](./miniprogram/images/money.jpg)

## SupportBY

**微信云开发**

ColorUI

## 参考文档

- [云开发文档](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html)

2 changes: 1 addition & 1 deletion miniprogram/pages/about/log/log.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</view>
<view class="margin-top-sm text-content">
<view>1.决定今天早起继续写代码</view>
<view>1.赖床玩手机到12:30</view>
<view>2.赖床玩手机到12:30</view>
<view>3.完善了搜索和提交&纠正功能</view>
</view>
</view>
Expand Down
18 changes: 9 additions & 9 deletions miniprogram/pages/authorize/authorize.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,28 @@ Page({
bindGetUserInfo: function (e) {
console.log(e)
if (e.detail.userInfo) {//用户按了允许授权按钮

console.log(e.detail.userInfo)
wx.setStorage({
key: 'userInfo',
data: e.detail.userInfo
})
wx.cloud.callFunction()
wx.cloud.callFunction(
{
name:'add_user'
name:'add_user',
data:{
openid:e.detail.userInfo.openid
nikename:e.detail.userInfo.nickName
openid:e.detail.userInfo.openid,
nikename:e.detail.userInfo.nickName,
avatarUrl:e.detail.userInfo.avatarUrl
}
}
var pages = getCurrentPages(); // 获取页面栈
var prevPage = pages[pages.length - 2]; // 上一个页面
})
wx.navigateBack({
delta: 1
})
} else {//用户按了拒绝按钮

} else {//用户按了拒绝按钮
wx.navigateBack({
delta: 1
})
}
}
})
4 changes: 2 additions & 2 deletions miniprogram/pages/authorize/authorize.wxml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<view >
<view class='mycontainer'>
<button class='authorize' type="primary" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">微信登陆</button>
<text class='tips'>Tips: 必须授权才能使用全部功能</text>
<text class='tips'>Tips: 必须授权才能纠正和补充</text>
</view>
2 changes: 1 addition & 1 deletion miniprogram/pages/authorize/authorize.wxss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* pages/authorize/authorize.wxss */
.container{
.mycontainer{
width: 100%;
height: 100%;
display: flex;
Expand Down
37 changes: 35 additions & 2 deletions miniprogram/pages/correct/correct.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,42 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {

var that = this
wx.getStorage({
key: 'userInfo',
success: function (res) {
},
fail: function () {
that.userInfoAuthorize()
}
})
},
userInfoAuthorize: function () {
var that = this
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) { // 存储用户信息
wx.getUserInfo({
success: res => {
console.log(res.userInfo.nickName)
wx.setStorage({
key: app.globalData.userInfo,
data: res.userInfo,
})
//userinfo:用户信息,不含openid等敏感数据
app.globalData.wechatNickName = res.userInfo.nickName
app.globalData.wechatAvatarUrl = res.userInfo.avatarUrl
//app.globalData.wechatOpenid = res.userInfo.openid
}
})
} else { // 跳转到授权页面
wx.navigateTo({
url: '/pages/authorize/authorize',
})
}
}
})
},

/**
* 生命周期函数--监听页面隐藏
*/
Expand Down
37 changes: 2 additions & 35 deletions miniprogram/pages/home/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
var that = this
wx.getStorage({
key: 'userInfo',
success: function (res) {
},
fail: function () {
that.userInfoAuthorize()
}
})

},

/**
Expand Down Expand Up @@ -75,32 +67,7 @@ Page({
onShareAppMessage: function () {

},
userInfoAuthorize: function () {
var that = this
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) { // 存储用户信息
wx.getUserInfo({
success: res => {
console.log(res.userInfo.nickName)
wx.setStorage({
key: app.globalData.userInfo,
data: res.userInfo,
})
//userinfo:用户信息,不含openid等敏感数据
app.globalData.wechatNickName = res.userInfo.nickName
app.globalData.wechatAvatarUrl = res.userInfo.avatarUrl
//app.globalData.wechatOpenid = res.userInfo.openid
}
})
} else { // 跳转到授权页面
wx.navigateTo({
url: '/pages/authorize/authorize',
})
}
}
})
},

getStorelist:function(){
var that = this
/*wx.showLoading({
Expand Down

0 comments on commit 643fd52

Please sign in to comment.