cloud-web/src/views/market/myapi/index.vue

137 lines
4.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<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第三方插件jsjson文件图片文件等等,
//例如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>