<%@ WebHandler Language="C#" Class="CodeTest" %>

using System;
using System.Web;
using LitJson; public class CodeTest : IHttpHandler { public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
//获取webservice的数据
WebReference.Service1 wx = new WebReference.Service1();
string code = context.Request.Params["codes"];
WebReference.ProductInfo sd = wx.GetProductInfo(code);
JsonData data = new JsonData();
data["product_name"] = sd.Product_Name;
data["product_spec"] = sd.Product_Spec;
context.Response.Write(data.ToJson()); } public bool IsReusable {
get {
return false;
}
} }

  

//index.js
//获取应用实例
const app = getApp() Page({
data: {
motto: 'Hello World',
flag: 'false',
userInfo: {},
showView: true,
animation: '',
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
name:'',
spec:''
},
ClickHongbao: function () {
var animation = wx.createAnimation({
duration: 1000,
delay: 0,
transformOrigin: "50% 50%",
timingFunction: "linear"
}) this.animation = animation animation.translate(50, 0).step() this.setData({
animationData: animation.export()
}) setTimeout(function () {
animation.translate(0, 0).step()
this.setData({
animationData: animation.export()
})
var that = this;
that.setData({
showView: (!that.data.showView) }),
this.setData({
flag: (!that.data.flag)
}) }.bind(this), 100) },
closes: function () {
var that = this;
this.setData({
flag: (!that.data.flag)
}), that.setData({
showView: (!that.data.showView) })
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad: function () {
var that=this
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse){
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
} wx.request({
url: 'https://t.risingtec.cn/CodeTest.ashx',
data:{
codes:'9410887704315070'
},
header:{
"Content-Type": "application/x-www-form-urlencoded"
},
method:"POST",
success:function(res){
console.log(res);
that.setData({
name:res.data.product_name,
spec: res.data.product_spec
})
} })
},
getUserInfo: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})

微信小程序获取请求数据的更多相关文章

  1. 关于微信小程序post请求数据的坑

    在post请求数据的时候,发现数据没有发送给后台,需要在请求头里加"Content-Type": "application/x-www-form-urlencoded&q ...

  2. 微信小程序POST请求参数传递不到后台, 前台获取不到后端返回的数据, 以及 post 请求返回 404 但后台能收到数据

    1 微信小程序POST请求参数传递不到后台 需要在微信请求 wx.request 改变默认 header 配置为如下 wx.request({ url: 'test.php', //仅为示例,并非真实 ...

  3. 微信小程序的ajax数据请求wx.request

    微信小程序的ajax数据请求,很多同学找不到api在哪个位置,这里单独把小程序的ajax请求给列出来,微信小程序的请求就是wx.request这个api,wx.request(一些对象参数),微信小程 ...

  4. [微信小程序] 微信小程序获取用户定位信息并加载对应城市信息,wx.getLocation,腾讯地图小程序api,微信小程序经纬度逆解析地理信息

    因为需要在小程序加个定位并加载对应城市信息 然而小程序自带api目前只能获取经纬度不能逆解析,虽然自己解析方式,但是同时也要调用地图,难道用户每次进小程序还要强行打开地图选择地址才定位吗?多麻烦也不利 ...

  5. C# 微信小程序获取openid sessionkey

    项目介绍 1.微信小程序获取openid和session_key 2.后台使用C#开发 项目流程 准备工作 1 获取appid 1.1 下载微信web开发工具 https://developers.w ...

  6. .Net之微信小程序获取用户UnionID

    前言: 在实际项目开发中我们经常会遇到账号统一的问题,如何在不同端或者是不同的登录方式下保证同一个会员或者用户账号唯一(便于用户信息的管理).这段时间就有一个这样的需求,之前有个客户做了一个微信小程序 ...

  7. 微信小程序获取手机号码看这篇文章就够了

    前言 微信小程序获取手机号码,从官方文档到其他博主的文档 零零散散的 (我就是这样看过来 没有一篇满意的 也许是我搜索姿势不对) 依旧是前人栽树 后人乘凉 系列.保证看完 就可以实现获取手机号码功能 ...

  8. 微信小程序-获取当前位置和城市名

    微信小程序-获取当前城市位置 1, 获取当前地理位置,首先要拿到用户的授权wx.openSetting: 2,微信的getLocation接口,获取当前用户的地理位置(微信返回的是经纬度,速度等参数) ...

  9. 微信小程序 网络请求之re.request 和那些坑

    微信小程序有四种网络请求类型,下面只详细介绍普通HTTPS请求(wx.request) 普通HTTPS请求(wx.request) 上传文件(wx.uploadFile) 下载文件(wx.downlo ...

随机推荐

  1. 【题解】[ZJOI2009]狼和羊的故事

    题目戳我 \(\text{Solution:}\) 显然思路,把所有羊看成一个源点,所有狼看成一个汇点,格子之间连容量为\(1\)的边,直接跑最小割. 技巧: 注意到篱笆不能把羊给割掉,狼同理.所以, ...

  2. shell-变量的数值运算let内置命令

    1. let命令的用法 格式: let 赋值表达式 [注]let赋值表达式功能等同于:((赋值表达式))  范例1:给自变量i加8 [root@1-241 scripts]# i=2 [root@1- ...

  3. 2017年 实验四 B2C模拟实验

    实验四 B2C模拟实验                [实验目的] 掌握网上购物的基本流程和B2C平台的运营 [实验条件] ⑴.个人计算机一台 ⑵.计算机通过局域网形式接入互联网. (3).奥派电子商 ...

  4. 多测师讲解jmeter _接口请求_(003)高级讲师肖sir

    1.简单接口的请求 2. 3. 正则查看: 正则提取:在后置处理器中正则请求 设置:正则表达式 JSESSIONID提取器: Debug  sampler 总结:

  5. vs code 编译python 输出到调试控制台

    如图所示,在debug菜单中点击齿轮按钮,进入launch.json,更改console选项的值(有三种) "console": "internalConsole&quo ...

  6. IDEA 简拼输入

    1. sout = System.out.println(); 2. soutp = System.out.println(""); 3. soutv = System.out.p ...

  7. rs232转网络

    rs232转网络 rs232转网络ZLAN5103可以实现RS232/485/422和TCP/IP之间进行透明数据转发.方便地使得串口设备连接到以太网和Internet,实现串口设备的网络化升级.支持 ...

  8. C++ concurrent_queue

    ConcurrentQueue 用C++11提供的多线程类实现一个线程安全的队列: #include <queue> #include <mutex> #include < ...

  9. Python自动化准备工作(pycharm安装)

    一.安装Python 1.下载python-3.7.0-amd64.exe后双击 2.勾选Add Python3.7 to PATH可不用配置环境变量 3.点击下一步,可以按默认路径,也可以自己选择路 ...

  10. 【Azure Redis 缓存 Azure Cache For Redis】当使用Jedis客户端连接Redis时候,遇见JedisConnectionException: Could not get a resource from the pool / Redis connection lost

    问题情形 当在执行Redis一直指令时,有可能会遇见如下几种错误: 1) redis.clients.jedis.exceptions.JedisConnectionException: Could ...