修复异常
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
const init = () => new Promise(resolve => {
|
||||
const {axios, $glob} = window
|
||||
|
||||
let getAuthing = false
|
||||
const getToken = () => {
|
||||
getAuthing = true
|
||||
@@ -21,11 +20,20 @@ const init = () => new Promise(resolve => {
|
||||
config.headers['h-token'] = $glob.token
|
||||
return config
|
||||
}
|
||||
window.$wait = (t = 500) => new Promise(resolve => setTimeout(resolve, t))
|
||||
http.interceptors.request.use(async config => {
|
||||
while (getAuthing) {
|
||||
await $wait()
|
||||
window.$waitFor = (target, t = 500) => new Promise(resolve => {
|
||||
const interval = setInterval(() => {
|
||||
if (target) {
|
||||
clearInterval(interval)
|
||||
resolve(target)
|
||||
}
|
||||
}, t)
|
||||
if (target) {
|
||||
clearInterval(interval)
|
||||
resolve(target)
|
||||
}
|
||||
})
|
||||
http.interceptors.request.use(async config => {
|
||||
await $waitFor(!getAuthing)
|
||||
if (!$glob.token && !getAuthing) {
|
||||
await getToken()
|
||||
}
|
||||
@@ -33,6 +41,9 @@ const init = () => new Promise(resolve => {
|
||||
})
|
||||
http.interceptors.response.use(res => {
|
||||
if (res?.data) {
|
||||
if (res.data?.code == 6004) {
|
||||
return getToken().then(() => http.request(res.config))
|
||||
}
|
||||
return res.data
|
||||
} else if (res?.code == 401) {
|
||||
return getToken().then(() => http.request(res.config))
|
||||
@@ -42,4 +53,4 @@ const init = () => new Promise(resolve => {
|
||||
window.$http = http
|
||||
resolve()
|
||||
})
|
||||
await init()
|
||||
export default init()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script>
|
||||
const {groupCodeList = ["20010073"]} = window?.$glob?.params || {}
|
||||
export default {
|
||||
name: "AppStoresTable",
|
||||
label: "多店监控",
|
||||
@@ -38,6 +39,11 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
height: '600px',
|
||||
search: {
|
||||
type: '1',
|
||||
categoryId: '104',
|
||||
hourNum: "12"
|
||||
},
|
||||
stores: [],
|
||||
cameras: [],
|
||||
storeKeyGoods: [],
|
||||
@@ -81,26 +87,24 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
getData() {
|
||||
this.stores = this.stores.map(store => {
|
||||
const cameraStore = this.cameras.find(e => e.storeCode == store)
|
||||
const {storeName = "仟吉门店", storeCameraVOList: camera = []} = cameraStore
|
||||
const keyGoods = this.storeKeyGoods.filter(e => e.storeCode == store)
|
||||
const categorySale = this.categorySales.filter(e => e.storeCode == store)
|
||||
return {storeName, camera: camera.map(e => e.url), keyGoods, categorySale}
|
||||
this.stores = this.stores.map(({storeName, storeCode, storeCameraVOList = []}) => {
|
||||
const keyGoods = this.storeKeyGoods.filter(e => e.storeCode == storeCode)
|
||||
const categorySale = this.categorySales.filter(e => e.storeCode == storeCode)
|
||||
return {storeCode, storeName, camera: storeCameraVOList.map(e => e.url), keyGoods, categorySale}
|
||||
})
|
||||
},
|
||||
getCameras() {
|
||||
return $http.post("/api/store/camera/list", {
|
||||
storeCodes: this.stores
|
||||
return $http.post("/data-boot/la/screen/multipleStoreBoard/storeCamera", {
|
||||
...this.search, groupCodeList
|
||||
}).then(res => {
|
||||
if (res?.data) {
|
||||
this.cameras = res.data?.records || []
|
||||
this.stores = res.data?.records || []
|
||||
}
|
||||
})
|
||||
},
|
||||
getStoreKeyGoods() {
|
||||
return $http.post("/api/store/camera/list", {
|
||||
storeCodes: this.stores
|
||||
return $http.post("/data-boot/la/screen/multipleStoreBoard/storeKeyGoods", {
|
||||
...this.search, groupCodeList
|
||||
}).then(res => {
|
||||
if (res?.data) {
|
||||
this.storeKeyGoods = res.data
|
||||
@@ -108,21 +112,25 @@ export default {
|
||||
})
|
||||
},
|
||||
getCategorySales() {
|
||||
return $http.post("/api/store/camera/list", {
|
||||
storeCodes: this.stores
|
||||
return $http.post("/data-boot/la/screen/multipleStoreBoard/categorySale", {
|
||||
...this.search, groupCodeList
|
||||
}).then(res => {
|
||||
if (res?.data) {
|
||||
this.categorySales = res.data
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
gotoDetail(store) {
|
||||
$glob.query = {storeCode: store.storeCode}
|
||||
$glob.group = "9f299712-5549-413b-a93b-7c3e3b5bfadb"
|
||||
},
|
||||
},
|
||||
async mounted() {
|
||||
mounted() {
|
||||
this.height = `${this.$el.clientHeight}px`
|
||||
this.stores = JSON.parse(window.$glob.stores || "[]")
|
||||
while (!$http) await $wait()
|
||||
Promise.all([this.getCameras(), this.getStoreKeyGoods(), this.getCategorySales()]).then(() => this.getData())
|
||||
setTimeout(() => {
|
||||
const {$http, $waitFor} = window
|
||||
$waitFor($http).then(() => Promise.all([this.getCameras(), this.getStoreKeyGoods(), this.getCategorySales()])).then(() => this.getData())
|
||||
}, 2000)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -132,8 +140,8 @@ export default {
|
||||
<el-carousel indicator-position="none" :height="height" :autoplay="false">
|
||||
<el-carousel-item v-for="(group,i) in storeList" :key="i">
|
||||
<div class="layout">
|
||||
<div class="store" v-for="store in group" :key="store.id">
|
||||
<div class="header" v-text="store.storeName"/>
|
||||
<div class="store" v-for="store in group" :key="store.storeCode">
|
||||
<div class="header" v-text="store.storeName" @click="gotoDetail(store)"/>
|
||||
<el-carousel indicator-position="none" height="250px">
|
||||
<el-carousel-item v-for="(url,j) in store.camera" :key="[i,j].join('_')">
|
||||
<hls-player :url="url"/>
|
||||
@@ -156,7 +164,6 @@ export default {
|
||||
</div>
|
||||
</el-carousel-item>
|
||||
</el-carousel>
|
||||
|
||||
</section>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export default defineConfig({
|
||||
server: {
|
||||
port: 9000,
|
||||
proxy: {
|
||||
'/api': {
|
||||
'/data-boot': {
|
||||
target: 'http://10.0.97.209',
|
||||
changeOrigin: true,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user