You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
793 B

8 years ago
const API_URL = 'http://localhost:3000'
function getProducts (data) {
data = data ? `/${data}` : ''
return new Promise((resolve, reject) => {
wx.request({
url: `${API_URL}/products${data}`,
header: { 'Content-Type': 'application/json' },
success: resolve,
fail: reject
})
})
}
function postBuyProduct (data) {
return new Promise((resolve, reject) => {
wx.request({
url: `${API_URL}/products/buy`,
data: Object.assign({}, data),
header: { 'Content-Type': 'application/json' },
success: resolve,
fail: reject
})
})
}
module.exports = {
getProducts (data) {
return getProducts(data).then(res => res.data)
},
getProduct (data) {
return getProducts(data).then(res => res.data)
}
}