chooseList.js
1.8 KB
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
import {
request
} from "../../request/index.js";
// pages/chooseList/chooseList.js
Page({
/**
* 页面的初始数据
*/
data: {
pinData: [],
selected: '',
// 品牌|车系
title: '',
leftWrapH: 0
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options)
let listType = options.listType
let brandId = options.brandId
let that = this
// 计算滚动区域长度
wx.getSystemInfo({
success: function (res) {
that.setData({
leftWrapH: res.windowHeight * 2
})
}
})
if (listType == 1) {
this.setData({
title: '品牌'
})
this.getData(listType)
} else {
this.setData({
title: '车系'
})
this.getData2(listType,brandId)
}
},
// 获取品牌
getData(t) {
request({
url: '/api/h5/pinData' + t
}).then((res) => {
this.setData({
pinData: res.data.data
})
})
},
// 获取车系
getData2(t,b) {
request({
url: '/api/h5/pinData' + t,
data:{
id:b
}
}).then((res) => {
this.setData({
pinData: res.data.data
})
})
},
// 获取锚点
point(e) {
this.setData({
selected: e.currentTarget.dataset.idx,
})
},
//点击携带参数返回上页
takeitback(e) {
let name = e.currentTarget.dataset.name
let id = e.currentTarget.dataset.id
console.log(name, id)
wx.setStorageSync('brand', name)
wx.setStorageSync('brandId', id)
wx.navigateBack({
delta: 1,
})
},
takeitback2(e){
let name2 = e.currentTarget.dataset.name
let id2 = e.currentTarget.dataset.id
wx.setStorageSync('brand2', name2)
wx.setStorageSync('brandId2', id2)
wx.navigateBack({
delta: 1,
})
}
})