新增三个接口调用

pull/7/head^2
WeiRan 2024-08-30 09:28:45 +08:00
parent 0df439daaa
commit ecead0f5bf
9 changed files with 329 additions and 59 deletions

View File

@ -0,0 +1,40 @@
import request from "@/utils/request";
//发送邮箱验证码
export function apitest(email){
return request({
url:"/market/company/sendcode/"+email,
method: "POST",
})
}
export function sendrequest(options){
// 确保options是一个对象并且包含必要的属性
if (!options || typeof options !== 'object' || !options.apiRouter || typeof options.parameter === 'undefined') {
throw new Error('Invalid options: must be an object with apiRouter and optional parameter properties');
}
// 构建完整的URL
const fullUrl = `/background/api/${options.apiRouter}/${options.parameter || ''}`;
return request({
url:fullUrl,
method: "get",
data: options.parameter,
})
}
export function sendrequest1(options){
// 确保options是一个对象并且包含必要的属性
if (!options || typeof options !== 'object' || !options.apiRouter ) {
throw new Error('Invalid options: must be an object with apiRouter ');
}
// 构建完整的URL
const fullUrl = `/background/api/${options.apiRouter}`;
return request({
url:fullUrl,
method: "post",
data: options
})
}

View File

@ -0,0 +1,8 @@
import request from "@/utils/request";
export function companyauthentication(data){
return request({
url:"/market/company/companyauthentication",
method: "POST",
data: data
})
}

View File

