123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- const api_url = 'https://sqtg.hdlkeji.com' //社区团购
- var requestHandler = {
- url: "",
- params: {},
- success: function(res) {
- },
- fail: function() {
- }
- }
- //GET
- function GET(requestHandler) {
- request('GET', requestHandler)
- }
- //POST
- function POST(requestHandler) {
- request_post('POST', requestHandler)
- }
- function request(method, requestHandler) {
- var params = requestHandler.params;
- var url = requestHandler.url;
- wx.request({
- url: api_url + url,
- data: params,
- method: method,
- header: {
- 'Content-Type': 'application/json' // 默认值
- },
- success: function(res) {
- requestHandler.success(res)
- },
- fail: function() {
- requestHandler.fail();
- }
- })
- }
- function request_post(method, requestHandler) {
- var params = requestHandler.params;
- var url = requestHandler.url
- var distanceType = requestHandler.distance;
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.request({
- url: api_url + url,
- data: params,
- method: method,
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- success: function (res) {
- wx.hideLoading();
- requestHandler.success(res)
- },
- fail: function() {
- requestHandler.fail();
- }
- })
- }
- module.exports = {
- GET: GET,
- POST: POST,
- drawTextVertical: drawTextVertical
- }
|