feat: 调整样式
This commit is contained in:
@@ -13,16 +13,26 @@ Page({
|
||||
showImageSheet: false,
|
||||
imageSheetItems: [
|
||||
{ label: '拍照', value: 'camera' },
|
||||
{ label: '从相册选择', value: 'album' }
|
||||
]
|
||||
{ label: '从相册选取', value: 'album' }
|
||||
],
|
||||
topicColors: ['#558B2F', '#1976D2', '#7B1FA2', '#F57C00', '#C2185B', '#00796B'],
|
||||
topicBgColors: ['#E8F5E9', '#E3F2FD', '#F3E5F5', '#FFF3E0', '#FCE4EC', '#E0F2F1']
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
// No draft loading
|
||||
this.fetchTopics();
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
// No draft saving
|
||||
fetchTopics() {
|
||||
request.get('/topic/list').then(res => {
|
||||
const list = res.list || [];
|
||||
const topics = list.map(t => t.title);
|
||||
if (topics.length > 0) {
|
||||
this.setData({ suggestedTopics: topics });
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error('Fetch topics failed', err);
|
||||
});
|
||||
},
|
||||
|
||||
onContentInput(e) {
|
||||
@@ -105,7 +115,6 @@ Page({
|
||||
itemList: ['设为封面', '删除'],
|
||||
success: (res) => {
|
||||
if (res.tapIndex === 0) {
|
||||
// Move to first position
|
||||
const images = [...this.data.images];
|
||||
const [img] = images.splice(index, 1);
|
||||
images.unshift(img);
|
||||
@@ -121,14 +130,33 @@ Page({
|
||||
chooseLocation() {
|
||||
wx.chooseLocation({
|
||||
success: (res) => {
|
||||
this.setData({ location: res.name || res.address });
|
||||
const formatted = this.formatLocation(res.address, res.name);
|
||||
this.setData({ location: formatted });
|
||||
},
|
||||
fail: () => {
|
||||
// User cancelled or no permission
|
||||
}
|
||||
fail: () => { }
|
||||
});
|
||||
},
|
||||
|
||||
formatLocation(address, name) {
|
||||
if (!address) return name || '';
|
||||
|
||||
// Municipalities
|
||||
const munis = ['北京', '上海', '天津', '重庆'];
|
||||
for (let m of munis) {
|
||||
if (address.startsWith(m)) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
// Standard: Prov + City (Simplify names)
|
||||
const match = address.match(/^(.+?)(?:省|自治区)(.+?)(?:市|自治州|地区|盟)/);
|
||||
if (match) {
|
||||
return `${match[1]}.${match[2]}`;
|
||||
}
|
||||
|
||||
return name || address;
|
||||
},
|
||||
|
||||
toggleTopic(e) {
|
||||
const topic = e.currentTarget.dataset.topic;
|
||||
const hashtag = `#${topic} `;
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
</view>
|
||||
<view class="topic-list">
|
||||
<view class="topic-tag {{selectedTopics.includes(item) ? 'selected' : ''}}"
|
||||
style="{{selectedTopics.includes(item) ? 'color:' + topicColors[index % topicColors.length] + '; background-color:' + topicBgColors[index % topicBgColors.length] : ''}}"
|
||||
wx:for="{{suggestedTopics}}"
|
||||
wx:key="*this"
|
||||
bindtap="toggleTopic"
|
||||
|
||||
Reference in New Issue
Block a user