2026-07-07 16:38:13 +08:00
|
|
|
const { listSecondGoods } = require('../../api/secondGoodsApi')
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
loading: false,
|
2026-07-14 16:04:51 +08:00
|
|
|
keyword: '',
|
2026-07-07 16:38:13 +08:00
|
|
|
goods: []
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onLoad() {
|
|
|
|
|
this.load()
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onShow() {
|
|
|
|
|
this.load()
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
load() {
|
|
|
|
|
this.setData({ loading: true })
|
2026-07-14 16:04:51 +08:00
|
|
|
listSecondGoods(null, this.data.keyword)
|
2026-07-07 16:38:13 +08:00
|
|
|
.then((goods) => this.setData({ goods: goods || [] }))
|
|
|
|
|
.catch((error) => wx.showToast({ title: error.message, icon: 'none' }))
|
|
|
|
|
.finally(() => this.setData({ loading: false }))
|
|
|
|
|
},
|
|
|
|
|
|
2026-07-14 16:04:51 +08:00
|
|
|
onKeywordInput(event) {
|
|
|
|
|
this.setData({ keyword: event.detail.value })
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
search() {
|
|
|
|
|
this.load()
|
|
|
|
|
},
|
|
|
|
|
|
2026-07-07 16:38:13 +08:00
|
|
|
goCreate() {
|
|
|
|
|
wx.navigateTo({ url: '/pages/second-hand/create' })
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
callSeller(event) {
|
|
|
|
|
const phone = event.currentTarget.dataset.phone
|
|
|
|
|
if (!phone) {
|
|
|
|
|
wx.showToast({ title: '暂无电话', icon: 'none' })
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
wx.makePhoneCall({ phoneNumber: phone })
|
|
|
|
|
}
|
|
|
|
|
})
|