77 lines
1.7 KiB
JavaScript
77 lines
1.7 KiB
JavaScript
import { API } from './../../../utils/network/api'
|
|
const api = new API()
|
|
const app = getApp()
|
|
Page({
|
|
|
|
data: {
|
|
navbarData: {
|
|
showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
|
|
title: '常用语', //导航栏 中间的标题
|
|
},
|
|
height: app.globalData.height,
|
|
stickyProps: {
|
|
offsetTop: app.globalData.height*2 + 20,
|
|
zIndex: 99
|
|
},
|
|
list_1: [],
|
|
list_2: [],
|
|
show: false,
|
|
add_message: "",
|
|
current_words_type: 1,
|
|
focus: true
|
|
},
|
|
onTabChange(e){
|
|
this.setData({
|
|
current_words_type: e.detail.value
|
|
})
|
|
},
|
|
onShow(){
|
|
this.getList(1);
|
|
this.getList(2);
|
|
},
|
|
getList(words_type){
|
|
api.getDoctorWords({words_type: words_type}).then(response => {
|
|
console.log(response);
|
|
let list_name = "list_" + words_type;
|
|
console.log(list_name);
|
|
this.setData({
|
|
[list_name]: response.data,
|
|
})
|
|
}).catch(errors => {console.error(errors);})
|
|
},
|
|
add(e){
|
|
let words_type = this.data.current_words_type;
|
|
let words = this.data.add_message;
|
|
|
|
api.postDoctorWords({words_type: words_type, words: words}).then(response => {
|
|
console.log(response);
|
|
let list_name = "list_" + words_type;
|
|
let list = this.data[list_name];
|
|
let obj = {};
|
|
obj.words = words;
|
|
list.push(obj);
|
|
console.log(list_name);
|
|
this.setData({
|
|
[list_name]: list,
|
|
add_message: "",
|
|
show: false
|
|
})
|
|
}).catch(errors => {console.error(errors);})
|
|
},
|
|
showAdd(){
|
|
this.setData({
|
|
show: true,
|
|
});
|
|
},
|
|
|
|
onClose() {
|
|
this.setData({
|
|
show: false,
|
|
});
|
|
},
|
|
onInput(){
|
|
this.setData({
|
|
focus: true
|
|
})
|
|
}
|
|
}) |