12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import { _decorator, Component, Node } from 'cc';
- const { ccclass, property } = _decorator;
- @ccclass('http')
- export class http {
- static login(){
- var xml = new XMLHttpRequest()
- xml.open('POST',"http://120.79.128.142:9502/api/v1/login")
- xml.setRequestHeader('Content-Type','text/plain');
- xml.send("{“token”:””,”wx_openid”:””,”wx_name”:””,”wx_avatar”:””,”ios_openid”:””,”account”:”13412598083”,”verify_code”:”1234”}")
-
-
- var array:String[] = ['loadstart','abort', 'error', 'load', 'loadend', 'timeout'];
- array.forEach(function (eventName) {
- xml[('on' + eventName) as 'onloadstart' | 'onabort' | 'onerror' | 'onload' | 'onloadend' | 'ontimeout'] = function () {
- var str = '\nEvent : ' + eventName;
- var lstr = ""
- if (eventName === 'timeout') {
- lstr += '(timeout)';
- }
- else if (eventName === 'loadend') {
- lstr += '...loadend!';
- }
- console.log("str==",str)
- console.log("lstr==",lstr)
- };
- });
- // Special event
- xml.onreadystatechange = function () {
- if (xml.readyState === 4 && xml.status >= 200) {
- //label.string = handler(xml.responseText);
- console.log("xml.responseText==",xml.responseText)
- } else if (xml.status === 404) {
- console.log("status ==",'404 page not found!')
- } else if (xml.readyState === 3) {
- console.log("status ==",'Request dealing!')
- } else if (xml.readyState === 2) {
- console.log("status ==", 'Request received!')
- } else if (xml.readyState === 1) {
- console.log("status ==", 'Server connection established! Request hasn\'t been received')
- } else if (xml.readyState === 0) {
- console.log("status ==", 'Request hasn\'t been initiated!')
- }
- };
- }
- }
|