- 用云调用二维码后返回res.result.buffer,用云函数上传后返回显示不出来?
1、index.js Page({ onLoad: function (options) { console.log('test') wx.cloud.callFunction({ name: "yhs1", data: {}, success: res =>{ console.log('test2') console.log('test1',res.result.buffer) this.setData({ imaget:res.result.buffer }) }, fail: err =>{ console.log() } }) }, check: function () { var imaget=this.data.imaget console.log('test1',imaget) console.log('test') wx.cloud.callFunction({ name: "yhs2", data: { demo:imaget }, success: res =>{ console.log('test2') console.log('test1',res.result) this.setData({ imaget2:res.fiedId }) }, fail: err =>{ console.log() } }) } }) 2、index.wxml <image style="width: 200px; height: 200px; background-color: #eeeeee;" mode="{{item.mode}}" src="{{imaget2}}"></image> <view class="crr"> <button class="ff" bindtap='check'>test</button> </view> 3、云函数yhs1 // 云函数入口文件 const cloud = require('wx-server-sdk') cloud.init({ env: 'testw-z6k1v' }) exports.main = async (event, context) => { try { const result = await cloud.openapi.wxacode.createQRCode({ path: 'page/index/index', width: 430 }) return result } catch (err) { return err } } 4、云函数yhs2 // 云函数入口文件 const cloud = require('wx-server-sdk') cloud.init({ env: 'testw-z6k1v', }) exports.main = async (event, context) => { return await cloud.uploadFile({ cloudPath: 'demo.jpg', fileContent: event.demo }) } 运行后: {contentType: "image/jpeg", buffer: ArrayBuffer(55707), errMsg: "openapi.wxacode.createQRCode:ok", errCode: 0}buffer: ArrayBuffer(55707)[[Int8Array]]: Int8Array(55707) [-1, -40, -1, -32, 0, 16, 74, 70, 73, 70, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, -1, -37, 0, 67, 0, 3, 2, 2, 3, 2, 2, 3, 3, 3, 3, 4, 3, 3, 4, 5, 8, 5, 5, 4, 4, 5, 10, 7, 7, 6, 8, 12, 10, 12, 12, 11, 10, 11, 11, 13, 14, 18, 16, 13, 14, 17, 14, 11, 11, 16, 22, 16, 17, 19, 20, 21, 21, 21, 12, 15, 23, 24, 22, 20, 24, 18, 20, 21, 20, -1, -37, 0, 67, 1, 3, 4, 4, 5, 4, 5, …][[Uint8Array]]: Uint8Array(55707) [255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 255, 219, 0, 67, 0, 3, 2, 2, 3, 2, 2, 3, 3, 3, 3, 4, 3, 3, 4, 5, 8, 5, 5, 4, 4, 5, 10, 7, 7, 6, 8, 12, 10, 12, 12, 11, 10, 11, 11, 13, 14, 18, 16, 13, 14, 17, 14, 11, 11, 16, 22, 16, 17, 19, 20, 21, 21, 21, 12, 15, 23, 24, 22, 20, 24, 18, 20, 21, 20, 255, 219, 0, 67, 1, 3, 4, 4, 5, 4, 5, …]byteLength: (...)__proto__: ArrayBuffercontentType: "image/jpeg"errCode: 0errMsg: "openapi.wxacode.createQRCode:ok"__proto__: Object index.js:28 test1 {contentType: "image/jpeg", buffer: ArrayBuffer(55707), errMsg: "openapi.wxacode.createQRCode:ok", errCode: 0}
2020-06-12 - 获取二维码返回不正确?
//index.js //获取应用实例 const app = getApp() Page({ onLoad: function () { wx.request({ url: 'https://api.weixin.qq.com/cgi-bin/token', header: { 'content-type': 'application/json' }, data: { grant_type: 'client_credential', appid: 'XXXXX', secret: '秘钥' }, success(res) { var accessToken = res.data.access_token wx.request({ url: 'https://api.weixin.qq.com/wxa/getwxacode?access_token=' + accessToken, method: 'POST', responseType: 'arraybuffer', data: { "path": 'pages/index/index', "width": 430, }, success(res) { console.log(res.data) let base64 = wx.arrayBufferToBase64(res.data) console.log(base64) let codeImg = 'data:image/PNG;base64,' + base64 console.log(codeImg) }, }) } }) } }) -------------------------------------------------- 运行后返回的accessToken有问题: ArrayBuffer(112) {} eyJlcnJjb2RlIjo0MDAwMSwiZXJybXNnIjoiaW52YWxpZCBjcmVkZW50aWFsLCBhY2Nlc3NfdG9rZW4gaXMgaW52YWxpZCBvciBub3QgbGF0ZXN0IGhpbnRzOiBbaEtmQ0tuQUNlLXJTVG9fIV0ifQ== data:image/PNG;base64,eyJlcnJjb2RlIjo0MDAwMSwiZXJybXNnIjoiaW52YWxpZCBjcmVkZW50aWFsLCBhY2Nlc3NfdG9rZW4gaXMgaW52YWxpZCBvciBub3QgbGF0ZXN0IGhpbnRzOiBbaEtmQ0tuQUNlLXJTVG9fIV0ifQ==
2020-06-11 - 云函数查询云数据记录出错误?
1、云函数 name const cloud = require('wx-server-sdk') wx.cloud.init({ env: "xxxxxx" }) const db = cloud.database() exports.main = async (event, context) => { try { return await db.collection('gxser').doc('a85ed387c100134853').get() } catch (err) { console.log(err) } } 2、pages中的index.js Page({ onAdd:function() { wx.cloud.callFunction({ name: "name", success(res) { console.log("请求成功", res) }, fail(res) { console.log("请求失败", res) } }) } }) 3、index.wxml <button bindtap="onAdd">用函数</button> -------------------------------------------------------------------------------------------- 运行提示: 请求失败 Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID b5007aac-a98c-11ea-922e-5254001dad8e, cloud function service error code -504002, error message wx is not defined; at cloud.callFunction api; at new u (VM319 WAService.js:2) at d (VM319 WAService.js:2) at f (VM319 WAService.js:2) at Function.success (VM319 WAService.js:2) at VM319 WAService.js:2 at T (VM319 WAService.js:2) at i.<anonymous> (VM319 WAService.js:2) at i.emit (VM319 WAService.js:2) at Si (VM319 WAService.js:2) at VM319 WAService.js:2
2020-06-08 - 需求:下部导航栏一个tabBar不够用问题?
小程序制作过程中,需要用到,多种身份对应多个tabBar,一个tabBar已经不能满足应用需求,如:客户端、管理端、服务端;
2020-06-06 - 云数据库的极限是多少记录?每个数据大小有极限吗?
云数据库的极限是多少记录?每个数据大小有极限吗?
2020-05-22 - 运行提示:调用支付JSAPI缺少参数:totalfee ,为什么?
1、云函数 const cloud = require('wx-server-sdk') cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) exports.main = async (event, context) => { const res = await cloud.cloudPay.unifiedOrder({ "body" : "小秋TIT店-超市", "outTradeNo" : "1217752501201407033233368018", "spbillCreateIp" : "127.0.0.1", "subMchId" : "1900009231", "totalFee" : 1, "envId": "test-f0b102", "functionName": "pay_cb" }) return res } 2、 小程序代码 wx.cloud.callFunction({ name: '函数名', data: { // ... }, success: res => { const payment = res.result.payment wx.requestPayment({ ...payment, success (res) { console.log('pay success', res) }, fail (res) { console.error('pay fail', err) } }) }, fail: console.error, }) 运行提示:调用支付JSAPI缺少参数:totalfee ,为什么?
2020-05-22 - 支付JSAPI缺少参数:totalFee ,为什么?
1、云函数 const cloud = require('wx-server-sdk') cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) exports.main = async (event, context) => { const res = await cloud.cloudPay.unifiedOrder({ "body" : "小秋TIT店-超市", "outTradeNo" : "1217752501201407033233368018", "spbillCreateIp" : "127.0.0.1", "subMchId" : "1900009231", "totalFee" : 1, "envId": "test-f0b102", "functionName": "pay_cb" }) return res } 2、 小程序代码 wx.cloud.callFunction({ name: '函数名', data: { // ... }, success: res => { const payment = res.result.payment wx.requestPayment({ ...payment, success (res) { console.log('pay success', res) }, fail (res) { console.error('pay fail', err) } }) }, fail: console.error, }) 运行提示:调用支付JSAPI缺少参数:totalfee ,为什么?
2020-05-22 - 做云函数,解析project.config.json 文件失败,请检查其内容或删除此文件?
我的第一个云函数我们以定义一个将两个数字相加的函数作为我们第一个云函数的示例。 在项目根目录找到 [代码]project.config.json[代码] 文件,新增 [代码]cloudfunctionRoot[代码] 字段,指定本地已存在的目录作为云函数的本地根目录 示例: { "cloudfunctionRoot": "./functions/" } 操作后提示:解析[代码]project.config.json[代码] 文件失败,请检查其内容或删除此文件 这是为什么? 我换了台电脑操作成功,为什么?????? 出错的电脑是win7,用了 Fidder;成功的电脑是win8,为什么???
2020-05-18 - 最新云支付相关代码注释正确吗?
//云函数代码 名称?pay.js const cloud = require('wx-server-sdk') cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) exports.main = async (event, context) => { const res = await cloud.cloudPay.unifiedOrder({ "body" : "小秋TIT店-超市", "outTradeNo" : "1217752501201407033233368018", //订单号 可以写成动态 "spbillCreateIp" : "123.207.180.217", //我的云函数ip 这个注释正确吗?云函数有ip吗? "subMchId" : "1900009231", // 商户ID "totalFee" : 1, //1分钱 "envId": "test-f0b102", //小程序云开发号 "functionName": "pay_cb" //回调云函数 这个函数能写一个空函数吗?? }) return res } // 小程序代码 wx.cloud.callFunction({ name: 'pay.js', //这个名称写的正确码? data: { // ... }, success: res => { const payment = res.result.payment wx.requestPayment({ ...payment, success (res) { console.log('pay success', res) }, fail (res) { console.error('pay fail', err) } }) }, fail: console.error, })
2020-05-16 - 已实现小程序MM跳转到小程序qq,但数据通过extraData传递,接收没有成功?
已实现小程序MM跳转到小程序qq,但数据通过extraData传递,接收没有成功? 一、小程序MM 1、index.js Page({ onchick:function(){ wx.navigateToMiniProgram({ appId: 'qqqqqqqqqqqqqqqq', path: 'pages/index/index',//可以传参 extraData: { //需要传递给目标小程序的数据,目标小程序可在 App.onLaunch(),App.onShow() 中获取到这份数据 mm:9 }, envVersion: 'develop', //重点**要打开的小程序版本,有效值 develop(开发版),trial(体验版),release(正式版) success(res) { console.log('打开成功')// 打开成功 } }) }, }) 2、index.wxml <button bindtap='onchick'>跳转</button> 3、app.json "navigateToMiniProgramAppIdList":[ "qqqqqqqqqqqqqqqq", "wwwwwwwwwwwwwwww" ] 二、小程序qq 1、app.js App({ onLaunch: function () { // 展示本地存储能力 }, onShow: function (res) { console.log('test0',res.query.mm) this.globalData.tt= res.query.mm //能给globalData中的tt赋值吗? }, globalData: { userInfo: null, tt:'', } }) 2、index.js Page({ data: { }, onLoad: function () { var app=getApp(); console.log("test---",app.globalData.tt) //提示 undefined??? var ddd=app.globalData.tt //从app.js中获取globalData中的tt this.setData:{ ddd:ddd //提示ddd无法定义?为什么? } }, }) 2、index.wxml <view > 测试{{ddd}} </view>
2020-05-15