//小程序开发api接口 const API_BASE_URL = 'https://mall.gylservice.com/gw?api=' 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, /* 登录 */ login: (data) => { //登录 return requestServer('app.login.login', 'post', data) }, wxLogin: (data) => { //微信一键登录 return requestServer('app.login.user', 'post', data) }, logout: (data) => { //退出登录 return requestServer('app.login.quit', 'post', data) }, getWXTemplate: (data) => { //获取订阅消息模板 return requestServer('app.message.getWxTemplate', 'post', data) }, /* 首页 */ homeIndex: (data) => { //首页 return requestServer('app.index.index', 'post', data) }, newArrival: (data) => { //新品上市 return requestServer('app.index.new_arrival', 'post', data) }, recommend: (data) => { //好物优选 return requestServer('app.index.recommend', 'post', data) }, productIndex: (data) => { //商品详情 return requestServer('app.product.index', 'post', data) }, /* 分类 */ searchIndex: (data) => { //分类页 return requestServer('app.search.index', 'post', data) }, listdetail: (data) => { //分类详情 return requestServer('app.search.listdetail', 'post', data) }, searchList: (data) => { //分类搜索 return requestServer('app.search.search', 'post', data) }, /* 购物车 */ appCart: (data) => { // return requestServer('app.app.cart', 'post', data) }, cartIndex: (data) => { //购物车 return requestServer('app.cart.index', 'post', data) }, productAddCart: (data) => { //加入购物车 return requestServer('app.product.add_cart', 'post', data) }, productUpNum: (data) => { //购物车商品添加数量 return requestServer('app.cart.up_cart', 'post', data) }, productDelcart: (data) => { //删除购物车 return requestServer('app.cart.delcart', 'post', data) }, productDelAllCart: (data) => { //清空购物车 return requestServer('app.cart.delAllCart', 'post', data) }, /* 我的 */ userIndex: (data) => { //个人中心 return requestServer('app.user.index', 'post', data) }, updatepassword: (data) => { //修改密码 return requestServer('app.user.updatepassword', 'post', data) }, /* 商品 */ mchClass: (data) => { //店铺分类 return requestServer('app.index.mchClass', 'post', data) }, shopList: (data) => { //店铺分类 return requestServer('app.index.recommend_stores', 'post', data) }, settlement: (data) => { //确认订单信息 return requestServer('app.order.Settlement', 'post', data) }, orderPayment: (data) => { //确认订单 payment return requestServer('app.order.payment', 'post', data) }, leaveSettlement: (data) => { return requestServer('app.order.leave_Settlement', 'post', data) }, addressIndex: (data) => { //地址管理列表 return requestServer('app.address.index', 'post', data) }, saveAddress: (data) => { //添加地址 return requestServer('app.address.SaveAddress', 'post', data) }, addressDelAdds: (data) => { //删除地址 return requestServer('app.address.del_adds', 'post', data) }, addressUpAdds: (data) => { //修改地址 return requestServer('app.address.up_adds', 'post', data) }, getLocation: (data) => { //获取地址信息 return requestServer('app.index.get_location', 'post', data) }, orderList: (data) => { //订单列表 return requestServer('app.order.index', 'post', data) }, orderDetails: (data) => { //订单详情 return requestServer('app.order.order_details', 'post', data) }, logisticsDetails: (data) => { //物流详情 return requestServer('app.order.logistics', 'post', data) }, removeOrder: (data) => { //取消订单 return requestServer('app.order.removeOrder', 'post', data) }, orderRemind: (data) => { //提醒发货 return requestServer('app.order.delivery_delivery', 'post', data) }, confirmOrder: (data) => { //确认收货 return requestServer('app.order.ok_Order', 'post', data) }, deleteOrder: (data) => { //删除订单 return requestServer('app.order.del_order', 'post', data) }, returnDataList: (data) => { //售后 return requestServer('app.order.ReturnDataList', 'post', data) }, footprint: (data) => { //历史足迹 return requestServer('app.footprint.index', 'post', data) }, favorites: (data) => { //我的收藏 return requestServer('app.addFavorites.collection', 'post', data) }, addFavoritesIndex: (data) => { //添加收藏 return requestServer('app.addFavorites.index', 'post', data) }, removeFavorites: (data) => { //取消收藏 return requestServer('app.addFavorites.removeFavorites', 'post', data) }, delallFavorites: (data) => { //清空收藏 return requestServer('app.addFavorites.alldel', 'post', data) }, storeHome: (data) => { //店铺主页 return requestServer('app.mch.store_homepage', 'post', data) }, seemystore: (data) => { //查看店铺信息 return requestServer('app.mch.see_my_store', 'post', data) }, messageList: (data) => { //查看店铺信息 return requestServer('app.message.index', 'post', data) }, }