@ -1,5 +1,15 @@
import request from "@/utils/request";
//发送邮箱验证码
export function sendcode(email){
return request({
url:"/market/company/sendcode/"+email,
method: "POST",
})
}
//绑定邮箱
export function linkemail(data){
return request({
url:"/market/company/list",

View File

@ -120,11 +120,11 @@
<template slot-scope="scope">
<el-button
size="mini"
@click="handleEdit(scope.$index, scope.row)">编辑</el-button>
@click="handleEdit(scope.$index, scope.row)">审核通过</el-button>
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)">删除</el-button>
@click="handleDelete(scope.$index, scope.row)">审核不通过</el-button>
</template>
</el-table-column>
</el-table>

View File

@ -12,9 +12,13 @@
<el-form-item label="产品介绍:">
{{myapi.productContent}}
</el-form-item>
<el-form-item label="重要路由:">
{{myapi.apiRouter}}
</el-form-item>
<el-row>
<el-col :span="24"><div class="grid-content bg-purple-dark">
<el-button type="info" @click="test()"></el-button>
<el-button type="info" @click="test(myapi)"></el-button>
<el-button type="primary">立即申请</el-button>
</div></el-col>
</el-row>
@ -22,34 +26,33 @@
</div></el-col>
</el-row>
<el-divider></el-divider>
<el-row class="first-row" >
<el-col :span="24"><div class="grid-content bg-purple-dark" >
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="API文档" name="first">
<el-form ref="form" :model="myapi" label-width="120px" :rules="rules">
<el-form-item label="接口地址:" >
{{myapi.productName}}
{{myapi.apiAddress}}
</el-form-item>
<el-form-item label="返回格式:">
{{myapi.productPrice}}/
{{myapi.returnFormat}}/
</el-form-item>
<el-form-item label="请求方式:">
{{myapi.productContent}}
</el-form-item>
<el-form-item label="简介:">
{{myapi.productContent}}
{{myapi.requestMethod}}
</el-form-item>
<el-form-item label="请求参数说明:">
{{myapi.productContent}}
</el-form-item>
<el-form-item label="返回参数说明:">
{{myapi.productContent}}
</el-form-item>
<el-form-item label="JSON返回示例:">
{{myapi.productContent}}
</el-form-item>
<el-form-item label="XML返回示例:">
{{myapi.productContent}}
</el-form-item>
</el-form>
</el-tab-pane>
@ -58,13 +61,70 @@
</el-tabs>
</div></el-col>
</el-row>
<!--测试对话框-->
<el-dialog
title="接口测试"
:visible.sync="dialogVisible"
width="30%"
:before-close="handleClose">
<el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="接口名称" prop="pass">
<el-input type="text" v-model="ruleForm.productName" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="接口地址" prop="pass">
<el-input type="text" v-model="ruleForm.apiAddress" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="请求方式" prop="pass">
<el-input type="text" v-model="ruleForm.requestMethod" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="请求参数" prop="pass" v-if="ruleForm.productName!==''" >
<el-input type="text" v-model="ruleForm.parameter" autocomplete="off"></el-input>
</el-form-item>
<div v-if="ruleForm.productName=='新闻头条'">
<el-form-item label="type" prop="pass" >
<el-input type="text" v-model="ruleForm.type" autocomplete="off"></el-input>
<span>说明支持类型top(推荐,默认)guonei(国内)guoji(国际)yule(娱乐)tiyu(体育)junshi(军事)keji(科技)caijing(财经)youxi(游戏)qiche(汽车)jiankang(健康)</span>
</el-form-item>
<el-form-item label="page" prop="pass" >
<el-input type="text" v-model="ruleForm.page" autocomplete="off"></el-input>
<span>说明当前页数, 默认1, 最大50</span>
</el-form-item>
<el-form-item label="page_size" prop="pass" >
<el-input type="text" v-model="ruleForm.pageSize" autocomplete="off"></el-input>
<span>说明每页返回条数, 默认30 , 最大30</span>
</el-form-item>
<el-form-item label="is_filter" prop="pass" >
<el-input type="text" v-model="ruleForm.isFilter" autocomplete="off"></el-input>
<span>说明是否只返回有内容详情的新闻, 1:, 默认0</span>
</el-form-item>
</div>
<el-form-item v-if="ruleForm.productName!=='新闻头条'">
<el-button type="primary" @click="submitForm(ruleForm)"></el-button>
</el-form-item>
<el-form-item v-if="ruleForm.productName=='新闻头条'">
<el-button type="primary" @click="newsForm(ruleForm)"></el-button>
</el-form-item>
</el-form>
<pre id="json-display">
</pre>
<ul id="news-list">
<!-- 这里将动态插入新闻项 -->
</ul>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">返回</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
//jsjsjson,
//import from ',
export default {
import {sendrequest, sendrequest1} from "@/api/apitest/apitest";
export default {
name: "Apitest",
//import使"
components: {},
@ -78,7 +138,9 @@
productPrice: '',
productContent: ''
},
activeName: 'first'
activeName: 'first',
dialogVisible: false,
ruleForm:{}
};
},
// data",
@ -90,6 +152,93 @@
//
handleClick(tab, event) {
console.log(tab, event);
},
//
test(myapi){
this.dialogVisible=true
this.ruleForm={
productName: myapi.productName,
apiAddress: myapi.apiAddress,
requestMethod: myapi.requestMethod,
apiRouter: myapi.apiRouter
}
},
//
handleClose(done) {
this.$confirm('确认关闭?')
.then(_ => {
done();
})
.catch(_ => {});
},
//
submitForm(ruleForm){
sendrequest(ruleForm).then(response=>{
const jsonData = response.data;
// 使JSON.stringify()JSON2
const formattedJson = JSON.stringify(jsonData, null, 2);
// <pre>innerHTMLJSON
document.getElementById('json-display').innerHTML = formattedJson;
})
},
//
newsForm(ruleForm) {
sendrequest1(ruleForm).then(response => {
console.log(response)
const jsonData1 = response.data; // response.dataJSON
// JSONJavaScript
const jsonData = JSON.parse(jsonData1);
//
var container = document.getElementById('news-list');
//
container.innerHTML = '';
// div
var resultDiv = document.createElement('div');
// jsonData.reason
if (jsonData.reason !== undefined) {
// reason
resultDiv.innerHTML += '<h2>Reason: ' + jsonData.reason.replace(/!/g, '') + '</h2>';
} else {
resultDiv.innerHTML += '<h2>Reason: Not available</h2>';
}
// jsonData.result
if (jsonData.result !== undefined) {
//
resultDiv.innerHTML += '<p>Stat: ' + jsonData.result.stat + '</p>';
resultDiv.innerHTML += '<p>Page: ' + jsonData.result.page + '</p>';
resultDiv.innerHTML += '<p>Page Size: ' + jsonData.result.pageSize + '</p>';
// jsonData.result.data
if (Array.isArray(jsonData.result.data)) {
// HTML
jsonData.result.data.forEach(item => {
resultDiv.innerHTML += `
<div>
<h3>${item.title}</h3>
<p>Unique Key: ${item.uniquekey}</p>
<p>Date: ${item.date}</p>
<p>Category: ${item.category}</p>
<p>Author: ${item.author_name}</p>
<p>URL: <a href="${item.url.replace(/\\/g, '')}">${item.url}</a></p>
</div>
`;
});
} else {
resultDiv.innerHTML += '<p>No data available.</p>';
}
} else {
resultDiv.innerHTML += '<p>Result information is not available.</p>';
}
// div
container.appendChild(resultDiv);
});
}
},
// - 访this",
@ -128,4 +277,13 @@
.first-row {
margin-bottom: 20px; /* 创建一个空间,以便可以清晰地看到边框 */
}
pre {
background-color: #f4f4f4; /* 浅灰色背景 */
border: 1px solid #ddd; /* 边框 */
padding: 10px; /* 内边距 */
overflow-x: auto; /* 水平滚动条(如果需要的话) */
white-space: pre-wrap; /* 保留空白符序列,但是正常地进行换行 */
word-wrap: break-word; /* 防止长单词或URL地址破坏布局 */
font-family: monospace, Menlo, Courier, 'Courier New', monospace; /* 使用等宽字体 */
}
</style>

