123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- const $ = global;
- const colors = [
- 'blue',
- 'green',
- 'pink',
- 'orange',
- 'purple'
- ];
- new $.Page({
- data: {
- list: []
- },
- onShow() {
- const meta = $.router.getMeta();
- const type = meta && meta.params && meta.params.type || '';
- $.request('classifies', 'GET', {}).then((res) => {
- const data = res.data;
- const list = [];
- if (data.length > 0) {
- data.forEach(d => {
- if (!d.pid) {
- if (type) {
- if (d.name.includes(type)) {
- d.array = [];
- list.push(d);
- }
- } else {
- d.array = [];
- list.push(d);
- }
- }
- });
- data.forEach(d => {
- if (d.pid) {
- list.forEach((l, index) => {
- l.color = colors[index];
- if (d.name.includes('咨询')) {
- d.isConsult = true;
- }
- if (l.id === d.pid) {
- l['array'].push(d);
- }
- });
- }
- });
- this.setData({
- list
- });
- $.router.clearCurMeta();
- }
- });
- },
- toIntroduce(e) {
- const {
- id,
- name
- } = e.currentTarget.dataset;
- if (id) {
- if (name.includes('母婴')) {
- $.router.goto({
- path: `/pages/goodsList/index`
- });
- } else if (name.includes('咨询')) {
- // $.router.goto({
- // path: `/pages/service/index`
- // });
- } else {
- $.router.goto({
- path: `/pages/introduce/index`,
- query: {
- id,
- name
- }
- });
- }
- }
- }
- });
|