vue
vue
云南吴小黑
这个作者很懒,什么都没留下…
展开
-
微信网页授权,解决REDIRECT_URL携带#号,微信返回时临时code等参数拼接在URL中间,而不是最后面
微信授权获取临时code的URLhttps://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_userinfo&state=012#wechat_redirect授权逻辑代码通过window.history.pushState({}, 0, jumpURL)解决问题=,其中jumpU.原创 2022-04-12 09:30:57 · 6151 阅读 · 0 评论 -
微信内嵌H5(uniapp)授权登录(静默授权)
1. 开发前准备注册微信公众号完成信息填写等;配置网页授权域名;2. 前端开发onLoad()中初始化临时codeonLoad(options) { this.initWechatParams();}initWechatParamsasync initWechatParams() { const _this = this; _this.loginParams.appId = "*****"; //解析URL的参数,获取临时code //code作为换取access_t原创 2022-03-25 14:53:49 · 3935 阅读 · 0 评论 -
微信小程序(uniapp)授权登录
1. 开发前准备2. 前端开发初始化openId和sessionKeyasync initWechat_MP() { const _this = this; console.log('wechat==========>', _this.wechat); if (_this.wechat && _this.wechat.openId && _this.wechat.sessionKey) { return; } uni.login({ su原创 2022-03-23 21:20:20 · 2197 阅读 · 0 评论 -
微信内嵌H5(uniapp)授权登录(非静默授权)
1. 开发准备在微信后台配置网页授权域名(主要要解决的是微信校验txt文件,开发时在微信开发者工具,我使用的是natapp做域名解析,通过natapp穿透到本地开发测试)IP白名单(不记得需不需要这一步,不需要可以不配置)2. 前端开发第一步:获取临时code(REDIRECT_URI必须是微信后台配置过的网页授权域名)initWechat_H5() { const h5AppId = this.$mStore.getters.globalConfig.wechatH5AppId ||原创 2022-03-23 21:04:11 · 1794 阅读 · 0 评论 -
微信小程序(uniapp)获取用户位置信息及选择位置
1. 开发前准备注册微信小程序账号并配置相关信息;注册腾讯地图开放平台并完成应用创建等;下载qqmap-wx-jssdk.min.js放到项目中;2. 获取用户当前位置wx.getLocation// #ifdef MP-WEIXINthis.initLocationInfoMP();// #endif//初始化位置initLocationInfoMP() { const _this = this; wx.getLocation({ //type: 'gcj02', //wg原创 2022-03-23 20:35:57 · 2280 阅读 · 1 评论 -
微信内嵌H5(uniapp)获取用户位置信息及打开内置地图
public class Wechat2HTTPConverter extends MappingJackson2HttpMessageConverter {public Wechat2HTTPConverter() { List<MediaType> mediaTypes = new ArrayList<>(); mediaTypes.add(MediaType.TEXT_PLAIN); setSupportedMediaTypes(mediaTypes)原创 2022-03-23 18:01:37 · 3601 阅读 · 0 评论 -
微信查询元素信息时boundingClientRect()和exec()区别
参考代码//代码1const query = wx.createSelectorQuery(); query.select('#id').boundingClientRect(res => { console.log('元素', res);}).exec();//代码2const query = wx.createSelectorQuery();query.select('#id').boundingClientRect().exec(resList => { cons.原创 2022-03-04 10:19:30 · 1519 阅读 · 0 评论 -
微信小程序和公众号(H5)获取元素信息
H5页面// #ifdef H5var query = wx.createSelectorQuery();query.select("#search-bar").boundingClientRect().exec(res => { console.log("searchBar:" + res);});// #endif小程序(非自定义组件)非自定义组件不用加.in(this)// #ifdef MP-WEIXINconst query = wx.createSelecto.原创 2022-03-04 09:36:18 · 596 阅读 · 0 评论 -
uniapp 组件封装-图片选择
在目录components下创建文件夹image目录,在image目录下创建index.vue文件,代码如下:<template name="avatar"> <view> <image :src="imgSrc.imgSrc" @tap="fSelect" :style="[imgStyle]" class="my-avatar" ></image> <canvas canvas-id="avatar-.原创 2021-09-29 11:26:08 · 347 阅读 · 0 评论 -
接口安全性处理
1.前端在header签名//引入md5加密import md5 from 'js-md5';const xEchoStr = '获取随机字符';const xTsStr = Date.now();const xApiKey = '接口KEY';headers: { 'Content-Type': 'application/json;charset=utf-8', //设置浏览器缓存时间 'Cache-Control': 'no-cache;max-age=0',原创 2021-09-06 13:02:57 · 150 阅读 · 0 评论 -
前端AES加密,后端AES解密
1.引入crypto-jsimport AES from 'crypto-js';2.两个加解密函数//十六位十六进制数作为密钥const key = AES.enc.Utf8.parse('0123456789ASDFGH');//十六位十六进制数作为密钥偏移量const iv = AES.enc.Utf8.parse('ASDFGH0123456789'); export const encrypt = word => { const src = AES.enc.Utf原创 2021-09-06 12:54:18 · 1797 阅读 · 4 评论 -
腾讯地图取点(切换位置)
直接点击取点进去chooseLocation() { const _this = this; wx.getSetting({ success(res) { if (res.authSetting['scope.userLocation'] != undefined && res.authSetting['scope.userLocation'] != true) { uni.showModal({ title: '位置授权', content:.原创 2021-08-12 11:24:11 · 698 阅读 · 0 评论 -
调用腾讯地图获取位置信息
1.调用wx.getLocation()获取用户授权【实现代码如下】:wx.getLocation({ //type: 'gcj02', //wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 success: res => { console.log('获取位置信息成功======>'); //res.longitude为纬度, res.longitude为经度 // 通过申请的key生成wxMap实例 let map原创 2021-08-12 11:13:55 · 761 阅读 · 0 评论