137 lines
4.6 KiB
Vue
137 lines
4.6 KiB
Vue
<template>
|
||
<div>
|
||
<el-row>
|
||
<el-col :span="24" style="border: 5px solid #ebeef5;">
|
||
<div class="grid-content bg-purple-dark">
|
||
<span>我的API</span>
|
||
<el-divider></el-divider>
|
||
<el-row>
|
||
<el-col :span="20"><div class="grid-content bg-purple">
|
||
<el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
|
||
<!-- <el-select v-model="ruleForm.productState" placeholder="请选择状态">-->
|
||
<!-- <el-option-->
|
||
<!-- v-for="item in options"-->
|
||
<!-- :key="item.value"-->
|
||
<!-- :label="item.label"-->
|
||
<!-- :value="item.value">-->
|
||
<!-- </el-option>-->
|
||
<!-- </el-select>-->
|
||
<el-input type="text" v-model="ruleForm.productName" style="width: 200px" autocomplete="off" placeholder="名称搜索"></el-input>
|
||
<el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
|
||
</el-form>
|
||
</div></el-col>
|
||
</el-row>
|
||
|
||
<el-row :gutter="12">
|
||
<el-col :span="8" v-for="myapi in myapiList" :key="index" >
|
||
<el-card class="box-card" >
|
||
<div slot="header" class="clearfix">
|
||
<el-form ref="form" :model="myapi" label-width="120px" :rules="rules">
|
||
<el-form-item label="产品名称">
|
||
<el-input v-model="myapi.productName">{{myapi.productName}}}</el-input>
|
||
</el-form-item>
|
||
<el-form-item label="产品价格">
|
||
<el-input v-model="myapi.productPrice">{{myapi.productPrice}}}</el-input>
|
||
</el-form-item>
|
||
<el-form-item label="产品介绍">
|
||
<el-input v-model="myapi.productContent">{{myapi.productContent}}}</el-input>
|
||
</el-form-item>
|
||
<el-row>
|
||
<el-col :span="6"><div class="grid-content bg-purple">
|
||
<el-button type="success" @click="test(myapi)">使用</el-button>
|
||
</div></el-col>
|
||
</el-row>
|
||
</el-form>
|
||
</div>
|
||
</el-card>
|
||
</el-col>
|
||
</el-row>
|
||
</div>
|
||
</el-col>
|
||
</el-row>
|
||
|
||
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等),
|
||
//例如:import 《组件名称》 from '《组件路径》,
|
||
import myapi from "@/views/market/myapi/index.vue";
|
||
import {selectmyapiList} from "@/api/market/myapi";
|
||
|
||
export default {
|
||
name: 'Myapi',
|
||
//import引入的组件需要注入到对象中才能使用"
|
||
components: {},
|
||
props: {},
|
||
data() {
|
||
//这里存放数据"
|
||
|
||
return {
|
||
myapiList:[],
|
||
myapi:{},
|
||
ruleForm:{},
|
||
value: ''
|
||
};
|
||
},
|
||
//计算属性 类似于data概念",
|
||
computed: {
|
||
myapi() {
|
||
return myapi
|
||
}
|
||
},
|
||
//监控data中的数据变化",
|
||
watch: {},
|
||
//方法集合",
|
||
methods: {
|
||
//我购买的api列表
|
||
getList(){
|
||
selectmyapiList(this.ruleForm).then(response=>{
|
||
console.log(response)
|
||
this.myapiList=response.data
|
||
})
|
||
},
|
||
//查询
|
||
submitForm(){
|
||
this.getList()
|
||
},
|
||
//测试
|
||
test(myapi) {
|
||
// 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实例)",
|
||
created() {
|
||
this.getList()
|
||
},
|
||
//生命周期 - 挂载完成(可以访问DOM元素)",
|
||
mounted() {
|
||
},
|
||
beforeCreate() {
|
||
}, //生命周期 - 创建之前",
|
||
beforeMount() {
|
||
}, //生命周期 - 挂载之前",
|
||
beforeUpdate() {
|
||
}, //生命周期 - 更新之前",
|
||
updated() {
|
||
}, //生命周期 - 更新之后",
|
||
beforeDestroy() {
|
||
}, //生命周期 - 销毁之前",
|
||
destroyed() {
|
||
}, //生命周期 - 销毁完成",
|
||
activated() {
|
||
} //如果页面有keep-alive缓存功能,这个函数会触发",
|
||
};
|
||
</script>
|
||
<style scoped>
|
||
|
||
</style>
|