You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
188 lines
5.0 KiB
188 lines
5.0 KiB
// index.js
|
|
const app = getApp();
|
|
Page({
|
|
data: {
|
|
value: "",
|
|
tabActive: 0,
|
|
active: 1,
|
|
height: app.globalData.navBarHeight + app.globalData.statusBarHeight,
|
|
statusBarHeight: app.globalData.statusBarHeight,
|
|
navBarHeight: app.globalData.navBarHeight,
|
|
navData: [],
|
|
sourceData: [],
|
|
mockData: [],
|
|
heightTop: 210,
|
|
showPop: false,
|
|
series: [],
|
|
type: 2,
|
|
sBrand: '',
|
|
daActive: -1,
|
|
dbActive: '',
|
|
dcActive: '',
|
|
model: ''
|
|
},
|
|
onLaunch() {
|
|
wx.getSystemInfo({
|
|
success: (res) => {
|
|
const ratio = 750 / res.windowWidth
|
|
const menuInfo = wx.getMenuButtonBoundingClientRect();
|
|
this.setData({
|
|
top: menuInfo.top * ratio,
|
|
left: menuInfo.left * ratio,
|
|
height: menuInfo.height * ratio,
|
|
})
|
|
}
|
|
})
|
|
},
|
|
onLoad() {
|
|
let pages = getCurrentPages();
|
|
let currentPage = pages[pages.length - 1]
|
|
let options = currentPage.options
|
|
this.setData({
|
|
type: options.type || 2
|
|
})
|
|
},
|
|
onShow() {
|
|
this.getData();
|
|
this.createSelectorQuery().select(".nav-top").boundingClientRect(res => {
|
|
if (res) {
|
|
const {
|
|
height
|
|
} = res;
|
|
this.setData({
|
|
heightTop: height
|
|
})
|
|
}
|
|
}).exec();
|
|
},
|
|
handlerSearch(e) {
|
|
let val = e.detail;
|
|
const arr = this.data.sourceData.filter(ele => {
|
|
return ele.brandname.toLowerCase().indexOf(val.toLowerCase()) != -1
|
|
})
|
|
this.setData({
|
|
navData: arr
|
|
})
|
|
},
|
|
handlerChoose(e) {
|
|
const row = e.currentTarget.dataset.row;
|
|
let n = this.data.navData.findIndex(ele => row.brandid === ele.brandid);
|
|
wx.setStorageSync('sBrand', row.brandname);
|
|
if (this.data.type === 1) {
|
|
// wx.switchTab({
|
|
// url: "/pages/brandCrisis/index"
|
|
// })
|
|
return;
|
|
}
|
|
this.setData({
|
|
showPop: true,
|
|
daActive: n
|
|
})
|
|
this.getSeries(row.brandname);
|
|
},
|
|
handlerChoose1(e) {
|
|
if (this.data.sBrand) {
|
|
return;
|
|
}
|
|
const row = e.currentTarget.dataset.row;
|
|
wx.setStorageSync('sBrand', row.brandname);
|
|
if (this.data.type === 1) {
|
|
// wx.switchTab({
|
|
// url: "/pages/brandCrisis/index"
|
|
// })
|
|
return;
|
|
}
|
|
this.setData({
|
|
showPop: true,
|
|
dbActive: row.brandid
|
|
})
|
|
this.getSeries(row.brandname);
|
|
},
|
|
handlerCloseDialog() {
|
|
this.setData({
|
|
showPop: false
|
|
})
|
|
},
|
|
handlerChooseS(e) {
|
|
const row = e.currentTarget.dataset.row;
|
|
wx.setStorageSync('sSeriesName', row.name);
|
|
this.setData({
|
|
dcActive: row.name
|
|
})
|
|
},
|
|
getSeries(brandname) {
|
|
let obj = {
|
|
action: 'getUserSeriesName',
|
|
token: app.globalData.getStorage('token'),
|
|
sBrandName: brandname
|
|
}
|
|
app.globalData.request(obj).then(res => {
|
|
this.setData({
|
|
series: res
|
|
})
|
|
})
|
|
},
|
|
getData() {
|
|
//页面数据
|
|
wx.showToast({
|
|
title: '加载中',
|
|
icon: 'loading',
|
|
duration: 30000
|
|
})
|
|
app.globalData.request({
|
|
action: 'getUserBrand',
|
|
token: app.globalData.getStorage('token'),
|
|
}).then(res => {
|
|
let arr = [];
|
|
for (let i = 65; i <= 90; i++) {
|
|
arr.push({
|
|
name: String.fromCharCode(i),
|
|
data: []
|
|
});
|
|
}
|
|
for (let i of res) {
|
|
for (let j of arr) {
|
|
if (i.firstword == j.name) {
|
|
j.data.push(i)
|
|
}
|
|
}
|
|
}
|
|
let newArr = [];
|
|
let obj = {};
|
|
for (var i = 0; i < res.length; i++) {
|
|
if (!obj[res[i].brandid]) {
|
|
newArr.push(res[i])
|
|
obj[res[i].brandid] = true
|
|
}
|
|
}
|
|
this.setData({
|
|
mockData: arr,
|
|
navData: newArr,
|
|
sourceData: newArr
|
|
})
|
|
setTimeout(() => {
|
|
wx.hideToast();
|
|
}, 1000)
|
|
})
|
|
},
|
|
handlerBack() {
|
|
wx.navigateBack({
|
|
delta: 1
|
|
});
|
|
},
|
|
onChange(event) {
|
|
this.setData({
|
|
model: event.detail,
|
|
});
|
|
wx.setStorageSync('sSeries', event.detail);
|
|
},
|
|
onClick(event) {
|
|
const {
|
|
name
|
|
} = event.currentTarget.dataset;
|
|
this.setData({
|
|
model: name
|
|
});
|
|
wx.setStorageSync('sSeries', name);
|
|
}
|
|
}); |