View File

@ -58,10 +58,47 @@
<el-dialog
:title="dialogtitle"
:visible.sync="dialogVisible"
width="30%"
width="50%"
:before-close="handleClose">
<!--个人认证-->
<div v-if="this.index==1">
<h2>基本信息填写</h2><br>
<el-form :model="personForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="实名认证附件上传:" prop="pass">
<el-upload
action="/dev-api/market/user/upload"
list-type="picture-card"
:on-preview="handlePictureCardPreview"
:on-remove="handleRemove"
:on-success="handleSuccess1"
:limit="2">
<i class="el-icon-plus"></i>
</el-upload>
<el-dialog :visible.sync="dialogVisiblepicture">
<img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>
<span>请上传清晰完整的营业执照副本照片</span>
</el-form-item>
<el-form-item label="公司名称:" prop="companyName">
<el-input type="text" v-model="personForm.companyName" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="真实姓名:" prop="USCI">
<el-input type="text" v-model="personForm.USCI" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="证件类型:" prop="companyLeader">
<span>居民身份证</span>
</el-form-item>
<el-form-item label="证件号码:" prop="registrantName">
<el-input type="text" v-model="personForm.registrantName" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="手机号码:" prop="registrantPhone">
<el-input type="text" v-model="personForm.registrantPhone" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<center>
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="personyes()"></el-button>
</center>
</div>
<!--企业认证-->
@ -74,7 +111,8 @@
list-type="picture-card"
:on-preview="handlePictureCardPreview"
:on-remove="handleRemove"
:on-success="handleSuccess">
:on-success="handleSuccess"
:limit="1">
<i class="el-icon-plus"></i>
</el-upload>
<el-dialog :visible.sync="dialogVisiblepicture">
@ -104,11 +142,12 @@
<el-input type="text" v-model="companyForm.companyAddress" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<center>
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="companyyes(companyForm)"></el-button>
</center>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="yes()"></el-button>
</span>
</el-dialog>
</div>
@ -130,6 +169,9 @@
index:'',
dialogtitle:'',
companyForm:{},
personForm:{
personCardPicture:[]
},
dialogImageUrl: '',
dialogVisiblepicture: false
};
@ -158,8 +200,14 @@
})
.catch(_ => {});
},
yes(){
this.index=''
//
personyes(){
this.dialogVisible=false
},
//
companyyes(companyForm){
companyauthentication()
this.dialogVisible=false
},
//
@ -170,8 +218,16 @@
this.dialogImageUrl = file.url;
this.dialogVisible = true;
},
//
handleSuccess(response,file,fileList){
this.companyForm.businessLicense=response.data
},
//
handleSuccess1(response,file,fileList){
this.personForm.personCardPicture=[]
for(const i in fileList){
this.personForm.personCardPicture.push(fileList[i]).response.data
}
}
},
// - 访this",

