You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
2.0 KiB
109 lines
2.0 KiB
//const that = this;
|
|
const db = wx.cloud.database().collection("student_Demands");
|
|
// pages/MainTest/MainTest.js
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
currentTab: 0,
|
|
showPopup: false,
|
|
teacher: {},
|
|
exist: false,
|
|
rec: false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
// wx.showLoading({
|
|
// title: '加载中',
|
|
// })
|
|
//检测用户是否注册过
|
|
wx.cloud.database()
|
|
.collection('user_Data')
|
|
.get({
|
|
success: (res) => {
|
|
var exist = (res.data.length>0)? true: false
|
|
this.setData({
|
|
exist
|
|
})
|
|
console.log(this.data.exist);
|
|
}
|
|
})
|
|
|
|
// 调用云函数获取教师信息
|
|
wx.cloud.callFunction({
|
|
name: "recommend",
|
|
success: (res) => {
|
|
this.setData({
|
|
teacher: res.result.data
|
|
})
|
|
// console.log(this.data.teacher[1]);
|
|
}
|
|
})
|
|
},
|
|
|
|
changeTab(e) {
|
|
const index = e.currentTarget.dataset.index;
|
|
this.setData({
|
|
currentTab: parseInt(index)
|
|
});
|
|
},
|
|
onAddButtonTap: function() {
|
|
this.setData({
|
|
showPopup: true
|
|
});
|
|
},
|
|
onBackButtonTap: function() {
|
|
this.setData({
|
|
showPopup: false
|
|
});
|
|
},
|
|
|
|
handleSubmit: function() {
|
|
// 处理....
|
|
// 提交成功后隐藏弹窗
|
|
this.setData({
|
|
showPopup: false
|
|
});
|
|
},
|
|
|
|
navToComments: () => {
|
|
wx.navigateTo({
|
|
url: '/pages/Comments/Comments',
|
|
})
|
|
},
|
|
|
|
navToDetails: () => {
|
|
wx.navigateTo({
|
|
url: '/pages/Details/details',
|
|
success: function(res) {
|
|
// 通过eventChannel向被打开页面传送数据
|
|
res.eventChannel.emit('acceptDataFromOpenerPage', { data: 'test' })
|
|
}
|
|
})
|
|
},
|
|
|
|
// contactTeacher(event) {
|
|
// // console.log(event);
|
|
// wx.makePhoneCall({
|
|
// phoneNumber: event.currentTarget.dataset.item,
|
|
// })
|
|
// }
|
|
inputChange(e) {
|
|
this.setData({
|
|
inputValue: e.detail.value
|
|
});
|
|
},
|
|
|
|
recommend() {
|
|
// TODO
|
|
this.setData({
|
|
rec: true
|
|
})
|
|
console.log("rec");
|
|
}
|
|
}) |