123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- // president/pages/home/home.js
- import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
- import { BookDetailView, GetLibraryTopTen, CallOutBooks } 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,
- isResult:false,
- GrangeList: ['学前段', '低年段', '中年段', '高年段'],
- bookList: [
- {
- name: '在馆书籍',
- amount: '',
- unit: '本'
- },
- {
- name: '服务期会员',
- amount: '',
- unit: '人'
- },
- {
- name: '在借书籍',
- amount: '',
- unit: '本'
- },
- ],
- isShow: 0,
- itemIndex: 0,
- items: ['根据入馆时间排序', '根据书籍借阅量排序', '根据馆藏稀缺度排序'],
- list: [
- // {
- // "heat": "1",
- // "local_image": "",
- // "isbn13": "9787539158013",
- // "book_info_id": "992f05d8-ab46-11e8-93e1-00163e0c97b1",
- // "book_detail_id": "08be3ac9-a526-11e8-93e1-00163e0c97b1",
- // "theme": "大语文-传统国学",
- // "title": "新课标小学语文阅读丛书"
- // },
- // {
- // "heat": "2",
- // "local_image": "",
- // "isbn13": "97878072112663",
- // "book_info_id": "992fc438-ab46-11e8-93e1-00163e0c97b1",
- // "book_detail_id": "08be828c-a526-11e8-93e1-00163e0c97b1",
- // "theme": "情感梦想",
- // "title": "儿童职业启蒙美绘本-我要当建筑师"
- // }
- ],
- 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 })
- this.getData(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 () {
- // this.setData({ pageNo: 1 })
- // this.getData(res => {
- // wx.stopPullDownRefresh()
- // })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- // const { isAll } = this.data
- // if (isAll) return
- // this.getData()
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- if (isFn(sharePage)) return sharePage()
- },
- /**
- * 展示选择框
- */
- showItemCtl: function () {
- const { isShow } = this.data
- this.setData({ isShow: !isShow })
- },
- /**
- * 展示选择框
- */
- selectItemCtl: function (e) {
- const { index } = e.currentTarget.dataset
- const { itemIndex, items } = this.data
- if (index == itemIndex) return
- this.setData({ itemIndex: index, isShow: 0, pageNo: 1 })
- this.getData()
- },
- /**
- * 获取书籍数据
- */
- getData: function (cb) {
- const continuousFn = { fn: this.getData, param: { ...arguments } }
- const { content, options, pageNo, pageSize, itemIndex, title } = this.data
- const { libId } = this.data.options;
- GetLibraryTopTen({ data: { libId, title }, continuousFn }).then(res => {
- const { list } = res.data
- let listTemp = []
- if (pageNo == 1) {
- listTemp = [].concat(list)
- } else {
- listTemp = [].concat(this.data.list, list)
- }
- this.setData({ list: listTemp, pageNo: list.length == pageSize ? pageNo + 1 : pageNo, isAll: list.length < pageSize })
- cb && cb(res)
- }).catch(res => {
- cb && cb(res)
- })
- },
- /**
- * 调出书籍
- */
- getBooksCtl: function (e) {
- const { index } = e.currentTarget.dataset;
- const continuousFn = { fn: this.getBooksCtl, param: { ...arguments } }
- const { list, options } = this.data
- const { libId } = options
- const { book_info_id, book_detail_id, isbn13 } = list[index]
- CallOutBooks({ data: { libId, bookInfoId: book_info_id, bookDetailId: book_detail_id, isbn13 }, continuousFn }).then(res => {
- wx.showToast({
- title: `已加入调出列表`
- })
- this.getData()
- })
- },
- /**
- * 输入搜索值
- */
- inputSearchCtl: function (e) {
- const { value } = e.detail
- const { title } = this.data
- if (title == value) return
- const temp = {}
- temp[`title`] = value
- this.setData(temp)
- },
- /**
- * 清除搜索值
- */
- clearSearchCtl: function () {
- const temp = {}
- temp[`title`] = ''
- this.setData(temp)
- },
- /**
- * 提交搜索值
- */
- submitSearchCtl: function () {
- const { title } = this.data
- if (!title){
- wx.showToast({
- title: `书名不能为空`,
- icon: 'none'
- })
- return
- }
- navigateTo({
- url: 'president/pages/search_headquarters_books/search_headquarters_books?title=' + title,
- })
- },
- /**
- * 搜索页面
- */
- BooksInfoPage: function (e) {
- const { title } = e.currentTarget.dataset
- navigateTo({
- url: 'president/pages/book_Imformation/book_Imformation?title='+ title ,
- })
- },
- })
|