zoukankan      html  css  js  c++  java
  • 微信小程序获取请求数据

    <%@ 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
        })
      }
    })
  • 相关阅读:
    Linux04 目录的相关操作(mkdir、rmdir、rm、cp)
    【PDARTS】2019-ICCV-Progressive Differentiable Architecture Search Bridging the Depth Gap Between Search and Evaluation-论文阅读
    【NAS with RL】2017-ICLR-Neural Architecture Search with Reinforcement Learning-论文阅读
    智能手机娱乐时代的反思——《娱乐至死》读书笔记
    人必活着,爱才能有所附丽——《玩偶之家》读书笔记
    Brute Force暴力破解
    学生信息管理系统.cpp(大二上)
    通讯录管理系统(大一上)
    如何在Unity中画抛物线
    Unity2.5D Sprite层级显示遮挡问题处理
  • 原文地址:https://www.cnblogs.com/mengluo/p/7929271.html
Copyright © 2011-2022 走看看