diff --git a/app.js b/app.js
index 9467b93..14ce3f7 100644
--- a/app.js
+++ b/app.js
@@ -32,6 +32,35 @@ App({
}
},
+ request: function(obj) {
+ var header = obj.header || {}
+ if (!header['content-type']) {
+ header['content-type'] = 'application/json'
+ }
+ if (!header['Authorization']) {
+ header['Authorization'] = getApp().globalData.token
+ }
+
+ wx.request({
+ url: obj.url,
+ data: obj.data || {},
+ method: obj.method || 'GET',
+ header: header,
+ success: function(res) {
+ if (res.statusCode === 401) {
+
+ }
+ typeof obj.success == "function" && obj.success(res)
+ },
+ fail: obj.fail || function() {},
+ complete: obj.complete || function() {}
+ })
+ },
+
+ authRequest: function(obj) {
+ function unauthorizeCallback() {}
+ },
+
globalData:{
userInfo: null,
currentCustomer: null,
diff --git a/pages/cart/cart.wxml b/pages/cart/cart.wxml
index c954eca..10a5101 100644
--- a/pages/cart/cart.wxml
+++ b/pages/cart/cart.wxml
@@ -16,7 +16,7 @@
-
+
使用优惠券
diff --git a/pages/cart/cart.wxss b/pages/cart/cart.wxss
index cd431ed..5c20ab7 100644
--- a/pages/cart/cart.wxss
+++ b/pages/cart/cart.wxss
@@ -24,6 +24,7 @@
.item {
height: 180rpx;
padding: 15rpx;
+ padding-left: 10rpx;
background-color: #fff;
border-bottom: 1px solid #e4e4e4;
color: #333;
@@ -115,4 +116,10 @@
.separate {
height: 18rpx;
background-color: #f2f2f2;
+}
+
+.use-coupon {
+ font-size: 30rpx;
+ line-height: 55rpx;
+ margin-left: 15rpx;
}
\ No newline at end of file
diff --git a/pages/cart/coupon.js b/pages/cart/coupon.js
index 9c49649..12791c8 100644
--- a/pages/cart/coupon.js
+++ b/pages/cart/coupon.js
@@ -17,19 +17,12 @@ Page({
// var data = wx.getStorageSync('coupons')
// this.setData({coupons: data})
var that = this
- var data = {}
- data['token'] = app.globalData.token
- wx.request({
+ app.request({
url: `${app.globalData.API_URL}/coupons`,
- data: data,
method: 'GET',
success: function(res){
var data = app.store.sync(res.data)
that.setData({coupons: data})
- },
- fail: function() {
- },
- complete: function() {
}
})
}
diff --git a/utils/address.js b/utils/address.js
index 85accc7..f4e6a8e 100644
--- a/utils/address.js
+++ b/utils/address.js
@@ -1,7 +1,7 @@
const app = getApp()
function postAddress (data) {
- wx.request({
+ app.request({
method: 'POST',
url: `${app.globalData.API_URL}/addresses/new`,
data: Object.assign({}, data),
diff --git a/utils/order.js b/utils/order.js
index d87dd31..b532bfa 100644
--- a/utils/order.js
+++ b/utils/order.js
@@ -1,11 +1,10 @@
const app = getApp()
function postBilling (data, resolve) {
- data['token'] = app.globalData.token
- wx.request({
+ app.request({
method: 'POST',
url: `${app.globalData.API_URL}/orders/create_applet_order`,
- data: data,
+ data: data || {},
header: { 'Content-Type': 'application/json'},
success: resolve,
fail: function(){}
diff --git a/utils/product.js b/utils/product.js
index ef87b41..0c47f65 100644
--- a/utils/product.js
+++ b/utils/product.js
@@ -1,7 +1,7 @@
const app = getApp()
function getProducts (resolve) {
- wx.request({
+ app.request({
url: `${app.globalData.API_URL}/products`,
header: { 'Content-Type': 'application/json' },
success: resolve,
@@ -10,7 +10,7 @@ function getProducts (resolve) {
}
function getSlides (resolve) {
- wx.request({
+ app.request({
url: `${app.globalData.API_URL}/home_slides`,
header: { 'Content-Type': 'application/json' },
success: resolve,
@@ -19,7 +19,7 @@ function getSlides (resolve) {
}
function getCategories (data, resolve, reject) {
- wx.request({
+ app.request({
url: `${app.globalData.API_URL}/products?type=${data}`,
header: { 'Content-Type': 'application/json'},
success: resolve,
diff --git a/utils/profile.js b/utils/profile.js
index df82865..e704db1 100644
--- a/utils/profile.js
+++ b/utils/profile.js
@@ -1,7 +1,7 @@
const app = getApp()
function getZichanSlides (resolve) {
- wx.request({
+ app.request({
url: `${app.globalData.API_URL}/my_assets`,
data: {token: app.globalData.token},
header: { 'Content-Type': 'application/json'},
@@ -45,7 +45,7 @@ function getCustomerInfo (data, cb) {
}
function getPassCode (mobile, cb) {
- wx.request({
+ app.request({
url: `${app.globalData.API_URL}/send_validation_code/send_message`,
header: { 'Content-Type': 'application/json'},
data: {