微信小程序用户授权,以及判断登录是否过期的方法
初始界面:
判断用户是否过期(如果未过期则重新登录):
获取用户信息:
获取用户的信息并在前台显示:
主要实现两个功能:
①判断登录是否过期,如果过期则就重新登录,如果没过期就提示未过期
②获取用户的信息,并在前台显示
index.wxml
1 2 3 4 5 6 7 |
|
index.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
index.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
关于这个php文件的说明:
①获取appid和secret:
②当你点击登录的时候,出现这些东西就说明php文件调用成功
③登录凭证校检地址(该里面的参数即可):
④域名要合法
在小程序平台上:
在web开发者工具里: