GithubHelp home page GithubHelp logo

wxapp-login-demo's Introduction

微信小程序登录 demo

小程序登录 demo 分为客户端和服务端两个部分

本项目为小程序客户端, 服务端为 wxapp-login-server

实现功能

  • 支持自定义登录态, 完全清除缓存后依然可以返回正确的用户信息
  • 支持绑定用户信息 (昵称, 头像等)
  • 支持绑定用户手机号
  • 实现 cookie 基础功能, 可直接复用 Web 端接口
  • 实现 session 过期判断

使用方法

将小程序 wxapp-login-demo 和服务端 wxapp-login-server 两个项目都 clone 至本地

使用前请参考 使用测试 appId

wxapp-login-server

使用 Node.js 实现登录服务端

# 安装依赖
$ cnpm install

# 启动
$ npm start

注意, 服务端使用 js 变量来保存用户数据, 也就是说如果重启服务端, 用户数据就清空了

如需持久化存储用户数据, 需自行实现数据库相关逻辑

wxapp-login-demo

微信小程序

  1. 使用最新版微信开发者工具(需支持npm) 新建项目
  2. 根据文档安装依赖 cnpm install --production 并构建 npm
  3. 点击编译查看效果

使用测试 appId

开发者只能使用自己的测试 appId 和 appSecret 进行测试与开发

打开 https://developers.weixin.qq.com/sandbox 并登录

复制 appId 和 appSecret 至 wxapp-login-server 的 config.js

在微信开发者工具点击测试号: 小程序, 如图所示, 会自动修改 appId 为自己的 appId

wxapp-login-demo's People

Contributors

chunpu avatar

Watchers

James Cloos avatar 雨中的鱼 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.