This commit is contained in:
2017-12-05 11:59:58 +08:00
parent 5c708a3efd
commit 92d3f7a49e
50 changed files with 2396 additions and 1717 deletions

View File

@@ -3,17 +3,19 @@
@Name: 用户模块
*/
layui.define(['laypage', 'fly','form', 'element'], function(exports){
layui.define(['laypage', 'fly', 'element', 'flow'], function(exports){
var $ = layui.jquery;
var layer = layui.layer;
var util = layui.util;
var laytpl = layui.laytpl;
var form = layui.form();
var form = layui.form;
var laypage = layui.laypage;
var fly = layui.fly;
var element = layui.element();
var flow = layui.flow;
var element = layui.element;
var upload = layui.upload;
var gather = {}, dom = {
mine: $('#LAY_mine')
@@ -31,21 +33,26 @@ layui.define(['laypage', 'fly','form', 'element'], function(exports){
'{{# for(var i = 0; i < d.rows.length; i++){ }}\
<li>\
{{# if(d.rows[i].collection_time){ }}\
<a class="jie-title" href="/jie/{{d.rows[i].id}}.html" target="_blank">{{= d.rows[i].title}}</a>\
<i>收藏于{{ d.rows[i].collection_time }}</i>\
<a class="jie-title" href="/jie/{{d.rows[i].id}}/" target="_blank">{{= d.rows[i].title}}</a>\
<i>{{ d.rows[i].collection_time }} 收藏</i>\
{{# } else { }}\
{{# if(d.rows[i].status == 1){ }}\
<span class="fly-jing">精</span>\
<span class="fly-jing layui-hide-xs">精</span>\
{{# } }}\
{{# if(d.rows[i].accept >= 0){ }}\
<span class="jie-status jie-status-ok">已解决</span>\
<span class="jie-status jie-status-ok">已</span>\
{{# } else { }}\
<span class="jie-status">未结</span>\
{{# } }}\
<a class="jie-title" href="/jie/{{d.rows[i].id}}.html" target="_blank">{{= d.rows[i].title}}</a>\
<i>{{new Date(d.rows[i].time).toLocaleString()}}</i>\
{{# if(d.rows[i].status == -1){ }}\
<span class="jie-status">审核中</span>\
{{# } }}\
<a class="jie-title" href="/jie/{{d.rows[i].id}}/" target="_blank">{{= d.rows[i].title}}</a>\
<i class="layui-hide-xs">{{ layui.util.timeAgo(d.rows[i].time, 1) }}</i>\
{{# if(d.rows[i].accept == -1){ }}\
<a class="mine-edit" href="/jie/edit/{{d.rows[i].id}}">编辑</a>\
<a class="mine-edit layui-hide-xs" href="/jie/edit/{{d.rows[i].id}}" target="_blank">编辑</a>\
{{# } }}\
<em>{{d.rows[i].hits}}阅/{{d.rows[i].comment}}答</em>\
<em class="layui-hide-xs">{{d.rows[i].hits}}阅/{{d.rows[i].comment}}答</em>\
{{# } }}\
</li>\
{{# } }}'
@@ -68,14 +75,14 @@ layui.define(['laypage', 'fly','form', 'element'], function(exports){
fly.json(url, {}, function(res){
res.count = res.rows.length;
var rows = fly.sort(res.rows, 'collection_timestamp')
var rows = layui.sort(res.rows, 'collection_timestamp', 'desc')
,render = function(curr){
var data = []
,start = curr*nums - nums
,last = start + nums - 1;
if(last >= rows.length){
last = curr > 1 ? rows.length - (last - rows.length) : rows.length - 1;
last = curr > 1 ? start + (rows.length - start - 1) : rows.length - 1;
}
for(var i = start; i <= last; i++){
@@ -83,17 +90,16 @@ layui.define(['laypage', 'fly','form', 'element'], function(exports){
}
res.rows = data;
view(res);
};
render(curr)
gather.minelog['collect-page-' + curr] = res;
now || laypage({
cont: 'LAY_page1'
,pages: Math.ceil(rows.length/nums) //得到总页数
,skin: 'fly'
now || laypage.render({
elem: 'LAY_page1'
,count: rows.length
,curr: curr
,jump: function(e, first){
if(!first){
@@ -108,10 +114,9 @@ layui.define(['laypage', 'fly','form', 'element'], function(exports){
}, function(res){
view(res);
gather.minelog['mine-jie-page-' + curr] = res;
now || laypage({
cont: 'LAY_page'
,pages: res.pages
,skin: 'fly'
now || laypage.render({
elem: 'LAY_page'
,count: res.count
,curr: curr
,jump: function(e, first){
if(!first){
@@ -136,19 +141,22 @@ layui.define(['laypage', 'fly','form', 'element'], function(exports){
});
}
//Hash地址的定位
var layid = location.hash.replace(/^#/, '');
element.tabChange('user', layid);
//显示当前tab
if(location.hash){
element.tabChange('user', location.hash.replace(/^#/, ''));
}
element.on('tab(user)', function(elem){
location.hash = ''+ $(this).attr('lay-id');
element.on('tab(user)', function(){
var othis = $(this), layid = othis.attr('lay-id');
if(layid){
location.hash = layid;
}
});
//根据ip获取城市
if($('#L_city').val() === ''){
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function(){
$('#L_city').val(remote_ip_info.city);
$('#L_city').val(remote_ip_info.city||'');
});
}
@@ -156,26 +164,21 @@ layui.define(['laypage', 'fly','form', 'element'], function(exports){
if($('.upload-img')[0]){
layui.use('upload', function(upload){
var avatarAdd = $('.avatar-add');
layui.upload({
elem: '.upload-img input'
,method: 'post'
upload.render({
elem: '.upload-img'
,url: '/os/file/upload'
,size: 50
,before: function(){
avatarAdd.find('.loading').show();
}
,success: function(res){
//res = JSON.parse(res);
,done: function(res){
if(res.retcode == 0){
$.post('/os/user/update', {
fly.json('/os/user/update', {
bean:JSON.stringify({avatar: res.retinfo})
,columns:JSON.stringify(["avatar"])
}, function(res){
res = JSON.parse(res);
if(res.retcode != 0){
layer.msg(res.retinfo);
return false;
}
location.reload();
location.reload();
});
} else {
layer.msg(res.msg, {icon: 5});
@@ -189,6 +192,73 @@ layui.define(['laypage', 'fly','form', 'element'], function(exports){
});
}
//合作平台
if($('#LAY_coop')[0]){
//资源上传
$('#LAY_coop .uploadRes').each(function(index, item){
var othis = $(this);
upload.render({
elem: item
,url: '/os/file/upload?filename='+ othis.data('filename')
,accept: 'file'
,exts: 'zip'
,size: 30*1024
,before: function(){
layer.msg('正在上传', {
icon: 16
,time: -1
,shade: 0.7
});
}
,done: function(res){
if(res.code == 0){
layer.msg(res.msg, {icon: 6})
} else {
layer.msg(res.msg)
}
}
});
});
//成效展示
var effectTpl = ['{{# layui.each(d.data, function(index, item){ }}'
,'<tr>'
,'<td><a href="/u/{{ item.uid }}" target="_blank" style="color: #01AAED;">{{ item.uid }}</a></td>'
,'<td>{{ item.authProduct }}</td>'
,'<td>¥{{ item.rmb }}</td>'
,'<td>{{ item.create_time }}</td>'
,'</tr>'
,'{{# }); }}'].join('');
var effectView = function(res){
var html = laytpl(effectTpl).render(res);
$('#LAY_coop_effect').html(html);
$('#LAY_effect_count').html('你共有 <strong style="color: #FF5722;">'+ (res.count||0) +'</strong> 笔合作授权订单');
};
var effectShow = function(page){
fly.json('/cooperation/effect', {
page: page||1
}, function(res){
effectView(res);
laypage.render({
elem: 'LAY_effect_page'
,count: res.count
,curr: page
,jump: function(e, first){
if(!first){
effectShow(e.curr);
}
}
});
});
};
effectShow();
}
//提交成功后刷新
fly.form['set-mine'] = function(data, required){
layer.msg('修改成功', {
@@ -198,7 +268,7 @@ layui.define(['laypage', 'fly','form', 'element'], function(exports){
}, function(){
location.reload();
});
};
}
//表单验证
form.verify({
@@ -328,7 +398,7 @@ layui.define(['laypage', 'fly','form', 'element'], function(exports){
{{# for(var i = 0; i < len; i++){ }}\
<li data-id="{{d.rows[i].id}}">\
<blockquote class="layui-elem-quote">{{ d.rows[i].content}}</blockquote>\
<p><span>{{d.rows[i].time}}</span><a href="javascript:;" class="layui-btn layui-btn-small layui-btn-danger fly-delete">删除</a></p>\
<p><span>{{d.rows[i].time}}</span><a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger fly-delete">删除</a></p>\
</li>\
{{# } }}\
</ul>\
@@ -338,16 +408,18 @@ layui.define(['laypage', 'fly','form', 'element'], function(exports){
dom.minemsg.html('<div class="fly-none">您暂时没有最新消息</div>');
}
}
// fly.json('/message/find/', {}, function(res){
// var html = laytpl(tpl).render(res);
// dom.minemsg.html(html);
// if(res.rows.length > 0){
// delAll.removeClass('layui-hide');
// }
// });
/*
fly.json('/message/find/', {}, function(res){
var html = laytpl(tpl).render(res);
dom.minemsg.html(html);
if(res.rows.length > 0){
delAll.removeClass('layui-hide');
}
});
*/
//阅读后删除
dom.minemsg.on('click', '.mine-msg li .fly-delete', function(){
var othis = $(this).parents('li'), id = othis.data('id');
@@ -384,5 +456,5 @@ layui.define(['laypage', 'fly','form', 'element'], function(exports){
dom.minemsg[0] && gather.minemsg();
exports('user', null);
});