临时代码

main
RogerWork 11 months ago
parent b58dd22a6e
commit 4740477210
  1. 20
      src/apis/mock.js
  2. 2
      src/request/config.js
  3. 3
      src/request/index.js
  4. 63
      src/views/mock/index.vue

@ -34,3 +34,23 @@ export const set_overtime_config = (params) => {
params: req_params
})
}
export const start_mock = (params,data) => {
console.log(params)
return request({
url: 'api/start_mock',
method: 'post',
params: params,
data: data
})
}
export const end_mock = (params) => {
console.log(params)
return request({
url: 'api/end_mock',
method: 'get',
params: params,
})
}

@ -1,5 +1,5 @@
export default {
method: 'get',
// method: 'get',
baseURL: 'http://127.0.0.1:8000',
headers: {
'Content-Type': 'application/json;charset=UTF-8',

@ -5,10 +5,11 @@ import config from "@/request/config.js";
// import router from "@/router";
function request(options) {
console.log(options)
const instance = axios.create({...config})
options = {...options, instance} // 使用创建的实例
console.log(options)
// 请求拦截器
instance.interceptors.request.use(
config => {

@ -1,14 +1,14 @@
<script setup>
import {cinema_list} from '@/apis/update.js';
import {get_overtime_show_info, get_response_json, set_overtime_config} from "@/apis/mock.js";
import {onMounted} from "vue";
import {end_mock, get_overtime_show_info, get_response_json, set_overtime_config, start_mock} from "@/apis/mock.js";
import {onMounted, onBeforeUnmount} from "vue";
import {ref, computed} from "vue";
import {InfoFilled} from "@element-plus/icons-vue";
import JsonEditorVue from "json-editor-vue3";
const mockConfigPost = ref()
let cinema_items = ref([]);
const select_ip = ref('')
const selectIp = ref('')
const checkAll = ref(false)
const isIndeterminate = ref(false)
@ -33,7 +33,7 @@ const tabs_array = computed(() => {
tabs.push(tab_item)
}
})
console.log(select_ip.value)
console.log(selectIp.value)
return tabs
})
@ -84,7 +84,7 @@ const handleIpChange = () => {
}
const handleCheckAllChange = (val) => {
if (select_ip.value === '') {
if (selectIp.value === '') {
alert('请先选择测试影院IP!')
checkedMockConfig.value = []
checkAll.value = false
@ -98,7 +98,7 @@ const handleCheckAllChange = (val) => {
}
const handleCheckedMockChange = (value) => {
if (select_ip.value === '') {
if (selectIp.value === '') {
alert('请先选择测试影院IP!')
checkedMockConfig.value = []
checkAll.value = false
@ -166,7 +166,7 @@ const handleOvertimeConfigChange = () => {
//
const handleOvertimeConfigSave = () => {
if (selectedOvertimeShowType.value !== '' && selectedShowInfo.value !== '' && selectedStatus.value !== '') {
const params = {ip: select_ip.value, show_id: selectedShowInfo.value, audit_status: selectedStatus.value}
const params = {ip: selectIp.value, show_id: selectedShowInfo.value, audit_status: selectedStatus.value}
set_overtime_config(params).then(res => {
console.log(res)
}).catch(err => {
@ -178,7 +178,7 @@ const handleOvertimeConfigSave = () => {
// 退select
async function getOvertimeShowInfo() {
await get_overtime_show_info({ip: select_ip.value}).then(
await get_overtime_show_info({ip: selectIp.value}).then(
res => {
sellShowInfo.value = [...res['sell']]
refundShowInfo.value = [...res['refund']]
@ -201,7 +201,7 @@ function getResponseJson() {
mockConfigItems.forEach(
(api, index) => {
const req = {
ip: select_ip.value,
ip: selectIp.value,
api: api
}
if (api === 'download_film_info') {
@ -260,10 +260,11 @@ function getResponseJson() {
// json
const getOvertimeResponseJson = () => {
const req = {
ip: select_ip.value,
ip: selectIp.value,
api: 'get_overtime_ticket_status',
sessionCode: selectedShowInfo.value,
overtimeType: selectedOvertimeShowType.value === 'sell' ? '1' : '2'
show: selectedShowInfo.value,
type: selectedOvertimeShowType.value === 'sell' ? '0' : '1',
status: selectedStatus.value
}
get_response_json(req).then(res => {
allJsonData.value.get_overtime_ticket_status = res
@ -272,6 +273,7 @@ const getOvertimeResponseJson = () => {
})
}
//
const checkedItemsOrdered = computed(() => {
let temp = []
mockConfigItems.forEach(
@ -284,6 +286,12 @@ const checkedItemsOrdered = computed(() => {
return temp
})
const handleRunningChange = () => {
if (running.value === true) {
alert('开始模拟后修改的接口不会被模拟,如果需要修改接口模拟参数,请停止后再修改!')
}
}
// Json
const json_data = computed(
{
@ -297,6 +305,7 @@ const json_data = computed(
)
//
const running = ref(false)
const startBtn_disable = ref(false)
const startBtn_loading = ref(false)
@ -304,13 +313,36 @@ const handleStart = () => {
console.log(selectedOvertimeShowType.value)
console.log(selectedShowInfo.value)
console.log(selectedStatus.value)
if (checkedMockConfig.value.indexOf('get_overtime_ticket_status') >= 0) {
if (selectedOvertimeShowType.value === '' || selectedShowInfo.value === '' || selectedStatus.value === '') {
alert('请先设置‘超时票务查询’中的选项!')
return
}
}
running.value = true
startBtn_disable.value = true
startBtn_loading.value = true
const params = {ip: selectIp.value}
let mock_config = {}
mockConfigItems.forEach((item) => {
mock_config[item]= checkedMockConfig.value.indexOf(item) >= 0
})
console.log(mock_config)
const data = JSON.stringify({mock_config: mock_config})
console.log(data)
start_mock(params, data).then(res => {
}).catch(err => {
})
}
const handleEnd = () => {
running.value = false
startBtn_disable.value = false
startBtn_loading.value = false
const params = {ip: selectIp.value}
end_mock(params).then(res => {
}).catch(err => {
})
}
@ -321,6 +353,7 @@ onMounted(
}
)
</script>
<template>
@ -329,7 +362,7 @@ onMounted(
>
<el-row justify="start">
<el-col :span="4">
<el-select v-model="select_ip" class="m-2" placeholder="选择要模拟的影院IP" @change="handleIpChange">
<el-select v-model="selectIp" class="m-2" placeholder="选择要模拟的影院IP" @change="handleIpChange">
<el-option
v-for="item in cinema_items.value"
:key="item.value"
@ -346,7 +379,7 @@ onMounted(
title="接口设置说明:"
:width="400"
trigger="hover"
content="勾选需要测试的接口,点击‘开始’,启动对应单机的接口模拟,未勾选的接口会直接穿透到专资"
content="勾选需要测试的接口,点击‘开始’,启动对应单机的接口模拟,未勾选的接口会直接穿透到专资。需要指定接口的返回参数,可以在最下方编辑器中修改。"
>
<template #reference>
<el-icon>
@ -427,7 +460,7 @@ onMounted(
</el-col>
</el-row>
</div>
<JsonEditorVue class="editor" v-model="json_data" language="zh-CN"/>
<JsonEditorVue class="editor" v-model="json_data" language="zh-CN" @change="handleRunningChange"/>
</el-tab-pane>
</el-tabs>
</div>

Loading…
Cancel
Save