<%@ 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. 【题解】NOIP2018 填数游戏

    题目戳我 \(\text{Solution:}\) 题目标签是\(dp,\)但是纯暴力打表找规律可以有\(65\)分. 首先是对于\(O(2^{nm}*nm)\)的暴力搜索,显然都会. 考虑几条性质: ...

  2. Python基础笔记1-Python读写yaml文件(使用PyYAML库)

    最近在搭建自动化测试项目过程中经常遇到yaml文件的读写,为了方便后续使用,决定记下笔记. 一,YAML 简介 YAML,Yet Another Markup Language的简写,通常用来编写项目 ...

  3. 快速掌握ES6语法

    常量变量 let and const 先说说常量和变量的概念吧, 常量是说那种进行一次赋值后不会更改的值,比如说游戏账户的 ID, 变量是说赋值后有更改的需求的,比如游戏名,游戏密码. 在之前的 Ja ...

  4. go xpath

    package main import ( "fmt" "github.com/antchfx/htmlquery" "net/http" ...

  5. Centos定时备份 MySQL数据库

    一.编写数据库备份脚本 backupmysql.sh #!/bin/bash # Name:bakmysql.sh # This is a ShellScript For Auto DB Backup ...

  6. BERT模型详解

    1 简介 BERT全称Bidirectional Enoceder Representations from Transformers,即双向的Transformers的Encoder.是谷歌于201 ...

  7. Linux文件系统和管理-1文件系统目录

    文件系统目录结构 Linux常见目录及用途 bin binary 放的是二进制程序 /usr/bin 和这是同一回事 bin -> usr/bin /bin是 /usr/bin的快捷方式 boo ...

  8. c# 误区系列(二)

    前言 继续整理误区系列,可能会对刚入门的新手有些帮助,然后希望有错误的地方可以指出. 正文 关于泛型方法的确定 class Person<T> { public void add(T a) ...

  9. servlet 验证生命周期过程调用方法的次数

    1.书写一个servlet并编译,如: package testservlet; import java.io.IOException;import java.io.PrintWriter; impo ...

  10. centos7 添加环境变量

    修改/etc/profile文件使其永久性生效,并对所有系统用户生效 PATH=$PATH:/usr/local/php/bin export PATH source /etc/profile