本地-----------------------------------------------------------------------------------------------------
// wx.login({
// success: res => {
// var code = res.code; //返回code
// // console.log(code)
// // 小程序appid
// // wxd751fc845c90fbd8
// // 3df95e167161ab74e09ea54eda471c96
// var appId = 'wxd751fc845c90fbd8';
// // 小程序密钥
// var secret = '3df95e167161ab74e09ea54eda471c96';
// wx.request({
// url: 'https://api.weixin.qq.com/sns/jscode2session?appid=' + appId + '&secret=' + secret + '&js_code=' + code + '&grant_type=authorization_code',
// data: {},
// header: {
// 'content-type': 'json'
// },
// success: function (res) {
// // console.log(res)
// var openid = res.data.openid
// console.log(openid)
// that.globalData.userId = openid;
// // openid请求
// wx.request({
// url: 'http://192.168.1.15:8080/queryUsers',
// data:{
// openid: openid
// },
// success: function (res) {
// var result=res.data;
// if (result.length!=0){
// // app.globalData.user = result;
// // 同步缓存
// wx.setStorageSync('user', result[0]);
// var user = wx.getStorageSync('user');
// }else{
// wx.redirectTo({
// url: '/pages/userdata/userdata'
// })
// }
// }
// })
// }
// })
// }
// });
网络-----------------------------------------------------------------------------------------------------
wx.login({
success: res => {
if (res.code) {
// console.log(res.code)
var code1 = res.code;
wx.request({
url: 'https://www.didu86.com/Football-manager-web/Openid',
data: { code1: code1 },
success: function (res) {
// console.log(res)
var openid = res.data
// console.log(openid)
that.globalData.userId = openid
user请求---------------
wx.request({
url: 'https://www.didu86.com/Football-manager-web/queryUsers', //仅为示例,并非真实的接口地址
data: {
openid: openid,
},
success: function (res) {
var result = res.data;
wx.setStorageSync('user', result);
}
})
}
})
}
}
});
用户微信信息--------------------------------------------------------------------------------------------------------------------------------------------
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo;
wx.setStorageSync('userInfo', res.userInfo)
// console.log(res.userInfo)
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}else{
}
}
});
请求登入-------------------------------------------------------------------------------------------------------------------------------------------
index
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo;
wx.setStorageSync('userInfo', res.userInfo)
// console.log(res.userInfo)
// this.setData({
// userInfo: res.userInfo,
// hasUserInfo: true
// })
}
})
- 微信小程序 功能函数 支付接口
// 订单生成返回数据,弹出是否支付模态 wx.showModal({ title: '微信支付', content: '确定支付吗?', success: function (res) { if ( ...
- 微信小程序 功能函数 点击传参和页面
// 商品详情页跳转函数 detailInto: function (e) { // console.log() var change = e.currentTarget.dataset.id; wx ...
- 微信小程序 功能函数 定时震动
ffn: function () { let nnn = this.data.nnn nnn += 1; this.setData({ nnn: nnn }); if (nnn > 10) { ...
- 微信小程序 功能函数 客服
<view> <view class='btn-img'> <image class='image-full' src='../../imgs/index/tab6.pn ...
- 微信小程序 功能函数 将对象的键添加到数组 (函数深入)
// 将对象的键添加到数组 var arr = Object.keys(site); //英文 https://developer.mozilla.org/en-US/docs/Web/JavaScr ...
- 微信小程序 功能函数 购物车商品删除
// 购物车删除 deleteList(e) { const index = e.currentTarget.dataset.index; let carts = this.data.carts; c ...
- 微信小程序 功能函数 替换字符串内的指定字符
var str = 'abcadeacf'; var str1 = str.replace('a', 'o'); alert(str1); // 打印结果: obcadeacf var st ...
- 微信小程序 功能函数picker-view的弹出模态
<view class="list"> <form bindsubmit="formSubmit"> <view class=&q ...
- 微信小程序 功能函数 获取验证码*
yanZhengInput: function (e) { var that = this; var yanzheng = e.detail.value; var huozheng = this.da ...
随机推荐
- jsp jstl 值空格拼接导致的异常
红线标记处多了个空格,所以出现值错误
- Flutter - > Android dependency 'com.android.support:support-v4' has different version for the compile (26.1.0) and runtime (27.1.1) classpath.
Launching lib\main.dart on Nokia X6 in debug mode... Initializing gradle... Resolving dependencies.. ...
- Json对象与Json字符串的转化、JSON字符串与Java对象的转换(转)
一.Json对象与Json字符串的转化 1.jQuery插件支持的转换方式: $.parseJSON( jsonstr ); //jQuery.parseJSON(jsonstr),可以将json字符 ...
- IIS 配置网站
IIS 配置网站最常见的问题 1 文件夹权限问题 (C盘 windows下temp文件夹权限问题)2 版本问题 (框架版本问题如4.0 在2.0下运行,4.5在4.0下运行) 3如果是局域网,考虑动态 ...
- Unity学习笔记(5):动态加载Prefab
第一种方法,从Resources文件夹读取Prefab Assets/Resources文件夹是Unity中的一个特殊文件夹,在博主当前的认知里,放在这个文件夹里的Prefab可以被代码动态加载 直接 ...
- Linux(Contos7.5)环境搭建之Gitblit安装(三)
1.yum安装git(这一步暂时不清楚是否必要,因为在window上搭建并不需要)
- telnet命令详解
基础命令学习目录 原文链接:https://www.cnblogs.com/PatrickLiu/p/8556762.html telnet命令用于登录远程主机,对远程主机进行管理.telnet因为采 ...
- IDEA下载插件超时的原因
setting中红框的对勾去掉就可以下载插件了
- Notes of Daily Scrum Meeting(11.19)
Notes of Daily Scrum Meeting(11.19) 现在工程项目进入尾声了,我们的项目中还有一些问题需要解决,调试修改起来进度比较慢,所以昨天就没有贴出项目 进度,今天的团队工作总 ...
- sampleFactory(女娲造人)
使用简单工厂模式模拟女娲(Nvwa)造人(Person),如果传入参数M,则返回一个Man对象,如果传入参数W,则返回一个Woman对象,如果传入参数R,则返回一个Robot对象. package c ...