From 8baaf8ff943c0f0dae066dd20ee7719c50413b3e Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Fri, 29 Nov 2024 14:12:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=AB=E7=A0=81=E9=AA=8C?= =?UTF-8?q?=E5=88=B8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/coup/index.js | 199 +++++++++++++++++++++++++++++++++++++++ src/utils/request-php.js | 101 ++++++++++++++++++++ 2 files changed, 300 insertions(+) create mode 100644 src/api/coup/index.js create mode 100644 src/utils/request-php.js diff --git a/src/api/coup/index.js b/src/api/coup/index.js new file mode 100644 index 0000000..9ba574a --- /dev/null +++ b/src/api/coup/index.js @@ -0,0 +1,199 @@ +// 代客下单 +import request from "@/utils/request-php"; + +// 抖音团购核销准备 +export function $douyin_fulfilmentcertificateprepare(data) { + return request({ + url: 'douyin/fulfilmentcertificateprepare', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} +// 抖音团购核销 +export function $douyin_certificateprepare(data) { + return request({ + url: 'douyin/certificateprepare', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} + +// 抖音团购核销撤销 +export function $douyin_fulfilmentcertificatecancel(data) { + return request({ + url: 'douyin/fulfilmentcertificatecancel', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} +// 抖音团购核销记录 +export function $douyin_orderlist(data) { + return request({ + url: 'douyin/orderlist', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} + + +// 抖音门店列表 +export function $douyin_storelist(data) { + return request({ + url: 'douyin/storelist', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} + +// 抖音绑定门店 +export function $douyin_bindstore(data) { + return request({ + url: 'douyin/bindstore', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} +// 抖音订单查询 + +export function $douyin_orderquery(data) { + return request({ + url: 'douyin/orderquery', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} +//会员签入 +export function $douyin_checkIn(data) { + return request({ + url: 'douyin/checkIn', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} + +//美团 + +// 美团获取uisdk 绑定 链接 + +export function $meituan_getuisdkurl(data) { + return request({ + url: 'meituan/getuisdkurl', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} +// 美团获取uisdk 解绑 链接 + +export function $meituan_getuisdkuniurl(data) { + return request({ + url: 'meituan/getuisdkuniurl', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} +// 美团团购核销准备 + +export function $meituan_fulfilmentcertificateprepare(data) { + return request({ + url: 'meituan/fulfilmentcertificateprepare', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} +// 美团执行核销 + +export function $meituan_certificateprepare(data) { + return request({ + url: 'meituan/certificateprepare', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} +// 美团团购核销记录 + + +export function $meituan_orderlist(data) { + return request({ + url: 'meituan/orderlist', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} + +// 美团团购撤销 + + +export function $meituan_fulfilmentcertificatecancel(data) { + return request({ + url: 'meituan/fulfilmentcertificatecancel', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} + +// 美团查询绑定状态 +export function $meituan_searchstorestatus(data) { + return request({ + url: 'meituan/searchstorestatus', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} + +// 登出 +export function $logout(data) { + return request({ + url: 'user/logout', + method: "post", + data: { + shopId: localStorage.getItem("shopId"), + ...data + } + }); +} + diff --git a/src/utils/request-php.js b/src/utils/request-php.js new file mode 100644 index 0000000..a19cfbb --- /dev/null +++ b/src/utils/request-php.js @@ -0,0 +1,101 @@ +import axios from 'axios' +import router from '@/router/routers' +import { Notification } from 'element-ui' +import store from '../store' +import { getToken } from '@/utils/auth' +import Config from '@/settings' +import Cookies from 'js-cookie' +import { setToken } from '@/utils/globalCancelToken.js' +// 创建axios实例 +const service = axios.create({ + // baseURL: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_API : '/', + baseURL: 'https://czgdoumei.sxczgkj.com/index.php/api/', // api 的 base_url + timeout: Config.timeout // 请求超时时间 +}) + +// request拦截器 +service.interceptors.request.use( + config => { + if (getToken()) { + config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 + } + config.headers['Content-Type'] = 'application/json' + // 添加可取消请求配置 + config.cancelToken = new axios.CancelToken(c => setToken(c)) + return config + }, + error => { + Promise.reject(error) + } +) + +// response 拦截器 +service.interceptors.response.use( + response => { + return response.data + }, + error => { + console.log(error); + if (axios.isCancel(error)) { + console.log('请求已取消') + Notification.error({ + title: '请求已取消', + duration: 5000 + }) + return Promise.reject('请求已取消') + } + + // 兼容blob下载出错json提示 + if (error.response.data instanceof Blob && error.response.data.type.toLowerCase().indexOf('json') !== -1) { + const reader = new FileReader() + reader.readAsText(error.response.data, 'utf-8') + reader.onload = function (e) { + const errorMsg = JSON.parse(reader.result).message + Notification.error({ + title: errorMsg, + duration: 5000 + }) + } + } else { + let code = 0 + try { + code = error.response.data.status + } catch (e) { + if (error.toString().indexOf('Error: timeout') !== -1) { + Notification.error({ + title: '网络请求超时', + duration: 5000 + }) + return Promise.reject(error) + } + } + console.log(code) + if (code) { + if (code === 401) { + store.dispatch('LogOut').then(() => { + // 用户登录界面提示 + Cookies.set('point', 401) + location.reload() + }) + } else if (code === 403) { + router.push({ path: '/401' }) + } else { + const errorMsg = error.response.data.message + if (errorMsg !== undefined) { + Notification.error({ + title: errorMsg, + duration: 5000 + }) + } + } + } else { + Notification.error({ + title: '接口请求失败', + duration: 5000 + }) + } + } + return Promise.reject(error) + } +) +export default service