diff --git a/apps/editorial/models/editorial.js b/apps/editorial/models/editorial.js index a410db8..7b42464 100644 --- a/apps/editorial/models/editorial.js +++ b/apps/editorial/models/editorial.js @@ -28,6 +28,7 @@ const _processNavData = (list, type) => { const _processListData = (list) => { + list = list || []; list = camelCase(list); @@ -49,7 +50,9 @@ const _getResources = (type) => { if (result && result.code === 200) { return _processNavData(result.data, type); } else { + logger.error('资讯首页导航数据返回 code 不是 200'); + return {}; } }); diff --git a/apps/editorial/router.js b/apps/editorial/router.js index c731e44..86112e2 100644 --- a/apps/editorial/router.js +++ b/apps/editorial/router.js @@ -11,6 +11,8 @@ const cRoot = './controllers'; const editorial = require(cRoot + '/editorial'); router.get('/', editorial.index); // 咨询首页 + router.get('/list', editorial.list); // 咨询列表页 + module.exports = router; diff --git a/apps/me/controllers/address.js b/apps/me/controllers/address.js new file mode 100644 index 0000000..2b86b26 --- /dev/null +++ b/apps/me/controllers/address.js @@ -0,0 +1,99 @@ +/** + * [个人中心]收货地址 + * @author: jiangmin + * @date: 2016/07/05 + */ + +'use strict'; +const mcHandler = require('../models/menu-crumb-handler'); +const addressModel = require('../models/address'); + +/** + * 收货地址页面加载 + */ +const index = (req, res) => { + addressModel.getAddressDataAsync('123456', 20).then(result => { + for (let i = 0; i < result.data.length; i++) { + result.data[i].default = result.data[i].is_default === 'Y'; + } + result.data.leftLength = 20 - result.data.length; + res.render('index', { + module: 'me', + page: 'address', + isMe: true, + content: { + nav: mcHandler.getMeCrumb(), + navigation: mcHandler.getSideMenu('收货地址'), + banner: 'http://placehold.it/150x120', + address: true, + title: '收货地址', + data: result.data + } + }); + }); +}; + +/** + * 添加地址 + */ +const addAddressData = (req, res) => { + let uid = req.body.uid; + let address = req.body.address; + let areaCode = req.body.area_code; + let consignee = req.body.consignee; + let mobile = req.body.mobile; + let phone = req.body.phone; + + addressModel.addAddressData(uid, address, areaCode, consignee, mobile, phone).then(result => { + res.send(result); + }); +}; + +/** + * 修改地址 + */ +const updateAddressData = (req, res) => { + let id = req.body.id; + let uid = req.body.uid; + let address = req.body.address; + let areaCode = req.body.area_code; + let consignee = req.body.consignee; + let mobile = req.body.mobile; + let phone = req.body.phone; + + addressModel.updateAddressData(id, uid, address, areaCode, consignee, mobile, phone).then(result => { + res.send(result); + }); +}; + +/** + * 删除地址 + */ +const delAddressData = (req, res) => { + let id = req.body.id; + let uid = req.body.uid; + + addressModel.delAddressData(id, uid).then(result => { + res.send(result); + }); +}; + +/** + * 设置默认地址 + */ +const setDefaultAddress = (req, res) => { + let id = req.body.id; + let uid = req.body.uid; + + addressModel.setDefaultAddress(id, uid).then(result => { + res.send(result); + }); +}; + +module.exports = { + index, + addAddressData, + updateAddressData, + delAddressData, + setDefaultAddress +}; diff --git a/apps/me/controllers/order.js b/apps/me/controllers/order.js index 8f2f415..ad2d16c 100644 --- a/apps/me/controllers/order.js +++ b/apps/me/controllers/order.js @@ -38,7 +38,8 @@ const getOrderList = (req, res) => { layout: false, page: 'order', isMe: true, - orderList: result.order.orderList + orderList: result.order.orderList, + paginationOpts: result.order.paginationOpts }); }); }; diff --git a/apps/me/models/address.js b/apps/me/models/address.js new file mode 100644 index 0000000..15556cf --- /dev/null +++ b/apps/me/models/address.js @@ -0,0 +1,128 @@ +/** + * [个人中心]收货地址 + * @author: jiangmin + * @date: 2016/07/05 + */ + +'use strict'; + +const api = global.yoho.API; + +/** + * 地址列表数据 + * + * @param uid 用户ID + * @param limit 分页大小参数(默认10条) + * @return array 地址接口返回的数据 + */ +const getAddressDataAsync = (uid, limit) => { + return api.get('', { + method: 'app.address.gethidden', + uid: uid, + limit: limit + }).then(result => { + // console.log('列表结果result', result); + if (result.code === '200') { + return result.data; + } + return result; + }); +}; + +/** + * 保存地址数据 + * + * @param uid 用户ID + * @param address 地址信息 + * @param areaCode 城市码 + * @param consignee 收货人 + * @param mobile 手机号码 + * @param phone 电话号码 + * @return array 地址接口返回的数据 + */ +const addAddressData = (uid, address, areaCode, consignee, mobile, phone) => { + return api.get('', { + method: 'app.address.add', + uid: uid, + address: address, + area_code: areaCode, + consignee: consignee, + mobile: mobile, + phone: phone + }).then(result => { + // console.log("添加result",result); + return result; + }); +}; + +/** + * 修改地址数据 + * + * @param id 地址id + * @param uid 用户ID + * @param address 地址信息 + * @param areaCode 城市码 + * @param consignee 收货人 + * @param mobile 手机号码 + * @param phone 电话号码 + * @return array 地址接口返回的数据 + */ +const updateAddressData = (id, uid, address, areaCode, consignee, mobile, phone) => { + return api.get('', { + method: 'app.address.update', + id: id, + uid: uid, + address: address, + area_code: areaCode, + consignee: consignee, + mobile: mobile, + phone: phone + }).then(result => { + // console.log("修改result", result); + return result; + }); +}; + +/** + * 删除地址数据 + * + * @param id 地址id + * @param uid 用户ID + * @return array 地址接口返回的数据 + */ +const delAddressData = (id, uid) => { + return api.get('', { + method: 'app.address.del', + id: id, + uid: uid + }).then(result => { + // console.log("删除result",result); + return result; + }); +}; + +/** + * 设置默认地址 + * + * @param id 地址id + * @param uid 用户ID + * @return array 地址接口返回的数据 + */ +const setDefaultAddress = (id, uid) => { + return api.get('', { + method: 'app.address.setdefault', + id: id, + uid: uid + }).then(result => { + // console.log('设置默认result', result); + return result; + }); +}; + +module.exports = { + getAddressDataAsync: getAddressDataAsync, + addAddressData: addAddressData, + updateAddressData: updateAddressData, + delAddressData: delAddressData, + setDefaultAddress: setDefaultAddress +}; diff --git a/apps/me/models/order.js b/apps/me/models/order.js index 88539a8..983f6ad 100644 --- a/apps/me/models/order.js +++ b/apps/me/models/order.js @@ -1,3 +1,5 @@ +'use strict'; + const api = global.yoho.API; const camelCase = global.yoho.camelCase; @@ -9,9 +11,21 @@ const _getUserOrder = (type, page) => { page: page || 1, limit: 10 }).then(result => { - const orderList = result && result.data && result.data.order_list || []; + let orderList = []; + let total = false; + let curPage = 1; + + if (result && result.data) { + orderList = result.data.order_list; + total = result.data.total; + curPage = result.data.page; + } - return camelCase(orderList); + return { + orderList: camelCase(orderList), + total: total, + curPage: curPage + }; }); }; @@ -41,11 +55,19 @@ const getOrderData = (type, page) => { }; const order = Object.assign(fakeData, { - orderList: result.length && result || false + orderList: result.orderList.length && result.orderList || false }, navBar); + const paginationOpts = { + paginationOpts: { + total: result.total, + page: result.curPage, + limit: 10 + } + }; + return { - order: order + order: Object.assign(order, paginationOpts) }; }); }; diff --git a/apps/me/router.js b/apps/me/router.js index e29e337..a935c74 100644 --- a/apps/me/router.js +++ b/apps/me/router.js @@ -11,9 +11,17 @@ const cRoot = './controllers'; // 订单 const order = require(`${cRoot}/order`); +const address = require(`${cRoot}/address`); // 个人中心首页/订单 router.get(['/', '/order'], order.index); router.get('/getOrderList', order.getOrderList); +// 个人中心首页/收货地址 +router.get('/address', address.index); +router.post('/address/add', address.addAddressData); +router.post('/address/update', address.updateAddressData); +router.post('/address/del', address.delAddressData); +router.post('/address/default', address.setDefaultAddress); + module.exports = router; diff --git a/apps/me/views/partial/address.hbs b/apps/me/views/partial/address.hbs new file mode 100644 index 0000000..db83473 --- /dev/null +++ b/apps/me/views/partial/address.hbs @@ -0,0 +1,5 @@ +<div class="user-order"> + {{> common/subtitle}} + {{> address/content}} + {{> address/table}} +</div> diff --git a/apps/me/views/partial/address/content.hbs b/apps/me/views/partial/address/content.hbs new file mode 100644 index 0000000..9931fc3 --- /dev/null +++ b/apps/me/views/partial/address/content.hbs @@ -0,0 +1,40 @@ +<form id="address-form" name="address-form"> + <div class="address-page"> + <span class="blue tip">新增地址 电话为选填项,其他均为必填项</span> + <div class="add-address-detail"> + <div class="form-group"> + <label class="label-name"> 收货人:</label> + <input id="address_id" type="hidden" value=""> + <input id="consignee" class="input width-190" type="text" placeholder="请输入您的姓名" maxlength="10"> + <span class="blue error-tips">{{> icon/error-round}}收件人不能为空</span> + </div> + <div class="form-group"> + <label class="label-name">所在区域:</label> + <div id="address"></div> + <span class="blue error-tips">{{> icon/error-round}}所在区域不能为空</span> + </div> + <div class="form-group"> + <label class="label-name">详细地址:</label> + <input id="addressDetail" class="input width-275" type="text" placeholder="街道名称或小区名称" maxlength="60"> + <span class="blue error-tips">{{> icon/error-round}}详细地址不能为空</span> + </div> + <div class="form-group"> + <label class="label-name">手机号码:</label> + <input id="mobile" class="input width-190" type="text" placeholder="请输入手机号码(重要必填)" maxlength="11"> + <span class="blue error-tips">{{> icon/error-round}}手机号码不能为空</span> + </div> + <div class="form-group"> + <label class="label-name">电话号码:</label> + <input id="phone" class="input width-190" type="text" placeholder="请输入电话号码(选填)"> + </div> + <div class="form-group "> + <label class="label-name"></label> + <span class="iconfont radio default-address opreation"></span> + <label class="radio-lable">设置为默认收货地址</label> + </div> + <div class="form-group"> + <span class="btn opreation" id="save-address">保存</span> + </div> + </div> + </div> +</form> diff --git a/apps/me/views/partial/address/table.hbs b/apps/me/views/partial/address/table.hbs new file mode 100644 index 0000000..c33530f --- /dev/null +++ b/apps/me/views/partial/address/table.hbs @@ -0,0 +1,35 @@ +<div class="address-table"> + + <span class="blue table-title">已保存了{{data.length}}条地址,还能保存{{data.leftLength}}条地址</span> + <table class="a-table"> + <tr class="table-head"> + <th class="width-80">收货人</th> + <th class="width-195">所在区域</th> + <th class="width-280">详细地址</th> + <th class="width-120">手机/电话</th> + <th class="width-260">操作</th> + </tr> + {{#each data}} + <tr class="table-body"> + <input type="hidden" id="tr_{{address_id}}" value="{{address_id}}"> + <td class="width-80">{{consignee}}</td> + <td class="width-195">{{area}}</td> + <td class="width-255">{{address}}</td> + <td class="width-120"><p>{{mobile}}</p><p>{{phone}}</p></td> + <td class="width-260"> + <div> + <span class="blue opreation update-address" data-id="{{address_id}}">修改</span> + | + <span class="blue opreation del-address" data-id="{{address_id}}">删除</span> + {{#if default}} + <span class="btn set-default opreation current-default ">默认地址</span> + {{else}} + <span class="btn set-default opreation " data-id="{{address_id}}">设为默认</span> + {{/if}} + </div> + </td> + </tr> + {{/each}} + </table> + +</div> diff --git a/apps/me/views/partial/order/table-body.hbs b/apps/me/views/partial/order/table-body.hbs index c86f5a0..96bbc6a 100644 --- a/apps/me/views/partial/order/table-body.hbs +++ b/apps/me/views/partial/order/table-body.hbs @@ -54,6 +54,7 @@ </div> </div> {{/orderList}} +{{{ pagination paginationOpts }}} {{^}} <div class="bg"></div> <div class="msg"> diff --git a/apps/product/controllers/list.js b/apps/product/controllers/list.js index 6fba309..f03301f 100644 --- a/apps/product/controllers/list.js +++ b/apps/product/controllers/list.js @@ -1,102 +1,10 @@ - 'use strict'; const _ = require('lodash'); -const Search = require('../models/list'); -const BrandData = require('../models/brand-service'); +const Search = require('../models/search'); const camelCase = global.yoho.camelCase; const DateHelper = require('../models/helpers'); -function newFilter(key, value, name) { - return { - key: key, - value: value, - name: name - }; -} - -function filterHandle(filter, q) { - let priceRange = filter.priceRange; - let sizeInfo = filter.size; - let genders = DateHelper.genders(); - let brands = filter.brand; - let colors = DateHelper.colorConver(filter.color); - let sorts = filter.groupSort; - let filters = []; - - genders.forEach(g => { - if (g.value === q.gender) { - g.checked = true; - filters.push(newFilter('gender', q.gender, g.name)); - } - }); - - priceRange = Object.keys(priceRange).map((k) => { - let prices = k.split(','); - - if (k === q.price) { - filters.push(newFilter('price', q.price, `¥${prices[0]}-¥${prices[1]}`)); - } - return { - lower: prices[0], - higher: prices[1] - }; - }).sort((a, b) => { - return a.lower - b.lower; - }); - - if (!_.isArray(sizeInfo)) { - sizeInfo.checked = true; - sizeInfo = [sizeInfo]; - } - - if (q.size) { - sizeInfo.forEach(s => { - if (s.sizeId === parseInt(q.size, 10)) { - filters.push(newFilter('size', q.size, s.sizeName)); - } - }); - } - - if (q.brand) { - let brandNames = brands.filter(b => { - return (',' + q.brand + ',').indexOf(',' + b.id + ',') >= 0; - }).map(b => { - return b.brandName; - }).join('、'); - - filters.push(newFilter('brand', q.brand, brandNames)); - } - - if (q.color) { - colors.forEach(c => { - if (c.id === parseInt(q.color, 10)) { - c.cur = true; - - let fi = newFilter('color', q.color, c.title); - - fi.color = c; - filters.push(fi); - } - }); - } - - return { - people: genders, - sortData: sorts, - brandData: brands, - colors: colors, - size: sizeInfo, - priceRange: priceRange, - filters: filters, - showFilters: filters.length > 0, - letters: DateHelper.brandLetters(), - navPath: { - nav: DateHelper.getNav('', q.sort, sorts) - } - }; -} - const list = { index: (req, res, next) => { let page = req.query.page || 1; @@ -114,12 +22,6 @@ const list = { title: '列表' }; - if (brand) { - BrandData.getBannerInfoAsync(brand).then(brandInfo => { - console.log(brandInfo); - }); - } - Search.queryProduct({ page: page, brand: brand, @@ -135,7 +37,7 @@ const list = { let data = camelCase(result.data); if (data.filter) { - retDate.filter = filterHandle(data.filter, req.query); + retDate.filter = DateHelper.filterHandle(data.filter, req.query); } retDate.paginationData = { diff --git a/apps/product/controllers/shop.js b/apps/product/controllers/shop.js new file mode 100644 index 0000000..51a281d --- /dev/null +++ b/apps/product/controllers/shop.js @@ -0,0 +1,87 @@ +/** + * 店铺相关页面 + * + * 首页、列表页 + * + * @author: jiangfeng<jeff.jiang@yoho.cn> + */ + +'use strict'; + +const _ = require('lodash'); +const camelCase = global.yoho.camelCase; +const BrandData = require('../models/brand-service'); +const Search = require('../models/search'); +const DateHelper = require('../models/helpers'); + +function bannerFormat(banner) { + return { + bgImg: banner.brandBanner, + brandIntro: { + text: '品牌介绍' + }, + height: 150 + }; +} + +function shopMenu() { + let menus = [ + {name: '店铺首页', href: '/'}, + {name: '全部商品', href: '/shop', icon: ''}, + {name: '人气单品', href: '/list?order=xxx'}, + {name: '新品上架', href: '/list?order=s_t_desc'} + ]; + + return menus; +} + +const shop = { + + list(req, res, next) { + let data = { + module: 'product', + page: 'shop-list', + title: '店铺列表' + }; + + let domain = req.query.domain; + let q = req.query; + + q.page = q.page || 1; + data.shopMenu = shopMenu(); + + BrandData.getBrandByDomainAsync(domain).then(result => { + data.brandBanner = bannerFormat(result); + q.brand = result.id; + q.shop_id = q.shopId || ''; + }).then(() => { + return Search.queryProductOfBrand(q).then(result => { + + if (result && result.code === 200 && result.data) { + let ret = camelCase(result.data); + + if (ret.filter) { + data.filter = DateHelper.filterHandle(ret.filter, req.query); + } + + data.paginationData = { + page: q.page, + limit: ret.limit || 45, + total: ret.total, + pageTotal: ret.pageTotal, + queryParams: req.query + }; + + res.display('shop-list', _.assign(data, { + products: ret.productList, + order: q.order + })); + } else { + return Promise.reject('query product error'); + } + }); + }).catch(next); + } +}; + +module.exports = shop; diff --git a/apps/product/models/helpers.js b/apps/product/models/helpers.js index 90adb3c..c246238 100644 --- a/apps/product/models/helpers.js +++ b/apps/product/models/helpers.js @@ -1,13 +1,12 @@ 'use strict'; +const _ = require('lodash'); + const helpers = { - brandLetters() { + brandLetters(numberIndex) { let letters = []; - letters.push({ - letter: '0-9', - selected: false - }); + numberIndex = numberIndex || 0; for (let i = 'A'.charCodeAt(0); i <= 'Z'.charCodeAt(0); i++) { letters.push({ @@ -16,6 +15,18 @@ const helpers = { }); } + if (numberIndex === -1) { + letters.push({ + letter: '0-9', + selected: false + }); + } else if (numberIndex === 0) { + letters.unshift({ + letter: '0-9', + selected: false + }); + } + return letters; }, @@ -35,7 +46,7 @@ const helpers = { return { id: c.colorId, title: c.colorName, - rgb: c.colorValue || '#' + c.colorCode + rgb: c.colorValue ? `url(${c.colorValue})` : '#' + c.colorCode }; }); }, @@ -74,6 +85,96 @@ const helpers = { }); } return nav; + }, + + newFilter(key, value, name) { + return { + key: key, + value: value, + name: name + }; + }, + + filterHandle(filter, q) { + let priceRange = filter.priceRange; + let sizeInfo = filter.size; + let genders = this.genders(); + let brands = filter.brand; + let colors = this.colorConver(filter.color); + let sorts = filter.groupSort; + let filters = []; + + genders.forEach(g => { + if (g.value === q.gender) { + g.checked = true; + filters.push(this.newFilter('gender', q.gender, g.name)); + } + }); + + priceRange = Object.keys(priceRange).map((k) => { + let prices = k.split(','); + + if (k === q.price) { + filters.push(this.newFilter('price', q.price, `¥${prices[0]}-¥${prices[1]}`)); + } + return { + lower: prices[0], + higher: prices[1] + }; + }).sort((a, b) => { + return a.lower - b.lower; + }); + + if (!_.isArray(sizeInfo)) { + sizeInfo.checked = true; + sizeInfo = [sizeInfo]; + } + + if (q.size) { + sizeInfo.forEach(s => { + if (s.sizeId === parseInt(q.size, 10)) { + filters.push(this.newFilter('size', q.size, s.sizeName)); + } + }); + } + + if (q.brand) { + let brandNames = brands.filter(b => { + return (',' + q.brand + ',').indexOf(',' + b.id + ',') >= 0; + }).map(b => { + return b.brandName; + }).join('、'); + + filters.push(this.newFilter('brand', q.brand, brandNames)); + } + + if (q.color) { + colors.forEach(c => { + if (c.id === parseInt(q.color, 10)) { + c.cur = true; + + let fi = this.newFilter('color', q.color, c.title); + + fi.color = c; + filters.push(fi); + } + }); + } + + return { + people: genders, + sortData: sorts, + brandData: brands, + colors: colors, + size: sizeInfo, + priceRange: priceRange, + filters: filters, + showFilters: filters.length > 0, + letters: this.brandLetters(), + navPath: { + nav: this.getNav('', q.sort, sorts) + } + }; } }; diff --git a/apps/product/models/list.js b/apps/product/models/search.js index 201bad8..748beb6 100644 --- a/apps/product/models/list.js +++ b/apps/product/models/search.js @@ -1,10 +1,6 @@ - 'use strict'; -const SearchAPI = global.yoho.SearchAPI; const api = global.yoho.API; -const logger = global.yoho.logger; -const camelCase = global.yoho.camelCase; const _ = require('lodash'); function clearEmptyVal(obj) { @@ -17,26 +13,22 @@ function clearEmptyVal(obj) { } const Search = { - querySort(query) { - return SearchAPI.get('sortgroup.json', _.assign({ - sales: 'Y', - status: 1, - stocknumber: 1 - }, query)).then(data => { - if (data && data.code === 200 && data.data) { - return camelCase(data.data.sort); - } else { - return []; - } - }).catch(e => { - logger.error(e); - return Promise.resolve([]); - }); - }, queryProduct(params) { let finalParams = { - method: 'app.search.sales', + method: 'app.search.li', + limit: 45, + productSize: '384x511', + yh_channel: 1 + }; + + Object.assign(finalParams, clearEmptyVal(params)); + + return api.get('', finalParams); + }, + queryProductOfBrand(params) { + let finalParams = { + method: 'app.search.li', limit: 45, productSize: '384x511', yh_channel: 1 diff --git a/apps/product/models/shop-api.js b/apps/product/models/shop-api.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/apps/product/models/shop-api.js diff --git a/apps/product/router.js b/apps/product/router.js index 20b9356..a789fb2 100644 --- a/apps/product/router.js +++ b/apps/product/router.js @@ -10,10 +10,13 @@ const router = require('express').Router(); // eslint-disable-line const cRoot = './controllers'; const list = require(cRoot + '/list'); const item = require(cRoot + '/item'); +const shop = require(cRoot + '/shop'); // Your controller here -router.get('/list', list.index); // 组件demo页 +router.get('/list', list.index); // 列表页面 router.get(/\/item\/([\d]+)_([\d]+).html/, item.index); // 商品详情页 +router.get('/shop/list', shop.list); + module.exports = router; diff --git a/apps/product/views/action/shop-list.hbs b/apps/product/views/action/shop-list.hbs new file mode 100644 index 0000000..c53775d --- /dev/null +++ b/apps/product/views/action/shop-list.hbs @@ -0,0 +1,31 @@ +<div class="blk-page yoho-product-list"> + <div class="center-content"> + {{# filter.navPath}} + {{> path-nav}} + {{/ filter.navPath}} + </div> + <div class="center-content clearfix"> + {{> brand-banner-list }} + {{> list/shop-menu }} + </div> + <div class="center-content clearfix"> + <div class="left"> + {{!-- 筛选区域 --}} + {{#filter}} + {{> list/filter}} + {{/filter}} + </div> + <div class="right"> + {{!-- 已选中条件 --}} + {{#filter}} + {{> list/filter-area}} + {{/filter}} + {{!-- 排序 --}} + {{> list/order-area}} + {{!-- 商品列表 --}} + {{> list/goods-box}} + {{!-- 分页 --}} + {{{ pagination paginationData }}} + </div> + </div> +</div> diff --git a/apps/product/views/partial/brand-banner-list.hbs b/apps/product/views/partial/brand-banner-list.hbs new file mode 100644 index 0000000..2f5ad93 --- /dev/null +++ b/apps/product/views/partial/brand-banner-list.hbs @@ -0,0 +1,16 @@ +{{# brandBanner}} + <div class="brand-banner" style="background-image: url('{{image bgImg 1150 150}}')"> + <p class="opts"> + {{# brandIntro}} + <a href="{{link}}"> + <i class="iconfont"></i> + {{text}} + </a> + {{/ brandIntro}} + + <span id="brand-fav" class="brand-fav{{#if coled}} coled{{/if}}"> + {{> icon/collection}} + </span> + </p> + </div> +{{/brandBanner}} diff --git a/apps/product/views/partial/brand-banner.hbs b/apps/product/views/partial/brand-banner.hbs index 7e00e83..1902c51 100644 --- a/apps/product/views/partial/brand-banner.hbs +++ b/apps/product/views/partial/brand-banner.hbs @@ -30,4 +30,4 @@ </div> </div> </div> -{{/ brandBanner}} \ No newline at end of file +{{/ brandBanner}} diff --git a/apps/product/views/partial/list/filter.hbs b/apps/product/views/partial/list/filter.hbs index f80796c..e961689 100644 --- a/apps/product/views/partial/list/filter.hbs +++ b/apps/product/views/partial/list/filter.hbs @@ -50,7 +50,11 @@ {{#each brandData}} <div class="input-radio" data-value="{{id}}"> {{> icon/radio}} - <label>{{brandNameEn}}</label> + {{#if brandNameEn}} + <label>{{brandNameEn}}</label> + {{^}} + <label>{{brandName}}</label> + {{/if}} </div> {{/each}} </div> @@ -111,4 +115,4 @@ {{/each}} </div> </div> -</div> \ No newline at end of file +</div> diff --git a/apps/product/views/partial/list/shop-menu.hbs b/apps/product/views/partial/list/shop-menu.hbs new file mode 100644 index 0000000..45eda0c --- /dev/null +++ b/apps/product/views/partial/list/shop-menu.hbs @@ -0,0 +1,12 @@ +<ul class="shop-menu"> + {{#each shopMenu}} + <li> + <a href="{{href}}"> + {{name}} + {{#icon}} + <i class="iconfont"></i> + {{/icon}} + </a> + </li> + {{/each}} +</ul> diff --git a/public/font/iconfont.svg b/public/font/iconfont.svg index a7ebfd5..af080d7 100644 --- a/public/font/iconfont.svg +++ b/public/font/iconfont.svg @@ -2,7 +2,11 @@ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > <svg xmlns="http://www.w3.org/2000/svg"> <metadata> +<<<<<<< HEAD Created by FontForge 20120731 at Thu Jul 7 17:43:49 2016 +======= +Created by FontForge 20120731 at Fri Jul 8 14:37:44 2016 +>>>>>>> feature/product By admin </metadata> <defs> @@ -19,7 +23,11 @@ Created by FontForge 20120731 at Thu Jul 7 17:43:49 2016 bbox="0 -224 1303 896.303" underline-thickness="50" underline-position="-100" +<<<<<<< HEAD unicode-range="U+0078-E638" +======= + unicode-range="U+0078-E63B" +>>>>>>> feature/product /> <missing-glyph horiz-adv-x="374" d="M34 0v682h272v-682h-272zM68 34h204v614h-204v-614z" /> @@ -130,6 +138,11 @@ d="M361 194q45 -63 81 -152h143q42 68 75 152l82 -29q-32 -69 -70 -123h202v-71h-724 <glyph glyph-name="uniE624" unicode="" d="M897 -212h-770q-44 0 -71 34.5t-21 82.5l89 598q3 31 30 52.5t61 21.5h51q4 111 73 173t171.5 62t171 -62t73.5 -173h54q34 0 61 -21.5t30 -52.5l89 -598q6 -48 -21 -82.5t-71 -34.5zM230 406q0 -25 18 -43t43 -18t42.5 18t17.5 43t-17.5 42.5t-42.5 17.5t-43 -17.5 t-18 -42.5zM510 767q-87 0 -144.5 -49t-61.5 -141h412q-4 92 -61.5 141t-144.5 49zM736 466q-25 0 -42.5 -17.5t-17.5 -42.5t17.5 -43t42.5 -18t43 18t18 43t-18 42.5t-43 17.5z" /> +<<<<<<< HEAD +======= + <glyph glyph-name="uniE625" unicode="" +d="M43 0h938l-469 811zM555 128h-86v85h86v-85zM555 299h-86v170h86v-170z" /> +>>>>>>> feature/product <glyph glyph-name="uniE626" unicode="" d="M139 233q-24 -59 -27.5 -108t15.5 -60q13 -7 32.5 7.5t38.5 45.5q16 -66 72 -116q-29 -11 -45.5 -28.5t-16.5 -37.5q0 -34 43.5 -57.5t105.5 -23.5q56 0 97.5 19.5t50.5 48.5h18q8 -29 50 -48.5t98 -19.5q62 0 105.5 23.5t43.5 57.5q0 20 -16.5 37.5t-45.5 28.5 q56 50 71 116q20 -31 39 -45.5t32 -7.5q19 11 16 60t-27 108q-19 46 -42 78t-43 40q1 7 1 12q0 35 -17 64v4q0 16 -7 30q-5 125 -77.5 207t-190 82t-189.5 -82t-77 -207q-7 -14 -7 -30v-4q-17 -29 -17 -64q0 -5 1 -12q-20 -8 -43.5 -40t-41.5 -78z" /> @@ -186,5 +199,12 @@ d="M512 -212q-104 0 -199 40.5t-163.5 109t-109 163.5t-40.5 199t40.5 199t109 163.5 t271.5 -112.5t271.5 112.5t112.5 271.5t-112.5 271.5t-271.5 112.5z" /> <glyph glyph-name="uniE638" unicode="" d="M511 833q-91 0 -174 -35.5t-143 -95.5t-95.5 -143t-35.5 -174t35.5 -174t95.5 -143t143 -95t174 -35t174 35t143 95t95.5 143t35.5 174t-35.5 174t-95.5 143t-143 95.5t-174 35.5z" /> +<<<<<<< HEAD +======= + <glyph glyph-name="uniE63A" unicode="" +d="M963 564l-117 -190h92v-43h-107v-58h107v-42h-107v-85h-55v85h-112v42h112v58h-112v43h95l-115 190h62q81 -142 98 -180h1q6 16 33 63l66 117h59z" /> + <glyph glyph-name="uniE63B" unicode="" +d="M0 -128h1024v1024zM826 301l-250 -282l-122 122q-9 9 -9 22t9.5 22.5t22.5 9.5t22 -9l77 -77l198 230q10 10 23 10t22 -10q10 -5 13 -16.5t-6 -21.5z" /> +>>>>>>> feature/product </font> </defs></svg> diff --git a/public/js/me/address.page.js b/public/js/me/address.page.js new file mode 100644 index 0000000..3342e65 --- /dev/null +++ b/public/js/me/address.page.js @@ -0,0 +1,263 @@ +/** + * [个人中心]收货地址 + * @author: jiangmin + * @date: 2016/07/05 + */ + + +var cascadingAddress = require('../plugins/cascading-address'); +var dialog = require('../plugins/dialog'); +var _confirm = dialog.Confirm; +var $addressId = $('#address_id'); +var $consignee = $('#consignee'); +var $address = $('#addressDetail'); +var $mobile = $('#mobile'); +var $phone = $('#phone'); +var currentLength = $('.a-table').find('tr').length - 1;// 当前地址条数 +var leftLength = 20 - currentLength;// 还剩地址条数 + +var Bll = { + // 获取输入框输入的值 + getInfo() { + // todo uid + var uid = '123456'; + + return { + id: $addressId.val(), + uid: uid, + consignee: $consignee.val(), + + // todo 地址码 + address: $address.val(), + mobile: $mobile.val(), + phone: $phone.val() + + // todo 设置默认值 + }; + }, + + // 清空输入框 + clearInput() { + $consignee.val(''); + + // todo 省市区清空 + $address.val(''); + $mobile.val(''); + $phone.val(''); + }, + + // 校验 + check(info) { + let flag = true; + let reg = new RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/); + + if (info.consignee === '' || info.address === '' || info.mobile === '') { + flag = '有必填项为空'; + } else if (!reg.test(info.mobile)) { + flag = '手机号码格式不对'; + } + return flag; + }, + + // 拼接一条数据的html + getHtml(info) { + var html = '<tr class="table-body">'; + + html += '<input type="hidden" id="tr_' + info.address_id + '" value="' + info.address_id + '">' + + '<td class=\'width-80\'>' + info.consignee + '</td>' + + '<td class=\'width-195\'>' + info.area + '</td>' + + '<td class=\'width-280\'>' + info.address + '</td>' + + '<td class=\'width-120\'><p>' + info.mobile + '</p><p>' + info.phone + '</p></td>' + + '<td class=\'width-260\'><div><span class=\'blue opreation update-address\'>修改</span>\n|\n' + + '<span class=\'blue opreation del-address\' data-id=\'' + info.address_id + '\'>删除</span>\n' + + '<span class=\'btn set-default opreation \' data-id=\'' + info.address_id + '\'>设为默认</span></div></td>'; + html += '</tr>'; + return html; + }, + + // 获取一条数据 + setInfo(id, td) { + $addressId.val(id); + $consignee.val(td.eq(0).text()); + + // todo 省市区逆向展示 + // $areaCode.val(td.eq(1).text()); + $address.val(td.eq(2).text()); + $mobile.val(td.eq(3).children().eq(0).text()); + $phone.val(td.eq(3).children().eq(1).text()); + }, + + // 设置表格头部 + setTableTile() { + $('.table-title').text('已保存了' + currentLength + + '条地址,还能保存' + leftLength + '条地址'); + } +}; + +require('./me'); + +// 设置收货地址 +$('.default-address').click(function() { + if ($(this).hasClass('checked')) { + $(this).removeClass('checked'); + $(this).html(''); + } else { + $(this).addClass('checked'); + $(this).html(''); + } +}); + +// 校验 +$consignee.keydown(function() { + $(this).next().hide(); +}); +$consignee.blur(function() { + if ($(this).val().trim() === '') { + $(this).next().show(); + } +}); +$address.keydown(function() { + $(this).next().hide(); +}); +$address.blur(function() { + if ($(this).val().trim() === '') { + $(this).next().show(); + } +}); +$mobile.keydown(function() { + $(this).next().hide(); +}); +$mobile.blur(function() { + if ($(this).val().trim() === '') { + $(this).next().show(); + } else { + let reg = new RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/); + + if (!reg.test(($(this).val().trim()))) { + $(this).next().show(); + $(this).next().html('手机号码格式不正确'); + } + } +}); + +// 保存收货地址 +$(document).on('click', '#save-address', function() { + var info = Bll.getInfo(); + var area = $('#address-form').serialize(); + + info.area_code = area.substring(area.length - 6); + if (Bll.check(info) === true) { + // 新增 + if (info.id === '') { + $.ajax({ + type: 'POST', + url: '/me/address/add', + dataType: 'json', + data: info, + success: function(data) { + let html = Bll.getHtml(data.data); + + currentLength++; + leftLength--; + $('tbody').append(html); + Bll.setTableTile(); + Bll.clearInput(); + } + }); + } else { // 修改 + console.log('上传info', info); + $.ajax({ + type: 'POST', + url: '/me/address/update', + dataType: 'json', + data: info, + success: function(data) { + if (data.code === 200) { + $('#tr_' + info.id).parent().before(Bll.getHtml(info)).remove(); + Bll.clearInput(); + } else { + + // alert('修改出错!'); + } + } + }); + } + } else { + alert(Bll.check(info)); + } +}); + +// 修改收货地址 +$('.update-address').click(function() { + let id = $(this).data('id'); + let tr = $(this).parents('.table-body'); + let td = tr.find('td'); + + Bll.setInfo(id, td); +}); + +// 删除收货地址 +$('.del-address').click(function() { + let id = $(this).data('id'); + var tr = $(this).parents('.table-body'); + + var a = new _confirm({ + content: '您确定要删除收货地址吗?', + cb: function() { + $.ajax({ + type: 'POST', + url: '/me/address/del', + dataType: 'json', + data: { + // todo uid + uid: '123456', + id: id + }, + success: function() { + currentLength--; + leftLength++; + tr.remove(); + Bll.setTableTile(); + a.close(); + } + }); + } + }).show(); +}); + +// 设置默认收货地址 +$(document).on('click', '.set-default', function() { + var tr = $(this).parents('.table-body'); + var tbody = tr.parent(); + let id = $(this).data('id'); + var self = this; + + $.ajax({ + type: 'POST', + url: '/me/address/default', + dataType: 'json', + data: { + // todo uid + uid: '123456', + id: id + }, + success: function() { + $('.current-default').removeClass('current-default').text('设为默认'); + $(self).addClass('current-default').text('默认地址'); + tbody.find('.table-body').eq(0).before('<tr class=\'table-body\'>' + tr.html() + '</tr>'); + tr.remove(); + } + }); +}); + + +$(function() { + // 运行此demo + // 1. 安装 npm i -g json-server + // 2. json-server --watch mock/address.json + cascadingAddress({ + el: '#address', + url: 'http://localhost:3000/areas/0', + resource: 'areas' + }); +}); diff --git a/public/js/me/order.page.js b/public/js/me/order.page.js index 1e2b201..a452d09 100644 --- a/public/js/me/order.page.js +++ b/public/js/me/order.page.js @@ -29,12 +29,12 @@ function getOrderList(type, page) { } }).done(function(res) { tableOperation.appendBody(res); + bindPaginationClick(); // eslint-disable-line }).fail(function(err) { console.log(err); }); } - function getQueryString() { var queryArr = location.search.substr(1).split('&'); var query = {}; @@ -49,6 +49,24 @@ function getQueryString() { return query; } +function bindPaginationClick() { + $('.blk-pagination li').off('click').on('click', function(e) { + var $this = $(this); + var page = $this.find('a').attr('href').split('=')[1]; + var type = getQueryString().type; + + e.preventDefault(); + + if (!$this.hasClass('active')) { + $('.blk-pagination li.active').removeClass('active'); + $this.addClass('active'); + + getOrderList(type, page); + } + + }); +} + $('.tabs li').on('click', function() { var $this = $(this); var typeMap = { @@ -62,7 +80,11 @@ $('.tabs li').on('click', function() { if (!$this.hasClass('active')) { $('.tabs li.active').removeClass('active'); $this.addClass('active'); + + getOrderList(type, page); } - getOrderList(type, page); }); + + +bindPaginationClick(); diff --git a/public/js/plugins/check.js b/public/js/plugins/check.js index 5e3b90e..38a3851 100644 --- a/public/js/plugins/check.js +++ b/public/js/plugins/check.js @@ -54,7 +54,7 @@ var jQuery = require('yoho-jquery'); $(this).each(function() { var options = $(this).data('options'); - check._uncheck(this, options); + check._unCheck(this, options); }); }, _check: function(ele, options) { @@ -70,7 +70,7 @@ var jQuery = require('yoho-jquery'); } } }, - _uncheck: function(ele, options) { + _unCheck: function(ele, options) { var icon = $(ele).find('.' + options.type); var checked = $(icon).hasClass('checked'); diff --git a/public/js/product/list.page.js b/public/js/product/list.page.js index 0b772f0..de915d6 100644 --- a/public/js/product/list.page.js +++ b/public/js/product/list.page.js @@ -1,260 +1,2 @@ -var $ = require('yoho-jquery'); -var common = require('../common'); - -var query = common.queryString(); - -var YohoListPage = { - rootDoc: $('.yoho-product-list'), - brandsDoc: $('.yoho-product-list .brand-list'), - mulitBrand: false, - goodsWrapper: $('.goods-area .goods-wrapper'), - goodsWrapperState: false, - page: query.page || 1, - init: function() { - require('yoho-jquery-accordion'); - require('../plugins/check'); - $('.yoho-ui-accordion', this.rootDoc).each(function() { - var opts = { - collapsible: true, - heightStyle: 'content' - }; - - if ($(this).hasClass('no-active')) { - opts.active = false; - } - $(this).accordion(opts); - }); - - $('.yoho-product-list .sex-body .input-radio').check({ - type: 'radio', - onChange: function(ele, checked, value) { - YohoListPage.go({ - gender: checked ? value : '' - }); - } - }); - - $('.yoho-product-list .list-body .input-radio').check({ - type: 'radio', - onChange: function(ele, checked, value) { - YohoListPage.go({ - sort: checked ? value : '' - }); - } - }); - - $('.yoho-product-list .price-body .input-radio').check({ - type: 'radio', - onChange: function(ele, checked, value) { - YohoListPage.go({ - price: checked ? value : '' - }); - } - }); - - $('.yoho-product-list .size-body .input-radio').check({ - type: 'radio', - onChange: function(ele, checked, value) { - YohoListPage.go({ - size: checked ? value : '' - }); - } - }); - - $('.yoho-product-list .brand-list .input-radio').check({ - type: 'radio', - onChange: function(ele, checked, value) { - if (!YohoListPage.mulitBrand) { - YohoListPage.go({brand: value}); - } else { - YohoListPage.showBrandMulitBtn(); - } - } - }); - - $('.yoho-product-list .color-body .input-radio').check({ - type: 'radio', - onChange: function(ele, checked, value) { - YohoListPage.go({ - color: checked ? value : '' - }); - } - }); - - YohoListPage.eventBind(); - }, - eventBind: function() { - $('.yoho-product-list .mulit-choose').click(function() { - YohoListPage.openBrandMulitChoose(); - }); - - $('.yoho-product-list .brand-btns .cancel').click(function() { - YohoListPage.closeBrandMulitChoose(); - }); - - $('.yoho-product-list .brand-btns .confirm').click(function() { - if (!$(this).hasClass('disable')) { - YohoListPage.go({ - brand: YohoListPage.getSelectBrands().join(',') - }); - } - }); - - $('.yoho-product-list .brand-body input').on('keyup', function() { - YohoListPage.filterBrand($(this).val().toLowerCase()); - }); - - $('.yoho-product-list .brand-letter-items .item').hover(function() { - $('.yoho-product-list .brand-letter-items .item').removeClass('select'); - $(this).addClass('select'); - YohoListPage.filterBrand($(this).data('value').toLowerCase()); - }); - - $('.goods-area > .goods').mouseenter(function(e) { - YohoListPage.showGoodsWrapper(e); - }); - - $('.goods-wrapper').mouseleave(function(e) { - YohoListPage.hideGoodsWrapper(e); - }); - - $('.filter-area .filter-item').click(function() { - var key = $(this).data('key'); - var data = {}; - - data[key] = ''; - YohoListPage.go(data); - }); - - $('.filter-area .cancel').click(function() { - var data = {}; - - $('.filter-area .filter-item').each(function() { - var key = $(this).data('key'); - - data[key] = ''; - }); - - YohoListPage.go(data); - }); - - $('.order-area .page').click(function() { - if (!$(this).hasClass('disable')) { - if ($(this).hasClass('page-pre')) { - YohoListPage.go({ - page: YohoListPage.page - 1 - }); - } else { - YohoListPage.go({ - page: YohoListPage.page + 1 - }); - } - } - }); - - $('.order-area .order').click(function() { - var order = $(this).data('order'); - var target = $(this).data('target'); - var orders = order.split(','); - var newOrder = ''; - - if (query.order === orders[0]) { - newOrder = orders[1] || ''; - } else { - newOrder = orders[0]; - } - - $('.order-area .order').removeClass('selected'); - $(this).addClass('selected'); - $('.' + target).find('.iconfont').each(function() { - if ($(this).hasClass(newOrder)) { - $(this).addClass('selected'); - } else { - $(this).removeClass('selected'); - } - }); - - YohoListPage.go({ - order: newOrder - }); - }); - }, - openBrandMulitChoose: function() { - $('.yoho-product-list .mulit-choose').hide(); - YohoListPage.mulitBrand = true; - YohoListPage.showBrandMulitBtn(); - }, - closeBrandMulitChoose: function() { - $('.yoho-product-list .mulit-choose').show(); - $('.yoho-product-list .brand-btns').addClass('hide'); - - $('.yoho-product-list .brand-list .input-radio').check('unCheckAll'); - YohoListPage.mulitBrand = false; - }, - showBrandMulitBtn: function() { - $('.brand-btns', this.rootDoc).removeClass('hide'); - if (YohoListPage.getSelectBrands().length > 0) { - $('.brand-btns .confirm', this.rootDoc).removeClass('disable'); - } else { - $('.brand-btns .confirm', this.rootDoc).addClass('disable'); - } - }, - filterBrand: function(letter) { - $('.yoho-product-list .brand-list .input-radio').each(function() { - if ($('label', this).text().toLowerCase().indexOf(letter) === 0) { - $(this).show(); - } else { - $(this).hide(); - } - }); - }, - getSelectBrands: function() { - let brands = []; - - $('.input-radio .radio', this.brandsDoc).each(function() { - if ($(this).hasClass('checked')) { - brands.push($(this).parent().data('value')); - } - }); - return brands; - }, - showGoodsWrapper: function(e) { - var position = $(e.currentTarget).position(); - var productId = $(e.currentTarget).data('id'); - - if (YohoListPage.goodsWrapperState && YohoListPage.productId !== productId) { - YohoListPage.goodsWrapperState = false; - } - - if (!YohoListPage.goodsWrapperState) { - YohoListPage.productId = productId; - position.top += 10; - $(this.goodsWrapper).css(position); - $('.goods', this.goodsWrapper).html($(e.currentTarget).html()); - $('.goods-img-list', this.goodsWrapper).empty(); - $(e.currentTarget).find('.goods-list i').each(function() { - $('.goods-img-list', this.goodsWrapper).append( - '<img src="' + $(this).text() + '" width="60" height="80" alt="">'); - }); - $(this.goodsWrapper).show(); - YohoListPage.goodsWrapperState = true; - - $('.goods-img-list img', this.goodsWrapper).hover(function() { - $('.goods .goods-img img', YohoListPage.goodsWrapper).attr('src', $(this).attr('src')); - }); - } - }, - hideGoodsWrapper: function() { - YohoListPage.goodsWrapperState = false; - $('.goods-area .goods-wrapper').hide(); - }, - - go: function(q) { - var qs = $.extend(common.queryString(), q); - - location.search = $.param(qs); - } -}; - -YohoListPage.init(); +require('./list/list-search'); diff --git a/public/js/product/list/list-search.js b/public/js/product/list/list-search.js new file mode 100644 index 0000000..13e9410 --- /dev/null +++ b/public/js/product/list/list-search.js @@ -0,0 +1,271 @@ +var $ = require('yoho-jquery'); +var common = require('../../common'); + +var query = common.queryString(); + +var YohoListPage = { + rootDoc: $('.yoho-product-list'), + brandsDoc: $('.yoho-product-list .brand-list'), + mulitBrand: false, + goodsWrapper: $('.goods-area .goods-wrapper'), + goodsWrapperState: false, + page: query.page || 1, + init: function() { + require('yoho-jquery-accordion'); + require('../../plugins/check'); + $('.yoho-ui-accordion', this.rootDoc).each(function() { + var opts = { + collapsible: true, + heightStyle: 'content' + }; + + if ($(this).hasClass('no-active')) { + opts.active = false; + } + $(this).accordion(opts); + }); + + $('.sex-body .input-radio', this.rootDoc).check({ + type: 'radio', + onChange: function(ele, checked, value) { + YohoListPage.go({ + gender: checked ? value : '' + }); + } + }); + + $('.list-body .input-radio', this.rootDoc).check({ + type: 'radio', + onChange: function(ele, checked, value) { + YohoListPage.go({ + sort: checked ? value : '' + }); + } + }); + + $('.price-body .input-radio', this.rootDoc).check({ + type: 'radio', + onChange: function(ele, checked, value) { + YohoListPage.go({ + price: checked ? value : '' + }); + } + }); + + $('.size-body .input-radio', this.rootDoc).check({ + type: 'radio', + onChange: function(ele, checked, value) { + YohoListPage.go({ + size: checked ? value : '' + }); + } + }); + + $('.brand-list .input-radio', this.rootDoc).check({ + type: 'radio', + onChange: function(ele, checked, value) { + if (!YohoListPage.mulitBrand) { + YohoListPage.go({brand: value}); + } else { + YohoListPage.showBrandMulitBtn(); + } + } + }); + + $('.color-body .input-radio', this.rootDoc).check({ + type: 'radio', + onChange: function(ele, checked, value) { + YohoListPage.go({ + color: checked ? value : '' + }); + } + }); + + YohoListPage.eventBind(); + }, + eventBind: function() { + $('.mulit-choose', this.rootDoc).click(function() { + YohoListPage.openBrandMulitChoose(); + }); + + $('.brand-btns .cancel', this.rootDoc).click(function() { + YohoListPage.closeBrandMulitChoose(); + }); + + $('.brand-btns .confirm', this.rootDoc).click(function() { + if (!$(this).hasClass('disable')) { + YohoListPage.go({ + brand: YohoListPage.getSelectBrands().join(',') + }); + } + }); + + $('.yoho-product-list .brand-body input').on('keyup', function() { + YohoListPage.filterBrand($(this).val().toLowerCase()); + }); + + $('.yoho-product-list .brand-letter-items .item').hover(function() { + $('.yoho-product-list .brand-letter-items .item').removeClass('select'); + $(this).addClass('select'); + YohoListPage.filterBrand($(this).data('value').toLowerCase()); + }); + + $('.goods-area > .goods').mouseenter(function(e) { + YohoListPage.showGoodsWrapper(e); + }); + + $('.goods-wrapper').mouseleave(function(e) { + YohoListPage.hideGoodsWrapper(e); + }); + + $('.filter-area .filter-item').click(function() { + var key = $(this).data('key'); + var data = {}; + + data[key] = ''; + YohoListPage.go(data); + }); + + $('.filter-area .cancel').click(function() { + var data = {}; + + $('.filter-area .filter-item').each(function() { + var key = $(this).data('key'); + + data[key] = ''; + }); + + YohoListPage.go(data); + }); + + $('.order-area .page').click(function() { + if (!$(this).hasClass('disable')) { + if ($(this).hasClass('page-pre')) { + YohoListPage.go({ + page: YohoListPage.page - 1 + }); + } else { + YohoListPage.go({ + page: YohoListPage.page + 1 + }); + } + } + }); + + $('.order-area .order').click(function() { + var order = $(this).data('order'); + var target = $(this).data('target'); + var orders = order.split(','); + var newOrder = ''; + + if (query.order === orders[0]) { + newOrder = orders[1] || ''; + } else { + newOrder = orders[0]; + } + + $('.order-area .order').removeClass('selected'); + $(this).addClass('selected'); + $('.' + target).find('.iconfont').each(function() { + if ($(this).hasClass(newOrder)) { + $(this).addClass('selected'); + } else { + $(this).removeClass('selected'); + } + }); + + YohoListPage.go({ + order: newOrder + }); + }); + }, + openBrandMulitChoose: function() { + $('.yoho-product-list .mulit-choose').hide(); + YohoListPage.mulitBrand = true; + YohoListPage.showBrandMulitBtn(); + }, + closeBrandMulitChoose: function() { + $('.yoho-product-list .mulit-choose').show(); + $('.yoho-product-list .brand-btns').addClass('hide'); + + $('.yoho-product-list .brand-list .input-radio').check('unCheckAll'); + YohoListPage.mulitBrand = false; + }, + showBrandMulitBtn: function() { + $('.brand-btns', this.rootDoc).removeClass('hide'); + if (YohoListPage.getSelectBrands().length > 0) { + $('.brand-btns .confirm', this.rootDoc).removeClass('disable'); + } else { + $('.brand-btns .confirm', this.rootDoc).addClass('disable'); + } + }, + filterBrand: function(letter) { + $('.yoho-product-list .brand-list .input-radio').each(function() { + if (letter === '0-9') { + var first = $('label', this).text().toLowerCase().charAt(0); // eslint-disable-line + + if ((first >= 'a' && first <= 'z') || (first >= 'A' && first <= 'Z')) { + $(this).hide(); + } else { + $(this).show(); + } + } else { + if ($('label', this).text().toLowerCase().indexOf(letter) === 0) { + $(this).show(); + } else { + $(this).hide(); + } + } + }); + }, + getSelectBrands: function() { + let brands = []; + + $('.input-radio .radio', this.brandsDoc).each(function() { + if ($(this).hasClass('checked')) { + brands.push($(this).parent().data('value')); + } + }); + return brands; + }, + showGoodsWrapper: function(e) { + var position = $(e.currentTarget).position(); + var productId = $(e.currentTarget).data('id'); + + if (YohoListPage.goodsWrapperState && YohoListPage.productId !== productId) { + YohoListPage.goodsWrapperState = false; + } + + if (!YohoListPage.goodsWrapperState) { + YohoListPage.productId = productId; + position.top += 10; + $(this.goodsWrapper).css(position); + $('.goods', this.goodsWrapper).html($(e.currentTarget).html()); + $('.goods-img-list', this.goodsWrapper).empty(); + $(e.currentTarget).find('.goods-list i').each(function() { + $('.goods-img-list', this.goodsWrapper).append( + '<img src="' + $(this).text() + '" width="60" height="80" alt="">'); + }); + $(this.goodsWrapper).show(); + YohoListPage.goodsWrapperState = true; + + $('.goods-img-list img', this.goodsWrapper).hover(function() { + $('.goods .goods-img img', YohoListPage.goodsWrapper).attr('src', $(this).attr('src')); + }); + } + }, + hideGoodsWrapper: function() { + YohoListPage.goodsWrapperState = false; + $('.goods-area .goods-wrapper').hide(); + }, + + go: function(q) { + var qs = $.extend(common.queryString(), q); + + location.search = $.param(qs); + } +}; + +YohoListPage.init(); + +module.exports = YohoListPage; diff --git a/public/js/product/shop-list.page.js b/public/js/product/shop-list.page.js new file mode 100644 index 0000000..de915d6 --- /dev/null +++ b/public/js/product/shop-list.page.js @@ -0,0 +1,2 @@ + +require('./list/list-search'); diff --git a/public/scss/me/_address.css b/public/scss/me/_address.css new file mode 100644 index 0000000..77a2ea8 --- /dev/null +++ b/public/scss/me/_address.css @@ -0,0 +1,132 @@ +.address-page { + + .title { + font-size: 30px; + height: 100px; + line-height: 100px; + text-align: left; + } + .tip { + font-size: 14px; + } + + .add-address-detail { + padding: 15px 0 0; + + .form-group { + clear: both; + margin-bottom: 20px; + + .default-address, + #address, + .btn { + + margin-left: 83px; + } + + .label-name { + font-size: 14px; + text-align: left; + float: left; + line-height: 26px; + } + + .width-190 { + width: 190px; + margin-left: 20px; + } + .width-275 { + width: 275px; + margin-left: 20px; + } + .iconfont { + font-size: 14px; + } + .radio-lable { + font-size: 14px; + } + .error-tips { + font-size: 12px; + height: 26px; + line-height: 26px; + margin-left: 20px; + + .iconfont { + font-size: 12px; + margin-right: 5px; + } + } + .opreation { + cursor: pointer; + } + + } + } +} + +.address-table { + .table-title { + font-size: 10px; + height: 40px; + line-height: 40px; + } + + .a-table { + + tr, + th, + td { + + font-size: 15px; + border: 1px solid #eee; + padding: 0 5px; + text-align: left; + } + + .opreation { + cursor: pointer; + } + + .table-head { + background: #f5f5f5; + height: 30px; + } + + .table-body td { + padding: 8px 5px; + } + + .width-80 { + width: 80px; + } + + .width-195 { + width: 195px; + } + + .width-255 { + width: 255px; + word-break: break-all; + } + + .width-120 { + width: 120px; + + p:first-child { + margin-bottom: 5px; + } + } + + .width-260 { + width: 260px; + } + + .current-default, + .set-default { + + display: inline-block; + margin-left: 20px; + } + + } +} diff --git a/public/scss/me/_index.css b/public/scss/me/_index.css index ac884a1..0852918 100644 --- a/public/scss/me/_index.css +++ b/public/scss/me/_index.css @@ -101,4 +101,5 @@ } } +@import "address"; @import "order/index"; diff --git a/public/scss/me/order/_table.css b/public/scss/me/order/_table.css index 2febce2..2dc9dde 100644 --- a/public/scss/me/order/_table.css +++ b/public/scss/me/order/_table.css @@ -207,5 +207,10 @@ } } } + + .blk-pagination { + margin: $bigSpace auto -$bigSpace; + text-align: center; + } } diff --git a/public/scss/product/_index.css b/public/scss/product/_index.css index 24ef478..9f657dd 100644 --- a/public/scss/product/_index.css +++ b/public/scss/product/_index.css @@ -1,5 +1,6 @@ @import 'list'; @import 'item'; +@import 'shop-list'; /* 组件 */ @import 'brand-banner'; diff --git a/public/scss/product/_list.css b/public/scss/product/_list.css index 96070aa..12f2087 100644 --- a/public/scss/product/_list.css +++ b/public/scss/product/_list.css @@ -11,18 +11,19 @@ } } .input-radio { - padding: 10px 0; + padding: 10px 1px; .round-color { - width: 16px; - height: 15px; + width: 22px; + height: 21px; + vertical-align: middle; .iconfont { - font-size: 16px; + font-size: 22px; } .iconfont.icon-cover { - font-size: 16px; + font-size: 22px; } } } @@ -192,13 +193,16 @@ .filter-item { display: inline-block; margin: 12px 10px; - padding: 10px 5px; font-size: 14px; border: 1px solid #adacad; background-color: #fff; + padding: 8px; span { font-size: 14px; + display: inline-block; + height: 21px; + line-height: 21px; } span.label { @@ -210,15 +214,17 @@ } .round-color { - width: 16px; - height: 15px; + width: 22px; + height: 20px; + vertical-align: middle; + margin-left: 5px; .iconfont { - font-size: 16px; + font-size: 22px; } .iconfont.icon-cover { - font-size: 16px; + font-size: 22px; } } } @@ -389,14 +395,6 @@ } } - .c-blue { - color: blue; - } - - .c-red { - color: red; - } - .blk-pagination { text-align: center; margin: 20px 0 40px; diff --git a/public/scss/product/_shop-list.css b/public/scss/product/_shop-list.css new file mode 100644 index 0000000..68929f6 --- /dev/null +++ b/public/scss/product/_shop-list.css @@ -0,0 +1,48 @@ +.yoho-product-list { + + .brand-banner { + width: 100%; + height: 150px; + background-size: 100% 100%; + position: relative; + + p.opts { + display: block; + position: absolute; + right: 20px; + bottom: 30px; + font-size: 14px; + + a, + .brand-fav { + color: #fff; + border: 1px solid #fff; + padding: 10px; + margin-left: 10px; + + .iconfont { + font-size: 14px; + } + } + } + } + + .shop-menu { + + border-bottom: 1px solid #eee; + margin-bottom: 30px; + + li { + display: inline-block; + margin: 10px 30px; + + a { + font-size: 12px; + } + + .iconfont { + font-size: 14px; + } + } + } +}