diff --git a/config/config.js b/config/config.js index 1f37a20..0090d97 100755 --- a/config/config.js +++ b/config/config.js @@ -1,52 +1,64 @@ var config = { name: "富茂", - url: "https://ciformall.youlane.cn/C/api", + url: "https://ciformall.youlane.cn/C", //url: "http://dac6735a.ngrok.io/C/api", api: { /** * 接口用途:login */ - login: '/user/login', + login: '/api/user/login', /** * 授权后获取用户的昵称,unionId等信息 */ - getUserInfo: '/user/getUserInfo', + getUserInfo: '/api/user/getUserInfo', /** * 接口用途:授权后获取用户的手机号 */ - getUserPhone: '/user/getUserPhone', + getUserPhone: '/api/user/getUserPhone', /** * 检查用户授权状态 */ - checkUserStatus: '/user/checkUserStatus', + checkUserStatus: '/api/user/checkUserStatus', /** * 优惠券查询 */ - couponList: '/wxCoupon/list', + couponList: '/api/wxCoupon/list', /** * 优惠券详情 */ - couponDetail: '/wxCoupon/findById', + couponDetail: '/api/wxCoupon/findById', /** * 业态查询 */ - couponChannelList: '/wxCouponChannel/list', + couponChannelList: '/api/wxCouponChannel/list', /** * 下订单 */ - orderSave: '/order/save', + orderSave: '/api/order/save', /** * 支付订单 */ - payOrderCreate: '/pay/create', + payOrderCreate: '/api/pay/create', /** * 订单状态更新 */ - payOrderUpdate: '/pay/updatePayOrder', + payOrderUpdate: '/api/pay/updatePayOrder', /** * 订单列表 */ - orderList: '/order/list', + orderList: '/api/order/list', + /** + * 券包 + */ + couponOrderList: '/api/couponOrder/list', + /** + * 验证码发送 + */ + sendValidationCode: '/wxMsgValidationcode/sendvalidationcode', + /** + * 验证码确认 + */ + validationCode: '/wxMsgValidationcode/hasvalidationcode', }, weapp: { diff --git a/pages/coupons/index/index.js b/pages/coupons/index/index.js index cbe946a..6b55ba3 100644 --- a/pages/coupons/index/index.js +++ b/pages/coupons/index/index.js @@ -1,7 +1,6 @@ -let Http = require('../../../utils/http.js') let format = require('../../../utils/util.js') let app = getApp() - +const Http = require("../../../utils/HttpBasics") //1535126400000 Page({ data: { @@ -30,18 +29,24 @@ Page({ this.getList(0) }, getList(key) { - Http.getResquest('/api/couponOrder/list', app.globalData.token, '加载中', { - pageNum: 1, - pageSize: 10, - orderStatus: key - }, (res) => { + Http.get({ + url: config.api.couponOrderList, + data: { + pageNum: 1, + pageSize: 10, + orderStatus: key + } + }) + .then(function(res) { + console.log(res) res.data.list.map(file => { file.expiredTime = format.formatTime(file.expiredTime, 'yyyy-MM-dddd hh:mm:ss') }) this.setData({ list: res.data.list }) - console.log(res) + },function(error){ + }) }, handleChange({ diff --git a/pages/getphoneInfo/phoneinput/phoneinput.js b/pages/getphoneInfo/phoneinput/phoneinput.js index 1dbf6aa..ebcc9d6 100644 --- a/pages/getphoneInfo/phoneinput/phoneinput.js +++ b/pages/getphoneInfo/phoneinput/phoneinput.js @@ -1,5 +1,6 @@ // pages/forgetpwd/forgetpwd.js -const Http = require('../../../utils/http.js') +let config = require('../../../config/config.js') +let Http = require('../../../utils/HttpBasics') const app = getApp() Page({ @@ -18,23 +19,22 @@ Page({ }, next() { console.log(this.data.yzm) - Http.getResquest('/wxMsgValidationcode/hasvalidationcode', '', '加载中', { - phone: this.data.phone, - code: this.data.yzm, - type: 1, - appid: app.globalData.appId - }, (res) => { - console.log(res) - if (res.code == 200) { - //wx.navigateTo({ - // url: `../setpwd/setpwd?phone=${this.data.phone}&code=${this.data.yzm}` - //}) - } else { - wx.showToast({ - title: res.res, - }) + Http.get({ + url: config.api.validationCode, + data: { + phone: this.data.phone, + code: this.data.yzm, + type: 1, + appid: app.globalData.appId } }) + .then(function(res){ + + },function(error){ + wx.showToast({ + title: error.data, + }) + }) }, send() { var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/; @@ -43,30 +43,35 @@ Page({ flag: false, retry: true }) - Http.getResquest('/wxMsgValidationcode/sendvalidationcode', '', '加载中', { - phone: this.data.phone, - type: 1, - appid: app.globalData.appId - }, (res) => { + Http.get({ + url: config.api.validationCode, + data: { + phone: this.data.phone, + code: this.data.yzm, + type: 1, + appid: app.globalData.appId + } + }) + .then(function(res){ console.log(res) var timer = setInterval(() => { this.data.time-- - this.setData({ - time: this.data.time - }) + this.setData({ + time: this.data.time + }) if (this.data.time == 0) { clearInterval(timer) this.setData({ flag: true, retry: false, - time:60 + time: 60 }) } }, 1000) - }) - } else { - wx.showToast({ - title: '请输入有效手机号', + }, function(error){ + wx.showToast({ + title: '请输入有效手机号', + }) }) } } diff --git a/pages/index/rushToBuy/index.js b/pages/index/rushToBuy/index.js index 7765654..c232313 100644 --- a/pages/index/rushToBuy/index.js +++ b/pages/index/rushToBuy/index.js @@ -53,14 +53,15 @@ Component({ }, ready() { Http.get({ - url: config.api.couponChannelList, data: { + url: config.api.couponChannelList, + data: { pageNum: 1, pageSize: 10 } - }).then(res=>{ + }).then(res => { this.setData({ list: res.list }) }) } -}) +}) \ No newline at end of file diff --git a/pages/order/index/index.js b/pages/order/index/index.js index a2be8eb..46fc481 100644 --- a/pages/order/index/index.js +++ b/pages/order/index/index.js @@ -21,26 +21,26 @@ Page({ current_scroll: '1' }, onLoad(e) { - this.getList(e.id) + this.getList(e.id, 1) this.setData({ current_scroll: e.id }); }, - getList(key) { + getList(key, pageNum) { wx.showLoading({ title: 'loading...', }) Http.get({ - url: '/api/order/list', + url: config.api.orderList, data: { - pageNum: 1, - pageSize: 10, + pageNum: pageNum, + pageSize: 3, orderStatus: key } }).then((res) => { wx.hideLoading(); this.setData({ - list: res.list + list: res.data.list }) }) }, @@ -50,7 +50,7 @@ Page({ }); }, handleChangeScroll({ detail }) { - this.getList(detail.key) + this.getList(detail.key, 1) this.setData({ current_scroll: detail.key }); diff --git a/utils/http.js b/utils/http.js deleted file mode 100644 index cdf3067..0000000 --- a/utils/http.js +++ /dev/null @@ -1,70 +0,0 @@ -let host = 'https://ciformall.youlane.cn/C' - -const postResquest = (url, token, message, postData, doSuccess, doFail) => { - let body = { ...postData }; - if (message != "") { - wx.showLoading({ - title: message, - }) - } - wx.request({ - //项目的真正接口,通过字符串拼接方式实现 - url: host + url, - header: { - "content-type": "application/json;charset=UTF-8", - "token": token - }, - data: body, - method: 'POST', - success: function (res) { - //参数值为res.data,直接将返回的数据传入 - if (message != "") { - wx.hideLoading() - }; - doSuccess(res.data); - }, - fail: function (res) { - if (message != "") { - wx.hideLoading() - }; - wx.showToast({ - title: '网络错误', - }) - }, - }) -} -const getResquest = (url, token, message, getData, doSuccess, doFail) => { - let body = { ...getData }; - if (message != "") { - wx.showLoading({ - title: message, - }) - } - wx.request({ - url: host + url, - header: { - "content-type": "application/json;charset=UTF-8", - "token": token - }, - data: body, - method: 'GET', - success: function (res) { - if (message != "") { - wx.hideLoading() - }; - doSuccess(res.data); - }, - fail: function (res) { - if (message != "") { - wx.hideLoading() - }; - wx.showToast({ - title: '网络错误', - }) - }, - }) -} -module.exports = { - postResquest: postResquest, - getResquest: getResquest -} \ No newline at end of file