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
102
103
104
105
106
107
108
109
110
| // pages/test/testCover.js
| const app = getApp()
| Page({
|
| /**
| * 页面的初始数据
| */
| data: {
| bookId: 0,
| bookName: '',
| cmsId: '',
| productLinkPath: '',
| rootCmsItemId: '',
| answerTitle: '',
| },
|
| /**
| * 生命周期函数--监听页面加载
| */
| onLoad(options) {
| const token = wx.getStorageSync(app.config.tokenKey)
| if (!token) {
| loginInfo(app, (data) => {
| // 如果不是第一次登录,会执行回调
| if (data) {
| // 登录成功,自动记录token和用户信息,并返回true
| if (options.scene) {
| this.getBookInfo(options.scene)
| }
| }
| })
| } else {
| // 如果是第一次登录,会跳转至绑定用户信息页面,填写完用户信息后进行登录并储存token和用户信息,结束后跳转回当前页面(携带页面参数)
| if (options.scene) {
| this.getBookInfo(options.scene)
| }
| }
|
|
| },
|
| /**
| * 生命周期函数--监听页面初次渲染完成
| */
| onReady() {
|
| },
|
| /**
| * 生命周期函数--监听页面显示
| */
| onShow() {
|
| },
|
| getBookInfo(refcode) {
| const obj = {
| storeInfo: app.config.jslx,
| path: app.config.jslx,
| queryType: 'ProductCmsItem',
| SysType: "CmsFolder",
| RefCode: refcode,
| paging: {
| start: 0,
| size: 99,
| },
| coverSize: {
| width: 260
| },
| fields: {
| ProductLinkInfo: [],
| productLinkPath: [],
| }
| }
| app.MG.resource.getItem(obj).then((res) => {
| console.log(res.datas, '图书信息')
| let idPathList = [];
| let book = res.datas[0]
| this.setData({
| bookId: book.productLinkInfo.ProductId,
| bookName: book.productLinkInfo.Name,
| productLinkPath: book.productLinkInfo.LinkPath + "\\" + book.id,
| rootCmsItemId: book.productLinkInfo.LinkPath,
| cmsId: book.id,
| answerTitle: book.name
| })
| idPathList.push({
| id: book.id,
| name: book.name,
| productLinkPath: this.data.productLinkPath,
| type: book.type,
| })
| wx.redirectTo({
| url: `/packageBookService/pages/bookServices/examination/examination?bookId=${
| this.data.bookId
| }&productLinkPath=${this.data.productLinkPath}& =${
| this.data.rootCmsItemId
| }&idPathList=${JSON.stringify(idPathList)}&answerTitle=${
| this.data.answerTitle
| }&answerType=${"option"}&storeInfo=${book.storeInfo}`,
| });
| })
| },
| /**
| * 用户点击右上角分享
| */
| onShareAppMessage() {
|
| }
| })
|
|