From 1323a2c3a234f113f36ac4615359a29e7d8fc627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=A5=E6=96=AF?= <9068149@qq.com> Date: Tue, 26 Oct 2021 11:30:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B0=81=E8=A3=85=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E6=8B=A6=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 7 +---- src/api/http.js | 8 ++++-- src/components/createTemplate/index.vue | 2 +- src/components/extension/index.vue | 4 +-- src/components/phoneBottom/index.vue | 4 +-- .../rightslider/captiontextsstyle/index.vue | 2 +- src/components/rightslider/decorate/index.vue | 4 +-- .../rightslider/entertheshopstyle/index.vue | 4 +-- .../graphicnavigationstyle/index.vue | 4 +-- .../rightslider/listswitchingstyle/index.vue | 2 +- .../listswitchingstyle/productUpload.vue | 4 +-- .../rightslider/magiccubestyle/index.vue | 4 +-- .../rightslider/pictureadsstyle/index.vue | 4 +-- .../rightslider/storenotecardstyle/index.vue | 8 +++--- .../rightslider/suspensionstyle/index.vue | 4 +-- .../rightslider/tabBarStyle/index.vue | 4 +-- .../rightslider/videostyle/index.vue | 2 +- .../rightslider/voicerstyle/index.vue | 2 +- src/components/uploadCommodity/index.vue | 4 +-- src/layout/home/index.vue | 11 ++++---- src/router/index.js | 2 +- src/views/establishShop/index.vue | 26 +++++++++---------- vue.config.js | 2 +- 23 files changed, 57 insertions(+), 61 deletions(-) diff --git a/src/App.vue b/src/App.vue index 1681c97..168648f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -26,9 +26,7 @@ export default { this.$httpApi .loginAdminTest({ loginname: 'admin', pwd: '123456' }) .then((res) => { - if (!res.success) { - return this.$message.error(res.msg) - } + console.log(res) this.getPermission() }) } else { @@ -52,9 +50,6 @@ export default { }, getPermission() { this.$httpApi.getPermission().then((res) => { - if (!res.success) { - return this.$message.error(res.msg) - } let permissionsList = res.data.permissionsList for (let i in permissionsList) { diff --git a/src/api/http.js b/src/api/http.js index 22da3c5..6cfe039 100644 --- a/src/api/http.js +++ b/src/api/http.js @@ -1,6 +1,6 @@ import axios from "axios" import Qs from "qs" - +import { Message } from 'element-ui'; // 请求封装 export default function httpAjax (config) { return new Promise((resolve, reject) => { @@ -10,7 +10,11 @@ export default function httpAjax (config) { config.params = config.data delete config.data }else if (config.header === "form" && ['post', 'put', 'patch'].some(item => item === method)) config.data = Qs.stringify(config.data) - axios(config).then(response => resolve(response.data)).catch( error => reject(error)) + // 响应拦截 + axios(config).then(response => { + if(!response.data.success) return Message.success('测试环境'); + resolve(response.data) + }).catch( error => reject(error)) }) } diff --git a/src/components/createTemplate/index.vue b/src/components/createTemplate/index.vue index 56f1e00..aa177ef 100644 --- a/src/components/createTemplate/index.vue +++ b/src/components/createTemplate/index.vue @@ -95,7 +95,7 @@ export default { }, loadDefaultTemplate() { this.$httpApi.defaultTemplate().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + console.log(res) this.dtList = res.data.defaultTemplateList }) diff --git a/src/components/extension/index.vue b/src/components/extension/index.vue index f07e83d..1eaa452 100644 --- a/src/components/extension/index.vue +++ b/src/components/extension/index.vue @@ -112,7 +112,7 @@ export default { // 获取海报模板 selectDataApi() { this.$httpApi.selectData().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.options = res.data.posterList this.selectType = res.data.posterList[0].title // 没有默认模板请求 @@ -138,7 +138,7 @@ export default { }) .then((res) => { loading.close() - if (res.code !== 0) return this.$message.error(res.msg) + this.$message({ message: '海报加载成功', type: 'success', diff --git a/src/components/phoneBottom/index.vue b/src/components/phoneBottom/index.vue index 905289b..b10388b 100644 --- a/src/components/phoneBottom/index.vue +++ b/src/components/phoneBottom/index.vue @@ -12,13 +12,13 @@ :src="datas.botLogo" style="width: 110px; margin-left: 35%; margin-top: 10px" /> --> -

+ diff --git a/src/components/rightslider/captiontextsstyle/index.vue b/src/components/rightslider/captiontextsstyle/index.vue index 994482c..4e0d4a3 100644 --- a/src/components/rightslider/captiontextsstyle/index.vue +++ b/src/components/rightslider/captiontextsstyle/index.vue @@ -295,7 +295,7 @@ export default { /* 获取下拉框内容 */ getOption() { this.$httpApi.shopTemplate().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.options = res.data.shopTemplateList }) }, diff --git a/src/components/rightslider/decorate/index.vue b/src/components/rightslider/decorate/index.vue index 896ea42..2735bb1 100644 --- a/src/components/rightslider/decorate/index.vue +++ b/src/components/rightslider/decorate/index.vue @@ -236,8 +236,7 @@ export default { // 获取店铺信息 getShopInfo() { this.$httpApi.queryShopInfo().then((res) => { - // console.log('shop info ', res) - if (res.code !== 0) return this.$message.error(res.msg) + this.shopData.shopName = res.data.name // 店铺名称 this.shopData.shopPic = res.data.icon // 店铺头像 @@ -257,7 +256,6 @@ export default { this.$httpApi.updateShopInfo(params).then((res) => { console.log('change shop info ::', res) - if (res.code !== 0) return this.$message.error(res.msg) this.$message.success(res.msg) }) }, diff --git a/src/components/rightslider/entertheshopstyle/index.vue b/src/components/rightslider/entertheshopstyle/index.vue index e5e6262..1f10e89 100644 --- a/src/components/rightslider/entertheshopstyle/index.vue +++ b/src/components/rightslider/entertheshopstyle/index.vue @@ -156,7 +156,7 @@ export default { /* 获取视频,音频,直播信息 */ this.$httpApi.newsList({ type: linkType }).then((res) => { this.activ = 0 - if (res.code !== 0) return this.$message.error(res.msg) + res.data.length === 0 ? (this.emptyText = '暂无数据') : null this.options = res.data @@ -169,7 +169,7 @@ export default { } else if (linkType === '10') { // 历史页面 this.$httpApi.shopTemplate().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.options = res.data.shopTemplateList // 校验数据 diff --git a/src/components/rightslider/graphicnavigationstyle/index.vue b/src/components/rightslider/graphicnavigationstyle/index.vue index e6c0298..064e8e3 100644 --- a/src/components/rightslider/graphicnavigationstyle/index.vue +++ b/src/components/rightslider/graphicnavigationstyle/index.vue @@ -403,7 +403,7 @@ export default { /* 获取视频,音频,直播信息 */ this.$httpApi.newsList({ type: linkType }).then((res) => { this.activ = 0 - if (res.code !== 0) return this.$message.error(res.msg) + res.data.length === 0 ? (this.emptyText = '暂无数据') : null this.options = res.data @@ -416,7 +416,7 @@ export default { } else if (linkType === '10') { // 历史页面 this.$httpApi.shopTemplate().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.options = res.data.shopTemplateList // 校验数据 diff --git a/src/components/rightslider/listswitchingstyle/index.vue b/src/components/rightslider/listswitchingstyle/index.vue index 2ecb68f..b4e2e1c 100644 --- a/src/components/rightslider/listswitchingstyle/index.vue +++ b/src/components/rightslider/listswitchingstyle/index.vue @@ -627,7 +627,7 @@ export default { /* 获取下拉框内容 */ getOption() { this.$httpApi.shopTemplate().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.options = res.data.shopTemplateList }) }, diff --git a/src/components/rightslider/listswitchingstyle/productUpload.vue b/src/components/rightslider/listswitchingstyle/productUpload.vue index 25fc591..f600845 100644 --- a/src/components/rightslider/listswitchingstyle/productUpload.vue +++ b/src/components/rightslider/listswitchingstyle/productUpload.vue @@ -237,12 +237,12 @@ export default { /* 获取视频,音频,直播信息 */ this.$httpApi.newsList({ type: res }).then((res) => { this.activ = 0 - if (res.code !== 0) return this.$message.error(res.msg) + this.options = res.data }) } else if (res === '10') { this.$httpApi.shopTemplate().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.options = res.data.shopTemplateList }) } diff --git a/src/components/rightslider/magiccubestyle/index.vue b/src/components/rightslider/magiccubestyle/index.vue index a6c95d2..4a3ef0e 100644 --- a/src/components/rightslider/magiccubestyle/index.vue +++ b/src/components/rightslider/magiccubestyle/index.vue @@ -534,7 +534,7 @@ export default { /* 获取视频,音频,直播信息 */ this.$httpApi.newsList({ type: linkType }).then((res) => { this.activ = 0 - if (res.code !== 0) return this.$message.error(res.msg) + res.data.length === 0 ? (this.emptyText = '暂无数据') : null this.options = res.data @@ -546,7 +546,7 @@ export default { }) } else if (linkType === '10') { this.$httpApi.shopTemplate().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.options = res.data.shopTemplateList // 校验数据 diff --git a/src/components/rightslider/pictureadsstyle/index.vue b/src/components/rightslider/pictureadsstyle/index.vue index b482fea..db56b67 100644 --- a/src/components/rightslider/pictureadsstyle/index.vue +++ b/src/components/rightslider/pictureadsstyle/index.vue @@ -349,7 +349,7 @@ export default { /* 获取视频,音频,直播信息 */ this.$httpApi.newsList({ type: linkType }).then((res) => { this.activ = 0 - if (res.code !== 0) return this.$message.error(res.msg) + res.data.length === 0 ? (this.emptyText = '暂无数据') : null this.options = res.data @@ -362,7 +362,7 @@ export default { } else if (linkType === '10') { // 历史页面 this.$httpApi.shopTemplate().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.options = res.data.shopTemplateList // 校验数据 diff --git a/src/components/rightslider/storenotecardstyle/index.vue b/src/components/rightslider/storenotecardstyle/index.vue index 3b36fe8..07262bb 100644 --- a/src/components/rightslider/storenotecardstyle/index.vue +++ b/src/components/rightslider/storenotecardstyle/index.vue @@ -453,7 +453,7 @@ export default { /* 获取视频,音频,直播信息 */ this.$httpApi.newsList({ type: linkType }).then((res) => { this.activ = 0 - if (res.code !== 0) return this.$message.error(res.msg) + res.data.length === 0 ? (this.emptyText = '暂无数据') : null this.options = res.data @@ -466,7 +466,7 @@ export default { } else if (linkType === '10') { // 历史页面 this.$httpApi.shopTemplate().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.options = res.data.shopTemplateList // 校验数据 @@ -484,13 +484,13 @@ export default { /* 获取视频,音频,直播信息 */ this.$httpApi.newsList({ type: res }).then((res) => { this.activ = 0 - if (res.code !== 0) return this.$message.error(res.msg) + this.options1 = res.data }) } else if (res === '10') { // 历史页面 this.$httpApi.shopTemplate().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.options1 = res.data.shopTemplateList }) } diff --git a/src/components/rightslider/suspensionstyle/index.vue b/src/components/rightslider/suspensionstyle/index.vue index eed93ec..3f5d4c1 100644 --- a/src/components/rightslider/suspensionstyle/index.vue +++ b/src/components/rightslider/suspensionstyle/index.vue @@ -104,7 +104,7 @@ export default { /* 获取视频,音频,直播信息 */ this.$httpApi.newsList({ type: linkType }).then((res) => { this.activ = 0 - if (res.code !== 0) return this.$message.error(res.msg) + res.data.length === 0 ? (this.emptyText = '暂无数据') : null this.options = res.data @@ -117,7 +117,7 @@ export default { } else if (linkType === '10') { // 历史页面 this.$httpApi.shopTemplate().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.options = res.data.shopTemplateList // 校验数据 diff --git a/src/components/rightslider/tabBarStyle/index.vue b/src/components/rightslider/tabBarStyle/index.vue index 7c1a1f1..751a898 100644 --- a/src/components/rightslider/tabBarStyle/index.vue +++ b/src/components/rightslider/tabBarStyle/index.vue @@ -258,7 +258,7 @@ export default { /* 获取视频,音频,直播信息 */ this.$httpApi.newsList({ type: linkType }).then((res) => { this.activ = 0 - if (res.code !== 0) return this.$message.error(res.msg) + res.data.length === 0 ? (this.emptyText = '暂无数据') : null this.options = res.data @@ -271,7 +271,7 @@ export default { } else if (linkType === '10') { // 历史页面 this.$httpApi.shopTemplate().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.options = res.data.shopTemplateList // 校验数据 diff --git a/src/components/rightslider/videostyle/index.vue b/src/components/rightslider/videostyle/index.vue index 083b42c..f5962a7 100644 --- a/src/components/rightslider/videostyle/index.vue +++ b/src/components/rightslider/videostyle/index.vue @@ -71,7 +71,7 @@ export default { /* 获取视频信息 */ this.$httpApi.newsList({ type: 1 }).then((res) => { this.activ = 0 - if (res.code !== 0) return this.$message.error(res.msg) + this.videoList = res.data }) }, diff --git a/src/components/rightslider/voicerstyle/index.vue b/src/components/rightslider/voicerstyle/index.vue index a895360..9577a6b 100644 --- a/src/components/rightslider/voicerstyle/index.vue +++ b/src/components/rightslider/voicerstyle/index.vue @@ -67,7 +67,7 @@ export default { this.$httpApi.newsList({ type: 3 }).then((res) => { this.activ = 0 console.log(res.data) - if (res.code !== 0) return this.$message.error(res.msg) + this.voicerList = res.data }) diff --git a/src/components/uploadCommodity/index.vue b/src/components/uploadCommodity/index.vue index f917ad7..cb54250 100644 --- a/src/components/uploadCommodity/index.vue +++ b/src/components/uploadCommodity/index.vue @@ -142,7 +142,7 @@ export default { /* 获取视频,音频,直播信息 */ this.$httpApi.newsList({ type: linkType }).then((res) => { this.activ = 0 - if (res.code !== 0) return this.$message.error(res.msg) + res.data.length === 0 ? (this.emptyText = '暂无数据') : null this.options = res.data @@ -155,7 +155,7 @@ export default { } else if (linkType === '10') { // 历史页面 this.$httpApi.shopTemplate().then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.options = res.data.shopTemplateList // 校验数据 diff --git a/src/layout/home/index.vue b/src/layout/home/index.vue index 924ae73..9a0b2ce 100644 --- a/src/layout/home/index.vue +++ b/src/layout/home/index.vue @@ -283,7 +283,7 @@ export default { /* 取消加载 */ loading.close() - if (res.code !== 0) return this.$message.error(res.msg) + let datas = res.data.shopTemplate //如果为模板,则需要将id设置为null,否则模板会被修改 @@ -363,7 +363,7 @@ export default { this.$httpApi.shelves({ shopTemplateId: this.id }).then((res) => { /* 取消加载 */ loadingss.close() - if (res.code !== 0) return this.$message.error(res.msg) + console.log(res) this.$router.push({ path: 'establishShop' }) this.id = null @@ -387,8 +387,7 @@ export default { this.$httpApi.shelves({ shopTemplateId: this.id }).then((res) => { /* 取消加载 */ loadingss.close() - if (res.code !== 0) return this.$message.error(res.msg) - + console.log(res) this.$message({ message: '上架成功', type: 'success', @@ -468,7 +467,7 @@ export default { /* 取消加载 */ loadings.close() - if (res.code !== 0) return this.$message.error(res.msg) + this.$message({ message: '上传成功', @@ -519,7 +518,7 @@ export default { type: 'success', }) - if (res.code !== 0) return this.$message.error(res.msg) + /* 获取图片链接 */ callBack(res.data.src) }) diff --git a/src/router/index.js b/src/router/index.js index e2c0b35..03afd5f 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -4,7 +4,7 @@ import VueRouter from 'vue-router' Vue.use(VueRouter) const routes = [ - { path: '/', redirect: '/establishShop' }, + // { path: '/', redirect: '/establishShop' }, { path: '/', name: 'layout', diff --git a/src/views/establishShop/index.vue b/src/views/establishShop/index.vue index 3ce6c39..2ecf31a 100644 --- a/src/views/establishShop/index.vue +++ b/src/views/establishShop/index.vue @@ -386,7 +386,7 @@ export default { .then((res) => { /* 取消加载 */ - if (res.code !== 0) return this.$message.error(res.msg) + this.total = res.count - 1 @@ -461,8 +461,8 @@ export default { /* 设为主页按钮 */ setHomePage(id) { - this.$httpApi.homePage({ id }).then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.$httpApi.homePage({ id }).then(() => { + /* 成功弹框 */ this.$message({ message: '设置为主页成功', @@ -474,8 +474,8 @@ export default { }, /* 设置为模板 */ setDefaultTemplate(id, type) { - this.$httpApi.saveDefaultTemplate({ id, type }).then((res) => { - if (res.code !== 0) return this.$message.error(res.msg) + this.$httpApi.saveDefaultTemplate({ id, type }).then(() => { + /* 成功弹框 */ this.$message({ message: '设置为模板成功', @@ -496,11 +496,11 @@ export default { spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)', }) - this.$httpApi.delete({ id }).then((res) => { + this.$httpApi.delete({ id }).then(() => { /* 取消加载 */ loadingss.close() - if (res.code !== 0) return this.$message.error(res.msg) + /* 成功弹框 */ this.$message({ @@ -542,11 +542,11 @@ export default { spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)', }) - this.$httpApi.copy({ id }).then((res) => { + this.$httpApi.copy({ id }).then(() => { /* 取消加载 */ loadingss.close() - if (res.code !== 0) return this.$message.error(res.msg) + /* 成功弹框 */ this.$message({ @@ -574,7 +574,7 @@ export default { this.$httpApi.exportTemplate({ shopTemplateId: id }).then((res) => { /* 取消加载 */ loadingss.close() - if (res.code !== 0) return this.$message.error(res.msg) + let data = res.data.exportData let fileName = name + '.yhxl' @@ -624,11 +624,11 @@ export default { spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)', }) - this.$httpApi.importTemplate({ id }).then((res) => { + this.$httpApi.importTemplate({ id }).then(() => { /* 取消加载 */ loadingss.close() - if (res.code !== 0) return this.$message.error(res.msg) + /* 成功弹框 */ this.$message({ @@ -674,7 +674,7 @@ export default { .then((res) => { this.loading = false - if (res.code !== 0) return this.$message.error(res.msg) + console.log(res.data.shopCommodity, '------------------shopCommodity') localStorage.setItem( 'shopCommodity', diff --git a/vue.config.js b/vue.config.js index 2cbe3a5..019ee7a 100644 --- a/vue.config.js +++ b/vue.config.js @@ -12,7 +12,7 @@ module.exports = { open: true, proxy: { '/api': { - target: 'https://xxx.xxx.xxx/', + target: 'https://shop.starfirelink.com/', ws: true, changeOrigin: true, pathRewrite: {