Init project
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
<template>
|
||||
<view class="v4-project-list">
|
||||
<view class="search-box flex jc-between ai-center">
|
||||
<input type="text" v-model="keyword" placeholder="请输入项目名称"/>
|
||||
<view class="btn flex jc-center ai-center" @click="search">
|
||||
<image :src="webUrl+'/20221019150834639123.png'"/>
|
||||
<text>搜索</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="item flex jc-between ai-center" v-for="(item,index) in list" :key="index" @click="getDetail(item.id)">
|
||||
<view class="flex ai-center">
|
||||
<image class="cover" :src="item.coverImage"/>
|
||||
<text>{{ item.name }}</text>
|
||||
</view>
|
||||
|
||||
<image class="icon" :src="webUrl+'/20220903145836941399.png'"/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {investmentInfo, investmentList} from "@/api/shop";
|
||||
|
||||
export default {
|
||||
name: "projectList",
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
page: 1, // 当前页
|
||||
keyword: "", // 搜索词
|
||||
pages: 0, // 总页数
|
||||
list: [],
|
||||
os: ""
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getOS();
|
||||
this.getData();
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.pages >= this.page) this.getData();
|
||||
},
|
||||
methods: {
|
||||
getOS() {
|
||||
uni.getSystemInfo({
|
||||
success: result => this.os = result.osName
|
||||
})
|
||||
},
|
||||
|
||||
search() {
|
||||
this.list = [];
|
||||
this.page = 1;
|
||||
this.getData();
|
||||
},
|
||||
|
||||
getData() {
|
||||
investmentList(this.page, this.keyword).then(({data}) => {
|
||||
this.pages = data.pages;
|
||||
this.page++;
|
||||
if (data.records.length > 0) {
|
||||
data.records.map(item => {
|
||||
this.list.push(item);
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getDetail(id) {
|
||||
investmentInfo(id).then(({data}) => {
|
||||
const file = data.contents[0];
|
||||
if (file.suffix === "pdf" && this.os === "android") {
|
||||
this.viewPdf(file.attachmentFiles[0])
|
||||
} else {
|
||||
let path = file.attachmentFiles[0];
|
||||
uni.navigateTo({
|
||||
url: "/pkg_common/views/pdf?path=" + encodeURI(path)
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
viewPdf(url) {
|
||||
uni.downloadFile({
|
||||
url,//可以是后台传过来的路径
|
||||
success: res => {
|
||||
const filePath = res.tempFilePath
|
||||
uni.openDocument({
|
||||
filePath,
|
||||
fileType: "pdf",
|
||||
success: result => {
|
||||
//成功
|
||||
},
|
||||
fail: err => {
|
||||
uni.showModal({
|
||||
title: "openDocument fail",
|
||||
content: JSON.stringify(err)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
uni.showModal({
|
||||
title: "downloadFile fail",
|
||||
content: JSON.stringify(err)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.v4-project-list {
|
||||
.search-box {
|
||||
height: 80rpx;
|
||||
margin: 40rpx 32rpx;
|
||||
box-sizing: border-box;
|
||||
padding: 0 16rpx 0 32rpx;
|
||||
background: #fff;
|
||||
border-radius: 40rpx;
|
||||
font-size: 24rpx;
|
||||
|
||||
image {
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 128rpx;
|
||||
height: 54rpx;
|
||||
background: #FD574B;
|
||||
border-radius: 28rpx;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.item {
|
||||
height: 160rpx;
|
||||
box-sizing: border-box;
|
||||
margin: 40rpx 32rpx;
|
||||
padding: 0 16rpx 0 28rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.16);
|
||||
border-radius: 8rpx;
|
||||
|
||||
.cover {
|
||||
width: 160rpx;
|
||||
height: 88rpx;
|
||||
margin-right: 40rpx;
|
||||
}
|
||||
|
||||
text {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user