123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- // pages/question/question.js
- import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../utils/util.js'
- import { AboutSharingSchool } from '../../utils/api.js'
- const { navigateTo, redirectTo, navigateBack } = routers()
- const { globalData, hasLibraryService, hasVipService } = getApp()
- const { baseImgUrl, qrcodeInvalidToastText } = globalData
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- isLoaded: 0,
- title: '',
- pageSize: 10,
- pageNo: 1,
- stat: 2,
- type: 1,
- list: []
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let stat = 0
- if (options.type == 1) {
- stat = 2
- } else if (options.type == 2) {
- stat = 6
- }
- this.setData({ options, stat })
- this.getList(res => {
- this.setData({ isLoaded: 1 })
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- const obj = { navigateTo, redirectTo, navigateBack, viewImage }
- for (const i in obj) {
- this[i] = obj[i]
- }
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- if (isFn(sharePage)) return sharePage()
- },
- /**
- * 获取列表
- */
- getList: function (cb) {
- const continuousFn = { fn: this.getList, param: { ...arguments } }
- const { title, pageSize, pageNo, stat, type } = this.data
- AboutSharingSchool({ data: { title, pageSize, pageNo, stat, type }, continuousFn }).then(res => {
- const { list } = res.data
- this.setData({ list })
- cb && cb(res)
- }).catch(res => {
- cb && cb(res)
- })
- }
- })
|