- 小程序调用一物一码的tickertocode时怎么获取code,请求参数文档描述不是很清晰?
终结:使用服务号的access_token 使用 服务号的openid 或者小程序的 openid 都可以 1.服务号申请了一物一码的功能 2.通过服务号的接口生成了一物一码的二维码,包含 code 和 生成二维码的信息 3.通过激活设置一物一码扫码跳转小程序指定页面 4.微信扫码会自动跳转到小程序并携带参数 ticket_code 数据 5.通过文档需要 ticker_code 并配合 openid 来转出来一物一码的code 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Unique_Item_Code/Unique_Item_Code_API_Documentation.html#9 现在问题是解码的时候 ticket_code 拿到了,用服务号的 appid 和 openid 或者 小程序的 appid 和 openid 都会出现错误。 请问: 1.这个文档使用的是 服务号 的信息,所以这一趟下来都是 服务号的 access_token 吗? 2.access_token 要和 openid 对应使用,我分别用了服务号和小程序下的 access_token 和 openid 的去请求 其中服务号的会提示 : "errcode\":40097,\"errmsg\":\"invalid args, 无效的code_ticket或与openid不对应... hint: [ofMD30862p550][2024-05-10 16:31:02] rid: 663ddb46-35de181a-3bba688c\ 小程序会提示: \"errcode\":40097,\"errmsg\":\"invalid args, 无效的code_ticket或与openid不对应... hint: [Pw01813230][2024-05-10 16:36:21] rid: 663ddc85-5cfbd6e7-75ed9d82\
05-10 - 在模板中使用if判断不生效
写一个弹出层,然后再页面上做if判断不生效 上代码和图 初始化: [图片] 点击按钮触发函数: [图片] 模板代码: [代码]<template name=[代码][代码]"toast"[代码][代码]>[代码][代码] [代码][代码]<view class=[代码][代码]'toast-out'[代码] [代码]wx:[代码][代码]if[代码][代码]=[代码][代码]"{{is_show}}"[代码][代码]>[代码][代码] [代码][代码]<view class=[代码][代码]'toast-in'[代码][代码]> [代码][代码] [代码][代码]<span class=[代码][代码]'iconfont {{iconClass}}'[代码][代码]><[代码][代码]/span[代码][代码]>[代码][代码] [代码][代码]<view class=[代码][代码]'toast-txt'[代码][代码]>[代码][代码] [代码][代码]{{txt}}[代码][代码] [代码][代码]<[代码][代码]/view[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]/view[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]/view[代码][代码]>[代码][代码]<[代码][代码]/template[代码][代码]>[代码] 函数代码: [代码]test:[代码][代码]function[代码][代码](){[代码][代码] [代码][代码]// this.toastShow(this,'登录名不能为空',"icon-suo")[代码][代码] [代码][代码]console.log([代码][代码]'================执行自定义函数'[代码][代码])[代码][代码] [代码][代码]app.toastShow([代码][代码]this[代码][代码],[代码][代码]'登录名不能为空'[代码][代码],[代码][代码]"icon-suo"[代码][代码]);[代码][代码]},[代码] app.js中封装的函数 [代码]toastShow:[代码][代码]function[代码][代码](that,str,icon){[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]is_show: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]txt: str,[代码][代码] [代码][代码]iconClass:icon[代码][代码] [代码][代码]});[代码][代码] [代码][代码]setTimeout([代码][代码]function[代码] [代码]() { [代码][代码]//toast[代码][代码]消失[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]is_show: [代码][代码]false[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}, 1500); [代码][代码]}[代码] 点击按钮,is_show的值变了,但是页面没有效果展示出来,直接注释掉这些的话页面是会有弹出层的 [代码]<template name=[代码][代码]"toast"[代码][代码]>[代码][代码] [代码][代码]<view [代码][代码]class[代码][代码]=[代码][代码]'toast-out'[代码][代码]>[代码][代码] [代码][代码]<view [代码][代码]class[代码][代码]=[代码][代码]'toast-in'[代码][代码]> [代码][代码] [代码][代码]<span [代码][代码]class[代码][代码]=[代码][代码]'iconfont {{iconClass}}'[代码][代码]></span>[代码][代码] [代码][代码]<view [代码][代码]class[代码][代码]=[代码][代码]'toast-txt'[代码][代码]>[代码][代码] [代码][代码]{{txt}}[代码][代码] [代码][代码]</view>[代码][代码] [代码][代码]</view>[代码][代码] [代码][代码]</view>[代码][代码]</template>[代码] [图片] em....新手求解
2018-07-23 - 发起请求提示complete未定义
刚接触小程序,自己写一个页面,初始化的时候加载缓存数据,当缓存数据不存在的时候请求。 然后在请求中初始化数据,返回 o.complete is not a functon [代码]var config = require([代码][代码]'../../utils/config.js'[代码][代码]);[代码][代码]var page = [代码][代码]0[代码][代码];[代码][代码]var limit = [代码][代码]10[代码][代码];[代码][代码]var get_info_data = function(that){[代码][代码] [代码][代码]wx.request({[代码][代码] [代码][代码]url: config.host + [代码][代码]'/index/user/info_list'[代码][代码],[代码][代码] [代码][代码]data:{[代码][代码] [代码][代码]page[代码][代码]:page[代码][代码],[代码][代码] [代码][代码]limit[代码][代码]:limit[代码][代码],[代码][代码] [代码][代码]},[代码][代码] [代码][代码]header:{[代码][代码] [代码][代码]'Content-type'[代码][代码]:[代码][代码]'application/json'[代码][代码],[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success[代码][代码]:function[代码][代码](res){[代码][代码] [代码][代码]var datas = res.data;[代码][代码] [代码][代码]if[代码] [代码](datas.code == [代码][代码]200[代码][代码]){[代码][代码] [代码][代码]var info_data = wx.getStorageSync([代码][代码]'info_data'[代码][代码]) || [];[代码][代码] [代码][代码]wx.setStorageSync([代码][代码]'info_data'[代码][代码], datas.data);[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]info_data: datas.data,[代码][代码] [代码][代码]info_data_state[代码][代码]:true[代码][代码],[代码][代码] [代码][代码]},[代码][代码]800[代码][代码]);[代码][代码] [代码][代码]page++;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail[代码][代码]:function[代码][代码](){[代码][代码] [代码][代码]},[代码][代码] [代码][代码]complete[代码][代码]:function[代码][代码](){[代码][代码] [代码] [代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码]};[代码][代码]Page({[代码][代码] [代码][代码]/**[代码][代码] [代码][代码]* 页面的初始数据[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]info_data:[],[代码][代码] [代码][代码]info_data_state: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]background: [[代码][代码]'demo-text-1'[代码][代码], [代码][代码]'demo-text-2'[代码][代码], [代码][代码]'demo-text-3'[代码][代码]],[代码][代码] [代码][代码]autoplay[代码][代码]:true[代码][代码],[代码][代码] [代码][代码]indicatorDots[代码][代码]:false[代码][代码],[代码][代码] [代码][代码]interval:[代码][代码]2000[代码][代码],[代码][代码] [代码][代码]duration:[代码][代码]1500[代码][代码],[代码][代码] [代码][代码]anshun: [代码][代码]true[代码][代码],//导航选中[代码][代码] [代码][代码]luke: [代码][代码]false[代码][代码],//导航选[代码][代码] [代码][代码]timeout[代码][代码]:false[代码][代码],//导航选中[代码][代码] [代码][代码]title_anshun:[代码][代码]'A'[代码][代码],[代码][代码] [代码][代码]title_luke:[代码][代码]'b'[代码][代码],[代码][代码] [代码][代码]title_timeout:[代码][代码]'c'[代码][代码],[代码][代码] [代码][代码]},[代码][代码] [代码][代码]anshun: function (e) {[代码][代码] [代码][代码]this.setData({[代码][代码] [代码][代码]anshun: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]luke: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]timeout[代码][代码]:false[代码][代码],[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]luke: function (e) {[代码][代码] [代码][代码]this.setData({[代码][代码] [代码][代码]anshun: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]luke: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]timeout: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}, [代码][代码] [代码][代码]timeout: function (e) {[代码][代码] [代码][代码]this.setData({[代码][代码] [代码][代码]anshun: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]luke: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]timeout: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]onShow[代码][代码]:function[代码][代码](){[代码][代码] [代码][代码]// 初始化数据 从缓存中读取用户角色信息[代码][代码] [代码][代码]try{[代码][代码] [代码][代码]var info_data = wx.getStorageSync([代码][代码]'info_data'[代码][代码]);[代码][代码] [代码][代码]console.log(info_data)[代码][代码] [代码][代码]if[代码][代码](info_data){[代码][代码] [代码][代码]this.setData({[代码][代码] [代码][代码]info_data[代码][代码]:info_data[代码][代码],[代码][代码] [代码][代码]info_data_state[代码][代码]:true[代码][代码],[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码]else[代码][代码]{[代码][代码] [代码][代码]get_info_data(this);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}catch(e){}[代码][代码] [代码] [代码] [代码][代码]}[代码][代码]})[代码]错误提示 [代码]VM1303:[代码][代码]1[代码] [代码]TypeError: o.complete [代码][代码]is[代码] [代码]not a [代码][代码]function[代码][代码] [代码][代码]at http:[代码][代码]//127.0.0.1:64951/appservice/__dev__/WAService.js:7:29321[代码][代码] [代码][代码]at e.(anonymous [代码][代码]function[代码][代码]) (http:[代码][代码]//127.0.0.1:64951/appservice/__dev__/WAService.js:3:29569)[代码][代码] [代码][代码]at a (http:[代码][代码]//127.0.0.1:64951/appservice/appservice:1003:9451)[代码][代码] [代码][代码]at e.registerCallback (http:[代码][代码]//127.0.0.1:64951/appservice/appservice:1003:9638)[代码][代码] [代码][代码]at m.forEach (http:[代码][代码]//127.0.0.1:64951/appservice/appservice:1003:5612)[代码][代码] [代码][代码]at [代码][代码]Array[代码][代码].forEach ()[代码][代码] [代码][代码]at d (http:[代码][代码]//127.0.0.1:64951/appservice/appservice:1003:5592)[代码][代码] [代码][代码]at WebSocket.j.onmessage (http:[代码][代码]//127.0.0.1:64951/appservice/appservice:1003:5485)[代码][代码]console.error @ VM1303:[代码][代码]1[代码][代码]m.forEach @ VM1308 appservice:[代码][代码]1003[代码][代码]d @ VM1308 appservice:[代码][代码]1003[代码][代码]j.onmessage @ VM1308 appservice:[代码][代码]1003[代码]新手求解
2018-07-16