/** @Name: 用户模块 */ 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 laypage = layui.laypage; var fly = layui.fly; var flow = layui.flow; var element = layui.element; var upload = layui.upload; var table = layui.table; var gather = {}, dom = { mine: $('#LAY_mine') ,mineview: $('.mine-view') ,minemsg: $('#LAY_minemsg') ,infobtn: $('#LAY_btninfo') }; //我的相关数据 //发贴list var post = table.render({ elem: '#art-post' ,url: artListUrl ,title: '' ,cols: [[ {type: 'numbers', fixed: 'left'} ,{field: 'title', title: '标题',minWidth: 250 ,templet: '
'} ,{field: 'status', title: '状态', width: 80} ,{field: 'ctime', title: '时间', width: 120} ,{field: 'datas', title: '数据', width: 120} ,{title: '操作', width: 150, align: 'center', toolbar: '#artTool'} ]] ,text: '对不起,加载出现异常!' ,page: true }); //收藏list table.render({ elem: '#coll-post' ,url: collListUrl ,title: '' ,cols: [[ {type: 'numbers', fixed: 'left'} ,{field: 'title', title: '标题',minWidth: 250,templet: ''} ,{field: 'auther', title: '作者', width: 120} ,{field: 'status', title: '状态', width: 80} ,{field: 'ctime', title: '时间', width: 120} ,{title: '取消', width: 80, align: 'center', toolbar: '#collTool'} ]] ,text: '对不起,加载出现异常!' ,page: true }); //监听行工具事件 table.on('tool(art-post)', function(obj){ var data = obj.data; var id = data.id; if(obj.event === 'del'){ layer.confirm('确定删除吗?',{ title:'删除文章', icon:3 },function(index){ layer.close(index); $.post(atrDelUrl,{"id":id},function(data){ if(data.code == 0){ layer.msg(data.msg,{ icon:6, time:2000 }); } else { layer.open({ title:'删除失败', content:data.msg, icon:5, adim:6 }) } } ); table.reload('art-post'); }); } else if(obj.event === 'edit'){//编辑 $.post(artEditUrl,{"id":id},function(){ location.href = artEditUrl + '?id=' + id; }); } }); //监听行工具事件 table.on('tool(coll-post)', function(obj){ var id = obj.data.id; if(obj.event === 'del'){ layer.confirm('确定取消收藏?',{ title:'取消收藏', icon:3 },function(index){ layer.close(index); $.post(collDelUrl,{"id":id},function(data){ if(data.code == 0){ layer.msg(data.msg,{ icon:6, time:2000 }); } else { layer.open({ title:'取消失败', content:data.msg, icon:5, adim:6 }) } } ); table.reload('coll-post'); }); } }); //显示当前tab if(location.hash){ element.tabChange('user', location.hash.replace(/^#/, '')); } 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||''); }); } //上传图片 if($('.upload-img')[0]){ layui.use('upload', function(upload){ var avatarAdd = $('.avatar-add'); upload.render({ elem: '.upload-img' ,url: uploadHeadImg ,size: 300 ,before: function(){ avatarAdd.find('.loading').show(); } ,done: function(res){ if(res.status == 0){ $.post(userSet, { avatar: res.url }, function(res){ location.reload(); }); } else { layer.msg(res.msg, {icon: 5}); } avatarAdd.find('.loading').hide(); } ,error: function(){ avatarAdd.find('.loading').hide(); } }); }); } //合作平台 if($('#LAY_coop')[0]){ //资源上传 $('#LAY_coop .uploadRes').each(function(index, item){ var othis = $(this); upload.render({ elem: item ,url: '/api/upload/cooperation/?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){ }}' ,'{{ d.rows[i].name}}给您发了站内信{{ d.rows[i].title}} {{ d.rows[i].read}}\ {{# } }}\ {{# if(d.rows[i].type == 2){ }}\
{{ d.rows[i].name}}回答了您的帖子{{ d.rows[i].title}} {{ d.rows[i].read}}\ {{# } }}\ {{# if(d.rows[i].type == 0){ }}\
系统消息:{{ d.rows[i].title}} {{ d.rows[i].read}}\ {{# } }}\
{{d.rows[i].time}}删除
\