1.指定页面不显示返回或首页按钮
onShow(){
uni.h
}
2.uni-app 开发微信小程序长按识别公众号

*2.使用image标签的show-menu-by-longpress属性
*show-menu-by-longpress开启长按识别功能
*/
<template>
<image
v-if="popupURL"
show-menu-by-longpress
:src="popupURL"
alt=""
class="popupURL-box"
/>
</template>
3.uni-app 开发微信小程序 推荐并携带推荐人信息小程序码
/*
*思路:
*1.获取小程序的token(APPID--微信公众平台-》开发管理-》开发设置获取,APPSECRET--微信公众平台-》开发管理-》开发设置获取)
*2.?id=或者scene 为携带的参数
*3.QRCode 生成小程序码
*4.getToken接口调用和getQrCode接口建议使用后台接口完成
*/
/*推荐页面
*/
<script>
import QRCode from './../../../common/weapp-qrcode.js'
methods: {
getToken() {
uni.showLoading({
title: '加载中',
mask: true,
})
let APPID = '******'
let APPSECRET = '******'
uni
.request({
url: `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${
APPID}&secret=${
APPSECRET}`,
method: 'GET',
})
.then((res) => {
if (res[1].data.expires_in != 7200) {
uni.showToast({
title: '分享失败,请重新尝试。',
icon: 'none',
duration: 2000,
})
uni.hideLoading()
return
}
this.getQrCode(res[1].data.access_token)
uni.hideLoading()
})
.catch((err) => {
console.log(err)
uni.hideLoading()
})
},
getQrCode(access_token) {
let scene =
'id=' + uni.getStorageSync('userInfo').additionalInformation.userId
//获取小程序码带参数
const that = this
uni.request({
url:
'https://api.weixin.qq.com/wxa/getwxacode?access_token=' +
access_token, //固定链接,不用改
method: 'POST',
responseType: 'arraybuffer', //设置响应类型
data: {
scene: scene,
path:
'pages/login/login?id=' +
uni.getStorageSync('userInfo').additionalInformation.userId, // 必须是已经发布的小程序存在的页面(否则报错) ()
width: 200,
auto_color: true, // 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
line_color: {
r: '0',
g: '0',
b: '0',
}, // auto_color 为 false 时生效,使用 rgb 设置颜色
},
success: function (res) {
console.log('获取二维码', res) //返回的是ArrayBuffer 对象
setTimeout(() => {
that.popupURL =
'data:image/PNG;BASE64,' + uni.arrayBufferToBase64(res.data) //以图片的形式展示
}, 50)
},
})
},
}
</script>
/*获取
*/
<script>
onLoad(options) {
uni.setStorageSync('accountId', options.id)
},
</script>