2019-06-20
关注
                            
**域名回收专员5分钟前,TA获得超过2个赞
                            
                        代码如下:
| 
							 
								1 
							
								2 
							
								3 
							
								4 
							
								5 
							
								6 
							
								7 
							
								8 
							
								9 
							
								10 
							
								11 
							
								12 
							
								13 
							
								14 
							
								15 
							
								16 
							
								17 
							
								18 
							
								19 
							
								20 
							
								21 
							
								22 
						 | 
						
							var HOST = 'http://localhost/lendoo/public/index.php/';// 网站请求接口,统一为postfunction post(req) { //发起网络请求 wx.request({ url: HOST + req.uri,  data: req.param,  header: {   "content-type": "application/x-www-form-urlencoded" }, method: 'POST',  success: function (res) {  req.success(res.data) },  fail: function (res) {   console.log(res); } })}// 导出模块module.exports = { post: post} | 
					
然后前端调用就可以这样做了:
| 
							 
								1 
							
								2 
							
								3 
							
								4 
							
								5 
							
								6 
							
								7 
							
								8 
							
								9 
							
								10 
							
								11 
							
								12 
							
								13 
						 | 
						
							var http = require('../../utils/http.js');... http.post({   uri: http.orderListUri,   param: {   third_session: wx.getStorageSync('third_session')  },     success: function (data) {   that.setData({    orderList: data  });  } }); | 
					
一般对自己写的接口给自己用的时候,method方法或header都是约定好的,所以不用重复书写。
| 
							 
								1 
							
								2 
							
								3 
							
								4 
						 | 
						
							header: {   "content-type": "application/x-www-form-urlencoded"  },method: 'POST' | 
					
而fail回调方法也可以统一处理;进一步地,也可以对success回调里的针对code值进一步判断,特定错误码统一处理,比如跳转登录页面等。
经过上述处理,是不是变得简洁了?
已解决 1836 人的问题
                1、域名回收平台都回收哪些域名?
2、高价回收域名安全吗?
3、过期域名回收**吗?
4、阿里云域名回收步骤?
5、备案域名回收吗?