kydc/entry-edit/entry-edit.js

39 lines
932 B
JavaScript
Raw Normal View History

const app = getApp()
Page({
data: {
entryType: 'word',
enText: '',
zhText: '',
exampleText: '',
},
goBack() {
wx.navigateBack()
},
onEnInput(e) {
this.setData({ enText: e.detail.value })
},
onZhInput(e) {
this.setData({ zhText: e.detail.value })
},
onExampleInput(e) {
this.setData({ exampleText: e.detail.value })
},
save() {
wx.request({
url: `${app.globalData.baseUrl}/api/v1/entries`,
method: 'POST',
header: { 'Content-Type': 'application/json', 'X-OpenID': app.globalData.openid || '' },
data: {
entry_type: this.data.entryType,
en_text: this.data.enText,
zh_text: this.data.zhText,
example_text: this.data.exampleText,
source_type: 'manual',
upload_date: new Date().toISOString().slice(0, 10),
},
success: () => wx.showToast({ title: '已保存', icon: 'success' }),
})
},
})