双屏联动

This commit is contained in:
zmj 2024-02-02 15:44:13 +08:00
parent c666592979
commit 2d541ba5ba
11 changed files with 132 additions and 347 deletions

View File

@ -5,54 +5,27 @@ import { Push } from '@/common/push'
// var ws = new WebSocket("ws://192.168.106.167:8080"); const openPush=()=>{
var connection = new Push({
// //WebSocketonopen url: 'wss://chat.lihaink.cn/tts', // websocket
// ws.onopen = function () {
// console.log("open");
// }
// //onmessagee.dataserver
// ws.onmessage = function (e) {
// let data =JSON.parse(e.data)
// globalEventBus.emit(data.event, data.data ||'')
// }
var connection = new Push({
url: 'ws://192.168.1.24:3131', // websocket
app_key: 'aaea61749929eb53a4bd75a1474c1d27', app_key: 'aaea61749929eb53a4bd75a1474c1d27',
}); });
// uid1 // uid1
var uid = 2; var uid = 10;
// user-2uid1 // user-2uid1
var user_channel = connection.subscribe('user-' + uid); var user_channel = connection.subscribe('user-' + uid);
// user-2message // user-2message
user_channel.on('message', function (data) { user_channel.on('message', function (data) {
console.log("收到消息",data)
globalEventBus.emit(data.content.event, data.content.data) globalEventBus.emit(data.content.event, data.content.data)
console.log("收到消息",data)
}); });
// 线 // 线
user_channel.on('close', function () { user_channel.on('close', function () {
}); });
}
const areaStroe = areaObj() const areaStroe = areaObj()
let res = { let res = {
@ -77,28 +50,14 @@ localStorage.setItem("TRADE_USER", JSON.stringify(res.data))
let { area_code, street_code } = res.data.user let { area_code, street_code } = res.data.user
areaStroe.changeArea({ areaCode: area_code, streetCode: street_code }) areaStroe.changeArea({ areaCode: area_code, streetCode: street_code })
if (localStorage.getItem("TRADE_USER")) { if (localStorage.getItem("TRADE_USER")) {
let userInfo = JSON.parse(localStorage.getItem('TRADE_USER')) let userInfo = JSON.parse(localStorage.getItem('TRADE_USER'))
areaStroe.changeUserInfo(userInfo) areaStroe.changeUserInfo(userInfo)
let { area_code, street_code } = userInfo.user let { area_code, street_code } = userInfo.user
areaStroe.changeArea({ areaCode: area_code, streetCode: street_code }) areaStroe.changeArea({ areaCode: area_code, streetCode: street_code })
} }
if(! JSON.parse(localStorage.getItem("TRADE_TYPE")) )openPush();
</script> </script>
<template> <template>

View File

@ -3,7 +3,7 @@ import axios from "axios";
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import router from "./router"; import router from "./router";
let expire = localStorage.getItem("TRADE_USER") ? JSON.parse(localStorage.getItem("TRADE_USER")).expire : {} // let expire = localStorage.getItem("TRADE_USER") ? JSON.parse(localStorage.getItem("TRADE_USER")).expire : {}
// 创建axios 实例 // 创建axios 实例
@ -11,27 +11,26 @@ const instacne = axios.create({
baseURL: "https://shop.lihaink.cn/", baseURL: "https://shop.lihaink.cn/",
timeout: 30000, timeout: 30000,
}); });
const instacneSend = axios.create({
baseURL: "http://chat.lihaink.cn/index/",
timeout: 30000,
});
// 请求拦截 // 请求拦截
instacne.interceptors.request.use( instacne.interceptors.request.use(
(config) => { (config) => {
// 在发送请求之前做什么 // 在发送请求之前做什么
let timestamp = Math.floor(new Date().getTime() / 1000); // let timestamp = Math.floor(new Date().getTime() / 1000);
// if (expire) {
if (expire) { // if (timestamp > expire) {
// ElMessage({
if (timestamp > expire) { // message: "登录过期,请重新登录",
ElMessage({ // type: 'warning',
message: "登录过期,请重新登录", // })
type: 'warning', // localStorage.removeItem('TRADE_USER')
}) // router.replace('/login')
// }
localStorage.removeItem('TRADE_USER') // }
router.replace('/login')
}
}
return config; return config;
}, },
@ -61,7 +60,9 @@ instacne.interceptors.response.use(
); );
export function sendMsg(params) {
return instacneSend.get('/dataviewTouchPush', { params })
}
export function getUserNumApi(params) { export function getUserNumApi(params) {
return instacne.get('/api/dataview/user_merchat_count', { params }) return instacne.get('/api/dataview/user_merchat_count', { params })

View File

@ -1,14 +1,10 @@
<template> <template>
<Transition> <div class="address" >
<div class="address" v-if="props.choseArea"> <div class="address-li" @click="choseAreaFn">{{ "泸县" }} </div>
<div class="address-li" @click="choseAreaFn">{{ areaStore.area.name||"泸县" }} </div>
<div class="address-li" @click="choseTownFn(item.code, item.name)" v-for="( item, index ) in areaList ">{{ <div class="address-li" @click="choseTownFn(item.code, item.name)" v-for="( item, index ) in areaList ">{{
item.name }} item.name }}
</div> </div>
</div> </div>
</Transition>
</template> </template>
<script setup> <script setup>
@ -16,69 +12,60 @@ import { defineProps, defineEmits, onMounted, reactive, watch ,ref} from "vue"
import { useRouter, useRoute } from 'vue-router' import { useRouter, useRoute } from 'vue-router'
import { areaObj } from '@/store/index.js' import { areaObj } from '@/store/index.js'
import axios from "axios" import axios from "axios"
import { sendMsg } from "@/api.js"
import { globalEventBus } from '@/common/eventBus' import { globalEventBus } from '@/common/eventBus'
let areaStore = areaObj() let areaStore = areaObj()
const areaName=ref("泸县")
const isMainScreen=JSON.parse(localStorage.getItem("TRADE_TYPE"))
const router = useRouter() const router = useRouter()
const emit = defineEmits(['offAreaList']) const emit = defineEmits(['offAreaList'])
const props = defineProps({ const props = defineProps({
choseArea: Boolean, choseArea: Boolean,
}) })
const sendFn = (event, data = '') => {
sendMsg({ channel: 'user-10', event, data })
}
let areaList = reactive([]) let areaList = reactive([])
// //
const choseTownFn = (id, name) => { const choseTownFn = (id, name) => {
areaStore.changeArea({ if(isMainScreen){
sendFn('header7', { name, code: id })
}else{
areaStore.changeArea({
areaCode: areaStore.area.areaCode, areaCode: areaStore.area.areaCode,
streetCode: id, streetCode: id,
name:name name:name
}) })
props.choseArea = false props.choseArea = false
emit('offAreaList', name) emit('offAreaList', name)
router.replace('/townDetail?code=' + id) router.replace('/townDetail?code=' + id)
}
} }
// x // x
const choseAreaFn = () => { const choseAreaFn = () => {
areaStore.changeArea({ if(isMainScreen){
sendFn('header6', { name: "泸县", code: 0 })
}else{
areaStore.changeArea({
areaCode: areaStore.area.areaCode, areaCode: areaStore.area.areaCode,
streetCode: null, streetCode: null,
name:areaStore.area.name name:'泸县'
}) })
props.choseArea = false props.choseArea = false
emit('offAreaList',areaStore.area.name) emit('offAreaList',areaStore.area.name)
router.replace('/') router.replace('/')
}
} }
onMounted(() => { onMounted(() => {
axios.get(`https://crmeb-test.shop.lihaink.cn/api/city/get_street?area_code=${areaStore.area.areaCode}`) axios.get(`https://shop.lihaink.cn/api/city/get_street?area_code=${areaStore.area.areaCode}`)
.then(function (response) { .then(function (response) {
response.data.data.forEach(item => { response.data.data.forEach(item => {
areaList.push(item) areaList.push(item)
}) })
})
})
.catch(function (error) {
//
})
.finally(function () {
//
});
}) })
globalEventBus.on('header6', data => { globalEventBus.on('header6', data => {
@ -86,7 +73,7 @@ globalEventBus.on('header6', data => {
}) })
globalEventBus.on('header7', data => { globalEventBus.on('header7', data => {
choseTownFn(data.id,data.name) choseTownFn(data.code,data.name)
}) })
@ -95,22 +82,16 @@ globalEventBus.on('header7', data => {
<style lang="scss" scoped> <style lang="scss" scoped>
.address { .address {
left: 1vw;
top: 18px;
position: absolute;
width: 8vw; width: 8vw;
height: 18vh;
background-color: #001E32; background-color: #001E32;
color: #C7DBE3; color: #C7DBE3;
z-index: 9999; z-index: 9999;
overflow-y: auto; overflow-y: auto;
box-sizing: border-box; box-sizing: border-box;
padding: 5px;
.address-li { .address-li {
padding: 2px 5px; padding: 5px;
cursor: pointer; cursor: pointer;
border-bottom: 0.1px solid #0E293C; border-bottom: 0.1px solid #0E293C;
} }
} }

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="headers"> <div class="headers">
<div class="logo" > <div class="logo">
</div> </div>
<div class="tab" v-if="role != 1"> <div class="tab" v-if="role != 1">
@ -28,23 +28,19 @@
src="/static/index/DD.png" alt=""> src="/static/index/DD.png" alt="">
<img @click="showFn(3, '/order')" class="tab-img" v-else style="width: 7vw;height:3vh;" <img @click="showFn(3, '/order')" class="tab-img" v-else style="width: 7vw;height:3vh;"
src="/static/index/DDXZ.png" alt=""> src="/static/index/DDXZ.png" alt="">
</div> </div>
<div class="tab-li"> <div class="tab-li">
<img @click="showFn(4, '/finance')" class="tab-img" v-if="show[4]" style="width: 6vw;height:2vh;" <img @click="showFn(4, '/finance')" class="tab-img" v-if="show[4]" style="width: 6vw;height:2vh;"
src="/static/index/CW.png" alt=""> src="/static/index/CW.png" alt="">
<img @click="showFn(4, '/finance')" class="tab-img" v-else style="width: 7vw;height:3vh;" <img @click="showFn(4, '/finance')" class="tab-img" v-else style="width: 7vw;height:3vh;"
src="/static/index/CWXZ.png" alt=""> src="/static/index/CWXZ.png" alt="">
</div> </div>
<div class="tab-li" v-if="route.path == '/storeLogin'" @click="router.replace('/Businesses')"> <div class="tab-li" v-if="route.path == '/storeLogin'" @click="router.replace('/Businesses')">
<img @click="showFn(4, '/finance')" class="tab-img" v-if="show[4]" style="width: 6vw;height:2vh;" <img @click="showFn(4, '/finance')" class="tab-img" v-if="show[4]" style="width: 6vw;height:2vh;"
src="/static/index/FH.png" alt=""> src="/static/index/FH.png" alt="">
</div> </div>
</div> </div>
<div class="tab" v-else> <div class="tab" v-else>
<div class="tab-li"> <div class="tab-li">
<img @click="showFn(2, '/storeLogin')" class="tab-img" v-if="show[2]" style="width: 6vw;height:2vh;" <img @click="showFn(2, '/storeLogin')" class="tab-img" v-if="show[2]" style="width: 6vw;height:2vh;"
src="/static/index/SH.png" alt=""> src="/static/index/SH.png" alt="">
@ -54,13 +50,11 @@
</div> </div>
<div class="right"> <div class="right">
<datePicker></datePicker> <datePicker></datePicker>
<div class="rigth-li" @click="choseAreaFn"> <img style="width: 1VW;height:1VW;margin-right: 0.5vw;" <div class="rigth-li b-cls" @click="choseAreaFn"> <img style="width: 1VW;height:1VW;margin-right: 0.5vw;"
src="/static/index/DW.png" alt=""> {{ areaStore.area.name||"泸县" }} src="/static/index/DW.png" alt=""> {{ areaStore.area.name || "泸县" }}
<areaList :choseArea="choseArea" @offAreaList="offAreaList" class="a-cls" :key="areaStore.area.areaCode" />
</div> </div>
<areaList :choseArea="choseArea" @offAreaList="offAreaList" style="left: 12vw;" :key="areaStore.area.areaCode">
</areaList>
<div class="right-line"> <div class="right-line">
<span> <span>
</span> </span>
@ -81,30 +75,20 @@
<span></span> <span></span>
<span></span> <span></span>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, reactive, onMounted, watch } from "vue" import { ref, reactive, onMounted, watch } from "vue"
import areaList from "./areaList.vue"; import areaList from "./areaList.vue";
import { useRouter, useRoute } from 'vue-router' import { useRouter, useRoute } from 'vue-router'
import { areaObj } from "@/store/index.js" import { areaObj } from "@/store/index.js"
import datePicker from "@/components/datePicker.vue" import datePicker from "@/components/datePicker.vue"
import { globalEventBus } from '@/common/eventBus' import { globalEventBus } from '@/common/eventBus'
import { sendMsg } from "@/api.js"
const areaStore = areaObj() const areaStore = areaObj()
const isMainScreen=JSON.parse(localStorage.getItem("TRADE_TYPE"))
let area = ref(areaStore.area.name || '') let area = ref(areaStore.area.name || '')
let userinfo = JSON.parse(localStorage.getItem('TRADE_USER')) let userinfo = JSON.parse(localStorage.getItem('TRADE_USER'))
let role = ref(userinfo.role) let role = ref(userinfo.role)
@ -114,52 +98,43 @@ const route = useRoute()
// //
const show = reactive([false, true, true, true, true]) const show = reactive([false, true, true, true, true])
const sendFn = (event, data = '') => {
sendMsg({ channel: 'user-10', event, data })
}
const showFn = (index, src) => { const showFn = (index, src) => {
show.forEach((item, i) => { show.forEach((item, i) => {
show[i] = true show[i] = true
}) })
show[index] = !show[index] show[index] = !show[index]
if (src) {
if (src && !isMainScreen) {
if (areaStore.area.streetCode && src == '/') { if (areaStore.area.streetCode && src == '/') {
router.push("/townDetail?code=510524102") router.push("/townDetail?code=510524102")
return return
} }
router.replace(src) router.replace(src)
}
else if(isMainScreen){
sendFn(`header${index+1}`)
} }
} }
const changeArea = (name, code) => { const changeArea = (name, code) => {
areaStore.changeArea({ areaStore.changeArea({
areaCode: code, areaCode: code,
streetCode: null, streetCode: null,
name, name,
}) })
// router.go(0)
router.replace('/') router.replace('/')
console.log(areaStore.area.name)
} }
if( !isMainScreen){
watch(
watch(
() => route.path, () => route.path,
(value, oldValue) => { (value, oldValue) => {
if (value == '/index') { if (value == '/index') {
showFn(0) showFn(0)
area.value = areaStore.area.name || '泸县' area.value = areaStore.area.name || '泸县'
@ -190,16 +165,13 @@ watch(
} }
) )
}
const choseAreaFn = () => { const choseAreaFn = () => {
if (role.value == 2) { if (role.value == 2) {
choseArea.value = true choseArea.value = true
} }
} }
// //
@ -207,13 +179,8 @@ const choseArea = ref(false)
// //
const offAreaList = (name) => { const offAreaList = (name) => {
choseArea.value = false choseArea.value = false
// area.value = name
} }
const out = () => { const out = () => {
localStorage.removeItem('TRADE_USER') localStorage.removeItem('TRADE_USER')
router.replace('/login') router.replace('/login')
@ -243,71 +210,30 @@ const updateTime = () => {
document.getElementById("time").innerHTML = currentTime; document.getElementById("time").innerHTML = currentTime;
document.getElementById("days").innerHTML = currentDays; document.getElementById("days").innerHTML = currentDays;
} }
const SCREEN_TYPE=JSON.parse(localStorage.getItem('SCREEN_TYPE'))
onMounted(() => { onMounted(() => {
setInterval(updateTime, 1000) setInterval(updateTime, 1000)
localStorage.setItem("SCREEN_TYPE",JSON.stringify(route.query)||'' )
}) })
globalEventBus.on('compheader1', data => { globalEventBus.on('compheader1', data => {
showFn(0, '/') showFn(0, '/')
if (SCREEN_TYPE.type == 'r') {
showFn(0, '/')
}
}) })
globalEventBus.on('compheader2', data => { globalEventBus.on('compheader2', data => {
showFn(1, '/commodity') showFn(1, '/commodity')
if (SCREEN_TYPE.type == 'r'){
showFn(1, '/commodity')
}
}) })
globalEventBus.on('compheader3', data => { globalEventBus.on('compheader3', data => {
showFn(2, '/Businesses') showFn(2, '/Businesses')
if (SCREEN_TYPE.type == 'r'){
showFn(2, '/Businesses')
}
}) })
globalEventBus.on('compheader4', data => { globalEventBus.on('compheader4', data => {
showFn(3, '/order') showFn(3, '/order')
if (SCREEN_TYPE.type == 'r'){
showFn(3, '/order')
}
}) })
globalEventBus.on('compheader5', data => { globalEventBus.on('compheader5', data => {
showFn(4, '/finance') showFn(4, '/finance')
if (SCREEN_TYPE.type == 'r'){
showFn(4, '/finance')
}
}) })
globalEventBus.on('choserArea', data => { globalEventBus.on('choserArea', data => {
changeArea(data.name, data.code) changeArea(data.name, data.code)
}) })
</script> </script>
@ -316,7 +242,6 @@ globalEventBus.on('choserArea', data => {
<style lang="scss" > <style lang="scss" >
.popperClass { .popperClass {
// background-color: red;
color: red; color: red;
border: none; border: none;
} }
@ -329,12 +254,9 @@ globalEventBus.on('choserArea', data => {
justify-content: space-between; justify-content: space-between;
background-image: url('/static/index/LOGO.png'); background-image: url('/static/index/LOGO.png');
background-color: #000C14; background-color: #000C14;
background-size: cover; background-size: cover;
.logo { .logo {
width: 20vw; width: 20vw;
// margin-right: 30px;
height: 40px; height: 40px;
align-items: center; align-items: center;
} }
@ -345,7 +267,6 @@ globalEventBus.on('choserArea', data => {
margin-left: 120px; margin-left: 120px;
width: auto; width: auto;
height: 100%; height: 100%;
// background-color: white;
.tab-li { .tab-li {
width: 8vw; width: 8vw;
@ -354,7 +275,6 @@ globalEventBus.on('choserArea', data => {
cursor: pointer; cursor: pointer;
height: 1.5vh; height: 1.5vh;
position: relative; position: relative;
// background-color: red;
.tab-img { .tab-img {
position: absolute; position: absolute;
@ -373,41 +293,6 @@ globalEventBus.on('choserArea', data => {
position: relative; position: relative;
align-items: center; align-items: center;
.address {
left: 1vw;
top: 18px;
position: absolute;
width: 8vw;
height: 18vh;
background-color: #001E32;
color: #C7DBE3;
z-index: 9999;
overflow-y: auto;
box-sizing: border-box;
padding: 5px;
.address-li {
padding: 2px 5px;
cursor: pointer;
border-bottom: 0.1px solid #0E293C;
}
}
.address::-webkit-scrollbar {
width: 10px;
background-color: #153041;
}
.address::-webkit-scrollbar-track {
background-color: #153041;
}
::-webkit-scrollbar-thumb {
background-color: #4AB9D0;
border-radius: 5px;
}
.rigth-li { .rigth-li {
height: 15px; height: 15px;
line-height: 15px; line-height: 15px;
@ -428,11 +313,29 @@ globalEventBus.on('choserArea', data => {
width: 1px; width: 1px;
height: 7px; height: 7px;
background-color: #4BB9D0; background-color: #4BB9D0;
} }
} }
} }
} }
.a-cls{
height: 0;
overflow: hidden;
position: absolute;
top: 2vh;
display: block;
z-index: 999;
transition: 300ms;
left: 2vw;
}
.b-cls{
position: relative;
}
.b-cls:hover .a-cls{
height: 18vh;
display: block;
}
.v-enter-active, .v-enter-active,
.v-leave-active { .v-leave-active {

View File

@ -34,8 +34,6 @@ import { ref, reactive, defineProps } from "vue"
import { getSalesRankApi } from "@/api.js" import { getSalesRankApi } from "@/api.js"
import * as echarts from 'echarts'; import * as echarts from 'echarts';
import { globalEventBus } from '@/common/eventBus' import { globalEventBus } from '@/common/eventBus'
const props = defineProps({ const props = defineProps({
areaCodes: Object, areaCodes: Object,
}) })
@ -48,8 +46,6 @@ let merchantRankingTotal = ref(0)
let productRankingTotal = ref(0) let productRankingTotal = ref(0)
let townProductCount = ref(0) let townProductCount = ref(0)
const addFn = (data) => { const addFn = (data) => {
let list = [] let list = []
data.forEach((item, i) => { data.forEach((item, i) => {
@ -58,16 +54,11 @@ const addFn = (data) => {
`<div style="line-height:30px; text-align: center;background-image: url('/index/PM${(i + 1) <= 3 ? (i + 1) : 4}.png');width: 30px;height: 30px;background-size: cover;" >${i + 1}</div> `, `<div style="line-height:30px; text-align: center;background-image: url('/index/PM${(i + 1) <= 3 ? (i + 1) : 4}.png');width: 30px;height: 30px;background-size: cover;" >${i + 1}</div> `,
`<div style='background:red;position:relative'><img src="${item.image || item.mini_banner}" style="width: 30px;height: 30px;position:absolute" alt=""></div>`, `<div style='background:red;position:relative'><img src="${item.image || item.mini_banner}" style="width: 30px;height: 30px;position:absolute" alt=""></div>`,
`<div style='height:40px;line-height:40px; white-space: nowrap; overflow: hidden;text-overflow: ellipsis;'>${item.store_name || item.mer_name}</div>`, `<div style='height:40px;line-height:40px; white-space: nowrap; overflow: hidden;text-overflow: ellipsis;'>${item.store_name || item.mer_name}</div>`,
`<div style=' transform: translateY(12px); width: 100%; height: 10px; background-color: #122E3F;overflow: hidden;'> <div style=' width: ${item.store_name ? (item.total_sales / productRankingTotal.value).toFixed(2) * 100 : (item.total_sales / townProductCount.value).toFixed(2) * 100}%;height: 100%; background: linear-gradient(to right, #4459CC, #53CAE2);transition: width 0.5s ease-in-out;'></div> </div>`, `<div style=' transform: translateY(12px); width: 100%; height: 10px; background-color: #122E3F;overflow: hidden;'> <div style=' width: ${item.store_name ? (item.total_sales / productRankingTotal.value).toFixed(2) * 100 : (item.total_sales / merchantRankingTotal.value).toFixed(2) * 100}%;height: 100%; background: linear-gradient(to right, #4459CC, #53CAE2);transition: width 0.5s ease-in-out;'></div> </div>`,
`<div style=' position: relative;line-height:30px;text-align:center' >${item.total_sales} <span style='font-size:10px'>单</span> `<div style=' position: relative;line-height:30px;text-align:center' >${item.total_sales} <span style='font-size:10px'>单</span>
<img src="/index/PHBBG.png" style="position: absolute;width: 100%;height: 30px; top:0px;left:0px" alt="">
<img src="/index/PHBBG.png" style="position: absolute;width: 100%;height: 30px; top:0px;left:0px" alt="">
</div>`, </div>`,
], ],
) )
}) })
return list return list
@ -239,6 +230,7 @@ getSalesRankApi(props.areaCodes).then(res => {
config.data = addFn(merchantRankingList) config.data = addFn(merchantRankingList)
pageNum.value = Math.ceil(townProductCountList.length / 8) pageNum.value = Math.ceil(townProductCountList.length / 8)
initStoreOption(townProductCountList.slice(0, 8), townProductCount.value) initStoreOption(townProductCountList.slice(0, 8), townProductCount.value)
console.log(townProductCount.value,'townProductCount')
}) })
const pageFN = (Num) => { const pageFN = (Num) => {

View File

@ -59,7 +59,6 @@ import * as echarts from 'echarts';
import { onMounted, defineProps } from "vue" import { onMounted, defineProps } from "vue"
import { order_user_num_countApi } from "@/api.js" import { order_user_num_countApi } from "@/api.js"
import { areaObj } from '../../store'; import { areaObj } from '../../store';
const areaStore = areaObj() const areaStore = areaObj()
order_user_num_countApi( order_user_num_countApi(
@ -73,9 +72,6 @@ order_user_num_countApi(
orderData2.series[0].data.push(res.data.monthOrderPayNum) orderData2.series[0].data.push(res.data.monthOrderPayNum)
initCharts('orderData', orderData) initCharts('orderData', orderData)
initCharts('orderData2', orderData2) initCharts('orderData2', orderData2)
console.log(45454)
}) })

View File

@ -1,4 +1,4 @@
import { createRouter, createWebHistory } from 'vue-router' import { createRouter, createWebHashHistory } from 'vue-router'
const routes = [ const routes = [
{ {
@ -52,21 +52,15 @@ const routes = [
name: 'login', name: 'login',
component: () => import('@/view/login.vue'), component: () => import('@/view/login.vue'),
}, },
] ]
const router = createRouter({ const router = createRouter({
mode: 'hash', history: createWebHashHistory(),
history: createWebHistory(),
routes routes
}) })
router.beforeEach(async (to, from, next) => { router.beforeEach(async (to, from, next) => {
let token = localStorage.getItem("TRADE_USER") let token = localStorage.getItem("TRADE_USER")
if (to.name == "login" && token) { if (to.name == "login" && token) {
next("/") next("/")
return return

View File

@ -5,33 +5,24 @@ import {
const lastMouth = () => { const lastMouth = () => {
var thirtyDaysAgo = new Date(); var thirtyDaysAgo = new Date();
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30); // 设置为30天前的日期 thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30); // 设置为30天前的日期
var year = thirtyDaysAgo.getFullYear(); var year = thirtyDaysAgo.getFullYear();
var month = thirtyDaysAgo.getMonth() + 1; // 月份从0开始需要加1 var month = thirtyDaysAgo.getMonth() + 1; // 月份从0开始需要加1
var day = thirtyDaysAgo.getDate(); var day = thirtyDaysAgo.getDate();
// 格式化为字符串如果需要补0可以使用padStart函数 // 格式化为字符串如果需要补0可以使用padStart函数
var formattedDate = year + '-' + month.toString().padStart(2, '0') + '-' + day.toString().padStart(2, '0'); var formattedDate = year + '-' + month.toString().padStart(2, '0') + '-' + day.toString().padStart(2, '0');
return formattedDate return formattedDate
} }
const now = () => { const now = () => {
// 创建一个新的Date对象表示当前日期和时间 // 创建一个新的Date对象表示当前日期和时间
var today = new Date(); var today = new Date();
// 获取年、月、日 // 获取年、月、日
var year = today.getFullYear(); var year = today.getFullYear();
var month = today.getMonth() + 1; // 月份从0开始需要加1 var month = today.getMonth() + 1; // 月份从0开始需要加1
var day = today.getDate(); var day = today.getDate();
// 格式化为字符串 // 格式化为字符串
var formattedDate = year + "-" + month + "-" + day; var formattedDate = year + "-" + month + "-" + day;
return formattedDate return formattedDate
} }
export const areaObj = defineStore('counter', { export const areaObj = defineStore('counter', {
@ -44,7 +35,7 @@ export const areaObj = defineStore('counter', {
}, },
time: [lastMouth(), now()], time: [lastMouth(), now()],
// 商户请求的参数 // 商户登录请求的参数
store: { store: {
areaCode: "", areaCode: "",
streetCode: "", streetCode: "",
@ -59,8 +50,6 @@ export const areaObj = defineStore('counter', {
}, },
changeUserInfo(obj) { changeUserInfo(obj) {
this.userInfo = obj this.userInfo = obj
if (obj?.user?.merchant) { if (obj?.user?.merchant) {
let { area_id, mer_id, street_id } = obj.user.merchant let { area_id, mer_id, street_id } = obj.user.merchant
this.store.areaCode = area_id this.store.areaCode = area_id

View File

@ -31,13 +31,7 @@ import { areaObj } from '@/store/index.js'
import router from "../router"; import router from "../router";
import { globalEventBus } from '@/common/eventBus' import { globalEventBus } from '@/common/eventBus'
const showLogin = ref(false) const showLogin = ref(false)
const areaStore = areaObj() const areaStore = areaObj()
const route = useRouter() const route = useRouter()
let status = ref(0) let status = ref(0)
@ -47,13 +41,10 @@ const num = (n) => {
htmls = htmls.concat('<input type="radio" name="rate" readonly>') htmls = htmls.concat('<input type="radio" name="rate" readonly>')
} }
return htmls return htmls
} }
let baseData = {} let baseData = {}
const changeTable = (num) => { const changeTable = (num) => {
configs.data.splice(0, configs.data.length) configs.data.splice(0, configs.data.length)
status.value = num status.value = num
merchant_listApi( merchant_listApi(
@ -69,7 +60,6 @@ const changeTable = (num) => {
} }
const hdClick = (e) => { const hdClick = (e) => {
if (e.columnIndex == 10) { if (e.columnIndex == 10) {
merchantApi( merchantApi(
@ -78,15 +68,13 @@ const hdClick = (e) => {
...areaStore.area ...areaStore.area
} }
).then(res => { ).then(res => {
localStorage.setItem('TRAD_STORE_INFO',JSON.stringify(res.data) )
areaStore.storeLogin(res.data) areaStore.storeLogin(res.data)
router.push('/storeLogin') router.push('/storeLogin')
}) })
} }
} }
const addConfigData = (data) => { const addConfigData = (data) => {
data.forEach((item, i) => { data.forEach((item, i) => {
if (i % 2 == 0) { if (i % 2 == 0) {
@ -120,15 +108,10 @@ const addConfigData = (data) => {
`<div style='width: 100%;text-align: center; height: 100%; color: aliceblue; background: #102B3E;'>${item.status ? '开启' : '关闭'}</div>`, `<div style='width: 100%;text-align: center; height: 100%; color: aliceblue; background: #102B3E;'>${item.status ? '开启' : '关闭'}</div>`,
`<div style='width: 100%;text-align: center; height: 100%; color: aliceblue; background: #102B3E;color:#3D9EB5; cursor: pointer;'>登录</div>`, `<div style='width: 100%;text-align: center; height: 100%; color: aliceblue; background: #102B3E;color:#3D9EB5; cursor: pointer;'>登录</div>`,
] ]
) )
} }
}) })
} }
const configs = reactive({ const configs = reactive({
@ -158,25 +141,25 @@ onMounted(() => {
globalEventBus.on('header3-1' , data => { globalEventBus.on('header3-1', data => {
changeTable(1) changeTable(1)
}) })
globalEventBus.on('header3-2' , data => { globalEventBus.on('header3-2', data => {
changeTable(0) changeTable(0)
}) })
globalEventBus.on('header3-3' , data => { globalEventBus.on('header3-3', data => {
merchantApi( merchantApi(
{ {
mer_id: data.id, mer_id: data.id,
...areaStore.area ...areaStore.area
} }
).then(res => { ).then(res => {
areaStore.storeLogin(res.data) areaStore.storeLogin(res.data)
router.push('/storeLogin') router.push('/storeLogin')
}) })
}) })
@ -231,8 +214,6 @@ globalEventBus.on('header3-3' , data => {
background-image: url('/static/index/actbg.png'); background-image: url('/static/index/actbg.png');
background-size: 100% 100%; background-size: 100% 100%;
border: none; border: none;
// border-bottom: 6px solid #BF6D5D
// border-bottom: 6px solid #BF6D5D;
} }
} }

View File

@ -6,7 +6,7 @@
<div class="box" :style="{ opacity: showLoading ? 0 : 1 }"> <div class="box" :style="{ opacity: showLoading ? 0 : 1 }">
<div class="body"> <div class="body">
<div class="l"> <div class="l">
<topLeft :areaCodes="areaStore.area" :key="areaStore.area.areaCode" /> <topLeft :areaCodes="areaStore.area" :key="areaStore.area.areaCode" />
</div> </div>
<div class="c" id=""> <div class="c" id="">
<topCenter :areaCodes="areaStore.area" :key="areaStore.area.areaCode"></topCenter> <topCenter :areaCodes="areaStore.area" :key="areaStore.area.areaCode"></topCenter>
@ -38,24 +38,22 @@ import bottomLeft from "@/components/index/bottomLeft.vue"
import bottomCenter from "@/components/index/bottomCenter.vue" import bottomCenter from "@/components/index/bottomCenter.vue"
import bottomRight from "@/components/index/bottomRight.vue" import bottomRight from "@/components/index/bottomRight.vue"
import { areaObj } from '@/store/index.js' import { areaObj } from '@/store/index.js'
import { useRouter } from "vue-router" import { useRouter, useRoute } from "vue-router"
const router = useRouter() const route = useRoute()
const showLoading = ref(true) const showLoading = ref(true)
const areaStore = areaObj() const areaStore = areaObj()
const areaCodes = reactive({ const areaCodes = reactive({
...areaStore.area ...areaStore.area
}) })
console.log(areaCodes,'areacodes')
setTimeout(() => { setTimeout(() => {
showLoading.value = false showLoading.value = false
}, 1000); }, 500);
if (route.query?.type) { localStorage.setItem("TRADE_TYPE", true) }
else {
localStorage.setItem("TRADE_TYPE", false)
}
</script> </script>
<style lang="scss"> <style lang="scss">
@keyframes jump { @keyframes jump {

View File

@ -124,24 +124,18 @@
</div> </div>
</div> </div>
<div class="bottom"> <div class="bottom">
<div class="ranking"> <div class="ranking">
<img src="/static/storeLogin/SPXSPH.png" class="img-cls" alt=""> <img src="/static/storeLogin/SPXSPH.png" class="img-cls" alt="">
<dv-scroll-board :config="config1" v-if="config1.data.length" class="list" /> <dv-scroll-board :config="config1" v-if="config1.data.length" class="list" />
</div> </div>
<div class="ranking"> <div class="ranking">
<img src="/static/storeLogin/SPFKPH.png" class="img-cls" alt=""> <img src="/static/storeLogin/SPFKPH.png" class="img-cls" alt="">
<dv-scroll-board :config="config2" v-if="config2.data.length" class="list" /> <dv-scroll-board :config="config2" v-if="config2.data.length" class="list" />
</div> </div>
<div class="ranking"> <div class="ranking">
<img src="/static/storeLogin/SPJGPH.png" class="img-cls" alt=""> <img src="/static/storeLogin/SPJGPH.png" class="img-cls" alt="">
<dv-scroll-board :config="config3" v-if="config3.data.length" class="list" /> <dv-scroll-board :config="config3" v-if="config3.data.length" class="list" />
</div> </div>
</div> </div>
</template> </template>
@ -153,18 +147,12 @@ import { merchant_count_mainApi, merchant_product_rankingApi, merchant_product_v
import { areaObj } from "../store"; import { areaObj } from "../store";
const areaStore = areaObj() const areaStore = areaObj()
let query let query;
let userInfo = JSON.parse(localStorage.getItem('TRADE_USER')) let userInfo = JSON.parse(localStorage.getItem('TRADE_USER'));
let storeLogin=JSON.parse(localStorage.getItem('TRAD_STORE_INFO'))
// console.log
if (areaStore.userInfo.user?.merchant) { if (areaStore.userInfo.user?.merchant) {
let { area_id, mer_id, street_id } = areaStore.userInfo.user?.merchant let { area_id, mer_id, street_id } = areaStore.userInfo.user?.merchant
query = { query = {
areaCode: area_id, areaCode: area_id,
streetCode: street_id, streetCode: street_id,
@ -181,8 +169,14 @@ if (userInfo.user?.merchant) {
} }
} }
if(storeLogin?.merchant){
let { area_id, mer_id, street_id } =storeLogin.merchant
query = {
areaCode: area_id,
streetCode: street_id,
mer_id: mer_id
}
}
const config1 = reactive({ const config1 = reactive({
oddRowBGC: "#001C2E", oddRowBGC: "#001C2E",
@ -289,7 +283,7 @@ const addData1 = (data) => {
`<div style='height:40px;line-height:40px; white-space: nowrap; overflow: hidden;text-overflow: ellipsis;'>${item.cart_info.product.store_name}</div>`, `<div style='height:40px;line-height:40px; white-space: nowrap; overflow: hidden;text-overflow: ellipsis;'>${item.cart_info.product.store_name}</div>`,
`<div style=' transform: translateY(12px); width: 100%; height: 10px; background-color: #122E3F;overflow: hidden;'> <div style=' width:${(item.total / total1) * 100}%;height: 100%; background: linear-gradient(to right, #4459CC, #53CAE2);transition: width 0.5s ease-in-out;'></div> </div>`, `<div style=' transform: translateY(12px); width: 100%; height: 10px; background-color: #122E3F;overflow: hidden;'> <div style=' width:${(item.total / total1) * 100}%;height: 100%; background: linear-gradient(to right, #4459CC, #53CAE2);transition: width 0.5s ease-in-out;'></div> </div>`,
`<div style=' position: relative;line-height:30px;text-align:center;' >${item.total} <span style='font-size:10px'>单</span> `<div style=' position: relative;line-height:30px;text-align:center;' >${item.total} <span style='font-size:10px'>单</span>
<img src="/static/index/PHBBG.png" style="position: absolute;width: 90px;height: 30px; top:0px;left:0px" alt=""> <img src="/index/PHBBG.png" style="position: absolute;width: 90px;height: 30px; top:0px;left:0px" alt="">
</div>`, </div>`,
] ]
) )
@ -309,7 +303,7 @@ const addData2 = (data) => {
`<div style='height:40px;line-height:40px; white-space: nowrap; overflow: hidden;text-overflow: ellipsis;'>${item.store_name}</div>`, `<div style='height:40px;line-height:40px; white-space: nowrap; overflow: hidden;text-overflow: ellipsis;'>${item.store_name}</div>`,
`<div style=' transform: translateY(12px); width: 100%; height: 10px; background-color: #122E3F;overflow: hidden;'> <div style=' width:${(item.total / total2) * 100}%;height: 100%; background: linear-gradient(to right, #4459CC, #53CAE2);transition: width 0.5s ease-in-out;'></div> </div>`, `<div style=' transform: translateY(12px); width: 100%; height: 10px; background-color: #122E3F;overflow: hidden;'> <div style=' width:${(item.total / total2) * 100}%;height: 100%; background: linear-gradient(to right, #4459CC, #53CAE2);transition: width 0.5s ease-in-out;'></div> </div>`,
`<div style=' position: relative;line-height:30px;text-align:center;' >${item.total} <span style='font-size:10px'>人</span> `<div style=' position: relative;line-height:30px;text-align:center;' >${item.total} <span style='font-size:10px'>人</span>
<img src="/static/index/PHBBG.png" style="position: absolute;width: 90px;height: 30px; top:0px;left:0px" alt=""> <img src="/index/PHBBG.png" style="position: absolute;width: 90px;height: 30px; top:0px;left:0px" alt="">
</div>`, </div>`,
] ]
) )
@ -329,14 +323,11 @@ const addData3 = (data) => {
`<div style='height:40px;line-height:40px; white-space: nowrap; overflow: hidden;text-overflow: ellipsis;'>${item.store_name}</div>`, `<div style='height:40px;line-height:40px; white-space: nowrap; overflow: hidden;text-overflow: ellipsis;'>${item.store_name}</div>`,
`<div style=' transform: translateY(12px); width: 100%; height: 10px; background-color: #122E3F;overflow: hidden;'> <div style=' width:${(item.total / total3) * 100}%;height: 100%; background: linear-gradient(to right, #4459CC, #53CAE2);transition: width 0.5s ease-in-out;'></div> </div>`, `<div style=' transform: translateY(12px); width: 100%; height: 10px; background-color: #122E3F;overflow: hidden;'> <div style=' width:${(item.total / total3) * 100}%;height: 100%; background: linear-gradient(to right, #4459CC, #53CAE2);transition: width 0.5s ease-in-out;'></div> </div>`,
`<div style=' position: relative;line-height:30px;text-align:center;' >${item.total} <span style='font-size:10px'>单</span> `<div style=' position: relative;line-height:30px;text-align:center;' >${item.total} <span style='font-size:10px'>单</span>
<img src="/static/index/PHBBG.png" style="position: absolute;width: 90px;height: 30px; top:0px;left:0px" alt=""> <img src="/index/PHBBG.png" style="position: absolute;width: 90px;height: 30px; top:0px;left:0px" alt="">
</div>`, </div>`,
] ]
) )
}) })
} }