init project
This commit is contained in:
93
pages/questions/index.js
Normal file
93
pages/questions/index.js
Normal file
@@ -0,0 +1,93 @@
|
||||
// pages/questions/index.js
|
||||
const app = getApp();
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
questions: []
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function(options) {
|
||||
app.$api.faqs({}).then(res => {
|
||||
this.setData({
|
||||
questions: res.faqs
|
||||
})
|
||||
}, err => {
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function() {
|
||||
return {
|
||||
title: '智慧云馆'
|
||||
}
|
||||
},
|
||||
|
||||
// 打开答案
|
||||
openAnswer(e) {
|
||||
let index = e.currentTarget.dataset.index;
|
||||
let list = [];
|
||||
for (let i = 0; i < this.data.questions.length; i++) {
|
||||
let item = this.data.questions[i]
|
||||
if (i == index) {
|
||||
item.isOpenAnswer = !item.isOpenAnswer;
|
||||
} else {
|
||||
item.isOpenAnswer = false;
|
||||
}
|
||||
list.push(item)
|
||||
}
|
||||
this.setData({
|
||||
questions: list
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user