本地-----------------------------------------------------------------------------------------------------
// 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 ...
随机推荐
- 15-[JavaScript]-ECMAScript 1
0.javaScript的发展历程 https://zhuanlan.zhihu.com/p/27985124 1.javaScript是什么? javaScript是一种web前端的描述语言,也是一 ...
- 2_C语言中的数据类型 (八)运算符
1 运算符表达式和语句 1.1 基本运算符 1.1.1 = 数据对象:泛指数据在内存的存储区域 左值:表示可以被更改的数据对象 右值:能赋给左值的量 1 ...
- C语言编译过程以及gcc编译参数
1.1 C语言编译过程,gcc参数简介 1.1.1 C语言编译过程 一.gcc - o a a.c -o:指定文件输出名字 二.C语言编译的过程: 1.1.1 ...
- P3164 [CQOI2014]和谐矩阵
P3164 [CQOI2014]和谐矩阵 乱写能AC,暴力踩标程(雾 第一眼 诶这题能暴力枚举2333!!! 第二眼 诶这题能高斯消元!那只需要把每个位置的数给设出来就能够列方程了!然后就可以\(O( ...
- JAVAWEB和数据库 Mysql连接不上的原因及解决方案
有可能是安装了phpstudy或者wampserver这类自带mysql的web集成环境, 在关闭集成环境时误关了相对应的mysql服务,所以我们需要手动启动服务. 启动mysql的命令: net s ...
- Jsp中格式化时间戳的常用标签
接下来一段时间的记录,虽然不是一些什么全新的知识,但是作为后台开发人员都是应该必须掌握的前端基础技能,说实话,每一个后台程序员的短板就在于前端技能的弱而造就了不能更上一层楼.从今天开始,我将彻底开启菜 ...
- Spring学习(十九)----- Spring的五种事务配置详解
前段时间对Spring的事务配置做了比较深入的研究,在此之间对Spring的事务配置虽说也配置过,但是一直没有一个清楚的认识.通过这次的学习发觉Spring的事务配置只要把思路理清,还是比较好掌握的. ...
- [硬件配置]Ubuntu 16.04下使用NETGEAR Nighthawk AC1900 (A7000) WIFi USB适配器
为了增强无人机与地面站之间的传输信号,组里买了这款WiFi信号接收器,无奈只有Windows和Mac OS版本的驱动程序.后来不知道从哪里得来的一个偏方可以安装Ubuntu下的驱动,特此记录. 内核降 ...
- centos7上的postgresql10安装和配置
安装数据库 安装参考官方文档:https://www.postgresql.org/download/linux/redhat/ 1.Install the repository RPM: yum i ...
- 【Shader】这是一篇记录随笔,我要开始学Shader了!
背景: 前天学校有场招聘会,转了一圈只看到一家和unity有关的公司,还是做VR游戏的,然后HR也很好说话.和我说话的HR正好是做UnityVR方面的,聊了会受益匪浅,自己就像是找到了方向似的,突然很 ...