[Feature] 显示诗人基本信息
This commit is contained in:
parent
e426e70bc9
commit
a31de8f4f3
|
@ -5,7 +5,11 @@ Component({
|
||||||
*/
|
*/
|
||||||
properties: {
|
properties: {
|
||||||
baseUrl: String,
|
baseUrl: String,
|
||||||
author: Object
|
author: Object,
|
||||||
|
arrow: {
|
||||||
|
type: Boolean,
|
||||||
|
value: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
<t-cell title="{{author.name}}"
|
<t-cell title="{{author.name}}"
|
||||||
arrow
|
arrow="{{arrow}}"
|
||||||
url="/pages/author-detail/author-detail?id={{author.id}}">
|
url="/pages/author-detail/author-detail?id={{author.id}}">
|
||||||
<view slot="left-icon">
|
<view slot="left-icon">
|
||||||
<t-avatar image="{{baseUrl}}{{author.avatar}}" />
|
<t-avatar image="{{baseUrl}}{{author.avatar}}" />
|
||||||
</view>
|
</view>
|
||||||
<view slot="description">
|
<view slot="description">
|
||||||
<text>{{author.name}} </text>
|
<text>{{author.age}} </text>
|
||||||
<text>[{{author.age}}] </text>
|
|
||||||
<text>({{author.born}}</text>
|
<text>({{author.born}}</text>
|
||||||
<text>~{{author.dead?author.dead:'今'}})</text>
|
<text>~{{author.dead?author.dead:'今'}})</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
// components/author-info/author-info.js
|
||||||
|
Component({
|
||||||
|
/**
|
||||||
|
* 组件的属性列表
|
||||||
|
*/
|
||||||
|
properties: {
|
||||||
|
info: Array
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件的初始数据
|
||||||
|
*/
|
||||||
|
data: {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件的方法列表
|
||||||
|
*/
|
||||||
|
methods: {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {
|
||||||
|
"t-empty": "tdesign-miniprogram/empty/empty"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
<view class="author-info">
|
||||||
|
<view class="author-kv"
|
||||||
|
wx:for="{{info}}"
|
||||||
|
wx:for-item="i"
|
||||||
|
wx:key="id">
|
||||||
|
<view class="author-key">{{i.key}}:</view>
|
||||||
|
<view class="author-value">{{i.value}}</view>
|
||||||
|
</view>
|
||||||
|
<t-empty wx:if="{{!info || info.length === 0}}"
|
||||||
|
icon="info-circle-filled"
|
||||||
|
description="暂无作者信息" />
|
||||||
|
</view>
|
|
@ -0,0 +1,20 @@
|
||||||
|
.author-info {
|
||||||
|
padding: 30rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-kv {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-key {
|
||||||
|
color: #0052d9;
|
||||||
|
width: 160rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.author-key {
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
export default {
|
export default {
|
||||||
backstageUrl: 'http://192.168.31.184:8080',
|
backstageUrl: 'http://192.168.31.184:8080',
|
||||||
|
// backstageUrl: 'https://poem.mczhengyi.top/prod-api',
|
||||||
ossUrl: ''
|
ossUrl: ''
|
||||||
}
|
}
|
|
@ -1,66 +1,31 @@
|
||||||
// pages/author-detail/author-detail.js
|
import network from '../../config/network';
|
||||||
|
import request from '../../utils/request'
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面的初始数据
|
|
||||||
*/
|
|
||||||
data: {
|
data: {
|
||||||
|
authorInfo: {},
|
||||||
|
authorId: 0,
|
||||||
|
baseUrl: network.backstageUrl,
|
||||||
|
authorKV: []
|
||||||
|
},
|
||||||
|
/** 获取作者基本信息 */
|
||||||
|
getAuthorInfo(authorId) {
|
||||||
|
request(`/poem/author/${authorId}`).then(res => {
|
||||||
|
this.setData({authorInfo: res.data.data})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/** 获取作者详情信息 */
|
||||||
|
getAuthorDetail(authorId) {
|
||||||
|
request(`/poem/info/list?authorId=${authorId}`).then(res => {
|
||||||
|
let authorDetail = res.data.data
|
||||||
|
this.setData({authorKV: authorDetail})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* 生命周期函数--监听页面加载
|
|
||||||
*/
|
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
|
let authorId = options?.id
|
||||||
},
|
if(!authorId) authorId = 100
|
||||||
|
this.setData({authorId})
|
||||||
/**
|
// 获取作者信息
|
||||||
* 生命周期函数--监听页面初次渲染完成
|
this.getAuthorInfo(authorId)
|
||||||
*/
|
this.getAuthorDetail(authorId)
|
||||||
onReady() {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生命周期函数--监听页面显示
|
|
||||||
*/
|
|
||||||
onShow() {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生命周期函数--监听页面隐藏
|
|
||||||
*/
|
|
||||||
onHide() {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生命周期函数--监听页面卸载
|
|
||||||
*/
|
|
||||||
onUnload() {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面相关事件处理函数--监听用户下拉动作
|
|
||||||
*/
|
|
||||||
onPullDownRefresh() {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面上拉触底事件的处理函数
|
|
||||||
*/
|
|
||||||
onReachBottom() {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户点击右上角分享
|
|
||||||
*/
|
|
||||||
onShareAppMessage() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
|
@ -1,3 +1,8 @@
|
||||||
{
|
{
|
||||||
"usingComponents": {}
|
"usingComponents": {
|
||||||
|
"t-tabs": "tdesign-miniprogram/tabs/tabs",
|
||||||
|
"t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel",
|
||||||
|
"author-card": "/components/author-card/author-card",
|
||||||
|
"author-info": "/components/author-info/author-info"
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,2 +1,18 @@
|
||||||
<!--pages/author-detail/author-detail.wxml-->
|
<view class="author-detail-container">
|
||||||
<text>pages/author-detail/author-detail.wxml</text>
|
<author-card author="{{authorInfo}}"
|
||||||
|
baseUrl="{{baseUrl}}"
|
||||||
|
arrow="{{false}}" />
|
||||||
|
<t-tabs defaultValue="{{0}}">
|
||||||
|
<t-tab-panel label="信息" value="0">
|
||||||
|
<author-info info="{{authorKV}}" />
|
||||||
|
</t-tab-panel>
|
||||||
|
<t-tab-panel label="成就" value="1">
|
||||||
|
</t-tab-panel>
|
||||||
|
<t-tab-panel label="作品" value="2">
|
||||||
|
</t-tab-panel>
|
||||||
|
<t-tab-panel label="生平" value="3">
|
||||||
|
</t-tab-panel>
|
||||||
|
<t-tab-panel label="典故" value="4">
|
||||||
|
</t-tab-panel>
|
||||||
|
</t-tabs>
|
||||||
|
</view>
|
|
@ -35,6 +35,13 @@
|
||||||
"query": "",
|
"query": "",
|
||||||
"launchMode": "default",
|
"launchMode": "default",
|
||||||
"scene": null
|
"scene": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "author-detail",
|
||||||
|
"pathName": "pages/author-detail/author-detail",
|
||||||
|
"query": "id=100",
|
||||||
|
"launchMode": "default",
|
||||||
|
"scene": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue