| | |
| | | // pages/index/bookDetail.js |
| | | import request from '../../assets/request/index' |
| | | |
| | | const app = getApp() |
| | | import { |
| | | loginInfo |
| | | } from '../../assets/js/login'; |
| | | Page({ |
| | | |
| | | /** |
| | |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | if (options.scene) { |
| | | this.setData({ |
| | | refcode: options.scene, |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | // 如果不是第一次登录,会执行回调 |
| | | if (data) { |
| | | if (options.scene) { |
| | | this.setData({ |
| | | refcode: options.scene, |
| | | }) |
| | | this.getBookList() |
| | | } |
| | | } |
| | | }) |
| | | this.getBookList() |
| | | } else { |
| | | if (options.scene) { |
| | | this.setData({ |
| | | refcode: options.scene, |
| | | }) |
| | | this.getBookList() |
| | | } |
| | | } |
| | | |
| | | }, |
| | | |
| | | /** |
| | |
| | | |
| | | }, |
| | | getBookList() { |
| | | const obj = { |
| | | storeInfo: app.config.jslx, |
| | | path: "*", |
| | | queryType: '*', |
| | | coverSize: { |
| | | width: 150 |
| | | }, |
| | | paging: { |
| | | start: 0, |
| | | size: 6 |
| | | }, |
| | | filterList: [{ |
| | | value: 'Normal', |
| | | field: 'state' |
| | | }], |
| | | fields: { |
| | | author: [], |
| | | 'RefCodes': [this.data.refcode] |
| | | } |
| | | let url = '/store/api/ApiQueryProductByAppUser' |
| | | let fields = { |
| | | Name: [], |
| | | 'RefCodes': [this.data.refcode] |
| | | } |
| | | app.MG.store.getProductList(obj).then((res) => { |
| | | console.log(res.datas, '图书信息') |
| | | let book = res.datas[0] |
| | | let queryBook = { |
| | | AccessControl: { |
| | | Path: '*', |
| | | StoreRefCode: `defaultGoodsStore${app.config.appId}`, |
| | | Type: '*', |
| | | LinkType: '' |
| | | }, |
| | | PageQuery: { |
| | | Start: 0, |
| | | Size: 3, |
| | | }, |
| | | SortQuery: [{ |
| | | LinkOrder: 'Desc' |
| | | }], |
| | | Name: [], |
| | | RefCode: [], |
| | | ...fields |
| | | } |
| | | let body = { |
| | | query: JSON.stringify({ |
| | | Query: [{ |
| | | queryBook: queryBook |
| | | }] |
| | | }) |
| | | } |
| | | request({ |
| | | url: url, |
| | | method: 'post', |
| | | data: body |
| | | }).then((res) => { |
| | | console.log(res[0], 'resp'); |
| | | let book = res[0].datas[0] |
| | | wx.redirectTo({ |
| | | url: `/packageBookService/pages/bookServices/detail/index?id=${book.id}&name=${book.name}&storeInfo=${app.config.jslx}`, |
| | | url: `/packageBookService/pages/bookServices/detail/index?id=${book.id}&name=${book.datas.Name}`, |
| | | }); |
| | | }) |
| | | }, |