• 微信小程序开发POST请求


    微信小程序开发POST请求

    wx.request( {  
          url: "http://op.juhe.cn/onebox/weather/query",  
          header: {  
            "Content-Type": "application/x-www-form-urlencoded"  
          },  
          method: "POST",  
         //data: { cityname: "上海", key: "de" },  
          data: Util.json2Form( { cityname: "上海", key: "fddf" }),  
          complete: function( res ) {  
          }
    })
    
    微信小程序示例
    
    wx.request({
      url: 'test.php', //仅为示例,并非真实的接口地址
      data: {
            x: '' , 
            y: ''
       }, 
      header: { 
        'content-type': 'application/json' 
      }, 
      success: function(res) { 
        console.log(res.data) 
      }
    })
    
    method: 'POST',
        header:{
          'content-type':'application/x-www-form-urlencoded'
        },
    
    onLoad: function() { 
      that = this; 
      wx.request( { 
       url: "url", 
       header: { 
        "Content-Type": "application/x-www-form-urlencoded" 
       }, 
       method: "POST", 
       data: {}, 
       complete: function( res ) { 
        console.log(res.data)
        }); 
        if( res == null || res.data == null ) { 
         console.error( '网络请求失败' ); 
         return; 
        } 
       } 
      }) 
     }, 
    
    data: Util.json2Form( { cityname: "北京", key: "1430ec127e097e1113259c5e1be1ba70" }), 
    
    header: {"Content-Type":"application/x-www-form-urlencoded"},
    
    wx.request({
          url : "https://www.",
          method: "POST",
          data: {
            answer : JSON.stringify(this.data.answer),
            pjid : this.data.pj.pjid,
            testpaperid : this.data.pj.testpaperid,
            student : JSON.stringify(this.data.student),
            message : this.data.message
          },
          header: {
            "Content-Type": "application/x-www-form-urlencoded"
          },
          success: function (res) {
            console.log(res.data);
            wx.navigateBack({
              delta: 1  //小程序关闭当前页面返回上一页面
            })
          },
        })
    

    在这里插入图片描述

    <!--pages/anquan/anquan.wxml-->
    <view class='bg'>
      <view class='item'>
        身份认证
        <view class='bk'>
          <!-- <textarea class="textarea" placeholder='身份认证' auto-height value='{{detailanquan.idCard}}' maxlength='10'></textarea> -->
          <input name='idCard' class="textarea" placeholder="{{detailanquan.idCard}}" value='{{detailanquan.idCard}}' bindinput="idCard" maxlength='15' auto-height/>
    
        </view>
        <button class='btn' bindtap='sfrz'>修改</button>
      </view>
      <view class="line"></view>
    
      <view class='item'>
        登录密码
        <view class='bk'>
          <!-- <textarea class="textarea" placeholder='登录密码' auto-height value='{{anquan.password}}' maxlength='100'></textarea> -->
          <input name='password' class="textarea" placeholder="{{anquan.password}}" value='{{anquan.password}}' bindinput="password" maxlength='100' auto-height/>
    
        </view>
        <button class='btn' bindtap='dlmm'>修改</button>
      </view>
      <view class="line"></view>
    
      <view class='item'>
        绑定手机
        <view class='bk'>
          <!-- <textarea class="textarea" placeholder='绑定手机' auto-height value='{{anquan.phone}}' maxlength='15'></textarea> -->
          <input name='phone' class="textarea" placeholder="{{anquan.phone}}" value='{{anquan.phone}}' bindinput="phone" maxlength='15' auto-height/>
    
        </view>
        <button class='btn' bindtap='bdsj'>设置</button>
      </view>
      <view class="line"></view>
    
      <view class='item'>
        绑定邮箱
        <view class='bk'>
          <!-- <textarea class="textarea" placeholder='绑定邮箱' auto-height value='{{anquan.email}}' maxlength='30'></textarea> -->
          <input name='email' class="textarea" placeholder="{{anquan.email}}" value='{{anquan.email}}' bindinput="email" maxlength='30' auto-height/>
    
        </view>
        <button class='btn' bindtap='bdyx'>修改</button>
      </view>
      <view class="line"></view>
    
      <view class='item'>
        微信绑定
        <view class='bk'>
          <!-- <textarea class="textarea" placeholder='微信绑定' auto-height value='{{anquan.wxUnionid}}' maxlength='100'></textarea> -->
          <input name='wxUnionid' class="textarea" placeholder="{{anquan.wxUnionid}}" value='{{anquan.wxUnionid}}' bindinput="wxUnionid" maxlength='100' auto-height/>
    
        </view>
        <button class='btn' bindtap='wxbd'>修改</button>
      </view>
      <view class="line"></view>
    </view>
    

    在这里插入图片描述

    <view class='bg'>
      <view class='item'>
        当前头像:
        <open-data type="userAvatarUrl" class='img'></open-data>
      </view>
    
      <form bindsubmit="formSubmit" bindreset="formReset">
        <view class='item'>
          
    
    
    
    
    
    
    昵称:
          <view class='bk'>
            <!-- <textarea class="textarea" placeholder='昵称' auto-height value='{{geren.nickname}}' maxlength='15'></textarea> -->
            <input name='nickname' class="textarea" placeholder="{{geren.nickname}}" value='{{geren.nickname}}' bindinput="nickname" maxlength='15' auto-height/>
          </view>
        </view>
    
        <view class='item'>
          真实姓名:
          <view class='bk'>
            <!-- <textarea class="textarea" placeholder='真实姓名' auto-height value='{{geren.sysUserDetail.realName}}' maxlength='10'></textarea> -->
            <input name='realName' class="textarea" placeholder="{{detailgeren.realName}}" value='{{detailgeren.realName}}' bindinput="realName" maxlength='15' auto-height/>
    
          </view>
        </view>
    
        <view class='item'>
          
    
    
    
    
    
    
    性别:
          <radio-group class="radio-group" bindchange="radioChange" name='gender'>
    
            <!-- <label class="radio" wx:for="{{items}}"> -->
            <label class='radio'>
              <!-- checked="{{item.checked}}" -->
              <radio value="{{items[0].name}}" checked='{{boy}}' /> {{items[0].value}}
              <radio value="{{items[1].name}}" checked='{{gril}}' /> {{items[1].value}}
            </label>
    
          </radio-group>
        </view>
    
        <view class='item'>
          
    
    
    
    
    
    
    生日:
          <view class='bk'>
            <view class='time'>
              <picker mode="date" value="{{date}}" start="1800-01-01" end="2222-01-01" bindchange="changeDate" name="birthday">
                <view>
                  {{date}}
                </view>
              </picker>
            </view>
          </view>
        </view>
    
        <view class='item'>
          
    
    
    
    居住地:
          <view class='bk'>
            <!-- <textarea class="textarea" placeholder='居住地' auto-height value='{{geren.sysUserDetail.address}}' maxlength='10'></textarea> -->
            <view>
              <picker bindchange="changeRegin" mode="region" value="{{region}}">
    
                <!-- <view class="tui-picker-detail">{{region[0]}} - {{region[1]}} - {{region[2]}}</view> -->
                <view>{{region[0]}} - {{region[1]}} - {{region[2]}}</view>
              </picker>
            </view>
          </view>
          <view>
            <input name="address" style="display: none;" value="{{region}}" />
          </view>
        </view>
    
        <view class='item'>
          详细地址:
          <view class='bk'>
            <!-- <textarea class="textarea" placeholder='详细地址' auto-height value='{{geren.sysUserDetail.detailAddress}}' maxlength='100'></textarea> -->
            <input name="detailAddress" class="textarea" placeholder="{{detailgeren.detailAddress}}" value='{{detailgeren.detailAddress}}' bindinput="detailAddress" maxlength='100' auto-height/>
    
          </view>
        </view>
    
        <!-- <button class='btn' bindtap='baocun'>保存</button> -->
        <view class='anniu'>
          <button class='btn' formType="submit">保存</button>
          <!-- <button class='btn' formType="reset">重置</button> -->
        </view>
    
      </form>
    </view>
    
  • 相关阅读:
    Java虚拟机一览表
    Java程序员的10道XML面试题
    bzoj 1644: [Usaco2007 Oct]Obstacle Course 障碍训练课【spfa】
    bzoj 1703: [Usaco2007 Mar]Ranking the Cows 奶牛排名【bitset+Floyd传递闭包】
    bzoj 1664: [Usaco2006 Open]County Fair Events 参加节日庆祝【dp+树状数组】
    bzoj 2100: [Usaco2010 Dec]Apple Delivery【spfa】
    bzoj 2015: [Usaco2010 Feb]Chocolate Giving【spfa】
    bzoj 1741: [Usaco2005 nov]Asteroids 穿越小行星群【最大点覆盖】
    bzoj 1645: [Usaco2007 Open]City Horizon 城市地平线【线段树+hash】
    bzoj 2060: [Usaco2010 Nov]Visiting Cows 拜访奶牛【树形dp】
  • 原文地址:https://www.cnblogs.com/dashucoding/p/9996881.html
Copyright © 2020-2023  润新知