(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["pages-API-request-request"],{3347:function(t,e,n){"use strict";var r=n("ee27");Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var a=r(n("d0af"));n("96cf");var i=r(n("c964")),o="https://unidemo.dcloud.net.cn/ajax/echo/text?name=uni-app",u=2e3,s={data:function(){return{title:"request",loading:!1,res:""}},methods:{sendRequest:function(t){switch(this.loading=!0,t){case"promise":this._requestPromise();break;case"await":this._requestAwait();break;default:this._request();break}},_request:function(){var t=this;uni.request({url:o,dataType:"text",data:{noncestr:Date.now()},success:function(e){console.log("request success",e),uni.showToast({title:"请求成功",icon:"success",mask:!0,duration:u}),t.res="请求结果 : "+JSON.stringify(e)},fail:function(t){console.log("request fail",t),uni.showModal({content:t.errMsg,showCancel:!1})},complete:function(){t.loading=!1}})},_requestPromise:function(){var t=this;uni.request({url:o,dataType:"text",data:{noncestr:Date.now()}}).then((function(e){console.log("request success",e[1]),uni.showToast({title:"请求成功",icon:"success",mask:!0,duration:u}),t.res="请求结果 : "+JSON.stringify(e[1]),t.loading=!1})).catch((function(e){console.log("request fail",e),uni.showModal({content:e.errMsg,showCancel:!1}),t.loading=!1}))},_requestAwait:function(){var t=this;return(0,i.default)(regeneratorRuntime.mark((function e(){var n,r,i,s;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,uni.request({url:o,dataType:"text",data:{noncestr:Date.now()}});case 2:n=e.sent,r=(0,a.default)(n,2),i=r[0],s=r[1],i?(console.log("request fail",i),uni.showModal({content:i.errMsg,showCancel:!1})):(console.log("request success",s),uni.showToast({title:"请求成功",icon:"success",mask:!0,duration:u}),t.res="请求结果 : "+JSON.stringify(s)),t.loading=!1;case 8:case"end":return e.stop()}}),e)})))()}}};e.default=s},"7f64":function(t,e,n){"use strict";var r,a=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("v-uni-view",[n("page-head",{attrs:{title:t.title}}),n("v-uni-view",{staticClass:"uni-padding-wrap uni-common-mt"},[n("v-uni-view",{staticClass:"uni-hello-text"},[t._v("请点击按钮向服务器发起请求")]),n("v-uni-view",{staticClass:"uni-textarea uni-common-mt"},[n("v-uni-textarea",{attrs:{value:t.res}})],1),n("v-uni-view",{staticClass:"uni-btn-v uni-common-mt"},[n("v-uni-button",{attrs:{type:"primary",loading:t.loading},on:{click:function(e){arguments[0]=e=t.$handleEvent(e),t.sendRequest.apply(void 0,arguments)}}},[t._v("发起请求（Callback）")]),n("v-uni-button",{attrs:{type:"primary",loading:t.loading},on:{click:function(e){arguments[0]=e=t.$handleEvent(e),t.sendRequest("promise")}}},[t._v("发起请求（Promise）")]),n("v-uni-button",{attrs:{type:"primary",loading:t.loading},on:{click:function(e){arguments[0]=e=t.$handleEvent(e),t.sendRequest("await")}}},[t._v("发起请求（Async/Await）")])],1)],1)],1)},i=[];n.d(e,"b",(function(){return a})),n.d(e,"c",(function(){return i})),n.d(e,"a",(function(){return r}))},"9cce":function(t,e,n){"use strict";n.r(e);var r=n("3347"),a=n.n(r);for(var i in r)"default"!==i&&function(t){n.d(e,t,(function(){return r[t]}))}(i);e["default"]=a.a},d0af:function(t,e,n){"use strict";function r(t){if(Array.isArray(t))return t}n.r(e);n("a4d3"),n("e01a"),n("d28b"),n("e260"),n("d3b7"),n("3ca3"),n("ddb0");function a(t,e){if("undefined"!==typeof Symbol&&Symbol.iterator in Object(t)){var n=[],r=!0,a=!1,i=void 0;try{for(var o,u=t[Symbol.iterator]();!(r=(o=u.next()).done);r=!0)if(n.push(o.value),e&&n.length===e)break}catch(s){a=!0,i=s}finally{try{r||null==u["return"]||u["return"]()}finally{if(a)throw i}}return n}}n("a630"),n("fb6a"),n("25f0");function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function o(t,e){if(t){if("string"===typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}function u(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(t,e){return r(t)||a(t,e)||o(t,e)||u()}n.d(e,"default",(function(){return s}))},e718:function(t,e,n){"use strict";n.r(e);var r=n("7f64"),a=n("9cce");for(var i in a)"default"!==i&&function(t){n.d(e,t,(function(){return a[t]}))}(i);var o,u=n("f0c5"),s=Object(u["a"])(a["default"],r["b"],r["c"],!1,null,null,null,!1,r["a"],o);e["default"]=s.exports}}]);