<%@ 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. JavaFX FileChooser文件选择器,缓存上一次打开的目录

    例1:点击按钮Choose File打开文件选择器,并打开指定的目录.这是通过final void setInitialDirectory(final File value)方法实现的. 1 impo ...

  2. K8S-kubeadm-集群证书续签

    ETCD证书 自签证书颁发机构(CA) ca.crt ca.key etcd集群中相互通信事业的客户端证书 peer.crt peer.key pod中定义Liveness探针事业的客户端证书 hea ...

  3. Fedora version history --- kernel version

    Fedora version history https://en.wikipedia.org/wiki/Fedora_version_history     Version (Code name)[ ...

  4. WPF开源控件扩展库 - MaterialDesignExtensions

    Material Design Extensions 在WPF开源控件库 Material Design in XAML Toolkit(本站介绍:链接)的基础上进行了控件扩展和特性新增.本开源项目中 ...

  5. 安装ipython

    安装ipython,首先系统上已安装python 在这里,我们已安装python3 在windows下: pip intsall ipython 在linux下: sudo apt install p ...

  6. 接口管理平台Yapi

    1.介绍 YApi 是由去哪儿移动架构组推出的一款开源项目,是高效.易用.功能强大的 api 管理平台,旨在为开发.产品.测试人员提供更优雅的接口管理服务. 官网:https://yapi.ymfe. ...

  7. Jquery中$("").事件()和$("").on("事件","指定的元素",function(){});的区别(jQuery动态绑定事件)

    这个是在学习时不懂的问题,记录下来方便查看 转至https://www.cnblogs.com/mr-wuxiansheng/p/7136864.html //绑定 下一页 的点击事件 $(" ...

  8. GDB常用调试命令(一)

    GDB是UNIX及UNIX-like下的调试工具,通常gdb使用前置条件:编译时加入debug信息,这里指的是C++. gcc/g++调试选项   gcc/g++是在编译时加入-g,-g分4个等级: ...

  9. Linux入门到放弃之六《磁盘和文件系统管理三》

    设置磁盘配额 对之前创建的逻辑卷设置磁盘配额,要求用户student对该逻辑卷 容量的软限制是:5G,硬限制是7G,文件个数软限制为:25个,硬限制为30个. (1)首先对/etc/fstab文件进行 ...

  10. 手把手教你搭建SVN服务

    参考一下地址 https://blog.csdn.net/marstonyjiang/article/details/52033916