Authored by 郭成尧

侧边栏ABCD

... ... @@ -5,8 +5,9 @@
* Time: 10:03
*/
'use strict';
const _ = require('lodash');
const helpers = global.yoho.helpers;
// const _ = require('lodash');
// const helpers = global.yoho.helpers;
const mRoot = '../models';
const brandModel = require(`${mRoot}/brand`);
... ... @@ -16,7 +17,7 @@ const brandModel = require(`${mRoot}/brand`);
const component = {
/* 品牌店铺页面 */
brand: (req, res, next) => {
brand: (req, res) => {
let params = req.query;
brandModel.getBrandData(params).then(result => {
... ... @@ -26,36 +27,6 @@ const component = {
result: result
});
});
},
letterList: (req, res, next) => {
res.json(
[
{
id: 'A',
name: 'A'
},
{
id: 'B',
name: 'B'
},
{
id: 'C',
name: 'C'
},
{
id: 'D',
name: 'D'
},
{
id: 'E',
name: 'E'
},
{
id: 'F',
name: 'F'
}
]
);
}
};
... ...
... ... @@ -14,6 +14,5 @@ const router = expressRouter();
router.get('/', channel.index); // 首页
router.get('/brand', channel.brand); // 店铺首页
router.get('/brand/letterList', channel.letterList); // 店铺首页
module.exports = router;
... ...
<template>
<ul class="list-box">
<li v-for="item in items"><a href="#{{item.id}}">{{item.name}}</a></li>
<li v-for="item in items"><a href="#{{item.index}}">{{item.name}}</a></li>
</ul>
</template>
<style>
... ... @@ -26,23 +26,27 @@
</style>
<script>
var $ = require('yoho-jquery');
// var $ = require('yoho-jquery');
let items = [];
module.exports = {
data: function () {
data() {
return {
items: []
}
items: items
};
},
init() {
$.ajax({
url: '/brand/letterList'
}).then(result => {
this.items = result;
}).fail(() => {
tip('网络错误');
// 品牌索引数据
for (let i = 65; i < 91; i++) {
let itemTemp = String.fromCharCode(i);
items.push({
index: itemTemp,
name: itemTemp
});
}
}
};
</script>
... ...