<file_sep>//返回顶部按钮
define(['jquery'], function($){
	function toTop(){
			//右侧边栏固定菜单移入移出
			$(".right-bar a").on('mouseenter', function(){
				$(".right-bar .iconfont").eq($(this).index()).css('color', '#333');
				$(".right-bar a div").eq($(this).index()).css('display', 'block');
			});
			$(".right-bar a").on('mouseleave', function(){
				$(".right-bar .iconfont").eq($(this).index()).css('color', '#bbb');
				$(".right-bar a div").eq($(this).index()).css('display', 'none');
			})
			if($(window).scrollTop()>=1200){
					$('#backtop').css('display', 'block');
				}else{
					$('#backtop').css('display', 'none');
				}
			$(window).scroll(function(){
				if($(window).scrollTop()>=1200){
					$('#backtop').css('display', 'block');
				}else{
					$('#backtop').css('display', 'none');
				}
			})
			$('#backtop').on('click', function(ev){
				ev.preventDefault();
				$('html,body').animate({scrollTop:0}, 1000);
			});
	}
	return {toTop: toTop};
})<file_sep>define(['jquery'], function($){
	function insert(){
		var navArr = ['荣耀', 'HUAWEI P系列', '荣耀畅玩系列', 'HUAWEI Mate系列', 'HUAWEI nova系列', '华为畅享系列', 'HUAWEI 麦芒系列', '移动4G+专区'];
		for(var i = 0; i < navArr.length; i++){
			$('.cate-attr .cate-values ul').append(`<li><a href="#">${navArr[i]}</a></li>`);
		}
		$.ajax({
			type: 'get',
			url: 'data/phone.json',
			success: function(arr){
				for(var i = 0; i < arr.length; i++){
					$(`<li>
							<div class="pro-panel">
								<div class="p-img">
									<a href="${arr[i].aUrl}">
										<img src="${arr[i].imgUrl}" alt="">
									</a>
								</div>
								<div class="p-title">
									<a href="#">${arr[i].title}</a>
								</div>
								<div class="p-price">${arr[i].price}</div>
								<div class="p-button clear">
									<a href="${arr[i].aUrl}" class="p-button-car">选购</a>
									<span class="p-button-score">${arr[i].evaluateNum}人评价</span>
								</div>
							</div>
						</li>`).appendTo('.phones .pro-list ul');
				}
				
			},
			error: function(msg){
			}
		});
		function selSort(arr, type){
			for(var i = 0; i < arr.length; i++){
				for(var j = i+1; j<arr.length; j++){
					if(arr[i][type]>arr[j][type]){
						[arr[i], arr[j]] = [arr[j], arr[i]];
					}
				}
			}
			return arr;
		}
		function sort(sortType){
			$('.sort-desc').removeClass('selected');
			$(this).parent().addClass('selected');
			$('.phones .pro-list').css('height', $('.phones .pro-list').height());
			$('.phones .pro-list ul').html('');
			$.ajax({
				type: 'get',
				url: 'data/phone.json',
				success: function(arr){
					//转成num
					for(var i = 0; i < arr.length; i++){
						arr[i].priceNum = parseInt(arr[i].priceNum);
						arr[i].evaluateNum = parseInt(arr[i].evaluateNum);
					}
					if(sortType == 'time'){

					}else{
						arr = selSort(arr, sortType)
					}
					for(var i = 0; i<arr.length;i++){
						$(`<li>
								<div class="pro-panel">
									<div class="p-img">
										<a href="${arr[i].aUrl}">
											<img src="${arr[i].imgUrl}" alt="">
										</a>
									</div>
									<div class="p-title">
										<a href="#">${arr[i].title}</a>
									</div>
									<div class="p-price">${arr[i].price}</div>
									<div class="p-button clear">
										<a href="${arr[i].aUrl}" class="p-button-car">选购</a>
										<span class="p-button-score">${arr[i].evaluateNum}人评价</span>
									</div>
								</div>
							</li>`).appendTo('.phones .pro-list ul');
					}
				},
				error: function(msg){
					console.log(msg);
				}
			});
		}
		$('#timeSort').on('click', 'a', function(){
			sort.call($(this), ['time']);
		});
		$('#priceSort').on('click', 'a', function(){
			sort.call($(this), ['priceNum']);
		});
		$('#scoreSort').on('click', 'a', function(){
			sort.call($(this), ['evaluateNum']);
		});
	}
	return {insert: insert}
});<file_sep>console.log('phone page');
require.config({
	paths:{
		jquery: 'jquery-1.11.3',
		cookie: 'jquery.cookie',
		phone: 'phone',
		toTop: 'toTop'
	},
	shim:{
		cookie: 'jquery'
	}
})
require(['phone', 'toTop'], function(phone, toTop){
	phone.insert();
	toTop.toTop();
})<file_sep>const gulp = require('gulp');

gulp.task('copy-html', function(){
	return gulp.src('*.html')
	.pipe(gulp.dest('dest'))
	.pipe(connect.reload());
})

gulp.task('images', function(){
	return gulp.src('img/*.{jpg,png}')
	.pipe(gulp.dest('dest/img'))
	.pipe(connect.reload());
})

gulp.task('data', function(){
	return gulp.src(['*.json', '!package.json'])
	.pipe(gulp.dest('dest/data'))
	.pipe(connect.reload());
})

gulp.task('build', ['copy-html', 'images', 'data'], function(){
	console.log("编译完成");
});

//scss
const scss = require('gulp-scss');
const minifyCss = require('gulp-minify-css');
const rename = require('gulp-rename');

gulp.task('scss', function(){
	return gulp.src('stylesheet/index.scss')
	.pipe(scss())
	.pipe(gulp.dest('dest/css'))
	.pipe(minifyCss())
	.pipe(rename('index.min.css'))
	.pipe(gulp.dest('dest/css'))
	.pipe(connect.reload());
})
gulp.task('phoneScss', function(){
	return gulp.src('stylesheet/phone.scss')
	.pipe(scss())
	.pipe(gulp.dest('dest/css'))
	.pipe(minifyCss())
	.pipe(rename('phone.min.css'))
	.pipe(gulp.dest('dest/css'))
	.pipe(connect.reload());
})
gulp.task('proScss', function(){
	return gulp.src('stylesheet/10086983017283.scss')
	.pipe(scss())
	.pipe(gulp.dest('dest/css'))
	.pipe(minifyCss())
	.pipe(rename('10086983017283.min.css'))
	.pipe(gulp.dest('dest/css'))
	.pipe(connect.reload());
})
//js
gulp.task('scripts', function(){
	return gulp.src(['*.js', '!gulpfile.js'])
	.pipe(gulp.dest('dest/js'))
	.pipe(connect.reload());
})

//listen
gulp.task('watch', function(){
	gulp.watch('*.html', ['copy-html']);
	gulp.watch('img/*.{jpg,png}', ['images']);
	gulp.watch(['*.json', '!package.json'], ['data']);
	gulp.watch('stylesheet/index.scss', ['scss']);
	gulp.watch('stylesheet/phone.scss', ['phoneScss']);
	gulp.watch('stylesheet/10086983017283.scss', ['proScss']);
	gulp.watch(['*.js', '!gulpfile.js'], ['scripts']);
})

//server
const connect = require('gulp-connect');

gulp.task('server', function(){
	connect.server({
		root: 'dest',
		port: 8888,
		livereload: true
	})
})

gulp.task('default', ['watch', 'server']);