View File

@ -29,12 +29,16 @@
<el-dialog
title="邮箱绑定"
:visible.sync="dialogVisible"
width="30%"
width="50%"
:before-close="handleClose">
<el-form :model="EmailForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="邮箱" prop="email">
<el-input type="text" v-model="EmailForm.email" autocomplete="off" placeholder="请输入绑定的邮箱"></el-input>
</el-form-item>
<el-form-item>
<el-input type="text" v-model="EmailForm.code" placeholder="请输入验证码"></el-input>
<button type="primary" @click="docode(EmailForm.email)"></button>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
@ -47,7 +51,7 @@
<script>
//jsjsjson,
//import from ',
import {linkemail} from "@/api/authentication/message";
import {linkemail, sendcode} from "@/api/authentication/message";
export default {
name: "Easymessage",
@ -81,6 +85,12 @@ export default {
})
.catch(_ => {});
},
//
docode(email){
sendcode(email).then(response=>{
alert(response.data)
})
},
//
yes(EmailForm){
linkemail(EmailForm).then(response=>{

View File

@ -73,19 +73,6 @@ export default {
myapiList:[],
myapi:{},
ruleForm:{},
options: [{
value: '选项1',
label: '全部'
}, {
value: '选项2',
label: '申请中'
}, {
value: '选项3',
label: '申请通过'
}, {
value: '选项4',
label: '审核失败'
}],
value: ''
};
},
@ -102,6 +89,7 @@ export default {
//api
getList(){
selectmyapiList(this.ruleForm).then(response=>{
console.log(response)
this.myapiList=response.data
})
},
@ -111,13 +99,14 @@ export default {
},
//
test(myapi) {
if (myapi && myapi.productAddress) {
let url = myapi.productAddress; // 使 product.address
window.open(url, '_blank'); // URL
} else {
console.error('无效的 address 或 product 未定义');
//
}
// if (myapi && myapi.productAddress) {
// let url = myapi.productAddress; // 使 product.address
// window.open(url, '_blank'); // URL
// } else {
// console.error(' address product ');
// //
// }
this.$router.push({path:"/apitest/index",query:{myapi:JSON.stringify(myapi)}})
}
},
// - 访this",

View File

@ -34,6 +34,9 @@
<el-form-item label="产品介绍:">
<el-textarea v-model="product.productContent">{{product.productContent}}</el-textarea>
</el-form-item>
<el-form-item label="重要路由:">
<el-textarea v-model="product.apiRouter">{{product.apiRouter}}</el-textarea>
</el-form-item>
<el-row>
<el-col :span="9"><div class="grid-content bg-purple">
<el-button type="primary" @click="test(product)"></el-button>
@ -128,22 +131,18 @@ export default {
this.getList()
},
//
// test(product){
// // let url = `http://21.12.0.10/prod-api/doc.html#/cloud-market//findListByuserPhone?userId=${this.userId}`;
// let url = `product`;
// window.open(url, '_blank'); // URL
//
// // this.$router.push({path:"/apitest/index",query:{myapi:JSON.stringify(product)}})
// },
test(product) {
if (product && product.productAddress) {
let url = product.productAddress; // 使 product.address
window.open(url, '_blank'); // URL
} else {
console.error('无效的 address 或 product 未定义');
//
}
test(product){
this.$router.push({path:"/apitest/index",query:{myapi:JSON.stringify(product)}})
},
// test(product) {
// if (product && product.productAddress) {
// let url = product.productAddress; // 使 product.address
// window.open(url, '_blank'); // URL
// } else {
// console.error(' address product ');
// //
// }
// },
handleSizeChange(val) {
console.log(`每页 ${val}`);
this.ruleForm.pageSize=val