yshop意向点餐系统v1.2.2

This commit is contained in:
hupeng committed 2023-12-17 10:19:51 +08:00
1 parent d03982bf66
commit fc575265c3
4685 files changed
+518513 -182051

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
import api from './api'
// 删除用户地址
export function addressDelete(data) {
return api.post(`/address/del/${data.id}`, undefined, { login: true })
}
// 设置默认地址
export function shopGetDistanceFromLocation(data) {
return api.post(`/address/getDistanceFromLocation`, data, { login: true })
}
// 添加或修改地址
export function getAddressAddAndEdit(data) {
return api.post(`/address/addAndEdit`, data, { login: true })
}
// 用户地址列表 l
export function addressAll(data) {
return api.get(`/address/list`, data, { login: true })
}
+166
View File
@@ -0,0 +1,166 @@
// #ifdef H5
// h5端
import Fly from 'flyio/dist/npm/fly'
// #endif
// #ifdef APP-PLUS
// app端
import Fly from 'flyio/dist/npm/wx'
// #endif
// #ifdef MP-WEIXIN
import Fly from 'flyio/dist/npm/wx'
// #endif
import { handleLoginFailure } from '@/utils'
import { isWeixin } from '@/utils/util'
import { VUE_APP_API_URL } from '@/config'
import cookie from '@/utils/cookie'
import { replace } from '@/utils/router'
const fly = new Fly()
fly.config.baseURL = VUE_APP_API_URL
fly.interceptors.response.use(
response => {
// console.log(response)
// 定时刷新access-token
return response
},
error => {
if (error.toString() == 'Error: Network Error') {
handleLoginFailure()
return Promise.reject({ msg: '未登录', toLogin: true })
}
if (error.status == 401) {
handleLoginFailure()
return Promise.reject({ msg: '未登录', toLogin: true })
}
if (error.response.data.status == 5109) {
uni.showToast({
title: error.response.data.msg,
icon: 'none',
duration: 2000,
})
}
return Promise.reject(error)
}
)
const defaultOpt = { login: true }
function baseRequest(options) {
const token = cookie.get('accessToken')
console.log('--> % token % token:\n', token)
options.headers = {
...options.headers,
}
// if (options.login === true) {
options.headers = {
...options.headers,
Authorization: 'Bearer ' + token,
}
// }
// 结构请求需要的参数
const { url, params, data, login, ...option } = options
// 发起请求
return fly
.request(url, params || data, {
...option,
})
.then(res => {
const data = res.data || {}
//console.log('res.status:',res)
// console.log('res.code:',res.code)
// #ifdef H5
if (res.data.code == 1004004002) {
if(isWeixin()){
const url = cookie.get('index_url')
console.log('redirect_uri:',url)
//const url = `${location.origin}/h5/#/pages/index/index`
location.href = url
return
}
}
// #endif
if (res.status !== 200) {
return Promise.reject({ msg: '请求失败', res, data })
}
if (data.code == 401) {
uni.hideLoading()
handleLoginFailure()
uni.showToast({
title: data.msg,
icon: 'none',
duration: 2000,
})
return Promise.reject({ msg: data.msg, res, data })
}
if (data.code != 0) {
uni.showToast({
title: data.msg,
icon: 'none',
duration: 2000,
})
return Promise.reject({ data, res })
}
return Promise.resolve(data.data, res)
// if ([401, 403].indexOf(data.status) !== -1) {
// handleLoginFailure()
// return Promise.reject({ msg: res.data.msg, res, data, toLogin: true })
// } else if (data.status === 200) {
// return Promise.resolve(data, res)
// } else if (data.status == 5101) {
// return Promise.reject({ msg: res.data.msg, res, data })
// } else {
// return Promise.reject({ msg: res.data.msg, res, data })
// }
})
}
/**
* http 请求基础类
* 参考文档 https://www.kancloud.cn/yunye/axios/234845
*
*/
const request = ['post', 'put', 'patch'].reduce((request, method) => {
/**
*
* @param url string 接口地址
* @param data object get参数
* @param options object axios 配置项
* @returns {AxiosPromise}
*/
request[method] = (url, data = {}, options = {}) => {
console.log(url, data)
return baseRequest(Object.assign({ url, data, method }, defaultOpt, options))
}
return request
}, {})
;['get', 'delete', 'head'].forEach(method => {
/**
*
* @param url string 接口地址
* @param params object get参数
* @param options object axios 配置项
* @returns {AxiosPromise}
*/
request[method] = (url, params = {}, options = {}) => {
return baseRequest(Object.assign({ url, params, method }, defaultOpt, options))
}
})
export default request
+37
View File
@@ -0,0 +1,37 @@
import api from './api'
/**
* 使用手机 + 验证码登录
*/
export function userLogin(data) {
return api.post('/member/auth/sms-login', data, { login: false })
}
/**
* 使用手机 + 验证码登录 member/auth/send-sms-code
*/
export function smsSend(data) {
return api.post('/member/auth/send-sms-code', data, { login: false })
}
/**
* 小程序 member/auth/auth-miniapp-login
*/
export function userLoginForWechatMini(data) {
return api.post('/member/auth/auth-miniapp-login', data, { login: false })
}
/**
* userAuthSession
*/
export function userAuthSession(data) {
return api.post('/member/auth/auth-session', data, { login: false })
}
/**
* wechatAuth
*/
export function wechatAuth(data) {
return api.get('/member/auth/auth-wechat-login', data, { login: false })
}
+31
View File
@@ -0,0 +1,31 @@
import api from './api'
/**
* couponReceive
*/
export function couponReceive(data) {
return api.post('/coupon/receive', data, { login: false })
}
/**
* couponMine
*/
export function couponMine(data) {
return api.get(`/coupon/my`, data, { login: false })
}
/**
* couponIndex let couponCount = (params = {}) => vm.$u.get('/coupon/count', params);
*/
export function couponIndexApi(data) {
return api.get(`/coupon/not`, data, { login: false })
}
/**
* couponCount
*/
export function couponCount(data) {
return api.get(`/coupon/count`, data, { login: false })
}
+15
View File
@@ -0,0 +1,15 @@
import api from './api'
/**
* 获得banner列表
*/
export function shopNearby(data) {
return api.get('/store/nearby', data, { login: false })
}
/**
* 获取首页信息
*/
export function menuGoods(data) {
return api.get('/product/products', data, { login: false })
}
+13
View File
@@ -0,0 +1,13 @@
import api from './api'
/**
* shopGetList
*/
export function shopGetList(data) {
return api.get('/store/list', data, { login: false })
}
export function menuAds(data) {
return api.get('/ad/list', data, { login: false })
}
+63
View File
@@ -0,0 +1,63 @@
import api from './api'
/**
* 订单列表
*/
export function orderTakeFoods(data) {
return api.get('/order/list', data, { login: false })
}
/**
* 订单创建
*/
export function orderSubmit(data) {
return api.post(`/order/create`, data, { login: false })
}
/**
* 订单列表
*/
export function orderGetOrders(data) {
return api.get(`/order/list`, data, { login: false })
}
/**
* 计算详情
*/
export function orderDetail(data) {
return api.get(`/order/detail/${data}`, data, { login: false })
}
/**
* 订单收货
*/
export function orderReceive(data) {
return api.post(`/order/take`, data, { login: false })
}
/**
* 订单退款
*/
export function orderRefund(data) {
return api.post(`/order/refund`, data, { login: false })
}
/**
* 订单支付
*/
export function payUnify(data) {
return api.post(`/order/pay`, data, { login: false })
}
/**
* getWechatConfig
*/
export function getWechatConfig() {
return api.get(`/member/wx-mp/create-jsapi-signature`, { url: location.href }, { login: false })
}
+55
View File
@@ -0,0 +1,55 @@
import api from './api'
/**
* 基本信息
*/
export function userGetUserInfo(data) {
return api.get('/member/user/get-info', data, { login: true })
}
/**
* 获取菜单
*/
export function mineService(data) {
return api.get('/service/list', data, { login: true })
}
/**
* 获取内容
*/
export function mineServiceContent(data) {
return api.get('/service/content', data, { login: true })
}
/**
* save
*/
export function userEdit(data) {
return api.post('/member/user/update-nickname', data, { login: true })
}
/**
* balanceGetBillList
*/
export function balanceGetBillList(data) {
return api.get('/member/user/getBill', data, { login: true })
}
/**
* 充值列表
*/
export function balanceGetMoneyList(data) {
return api.get('/recharge/getMoneyList', data, { login: true })
}
/**
* 充值
*/
export function balanceRecharge(data) {
return api.post('/member/user/recharge', data, { login: true })
}