首页,我的 写扫码点餐之前提交1.0.0

This commit is contained in:
wwz
2025-02-13 16:49:13 +08:00
parent 6cea5aeb42
commit f2513ef13a
48 changed files with 7757 additions and 514 deletions

20
common/api/api.js Normal file
View File

@@ -0,0 +1,20 @@
// 引入 request 文件
import request from '@/common/api/request.js'
//根据经纬度获取信息
export const APIgeocodelocation = (data) => {
return request({
url: '/location/geocode',
method: 'get',
data: data,
toast: false
})
}
//根据经纬度获取信息
export const APIcustomlogin = (data) => {
return request({
url: '/login/auth/custom/login',
method: 'post',
data: data
})
}

View File

@@ -0,0 +1,27 @@
// 引入 request 文件
import request from '@/common/api/request.js'
//获取优惠券参数列表
export const APIordergetYhqPara = (data) => {
return request({
url: '/order/getYhqPara',
method: 'get',
data: data
})
}
//系统优惠券
export const APIorderfindCoupons = (data) => {
return request({
url: '/order/findCoupons',
method: 'get',
data: data
})
}
// 我的优惠券
export const APIordermineCoupons = (data) => {
return request({
url: '/order/mineCoupons',
method: 'post',
data: data,
toast: false
})
}

46
common/api/index/index.js Normal file
View File

@@ -0,0 +1,46 @@
// 引入 request 文件
import request from '@/common/api/request.js'
//首页上半部分
export const APIhomehomePageUp = (data) => {
return request({
url: '/home/homePageUp',
method: 'post',
data: data
})
}
//首页上半部分
export const APIhome = (data) => {
return request({
url: '/home',
method: 'post',
data: data,
toast: false
})
}
//首页上半部分
export const APIshopUserInfo = (data) => {
return request({
url: '/user/shopUserInfo',
method: 'get',
data: data,
toast: false
})
}
//首页上半部分
export const APIgeocodelocation = (data) => {
return request({
url: '/location/geocode',
method: 'get',
data: data,
toast: false
})
}
///商户登录后 shopId和autokey
export const APIshopExtend = (data) => {
return request({
url: '/common/shopExtend',
method: 'post',
data: data,
toast: false
})
}

View File

@@ -0,0 +1,18 @@
// 引入 request 文件
import request from '@/common/api/request.js'
//获取top部分(店铺列表)
export const APIdistiricttopCommon = (data) => {
return request({
url: '/distirict/topCommon',
method: 'get',
data: data
})
}
//预约到店(店铺列表)
export const APIdistirictsubShopList = (data) => {
return request({
url: '/distirict/subShopList',
method: 'get',
data: data
})
}

View File

@@ -0,0 +1,11 @@
// 引入 request 文件
import request from '@/common/api/request.js'
//通过桌码获取店铺信息
export const APIproductqueryShop = (data) => {
return request({
url: '/product/queryShop',
method: 'get',
data: data
})
}

115
common/api/request.js Normal file
View File

@@ -0,0 +1,115 @@
export default (params) => {
let url = params.url;
let method = params.method || "get";
let data = params.data || {};
let type = params.type || 1;
let toast = params.toast || true;
let header = {
version: uni.conf.version,
type: uni.getSystemInfoSync().platform,
// #ifdef APP-PLUS
environment: 'app',
// #endif
// #ifdef H5
environment: 'H5',
// #endif
// #ifdef MP-WEIXIN
environment: 'wx',
// #endif
// #ifdef MP-ALIPAY
environment: 'alipay',
// #endif
token: uni.cache.get('token'),
openId: uni.cache.get('miniAppOpenId'),
id: uni.cache.get('userInfo').id,
shopId: uni.cache.get('shopId'),
userId: uni.cache.get('userInfo').id,
}
if (toast) {
uni.showLoading({
title: '加载中',
mask: true
})
}
return new Promise((resolve, reject) => {
uni.request({
url: uni.conf.baseUrl + url,
method: method,
header: header,
data: data,
success(response) {
const res = response.data
// 根据返回的状态码做出对应的操作
//获取成功
if (res.code == 0) {
uni.hideLoading();
uni.hideToast();
resolve(res);
} else {
switch (res.code) {
case '-4':
resolve(res)
// uni.showToast({
// title: res.message || res.msg || res.error,
// icon: "none",
// success: () => {
// setTimeout(() => {
// uni.reLaunch({
// url: "/pages/login/index",
// })
// }, 1000);
// }
// })
break;
case 404:
uni.showToast({
title: '请求地址不存在...',
duration: 2000,
})
break;
default:
// 是否提示
console.log(res)
if (toast) {
uni.showToast({
title: res.message || res.msg || res.error,
icon: "none",
success: () => {
setTimeout(res => {
}, 2000)
}
})
}
break;
}
}
},
fail(err) {
console.log(err)
if (err.errMsg.indexOf('request:fail') !== -1) {
uni.showToast({
title: '网络异常',
icon: "error",
duration: 2000
})
} else {
uni.showToast({
title: '未知异常',
duration: 2000
})
}
reject(err);
},
complete() {
// 不管成功还是失败都会执行
setTimeout(res => {
uni.hideLoading();
uni.hideToast();
}, 10000)
}
});
}).catch((e) => {});
};