// president/pages/home/home.js import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js' import { BookDetailView, CallInBooks} from '../../../utils/api.js' const { navigateTo, redirectTo, navigateBack } = routers() const { globalData } = getApp() const { baseImgUrl, thumbnail } = globalData Page({ /** * 页面的初始数据 */ data: { baseImgUrl, thumbnail, isLoaded: 0, title: '', pageSize: 10, pageNo: 1, isAll: 0, isFold:0, isResult: false, bookInfoId:'', isShow: 0, itemIndex: 0, footerData: { actIndex: 0, list: [ { text: '在馆书籍', icon: '../../../assets/zai_guan_shu_ji_gray.png', actIcon: '../../../assets/zai_guan_shu_ji_blue.png', url: 'president/pages/home/home', zindex: 3 }, { text: '好书推荐', icon: '../../../assets/wish_gray.png', actIcon: '../../../assets/wish_blue.png', url: 'president/pages/good_books_new/good_books_new', zindex: 3 }, { text: '调书清单', icon: '../../../assets/diao_shu_qing_dan_gray.png', actIcon: '../../../assets/diao_shu_qing_dan_blue.png', url: 'president/pages/book_inventory/book_inventory', zindex: 3 } ] }, nodataArray: { text: "暂时还没有这本书,可以申请哦~" } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { options.vipId = getGlobalVal('vipId', `vipId_${getGlobalVal('userId')}`) options.libId = getGlobalVal('list').length > 0 ? getGlobalVal('list')[0].libId : '' this.setData(options) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { const obj = { navigateTo, redirectTo, navigateBack, viewImage } for (const i in obj) { this[i] = obj[i] } }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getData() }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { if (isFn(sharePage)) return sharePage() }, /** * 获取书籍数据 */ getData: function (cb) { const continuousFn = { fn: this.getData, param: { ...arguments } } const { bookInfoId } = this.data BookDetailView({ data: { bookInfoId }, continuousFn }).then(res => { const { author, bookImg, bookInfoId, grade, heat, isbn13, summary, theme, title, sameList } = res.data this.setData({ author, bookImg, bookInfoId, grade, heat, isbn13, summary, theme, title, sameList, isLoaded:true}) cb && cb(res) }).catch(res => { cb && cb(res) }) }, /** * 调入 */ addFold: function () { const { isbn13, libId, bookInfoId} = this.data const continuousFn = { fn: this.addFold, param: { ...arguments } } CallInBooks({ data: { libId, bookInfoId, isbn13 }, continuousFn }).then(res => { wx.showToast({ title: `已加入调入清单`, icon: 'none', duration:2000 }) wx.navigateBack({ delta: 1, }) }) }, })