为什么二维码不刷新?
扫过一个二维码正常,第二个二维码扫过后与第一个二维码一样,过了10分钟左右,又可以扫第二个二维码了,第三个二维码又扫与第二个二维码一样,推测是刷新频率问题吗?换一台手机升成二维码可用,但第二次升成二维码又不可用?
1、pages/index/index.js
const DB= wx.cloud.database()
const app = getApp()
Page({
onLoad: function (options) {
var dname= options.dname;
var dname1= options.dname1;
this.setData({
dname:dname
})
console.log('测试------------------------------------2',dname)
console.log('测试-----------------------------------1',dname1)
console.log('测试-----------------------------------dname',dname)
wx.cloud.callFunction({ //扫码传递参数pdname2(编号)
name: "s2",
data: {
urlname: 'pages/hpage/index?dname='+dname
},
success: res =>{
console.log('test2')
console.log('test1',res.result)
this.setData({
ima:res.result.fileID
})
},
fail: err =>{
console.log()
}
})
}
})
2、云函数 s2
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({
env: 'xxxxxxxx'
})
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.wxacode.createQRCode({
path:event.urlname, //未验证
width: 430
})
const file = await cloud.uploadFile({
cloudPath: 'cm.jpg',
fileContent: result.buffer,
})
return file
} catch (err) {
return err
}
}
3、pages/index/index.wxml
4、pages/hpage/index.js
const db = wx.cloud.database()
const DB= wx.cloud.database()
const app = getApp()
Page({
data: {
},
onLoad: function (options) {
console.log('测试1------------------------------------',options)
var dname=options.dname;
this.setData({
dname:dname
})
console.log('测试2',dname)
DB.collection("tt").add({
data:{ // 添加数据到yxsjk1
dname:dname
}
})
}
})