import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js' import { GetThemeAllBook, PostApplyBookList } from '../../../utils/api.js' const { navigateTo, redirectTo, navigateBack } = routers() const { globalData } = getApp() const { baseImgUrl, thumbnail } = globalData Page({ /** * 页面的初始数据 */ data: { baseImgUrl, thumbnail, isLoaded: 0, title: '', pageNo: 1, pageSize: 10, isAll: false, navIndex: 0, list: [], isAllCheck: 0, isManage: 0, totalNum: 0, isDelete:false, stepList: [ { number: '1', text: '填写书单', unit: '->' }, { number: '2', text: '确认申请', unit: '->' }, { number: '3', text: '通过申请', unit: '->' }, { number: '4', text: '送书到馆', unit: '' }, ], }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { let _this = this options.vipId = getGlobalVal('vipId', `vipId_${getGlobalVal('userId')}`) options.libId = getGlobalVal('list').length > 0 ? getGlobalVal('list')[0].libId : '' // wx.setNavigationBarTitle({ // title: `${options.theme}`, // }) this.setData({ options, isAllCheck: options.status == 1 }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { const obj = { navigateTo, redirectTo, navigateBack, viewImage } for (const i in obj) { this[i] = obj[i] } }, /** * 生命周期函数--监听页面显示 */ onShow: function () { let _this = this wx.getStorage({ key: 'infofrominput', success: function (res) { const filterfromstorage =[] let obj = {}; for (let i = 0; i < res.data.length; i++) { if (!obj[res.data[i].title]) { filterfromstorage.push(res.data[i]); obj[res.data[i].title] = true; }} _this.setData({ infofromstorage: filterfromstorage, }) console.log(filterfromstorage) } }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { if (isFn(sharePage)) return sharePage() }, /** * 确认调入 */ getCallin: function () { const continuousFn = { fn: this.getCallin, param: { ...arguments } } const { infofromstorage, options } = this.data const { vipId, libId } = options PostApplyBookList({ data: { libId, bookList: infofromstorage }, continuousFn }).then(res => { wx.showToast({ title: `已加入调入列表` }) }) }, /** * 管理 */ cancelCallin: function () { const { isDelete } = this.data this.setData({ isDelete: !isDelete}) }, /** * 删除 */ deleteBtn:function(e){ const { index } = e.currentTarget.dataset const { infofromstorage } = this.data infofromstorage.splice(index, 1) this.setData({ infofromstorage}) wx.setStorageSync('infofrominput', infofromstorage) }, /** * 提交搜索值 */ submitSearchCtl: function () { const temp = {} temp[`pageNo`] = 1 this.setData(temp) this.getData() }, })