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.
 

221 lines
6.9 KiB

//小程序开发api接口
const API_BASE_URL = 'https://mall.gylservice.com/gw?module=app'
const requestServer = (url, method, data) => {
let _url = API_BASE_URL + url
return new Promise((resolve, reject) => {
var userInfo = wx.getStorageSync('userInfo');
var token = userInfo.token;
var accessId = wx.getStorageSync('accessId');
// console.log('token:' + token);
wx.request({
url: _url,
method: method,
data: data,
header: {
'content-type': 'application/x-www-form-urlencoded',
// accessId: accessId,
language: '',
"Accept": "*/*",
},
dataType: 'json',
success(res) {
resolve(res.data)
},
fail(error) {
reject(error)
},
complete(aaa) {
//加载完成
}
})
})
}
//promise
Promise.prototype.finally = function(callback) {
var Promise = this.constructor
return this.then(
function(value) {
Promise.resolve(callback()).then(
function() {
return value;
}
);
},
function(reason) {
Promise.resolve(callback()).then(
function() {
throw reason;
}
);
}
)
}
module.exports = {
requestServer,
appIndex: (data) => { //获取用户会话密钥
return requestServer('&action=app&app=index', 'post', data)
},
/* 首页 */
homeIndex: (data) => { //首页
return requestServer('&action=index&app=index', 'post', data)
},
newArrival: (data) => { //新品上市
return requestServer('&action=index&app=new_arrival', 'post', data)
},
recommend: (data) => { //好物优选
return requestServer('&action=index&app=recommend', 'post', data)
},
productIndex: (data) => { //商品详情
return requestServer('&action=product&app=index', 'post', data)
},
/* 分类 */
searchIndex: (data) => { //分类页
return requestServer('&action=search&app=index', 'post', data)
},
/* 购物车 */
appCart: (data) => { //
return requestServer('&action=app&app=cart', 'post', data)
},
cartIndex: (data) => { //购物车
return requestServer('&action=cart&app=index', 'post', data)
},
productAddCart: (data) => { //加入购物车
return requestServer('&action=product&app=add_cart', 'post', data)
},
productUpNum: (data) => { //购物车商品添加数量
return requestServer('&action=cart&app=up_cart', 'post', data)
},
productDelcart: (data) => { //删除购物车
return requestServer('&action=cart&app=delcart', 'post', data)
},
productDelAllCart: (data) => { //清空购物车
return requestServer('&action=cart&app=delAll_cart', 'post', data)
},
/* 我的 */
userIndex: (data) => { //个人中心
return requestServer('&action=user&app=index', 'post', data)
},
/* 登录 */
login: (data) => { //登录
return requestServer('&action=login&app=login', 'post', data)
},
mchClass: (data) => { //店铺分类
return requestServer('&action=index&app=mchClass', 'post', data)
},
shopList: (data) => { //店铺分类
return requestServer('&action=index&app=recommend_stores', 'post', data)
},
settlement: (data) => { //确认订单信息
return requestServer('&action=order&app=Settlement', 'post', data)
},
orderPayment: (data) => { //确认订单 payment
return requestServer('&action=order&app=payment', 'post', data)
},
leaveSettlement: (data) => {
return requestServer('&action=order&app=leave_Settlement', 'post', data)
},
addressIndex: (data) => { //地址管理列表
return requestServer('&action=address&app=index', 'post', data)
},
saveAddress: (data) => { //添加地址
return requestServer('&action=address&app=SaveAddress', 'post', data)
},
addressDelAdds: (data) => { //删除地址
return requestServer('&action=address&app=del_adds', 'post', data)
},
addressUpAdds: (data) => { //修改地址
return requestServer('&action=address&app=up_adds', 'post', data)
},
getLocation: (data) => { //获取地址信息
return requestServer('&action=index&app=get_location', 'post', data)
},
orderList: (data) => { //订单列表
return requestServer('&action=order&app=index', 'post', data)
},
orderDetails: (data) => { //订单详情
return requestServer('&action=order&app=order_details', 'post', data)
},
logisticsDetails: (data) => { //物流详情
return requestServer('&action=order&app=logistics', 'post', data)
},
removeOrder: (data) => { //取消订单
return requestServer('&action=order&app=removeOrder', 'post', data)
},
orderRemind: (data) => { //提醒发货
return requestServer('&action=order&app=delivery_delivery', 'post', data)
},
confirmOrder: (data) => { //确认收货
return requestServer('&action=order&app=ok_Order', 'post', data)
},
deleteOrder: (data) => { //删除订单
return requestServer('&action=order&app=del_order', 'post', data)
},
/* -------------------- */
userMaterial: (data) => { //
return requestServer('&action=user&app=material', 'post', data)
},
indexGetMore: (data) => { //更多
return requestServer('&action=index&app=get_more', 'post', data)
},
// newProduct: (data) => { //新品
// return requestServer('&action=product&m=new_product', 'post', data)
// },
productToCollection: (data) => {
return requestServer('&action=product&m=to_Collection', 'post', data)
},
// productShopping: (data) => {
// return requestServer('&action=product&m=Shopping', 'post', data)
// },
preservation: (data) => {
return requestServer('&action=user&m=Preservation', 'post', data)
},
addressDelselect: (data) => {
return requestServer('&action=address&m=del_select', 'post', data)
},
addressSetDefault: (data) => { //设置默认地址
return requestServer('&action=address&m=set_default', 'post', data)
},
addressUpAddsIndex: (data) => { //修改地址
return requestServer('&action=address&m=up_addsindex', 'post', data)
},
envelopeIndex: (data) => { //
return requestServer('&action=envelope&m=index', 'post', data)
},
envelopeShare: (data) => { //
return requestServer('&action=envelope&m=share', 'post', data)
},
appUser: (data) => { //
return requestServer('&action=app&m=user', 'post', data)
},
getcodeProductShare: (data) => { //
return requestServer('&action=getcode&m=product_share', 'post', data)
},
userPerfectIndex: (data) => { //
return requestServer('&action=user&m=perfect_index', 'post', data)
},
userSecretKey: (data) => { //
return requestServer('&action=user&m=secret_key', 'post', data)
},
userPerfect: (data) => { //
return requestServer('&action=user&m=perfect', 'post', data)
},
addFavoritesIndex: (data) => { //
return requestServer('&action=addFavorites&m=index', 'post', data)
},
removeFavorites: (data) => { //
return requestServer('&action=addFavorites&m=removeFavorites', 'post', data)
},
}