123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- // parents/pages/wish_detail/wish_detail.js
- import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
- import { WishBookDetail, WishHelp } from '../../../utils/api.js'
- const { navigateTo, redirectTo, navigateBack } = routers()
- const { globalData, hasLibraryService, hasVipService } = getApp()
- const { baseImgUrl, qrcodeInvalidToastText } = globalData
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- baseImgUrl,
- isLoaded: 0,
- userlist: [],
- book: {
- summary: '',
- local_image: '',
- author: '',
- title: '',
- cishu: ''
- },
- ishelp: 0,
- vipInfo: {
- photo: '',
- childName: '',
- wishWords: ''
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({ options })
- this.getData(res => {
- this.setData({ isLoaded: 1 })
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- const { vipInfo, options } = this.data
- const { vipId, isbn13, libId } = options
- const { childName } = vipInfo
- return {
- title: `${childName}的心愿书单详情`,
- path: `parents/pages/wish_detail/wish_detail?type=10&vipId=${vipId}&isbn13=${isbn13}&libId=${libId}`,
- success: res => {
- wx.showToast({
- title: '转发成功',
- icon: 'success'
- })
- }
- }
- },
- /**
- * 获取心愿详情
- */
- getData: function (cb) {
- const continuousFn = { fn: this.getData, param: { ...arguments } }
- const { isbn13, libId, vipId } = this.data.options
- WishBookDetail({ data: { isbn13, libId, vipId }, continuousFn }).then(res => {
- const { userlist, book, vipInfo, ishelp } = res.data
- const { cishu, isbn13 } = book
- if (cishu == 0) {
- wx.showToast({
- title: '此本书籍已助力成功,私塾家正在为您所在的图书馆配置入书单,书到馆后您可进行借阅或预约',
- icon: 'none'
- })
- setTimeout(() => {
- redirectTo({ url: 'parents/pages/book_detail/book_detail', paras: { isbn13 }, zindex: 3 })
- }, 1200)
- }
- this.setData({ userlist, book: { ...book }, vipInfo: { ...vipInfo }, ishelp })
- cb && cb(res)
- }).catch(res => {
- cb && cb(res)
- })
- },
- /**
- * 助力
- */
- helpWishCtl: function (e) {
- const continuousFn = { fn: this.helpWishCtl, param: { ...arguments } }
- const { book, options } = this.data
- const { vipId, isbn13, libId } = options
- WishHelp({ data: { vipId, isbn13, libId }, continuousFn }).then(res => {
- wx.showToast({
- title: '助力成功'
- })
- this.setData({ ishelp: 1 })
- })
- }
- })
|