| | |
| | | residue: 0, // 组卷剩余次数 |
| | | mockList: [], // 用户组卷提交信息 |
| | | }, |
| | | relatedBookLoading: false, |
| | | noRelatedBookData: false, |
| | | relatedBookPath: "", // 相关图书path |
| | | relatedBookData: [], // 相关图书列表 |
| | | flag: true, |
| | |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | // 检查登录状态 |
| | | // const token = wx.getStorageSync(app.config.tokenKey) |
| | | // if (!token) { |
| | | // loginInfo(app, (data) => { |
| | | // // 如果不是第一次登录,会执行回调 |
| | | // if (data) { |
| | | // // 登录成功,自动记录token和用户信息,并返回true |
| | | // } else { |
| | | // // 出现错误,返回false |
| | | // } |
| | | // }) |
| | | // } else { |
| | | // // 如果是第一次登录,会跳转至绑定用户信息页面,填写完用户信息后进行登录并储存token和用户信息,结束后跳转回当前页面(携带页面参数) |
| | | // } |
| | | |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = |
| | | (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | | this.setData({ |
| | | bookId: options.id, |
| | | bookId: options.id + "", |
| | | barHeight: systInfo.statusBarHeight, |
| | | navBarHeight: navBarHeight, |
| | | }); |
| | |
| | | name: options.name, |
| | | }, |
| | | }); |
| | | |
| | | this.getBookInfo(options.id); |
| | | this.getResourceClass(); // 获取资源所属分类 |
| | | const token = wx.getStorageSync(app.config.tokenKey); |
| | |
| | | }, |
| | | // 获取相关图书 |
| | | getAboutBook(path) { |
| | | // loadings.value.aboutBook = true |
| | | this.setData({ |
| | | relatedBookLoading: true, |
| | | noRelatedBookData: false, |
| | | }); |
| | | let query = { |
| | | path, |
| | | queryType: "*", |
| | |
| | | (item) => item.id != this.data.bookDetail.id |
| | | ); |
| | | let bookArr = []; |
| | | if (Arr.length) { |
| | | if (Arr.length > 3) { |
| | | for (var i = 0; i < 3; i++) { |
| | | var _num = Math.floor(Math.random() * Arr.length); |
| | | var mm = Arr[_num]; |
| | | Arr.splice(_num, 1); |
| | | bookArr.push(mm); |
| | | } |
| | | } else { |
| | | bookArr = Arr; |
| | | } |
| | | // if (Arr.length > 3) { |
| | | // for (var i = 0; i < 3; i++) { |
| | | // var _num = Math.floor(Math.random() * Arr.length); |
| | | // var mm = Arr[_num]; |
| | | // Arr.splice(_num, 1); |
| | | // bookArr.push(mm); |
| | | // } |
| | | // } else { |
| | | // bookArr = Arr; |
| | | // } |
| | | this.setData({ |
| | | relatedBookData: Arr, |
| | | relatedBookLoading: false, |
| | | }); |
| | | if (!this.data.relatedBookData.length) |
| | | this.setData({ |
| | | relatedBookData: bookArr, |
| | | noRelatedBookData: true, |
| | | }); |
| | | console.log("相关图书", this.data.relatedBookData); |
| | | } |
| | | console.log("相关图书", this.data.relatedBookData); |
| | | }); |
| | | // loadings.value.aboutBook = false |
| | | }, |
| | | goBookDetails(e) { |
| | | console.log(e); |
| | | this.onLoad({ id: e.detail.id, name: e.detail.name }); |
| | | }, |
| | | // 底部购买按钮 |
| | | buyBtn() { |