赞
踩
微信授权,储存授权的全部信息,传输页与接收页
传输页
- <template>
- <view>
- <button @click="getUserProfile">微信授权</button>
- <button @click="A">清除缓存</button>
- <u-button :plain="true" type="primary" size="small" text="跳转" @click="B">
- </u-button>
- </view>
- </template>
-
- <script>
- export default {
- data() {
- return {
- info:{
- nickName:'',
- avatarUrl:'',
- language:'',
- },
- }
- },
- //方法
- methods: {
- B() {
- uni.navigateTo({
- url: '路径'
- })
- },
- getUserProfile() {
- let that = this
- uni.getUserProfile({
- desc: "用于完善用户信息",
- success: (res1) => {
- that.info = res1.userInfo;
- console.log(res1)
- uni.showToast({
- icon:"none",
- title:'获取成功'
- })
- },
- fail: (err) => {
- console.log(err)
- uni.showToast({
- icon:"none",
- title:'用户拒绝获取'
- })
- }
- })
- },
- A(){
- uni.clearStorage()
- },
-
- }
- }
- </script>
-
- <style>
-
- </style>
接收页
- <template>
- <view>
- 用户 {{id}}
- </view>
- </template>
-
- <script>
- export default {
- data() {
- return {
- id:uni.getStorageSync('id'),
- }
- },
- //方法
- methods: {
- pullDown(){
- uni.startPullDownRefresh();
- },
- getStorage1(){
- uni.getStorage({
- key:'id',
- success(res){
- console.log('获取成功',res.data)
-
- }
- })
- }
- },
-
- }
- </script>
- <style>
-
- </style>
-
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。