<file_sep># yuekao
4月份月考
<file_sep>require(['main'],function(){
	require(['mui'],function(mui){ 
		click();
		function click(){
			var button=document.querySelector('button');
			mui('section').on('tap','button',function(){
				//获取数据
				var fen=document.querySelector('.fen');
				var lis=[...fen.querySelectorAll('input')];
				var fi=document.querySelector('.fi');
				var pr=document.querySelector('.pr');
		       //console.log(fi.value.trim(),lis[0].value.trim())
			mui.ajax('/api/creat',{
				data:{
					uname:fi.value.trim(),
					price:pr.value.trim(),
					pin:lis[0].value.trim(),
					fen:lis[1].value.trim(),
					fu:lis[2].value.trim(),
					add:lis[3].value.trim(),
					shu:lis[4].value.trim(),
					ke:lis[5].value.trim(),
					yan:lis[6].value.trim(),
					bei:lis[7].value.trim()
				},
				dataType:'json',//服务器返回json格式数据
				type:'post',//HTTP请求类型
				timeout:10000,//超时时间设置为10秒；
				success:function(data){
					if(data.code==1){
				      alert("成功")
					  location.href='../index.html'
					}else{
						alert("失败")
					}
				
				}
			});
			})
		}
	})
})<file_sep>var gulp=require('gulp');
var webserver=require('gulp-webserver');
gulp.task('web',function(){
	return gulp.src('./src')
	.pipe(webserver({
		port:8989,
		open:true,
		livereload:true,
		proxies:[
			{source:"/api/xuan",target:"http://localhost:3000/api/xuan"},
			{source:"/api/creat",target:"http://localhost:3000/api/creat"},
			{source:"/api/found",target:"http://localhost:3000/api/found"}
		]
	}))
})
<file_sep>[{
    "img": "img/i1.png",
    "uname": "珠片绣订SX-1126",
    "nei": "3D重手工",
    "biao": "现货"
}, {
    "img": "img/i2.png",
    "uname": "珠片绣订SX-1126",
    "nei": "3D重手工",
    "biao": "供应"
}, {
    "img": "img/i3.png",
    "uname": "珠片绣订SX-1126",
    "nei": "3D重手工",
    "biao": "现货"
}, {
    "img": "img/i4.png",
    "uname": "珠片绣订SX-1126",
    "nei": "3D重手工",
    "biao": "供应"
}, {
    "img": "img/i5.png",
    "uname": "珠片绣订SX-1126",
    "nei": "3D重手工",
    "biao": "供应"
}]

[{
    "uname": "1",
    "img": "img/i4.png",
    "price": 1,
    "pin": "1",
    "fen": "1",
    "fu": "1",
    "add": "1",
    "shu": "1",
    "yan": "1",
    "bei": "1",
    "ke": "1"
}]<file_sep>require(['main'], function() {
	require(['mui'], function(mui) {
		var con=0;
		var page=1;
		var limit=10;
		var list = document.querySelector('.list');
		mui.init({
			pullRefresh: {
				container: refreshContainer, //待刷新区域标识，querySelector能定位的css选择器均可，比如：id、.class等
				up: {
					contentrefresh: "正在加载...", //可选，正在加载状态时，上拉加载控件上显示的标题内容
					contentnomore: '没有更多数据了', //可选，请求完毕若没有更多数据时显示的提醒内容；
					callback: pullfresh //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
				}
			}
		});
		xuan();
		push();
		search();
        function  pullfresh(){
			setTimeout(function(){
				if(con==0){
					mui('#refreshContainer').pullRefresh().endPullupToRefresh(true);
				}else{
					mui('#refreshContainer').pullRefresh().endPullupToRefresh(false);
				}
				page++;
				xuan();
			},1000)
			
		}
		function xuan() {
			mui.ajax('/api/xuan', {
				data:{
					page:page,
					limit:limit
				},
				dataType: 'json', //服务器返回json格式数据
				type: 'post', //HTTP请求类型
				timeout: 10000, //超时时间设置为10秒；
				success: function(data) {
					con=data.data.length;
					console.log(con);
					//list.innerHTML.innerHTML='';
					list.innerHTML += data.data.map(function(item) {
						return `<li>
								<img src="${item.img}" alt="">
								 <h4>${item.uname}</h4>
								 <p><span>${item.nei}</span><span class="te">${item.biao}</span></p>
							</li>`
					}).join('')
				}
			});
		}
		function push(){
			var bu=document.querySelector('.bu');
			mui('.tex').on('tap','.bu',function(){
				location.href='../push.html'
			})
		}
		function search(){
			var ji=document.querySelector('.ji');
			ji.oninput=function(){
				console.log(this.value);
				var val=this.value.trim();
				mui.ajax('/api/found',{
					data:{
						uname:val
					},
					dataType:'json',//服务器返回json格式数据
					type:'post',//HTTP请求类型
					timeout:10000,//超时时间设置为10秒；
					success:function(data){
						console.log(data);
						var cha=document.querySelector('.cha');
						console.log(cha);
						cha.style.display="block";
						cha.innerHTML=data.data.map(function(item){
							return `<li>
							<p>工艺商品:${item.uname}</p>
							<p>价格:${item.price}</p>
							<p>${item.pin}</p>
							<p>${item.fen}</p>
							<p>${item.fu}</p>
							<p>${item.add}</p>
							<p>${item.shu}</p>
							<p>${item.yan}</p>
							<p>${item.bei}</p>
							</li>
							`
						}).join('');
						
					}
				});
			}
		}
	})
})
