首次提交
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
const api = require('../../../services/api')
|
||||
Page({
|
||||
data: { friends: [], addPhone: '', loading: true },
|
||||
onShow() { this.loadFriends() },
|
||||
async loadFriends() {
|
||||
try { const f = await api.get('/api/social/friends'); this.setData({ friends: f || [] }) } catch(e) {}
|
||||
this.setData({ loading: false })
|
||||
},
|
||||
onPhoneInput(e) { this.setData({ addPhone: e.detail.value }) },
|
||||
async onAdd() {
|
||||
if (!this.data.addPhone.trim()) return
|
||||
try { await api.post('/api/social/friends/request', { friendId: this.data.addPhone.trim() }); wx.showToast({ title: '请求已发送' }); this.setData({ addPhone: '' }) }
|
||||
catch(e) { wx.showToast({ title: e.message || '添加失败', icon: 'none' }) }
|
||||
},
|
||||
async onRemove(e) {
|
||||
const id = e.currentTarget.dataset.id
|
||||
wx.showModal({ title: '确认', content: '确定删除好友?', success: async (res) => {
|
||||
if (res.confirm) { try { await api.del('/api/social/friends/' + id); this.loadFriends() } catch(e) {} }
|
||||
}})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user