1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
| // pages/index/bookDetail.js
| import request from '../../assets/request/index'
|
| const app = getApp()
| import {
| loginInfo
| } from '../../assets/js/login';
| Page({
|
| /**
| * 页面的初始数据
| */
| data: {
| refcode: 0
| },
|
| /**
| * 生命周期函数--监听页面加载
| */
| onLoad(options) {
| const token = wx.getStorageSync(app.config.tokenKey)
| if (!token) {
| loginInfo(app, (data) => {
| // 如果不是第一次登录,会执行回调
| if (data) {
| if (options.scene) {
| this.setData({
| refcode: options.scene,
| })
| this.getBookList()
| }
| }
| })
| } else {
| if (options.scene) {
| this.setData({
| refcode: options.scene,
| })
| this.getBookList()
| }
| }
|
| },
|
| /**
| * 生命周期函数--监听页面初次渲染完成
| */
| onReady() {
|
| },
| getBookList() {
| let url = '/store/api/ApiQueryProductByAppUser'
| let fields = {
| Name: [],
| 'RefCodes': [this.data.refcode]
| }
| 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.datas.Name}`,
| });
| })
| },
|
| /**
| * 用户点击右上角分享
| */
| onShareAppMessage() {
|
| }
| })
|
|