1268 lines
36 KiB
JavaScript
1268 lines
36 KiB
JavaScript
define(['app', 'service','jquery','layer'], function (app) {
|
||
'use strict';
|
||
|
||
app.controller('HeaderCtrl', function ($rootScope, $scope, $state, Storage, Auth,$window,$interval,Config,$stateParams,ENV,$timeout) {
|
||
$(".loadingBox").remove();
|
||
$scope.$state = $state;
|
||
//顶部点击菜单显示
|
||
$scope.navShow = false;
|
||
$scope.navShowClick = function () {
|
||
$scope.navShow = !$scope.navShow;
|
||
}
|
||
$scope.childNavClose=function(){
|
||
$scope.navShow = false;
|
||
}
|
||
//判断用户是否登录显示用户中心或者登录
|
||
var tempWeb=localStorage.getItem("user");
|
||
if(tempWeb){
|
||
$rootScope.rootUser = true;
|
||
if(!Storage.get("user")){
|
||
Storage.set("user",tempWeb);
|
||
var session_time=new Date().getTime();
|
||
sessionStorage.session_time=session_time;//创建临时缓存判断过期登录
|
||
|
||
}
|
||
}else{
|
||
$rootScope.rootUser = false;
|
||
}
|
||
|
||
// 备案号信息获取
|
||
Config.configInfoFun().then(function(data){
|
||
|
||
$rootScope.tiXianCon=data.data.other ? data.data.other['course'] : '内容为空,敬请期待……';//提现教程
|
||
$rootScope.configObj=data.data.info;//备案号信息
|
||
$rootScope.configObjGame=data.data.gameinfo;//游戏信息
|
||
if(!$rootScope.configObjGame.fruits){
|
||
$rootScope.configObjGame.fruits=1;
|
||
}
|
||
$scope.logoUrl=ENV.imgSrc+data.data.gameinfo.logo;
|
||
$rootScope.mediaUrlHttp=data.data.gameinfo.url;
|
||
$scope.titleLogo=ENV.imgSrc+data.data.gameinfo.titillogo;
|
||
$rootScope.ComonEdit={
|
||
"keyWords":data.data.gameinfo.keyWords,
|
||
"companyName":data.data.info.companyName,
|
||
"companyWord":data.data.info.companyWord,
|
||
'user_type':data.data.user_type
|
||
};
|
||
if(data.data.gameinfo.appurl){
|
||
$rootScope.APPdownImg = "http://qr.liantu.com/api.php?w=250&m=0&text=" + data.data.gameinfo.appurl;
|
||
$rootScope.APPdownLoad=data.data.gameinfo.appurl;
|
||
}
|
||
//虚拟币
|
||
$rootScope.XNB=data.data.withdraw;// rebate 比例 type:3 虚拟币 4 人民币
|
||
|
||
var images=data.data.images;
|
||
for(var i in images){
|
||
if(images[i]){
|
||
images[i] = ENV.imgSrc+images[i];
|
||
}
|
||
|
||
}
|
||
//图片设置问题
|
||
$rootScope.imagesGroup=images;
|
||
});
|
||
|
||
//获取客服资料
|
||
Config.aboutUsService().then(function(data){
|
||
$rootScope.kefuAuth=data.kefu;
|
||
$rootScope.ServiceTel=data.rexian;
|
||
angular.forEach(data.service,function(v,k){
|
||
if(v.type=="weibo"){
|
||
$rootScope.guanfangWB=v;
|
||
}
|
||
if(v.type=="weixin"){
|
||
$rootScope.guanfangWX=v;
|
||
}
|
||
if(v.type=="shangwu"){
|
||
$rootScope.shangWuHZ=v;
|
||
}
|
||
if(v.type=="time"){
|
||
$rootScope.ServiceTime=v;
|
||
}
|
||
if(v.type=="address"){
|
||
$rootScope.companyAddress=v;
|
||
}
|
||
if(v.type=="QQ"){
|
||
$rootScope.QQ=v;
|
||
}
|
||
})
|
||
|
||
});
|
||
|
||
|
||
layui.use(['layer','form','laydate'],function() {
|
||
var layer = layui.layer,
|
||
laydate = layui.laydate,
|
||
form = layui.form();
|
||
|
||
//APP是否显示
|
||
$rootScope.APPdownShow=false;
|
||
$rootScope.APPdownFun=function(){
|
||
$rootScope.APPdownShow=!$scope.APPdownShow;
|
||
if($rootScope.APPdownShow && !$rootScope.APPdownLoad){
|
||
$rootScope.APPdownShow=false;
|
||
layer.msg("请在后台添加APP下载地址");
|
||
}
|
||
}
|
||
})
|
||
|
||
|
||
//农产链接地址
|
||
$scope.farmGameUrl=ENV.imgSrc;
|
||
|
||
//退出登陆
|
||
$rootScope.loginExit = function () {
|
||
Auth.loginExit().then(function(data){
|
||
Storage.remove('user');
|
||
$state.go('root.auth');
|
||
$rootScope.rootUser = false;
|
||
$rootScope.rootUserInfo = null;
|
||
layer.msg(data.msg);
|
||
layer.closeAll();
|
||
},function(data){
|
||
layer.msg(data.msg);
|
||
layer.closeAll();
|
||
});
|
||
}
|
||
//(先存储一个sessionStorage)获取用户上次登录时间(10分钟重新登录)
|
||
if(Storage.get('user')){//检测是不是有本地存储
|
||
var time_now=new Date().getTime();//不用成语1000
|
||
if(!sessionStorage.session_time){//没有session
|
||
Storage.remove('user');
|
||
$rootScope.rootUser = false;
|
||
$rootScope.rootUserInfo = null;
|
||
}else{//问题是页面刷新才能,判断运行,剩下的后台cookie 判断
|
||
if(time_now>sessionStorage.session_time+60*60*1000){
|
||
layer.msg("登陆超时,请重新登陆……");
|
||
$timeout(function(){
|
||
Storage.remove('user');
|
||
$rootScope.rootUser = false;
|
||
$rootScope.rootUserInfo = null;
|
||
},3000)
|
||
|
||
};
|
||
}
|
||
}else{//登录
|
||
Storage.remove('user');
|
||
$rootScope.rootUser = false;
|
||
$rootScope.rootUserInfo = null;
|
||
};
|
||
|
||
|
||
|
||
$scope.enterGameUrlFunBoot=function(){
|
||
$scope.enterGameUrlBoot="/farm?token="+Storage.get("user");
|
||
$scope.enterChatUrlBoot="/web/chat/index.html?token="+Storage.get("user");
|
||
return false;
|
||
}
|
||
|
||
|
||
});
|
||
//首页控制器
|
||
app.controller('homeCtrl', function ($rootScope,$scope, Config, Article,$stateParams) {//
|
||
$(window).scrollTop(0);
|
||
//获取 公告 3 新闻 4 攻略 5
|
||
Article.list(3).then(function (data) {
|
||
$scope.leftCon = data.list[0];
|
||
|
||
});
|
||
Article.list(4).then(function (data) {
|
||
$scope.rightCon = data.list[0];
|
||
});
|
||
Article.list(5).then(function (data) {
|
||
$scope.strategy = data.list[0];
|
||
});
|
||
|
||
});
|
||
//用户-登陆
|
||
app.controller('loginCtrl', function ($rootScope,$window,$scope, Check, Auth, $interval, Storage, $state,$stateParams) {
|
||
$scope.reset=3;
|
||
//记住账号自动登陆
|
||
$scope.remoberCheck=true;
|
||
$scope.remoberCheckFun=function(){
|
||
$scope.remoberCheck=!$scope.remoberCheck;
|
||
}
|
||
if($scope.remoberCheck){//获取本地存储的用户信息
|
||
var user=Storage.get("local");
|
||
if(user){
|
||
$scope.user=user.userTel;
|
||
$scope.password=user.userPwd;
|
||
}
|
||
};
|
||
|
||
layui.use(['layer','form','laydate'],function(){
|
||
var layer = layui.layer,
|
||
laydate = layui.laydate,
|
||
form = layui.form();
|
||
|
||
|
||
$(window).scrollTop(0);
|
||
|
||
//检测是不是已经登录过了,登录过了就直接返回用户中心
|
||
var tempLogin=Storage.get("local");
|
||
var tempLogined=Storage.get("user");
|
||
if(tempLogin && tempLogined){
|
||
$state.go("root.userCenter");
|
||
}
|
||
|
||
//检验函数
|
||
$scope.telCheck = function (tel) {//手机
|
||
if (Check.empty(tel)) {
|
||
layer.msg("手机号码不能为空");
|
||
return false;
|
||
}
|
||
if (Check.tel(tel)) {
|
||
layer.msg("请输入正确的手机号码");
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
$scope.pwdCheck = function (pwd) {//密码
|
||
if (Check.empty(pwd)) {
|
||
layer.msg("密码号码不能为空");
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
$scope.imgCheck = function (img) {//图片验证码
|
||
if (Check.empty(img)) {
|
||
layer.msg("图片验证码不能为空");
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
$scope.telCodeCheck = function (telCode) {//手机验证码
|
||
if (Check.empty(telCode)) {
|
||
layer.msg("短信验证码不能为空");
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
$scope.pwdCheckD = function (pwd1, pwd2) {
|
||
if (Check.empty(pwd1) || Check.empty(pwd2)) {
|
||
layer.msg("密码不能为空");
|
||
return false;
|
||
}
|
||
if (pwd1.length < 6) {
|
||
layer.msg("密码长度不能小于6位");
|
||
return false;
|
||
}
|
||
if (pwd1 != pwd2) {
|
||
layer.msg("两次密码不一样!")
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
//忘记密码
|
||
$scope.forgetFun = function () {
|
||
$scope.reset = 1;
|
||
|
||
var user=Storage.get("local");
|
||
if(user){
|
||
$scope.user=user.userTel;
|
||
}
|
||
Storage.remove("local");
|
||
}
|
||
|
||
|
||
|
||
|
||
//登陆
|
||
$scope.loginFun = function () {
|
||
//if (!$scope.telCheck($scope.user)) {
|
||
// return;
|
||
//}
|
||
if (Check.empty($scope.user)) {
|
||
layer.msg("手机号不能为空");
|
||
return;
|
||
}
|
||
if (!$scope.pwdCheck($scope.password)) {
|
||
return;
|
||
}
|
||
//if (!$scope.imgCheck($scope.imgCodeLogin)) {
|
||
// return;
|
||
//}
|
||
//登陆请求
|
||
Auth.login($scope.user, $scope.password).then(function (data) {
|
||
//登陆成功
|
||
console.log(data);
|
||
$rootScope.rootUser = true;
|
||
//检查本地是否存在
|
||
var tempUser=Storage.get('user');
|
||
if(tempUser){
|
||
Storage.remove('user');
|
||
};
|
||
Storage.set("user", data['error_msg']);//本地存储
|
||
//创建一个sessionStorage 判断是否重新登录
|
||
var session_time=new Date().getTime();
|
||
window.sessionStorage.session_time=session_time;//创建临时缓存判断过期登录
|
||
|
||
if($("#check").hasClass("ischeck")){//获取本地存储的用户信息
|
||
Storage.set("local", {'userTel':$scope.user,'userPwd':$scope.password});
|
||
}else{
|
||
Storage.remove("local");
|
||
};
|
||
|
||
$state.go('root.userCenter');//地址跳转用户中心
|
||
|
||
}, function (data) {
|
||
layer.msg(data['error_msg']);
|
||
if(data.error_msg=='验证码错误'){//imgCodetemp
|
||
var imgCodeTemp=$("#imgCodeLogin").attr('ng-src');
|
||
$("#imgCodeLogin").attr('src',imgCodeTemp+"?"+Math.random());
|
||
|
||
}
|
||
});
|
||
};
|
||
|
||
|
||
$scope.getTelNum = "获取手机验证码";
|
||
$scope.telLimit = true;//短信重复获取限制
|
||
|
||
//手机验证码获取
|
||
$scope.getTelFun = function () {
|
||
|
||
var num = 60;//验证码有效时间设置
|
||
if (!$scope.imgCheck($scope.imgCode)) {
|
||
return;
|
||
}
|
||
if (!$scope.telCheck($scope.user)) {
|
||
return;
|
||
}
|
||
|
||
if ($scope.telLimit) {
|
||
//开始请求短信
|
||
Auth.getTelCode($scope.user, '','restPwd',$scope.imgCode).then(function (data) {//成功
|
||
layer.msg(data.msg);
|
||
$scope.telLimit = false;
|
||
$scope.getTelNum = num + " s";
|
||
$scope.timer = $interval(function () {
|
||
num--;
|
||
if (num <= 0) {
|
||
$scope.getTelNum = "重新获取";
|
||
$scope.telLimit=true; //重新获取短信,及过期设置
|
||
$interval.cancel($scope.timer);//清除定时器
|
||
} else {
|
||
$scope.getTelNum = num + " s";
|
||
}
|
||
}, 1000);
|
||
}, function (data) {
|
||
layer.msg(data);
|
||
if(data=='验证码错误'){//imgCodetemp
|
||
var imgCodeTemp=$("#imgCode").attr('ng-src');
|
||
$("#imgCode").attr('src',imgCodeTemp+"?"+Math.random());
|
||
|
||
}
|
||
})
|
||
}
|
||
};
|
||
|
||
//忘记密码重置密码(点击下一步)
|
||
$scope.enterEdit = function () {
|
||
if (!$scope.telCheck($scope.user)) {
|
||
return;
|
||
}
|
||
if (!$scope.imgCheck($scope.imgCode)) {
|
||
return;
|
||
}
|
||
if (!$scope.telCodeCheck($scope.telCode)) {
|
||
return;
|
||
}
|
||
Auth.login($scope.user, '', $scope.restPwd, $scope.imgCode, '', $scope.telCode,'','restPwd').then(function (data) {//校验成功
|
||
$scope.reset = 2;
|
||
$scope.password='';
|
||
}, function (data) {//失败
|
||
layer.msg(data.msg);
|
||
});
|
||
|
||
};
|
||
//编辑密码提交
|
||
$scope.upDate = function () {
|
||
if (!$scope.pwdCheckD($scope.password, $scope.passwordD)) {
|
||
return;
|
||
}
|
||
//提交保存
|
||
Auth.login($scope.user, $scope.password, $scope.restPwd, $scope.imgCode, $scope.passwordD, $scope.telCode).then(function (data) {//校验成功
|
||
layer.msg(data.msg)
|
||
$scope.reset = 3;//修改密码成功之后 重新登录
|
||
$scope.password=$scope.imgCode=$scope.telCode=$scope.passwordD='';
|
||
}, function (data) {//失败
|
||
layer.msg(data.msg);
|
||
});
|
||
|
||
}
|
||
})
|
||
});
|
||
|
||
//用户-注册
|
||
app.controller('registerCtrl', function ($rootScope,$scope, Check, Auth, $interval, $state,$stateParams) {
|
||
$scope.getTelNum = "获取手机验证码";
|
||
$scope.RefCode=$stateParams.ref ? $stateParams.ref : '';//上级推广码
|
||
$scope.RefCodeDisable = $scope.RefCode ? true : false;
|
||
|
||
$scope.telLimit = true;//请求手机号 手机短信重复限制
|
||
layui.use(['layer','form','laydate'],function() {
|
||
var layer = layui.layer,
|
||
laydate = layui.laydate,
|
||
form = layui.form();
|
||
$(window).scrollTop(0);
|
||
|
||
/*var urlREgidt = window.location.href;
|
||
var urlRNum = urlREgidt.indexOf("?");
|
||
if (urlRNum > 0) {
|
||
$scope.RefCode = urlREgidt.substr(urlRNum + 5);
|
||
|
||
} else {
|
||
$scope.RefCode = '';
|
||
}*/
|
||
|
||
//手机验证码获取
|
||
$scope.getTelFun = function () {
|
||
|
||
var num = 60;//验证码有效时间设置
|
||
if (Check.empty($scope.imgCodeRegist)) {
|
||
layer.msg("图片验证码不能为空");
|
||
return;
|
||
}
|
||
if (Check.empty($scope.user)) {
|
||
layer.msg("手机号码不能为空");
|
||
return;
|
||
}
|
||
if (Check.tel($scope.user)) {
|
||
layer.msg("请输入正确的手机号码");
|
||
return;
|
||
}
|
||
if ($scope.telLimit) {
|
||
//开始请求短信
|
||
Auth.getTelCode($scope.user, '', "register", $scope.imgCodeRegist).then(function (data) {//成功
|
||
$scope.telLimit = false;
|
||
layer.msg(data.msg);
|
||
$scope.getTelNum = num + " s";
|
||
$scope.timer = $interval(function () {
|
||
num--;
|
||
if (num <= 0) {
|
||
$scope.getTelNum = "重新获取";
|
||
$scope.telLimit = true; //重新获取短信,及过期设置
|
||
$interval.cancel($scope.timer);//清除定时器
|
||
} else {
|
||
$scope.getTelNum = num + " s";
|
||
}
|
||
}, 1000);
|
||
}, function (data) {
|
||
layer.msg(data);
|
||
if(data=='验证码错误'){//imgCodetemp
|
||
var imgCodeTemp=$("#imgCodeRegist").attr('ng-src');
|
||
$("#imgCodeRegist").attr('src',imgCodeTemp+"?"+Math.random());
|
||
|
||
}
|
||
})
|
||
}
|
||
};
|
||
|
||
//是否同意用户协议
|
||
$scope.userAgreement = true;
|
||
$scope.userAgreementFun = function () {
|
||
$scope.userAgreement = !$scope.userAgreement;
|
||
}
|
||
//提交验证
|
||
$scope.submitF = function () {
|
||
|
||
if (Check.empty($scope.user)) {
|
||
layer.msg("手机号不能为空");
|
||
return;
|
||
}
|
||
if (Check.tel($scope.user)) {
|
||
layer.msg("请输入正确的手机号码");
|
||
return;
|
||
}
|
||
/* //手机验证码
|
||
if (Check.empty($scope.telCode)) {
|
||
layer.msg("短信验证码不能为空");
|
||
return;
|
||
}
|
||
|
||
if (Check.empty($scope.imgCodeRegist)) {
|
||
layer.msg("图片验证码不能为空");
|
||
return;
|
||
}
|
||
*/
|
||
//密码
|
||
if (Check.empty($scope.password) || Check.empty($scope.passwordD)) {
|
||
layer.msg("密码或者确认密码不能为空");
|
||
return;
|
||
}
|
||
if ($scope.password.length < 6) {
|
||
layer.msg("密码长度不能小于6位");
|
||
return;
|
||
}
|
||
if ($scope.password != $scope.passwordD) {
|
||
layer.msg("两次密码不一样!")
|
||
return;
|
||
}
|
||
|
||
if (Check.empty($scope.realname)) {
|
||
layer.msg("真实姓名不能为空");
|
||
return;
|
||
}
|
||
/*if (Check.idCard($scope.idCard)) {
|
||
layer.msg("请输入正确的身份证号码");
|
||
return;
|
||
}
|
||
*/
|
||
//推荐码
|
||
if(!$scope.userAgreement){
|
||
layer.msg("您还没有同意用户协议,不能够注册!");
|
||
return false;
|
||
}
|
||
|
||
if (Check.empty($scope.RefCode)) {
|
||
layer.confirm("您确认不填写推广码吗?", {
|
||
btn: ['确定', '取消'],
|
||
title: '果园'
|
||
}, function () {//确定
|
||
//手机 密码 分类(注册 登陆)
|
||
Auth.login($scope.user, $scope.password, $scope.realname, 'wapregister').then(function (data) {//成功
|
||
layer.confirm("注册成功请立即登录", {
|
||
btn: ['确定', '取消'],
|
||
title: '果园'
|
||
}, function () {//确定
|
||
window.location.href='/farm/index.html';
|
||
})
|
||
//layer.msg(data.error_msg);
|
||
//$state.go('root.auth');//地址跳转
|
||
|
||
}, function (data) {//失败
|
||
layer.msg(data.error_msg);
|
||
});
|
||
})
|
||
|
||
}else{
|
||
Auth.login($scope.user, $scope.password, $scope.realname,$scope.RefCode, 'wapregister').then(function (data) {//成功
|
||
layer.confirm("注册成功请立即登录", {
|
||
btn: ['确定', '取消'],
|
||
title: '果园'
|
||
}, function () {//确定
|
||
window.location.href='/farm/index.html';
|
||
})
|
||
}, function (data) {//失败
|
||
layer.msg(data.error_msg);
|
||
});
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
})
|
||
});
|
||
|
||
|
||
//游戏公告
|
||
app.controller('newsCtrl', function ($rootScope,$scope, Article, $stateParams) {
|
||
//passNum判断请求的是公告还是分类,并依据显示当前状态及数据 3 公告 4 新闻 5 攻略
|
||
$(window).scrollTop(0);
|
||
$scope.currentTap = $stateParams.passNum == '' ? 3 : $stateParams.passNum;
|
||
$scope.pageData = {list: ''};
|
||
|
||
|
||
//获取数据
|
||
$scope.pageTotalNum;//总条数
|
||
$scope.getNewsList = function (type,page, showNum) {//获取数据(分类,页码,每一页的条数)
|
||
var page = page ? page : 1;
|
||
var showNum = showNum ? showNum : 10;
|
||
Article.list($scope.currentTap, page, showNum).then(function (data) {
|
||
if(data=='null'){
|
||
$scope.pageData.list=null;
|
||
$scope.pageTotalNum = 1;
|
||
}
|
||
$scope.pageData.list = data.list;
|
||
$scope.pageTotalNum = data.total_page;
|
||
});
|
||
};
|
||
$scope.getData = function (type) {//判断是新闻还是公告
|
||
$scope.currentTap = type;
|
||
$scope.getNewsList($scope.currentTap);
|
||
$scope.currentPageNews = 1;
|
||
};
|
||
$scope.getData($scope.currentTap);//页面初始化加载默认数据
|
||
|
||
|
||
//分页制作
|
||
$scope.currentPageNews = 1;
|
||
$scope.pageInput = function (num) {//页码校验
|
||
var num = parseInt(num);
|
||
$scope.currentPageNews = num;
|
||
if ($scope.currentPageNews >= $scope.pageTotalNum || $scope.currentPageNews <= 0) {
|
||
if ($scope.currentPageNews >= $scope.pageTotalNum) {
|
||
$scope.currentPageNews = $scope.pageTotalNum;
|
||
} else if ($scope.currentPageNews <= 0) {
|
||
$scope.currentPageNews = 1;
|
||
}
|
||
}
|
||
return $scope.currentPageNews;
|
||
;
|
||
|
||
};
|
||
// 点击获取列表数据
|
||
$scope.goToGetList = function () {
|
||
return {
|
||
homePage: function () {//首页
|
||
if($scope.currentPageNews==1){
|
||
$scope.currentPageNews=1;
|
||
return false;
|
||
}
|
||
$scope.currentPageNews = 1;
|
||
$scope.getNewsList($scope.currentTap, $scope.currentPageNews);//获取数据
|
||
},
|
||
lasePage: function () {//末页
|
||
if($scope.currentPageNews == $scope.pageTotalNum){
|
||
$scope.currentPageNews = $scope.pageTotalNum;
|
||
return false;
|
||
}
|
||
$scope.currentPageNews = $scope.pageTotalNum;
|
||
$scope.getNewsList($scope.currentTap, $scope.currentPageNews);//获取数据
|
||
},
|
||
nextPage: function () {//下一页
|
||
$scope.currentPageNews += 1;
|
||
if($scope.currentPageNews > $scope.pageTotalNum){
|
||
$scope.currentPageNews = $scope.pageTotalNum
|
||
return false;
|
||
}
|
||
$scope.getNewsList($scope.currentTap, $scope.currentPageNews);//获取数据
|
||
},
|
||
prePage: function () {//上一页
|
||
$scope.currentPageNews -= 1;
|
||
if($scope.currentPageNews <= 0){
|
||
$scope.currentPageNews=1;
|
||
return false;
|
||
}
|
||
$scope.getNewsList($scope.currentTap, $scope.currentPageNews);//获取数据
|
||
},
|
||
goToPageFun: function(){
|
||
$scope.getNewsList($scope.currentTap, $scope.currentPageNews);//获取数据
|
||
}
|
||
}
|
||
}();
|
||
|
||
|
||
});
|
||
//详情页
|
||
app.controller('detailCtrl', function ($rootScope,$scope, Article, $stateParams) {
|
||
$(window).scrollTop(0);
|
||
$scope.pageType = $stateParams.type;//0 公告 1 分类
|
||
$scope.pageId = $stateParams.id;//id
|
||
Article.detail($scope.pageId).then(function (data) {
|
||
$scope.pageData = data[0];
|
||
})
|
||
|
||
|
||
});
|
||
|
||
//攻略资料
|
||
app.controller('strategyCtrl', function ($rootScope,$scope, Strategy, $stateParams, Check, Storage, $state,UserCenter,ENV,Market,Article) {
|
||
|
||
$scope.introValue = $stateParams.introValue == '' ? 0 : $stateParams.introValue;//介绍 0 游戏介绍 1 果实介绍 2土地介绍 3道具介绍 4 神像介绍 5 宠物介绍
|
||
$scope.currentTap = $stateParams.currentTap == undefined ? 0 : $stateParams.currentTap;//资料介绍分类 0 游戏介绍 1 攻略心得 2常见问题 3 新手指南 4 视频教程
|
||
$scope.directionImg="assets/img/G02.jpg?"+Math.random();//攻略图片显示路径
|
||
layui.use(['layer','form','laydate'],function() {
|
||
var layer = layui.layer,
|
||
laydate = layui.laydate,
|
||
form = layui.form();
|
||
$(window).scrollTop(0);
|
||
|
||
$scope.checkVal = function (val) {
|
||
$scope.introValue = val;
|
||
}
|
||
|
||
|
||
|
||
if ($scope.currentTap == 5 && $stateParams.id) {//这里是文章的攻略,没有办法进行评论和打赏
|
||
Article.detail($stateParams.id).then(function (data) {
|
||
//系统攻略显示
|
||
$scope.contextShow = 0;
|
||
$scope.gameTextInfo = data[0];
|
||
|
||
});
|
||
}
|
||
|
||
$scope.getCurrent = function (val) {
|
||
$scope.currentTap = val;
|
||
if (val == 1) {
|
||
//获取攻略列表 getListStr
|
||
// $scope.RewardStatus=$scope.AuthorId='';//打赏类型 作者
|
||
$scope.getListStr = function (page,type, auth) {
|
||
Strategy.list(page,type, auth).then(function (data) {
|
||
$scope.pageTotalNum = data.total_page;
|
||
$scope.ArticalList = data.list;//元数据
|
||
},function(data){
|
||
$scope.pageTotalNum=0;
|
||
$scope.ArticalList='';
|
||
if(data.code==403){
|
||
layer.msg(data.msg);
|
||
$rootScope.loginExit();
|
||
}else{
|
||
layer.msg(data.msg);
|
||
}
|
||
|
||
});
|
||
};
|
||
$scope.getListStr(1,$scope.RewardStatus, $scope.authChange);//获取攻略列表
|
||
//查询
|
||
$scope.searchFun = function () {//val 打赏 auth作者
|
||
$scope.getListStr($scope.currentPageNews,$scope.RewardStatus, $scope.authChange);
|
||
|
||
};
|
||
//作者列表查询
|
||
Strategy.authListFun().then(function (data) {
|
||
$scope.AuthInfoType = data;
|
||
},function (data) {
|
||
if(data.code==403){
|
||
layer.msg(data.msg);
|
||
$rootScope.loginExit();
|
||
}else{
|
||
layer.msg(data.msg);
|
||
}
|
||
});
|
||
// 作者等级
|
||
$scope.authChange;//指定作者
|
||
$scope.authChangeCheck = function () {
|
||
if ($scope.AuthorId) {
|
||
$scope.authChange = $scope.AuthorId.split("&")[0];
|
||
} else {
|
||
$scope.authChange = '';
|
||
}
|
||
}
|
||
|
||
|
||
//排序
|
||
$scope.orderCurrent = 0;//升降序 1sortDesc 降序 2sortAsc
|
||
$scope.orderTypeObj;//排序类型
|
||
// $scope.rewardOrder; //rewardOrder:rewardOrderType
|
||
$scope.rewardOrderType;//排序类型
|
||
$scope.listOrder = function (type) {//val 升降排序(需要判断) sortAsc(升) sortDesc(降)
|
||
|
||
$scope.orderCurrent += 1;
|
||
if ($scope.orderCurrent > 2) {
|
||
$scope.orderCurrent = 1;
|
||
}
|
||
var val;
|
||
if ($scope.orderCurrent == 1) {//
|
||
val = "DESC";
|
||
$scope.rewardOrderType = true;
|
||
} else if ($scope.orderCurrent == 2) {
|
||
val = "ASC";
|
||
$scope.rewardOrderType = false;
|
||
}
|
||
if (type == 'reward') {//打赏
|
||
$scope.orderTypeObj = 'reward';
|
||
Strategy.listOrder(val, '', '', '', $scope.RewardStatus, $scope.authChange).then(function (data) {
|
||
$scope.ArticalList = data.list;
|
||
$scope.pageTotalNum = data.total_page;
|
||
},function (data) {
|
||
if(data.code==403){
|
||
layer.msg(data.msg);
|
||
$rootScope.loginExit();
|
||
}else{
|
||
layer.msg(data.msg);
|
||
}
|
||
});
|
||
|
||
}
|
||
if (type == 'praise') {//好评
|
||
$scope.orderTypeObj = 'praise';
|
||
Strategy.listOrder('', val, '', '', $scope.RewardStatus, $scope.authChange).then(function (data) {
|
||
$scope.ArticalList = data.list;
|
||
$scope.pageTotalNum = data.total_page;
|
||
},function (data) {
|
||
if(data.code==403){
|
||
layer.msg(data.msg);
|
||
$rootScope.loginExit();
|
||
}else{
|
||
layer.msg(data.msg);
|
||
}
|
||
});
|
||
}
|
||
if (type == 'comments') {//中评
|
||
$scope.orderTypeObj = 'comments';
|
||
Strategy.listOrder('', '', val, '', $scope.RewardStatus, $scope.authChange).then(function (data) {
|
||
$scope.ArticalList = data.list;
|
||
$scope.pageTotalNum = data.total_page;
|
||
},function (data) {
|
||
if(data.code==403){
|
||
layer.msg(data.msg);
|
||
$rootScope.loginExit();
|
||
}else{
|
||
layer.msg(data.msg);
|
||
}
|
||
});
|
||
}
|
||
if (type == 'bad') {//差评
|
||
$scope.orderTypeObj = 'bad';
|
||
Strategy.listOrder('', '', '', val, $scope.RewardStatus, $scope.authChange).then(function (data) {
|
||
$scope.ArticalList = data.list;
|
||
$scope.pageTotalNum = data.total_page;
|
||
},function (data) {
|
||
if(data.code==403){
|
||
layer.msg(data.msg);
|
||
$rootScope.loginExit();
|
||
}else{
|
||
layer.msg(data.msg);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
|
||
//分页制作
|
||
$scope.currentPageNews = 1;
|
||
$scope.pageInput = function (num) {//页码校验
|
||
|
||
var num = parseInt(num);
|
||
$scope.currentPageNews = num;
|
||
if ($scope.currentPageNews >= $scope.pageTotalNum || $scope.currentPageNews <= 0) {
|
||
if ($scope.currentPageNews >= $scope.pageTotalNum) {
|
||
$scope.currentPageNews = $scope.pageTotalNum;
|
||
} else if ($scope.currentPageNews <= 0) {
|
||
$scope.currentPageNews = 1;
|
||
}
|
||
}
|
||
|
||
};
|
||
// 点击获取列表数据
|
||
$scope.goToGetList = function () {
|
||
return {
|
||
homePage: function () {//首页
|
||
if ($scope.currentPageNews == 1) {
|
||
$scope.currentPageNews = 1;
|
||
return false;
|
||
}
|
||
$scope.currentPageNews = 1;
|
||
$scope.getListStr($scope.currentPageNews,$scope.RewardStatus, $scope.authChange);
|
||
},
|
||
lasePage: function () {//末页
|
||
if ($scope.currentPageNews == $scope.pageTotalNum) {
|
||
$scope.currentPageNews = $scope.pageTotalNum;
|
||
return false;
|
||
}
|
||
$scope.currentPageNews = $scope.pageTotalNum;
|
||
$scope.getListStr($scope.currentPageNews,$scope.RewardStatus, $scope.authChange);
|
||
},
|
||
nextPage: function () {//下一页
|
||
$scope.currentPageNews += 1;
|
||
if ($scope.currentPageNews > $scope.pageTotalNum) {
|
||
$scope.currentPageNews = $scope.pageTotalNum
|
||
return false;
|
||
}
|
||
$scope.getListStr($scope.currentPageNews,$scope.RewardStatus, $scope.authChange);
|
||
},
|
||
prePage: function () {//上一页
|
||
$scope.currentPageNews -= 1;
|
||
if ($scope.currentPageNews <= 0) {
|
||
$scope.currentPageNews = 1;
|
||
return false;
|
||
}
|
||
$scope.getListStr($scope.currentPageNews,$scope.RewardStatus, $scope.authChange);
|
||
},
|
||
goToPageFun: function () {
|
||
$scope.getListStr($scope.currentPageNews,$scope.RewardStatus, $scope.authChange);
|
||
}
|
||
}
|
||
}();
|
||
|
||
|
||
}
|
||
if (val == 6) {
|
||
var loginAlready=Storage.get("user");
|
||
if(!loginAlready){
|
||
layer.confirm("您还没有登录,是否现在登陆,是否确认?", {
|
||
btn: ['确定', '取消'],
|
||
title: $rootScope.ComonEdit.keyWords+'果园'
|
||
}, function () {//确定
|
||
layer.closeAll('dialog');
|
||
$state.go('root.auth');//地址跳转
|
||
})
|
||
}else{
|
||
Market.productList().then(function (data) {
|
||
angular.forEach(data, function (v, k) {
|
||
//v.marketinfo.thumb = ENV.imgSrc + "/" + v.marketinfo.thumb;
|
||
})
|
||
$scope.freeArcType = 1;
|
||
$scope.pageDataProduct = data;
|
||
})
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
//点击攻略获取详情
|
||
$scope.ArcLevalcheck;//作者(金牌银牌图片)
|
||
$scope.aboutRaiderData;//作者相关的文章
|
||
$scope.aboutAuthLevel;
|
||
$scope.emptyShowTips=false;//提示信息不显示,true 显示
|
||
$scope.getArcDetail = function (type, idTxt, needPro,level) {// type(免费) id(文章) needPro 所需产品 //ArcLeval 作者等级,查看图片
|
||
var needChanP=needPro;
|
||
if(needPro){
|
||
$scope.rewardproduct = needPro;
|
||
}else{
|
||
$scope.rewardproduct = '';
|
||
}
|
||
|
||
$scope.aboutAuthLevel=level;
|
||
//打赏显示限制
|
||
// if (type == 1) {//1 限制 0 免费
|
||
// $scope.contextShow = 1;
|
||
// } else {
|
||
// $scope.contextShow = 0;
|
||
// }
|
||
|
||
Strategy.detail(type, idTxt).then(function (data) {
|
||
$scope.currentTap = 5;//详情显示
|
||
$scope.gameTextInfo = data.raider;
|
||
$scope.ArcLevalcheck = data.raider.level;
|
||
$scope.aboutRaiderData=data.aboutRaider;
|
||
if ($scope.gameTextInfo.content) {//1 限制 0 免费
|
||
$scope.contextShow = 0;
|
||
} else {
|
||
$scope.contextShow = 1;
|
||
}
|
||
},function(data){
|
||
if(data.code==403){
|
||
layer.msg(data.msg);
|
||
$rootScope.loginExit();
|
||
}else{
|
||
layer.msg(data.msg);
|
||
}
|
||
})
|
||
//好评提交函数
|
||
$scope.commentSubmit = function (commentType) {//好评中评差评分类
|
||
var loginAlready=Storage.get("user");
|
||
if(!loginAlready){
|
||
layer.confirm("您还没有登录,是否现在登陆,是否确认?", {
|
||
btn: ['确定', '取消'],
|
||
title: $rootScope.ComonEdit.keyWords+'果园'
|
||
}, function () {//确定
|
||
layer.closeAll('dialog');
|
||
$state.go('root.auth');//地址跳转
|
||
})
|
||
}else{
|
||
Strategy.commentSubmitFun(commentType, idTxt).then(function (data) {
|
||
layer.msg(data.msg);
|
||
$scope.getArcDetail(type, idTxt,needChanP);
|
||
},function (data) {
|
||
if(data.code==403){
|
||
layer.msg(data.msg);
|
||
$rootScope.loginExit();
|
||
}else{
|
||
layer.msg(data.msg);
|
||
}
|
||
});
|
||
}
|
||
|
||
};
|
||
|
||
//查看拥有产品的列表
|
||
$scope.newProductListObj = null;//所需要的产品对象
|
||
$scope.haveLogin;
|
||
$scope.userHavePro = function () {
|
||
UserCenter.havingProduct().then(function (data) {
|
||
if ( $scope.rewardproduct && $scope.rewardproduct.length > 0) {//指定打赏
|
||
|
||
angular.forEach(data.product, function (v, k) {
|
||
if ($scope.rewardproduct == v.sid) {
|
||
$scope.newProductListObj = v;
|
||
v.thumb = ENV.imgSrc + v.thumb;
|
||
$scope.freeArc = v.sid;
|
||
}
|
||
|
||
});
|
||
|
||
if($scope.newProductListObj==null){
|
||
$scope.emptyShowTips=true;
|
||
}else{
|
||
$scope.emptyShowTips=false;
|
||
}
|
||
|
||
|
||
} else {//免费
|
||
angular.forEach(data.product, function (v, k) {
|
||
v.thumb = ENV.imgSrc + v.thumb;
|
||
})
|
||
|
||
$scope.freeArc = data.product[0].sid;
|
||
// layer.msg($scope.freeArc);
|
||
$scope.newProductList = data.product;
|
||
$scope.newProductListObj = null;
|
||
}
|
||
$scope.haveLogin=true;
|
||
},function(data){
|
||
$scope.haveLogin=false;
|
||
});
|
||
}
|
||
$scope.userHavePro();
|
||
|
||
//打赏提交
|
||
$scope.payForRead = function (product, num, text, rid, auth) {//打赏物品(productid) 数量(productnum ) 评论(discuss ) uid rid auth
|
||
if(!$scope.haveLogin){
|
||
layer.confirm("您还没有登录,是否现在登陆,是否确认?", {
|
||
btn: ['确定', '取消'],
|
||
title: $rootScope.ComonEdit.keyWords+'果园'
|
||
}, function () {//确定
|
||
layer.closeAll('dialog');
|
||
$state.go('root.auth');//地址跳转
|
||
});
|
||
return;
|
||
}
|
||
var loginAlready=Storage.get("user");
|
||
if(!loginAlready){
|
||
layer.confirm("您还没有登录,是否现在登陆,是否确认?", {
|
||
btn: ['确定', '取消'],
|
||
title: $rootScope.ComonEdit.keyWords+'果园'
|
||
}, function () {//确定
|
||
layer.closeAll('dialog');
|
||
$state.go('root.auth');//地址跳转
|
||
});
|
||
return false;
|
||
}
|
||
|
||
if ($scope.newProductListObj != null) {
|
||
if (product != $scope.newProductListObj.sid) {
|
||
layer.msg("您没有作者指定的产品!");
|
||
return false;
|
||
}
|
||
}
|
||
|
||
// console.log(product+'/'+num+'/'+text+'/'+rid+'/'+auth);product, num, textNum, uid, rid, auth
|
||
var textNum;
|
||
if (text == 0) {
|
||
textNum = '这个家伙很懒,什么也没有留下!';
|
||
}
|
||
;
|
||
if (text == 1) {
|
||
textNum = '有点差劲,一天就一个草莓,没有达到我的预期!';
|
||
}
|
||
;
|
||
if (text == 2) {
|
||
textNum = '写的好,我按照大神攻略的做法赚了不少钱呢!';
|
||
}
|
||
;
|
||
if (text == 3) {
|
||
textNum = '本攻略水平一般,我用了就赚了两包烟钱。';
|
||
}
|
||
;
|
||
if (text == 4) {
|
||
textNum = '极品攻略,兄弟们赚爽了,还可以边旅游边挣钱,一个字爽!';
|
||
}
|
||
;
|
||
if (text == 5) {
|
||
textNum = '十分不错,就是用了之后玫瑰太多,仓库装不下了!';
|
||
}
|
||
;
|
||
|
||
|
||
if (product >= 0 && num >= 0 && text >= 0) {
|
||
|
||
|
||
|
||
Strategy.rewardSubmitFun(product, num, textNum, rid, auth).then(function (data) {
|
||
layer.msg(data.msg);
|
||
// $scope.contextShow = 0;
|
||
$scope.getArcDetail(type, idTxt,needChanP);//打赏成功刷新
|
||
$scope.userHavePro();
|
||
|
||
}, function (data) {
|
||
if(data.code==403){
|
||
layer.msg(data.msg);
|
||
$rootScope.loginExit();
|
||
}else{
|
||
layer.msg(data.msg);
|
||
}
|
||
})
|
||
} else {
|
||
layer.msg("请选择要打赏的物品、数量及评语!")
|
||
}
|
||
|
||
|
||
}
|
||
|
||
//打赏记录查询 rewardHistory
|
||
Strategy.rewardHistory(idTxt).then(function (data) {
|
||
angular.forEach(data, function (v, k) {
|
||
v.thumb = ENV.imgSrc + v.thumb;
|
||
})
|
||
$scope.historyData = data;
|
||
// if (data.length > 0) {
|
||
// $scope.contextShow = 0;
|
||
// }
|
||
|
||
},function (data) {
|
||
if(data.code==403){
|
||
layer.msg(data.msg);
|
||
$rootScope.loginExit();
|
||
}else{
|
||
layer.msg(data.msg);
|
||
}
|
||
});
|
||
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
//打赏选择 类别 和数量
|
||
$scope.freeArc;
|
||
$scope.freeNum = 10;//
|
||
$scope.freeText = 0;//评论话语
|
||
$scope.freeArcType = 0;
|
||
|
||
$scope.freeChecked = function (val) {//类别拥有产品
|
||
$scope.freeArc = val;//传递的是sid
|
||
}
|
||
|
||
|
||
$scope.freeNumFun = function (num) {//数量
|
||
$scope.freeNum = num;
|
||
|
||
}
|
||
$scope.freeTextFun = function (num) {//数量
|
||
$scope.freeText = num;
|
||
|
||
}
|
||
|
||
|
||
/*投稿编写文章*/
|
||
$scope.textEdit = false;
|
||
$scope.imgEdit = false;
|
||
$scope.addText = function () {
|
||
$scope.textEdit = !$scope.textEdit;
|
||
}
|
||
$scope.addImg = function () {
|
||
$scope.imgEdit = !$scope.imgEdit;
|
||
}
|
||
//0 免费 1 限制 获取产品列表(投稿) title, auth, content, type,rewardproduct
|
||
$scope.ArticleUodataType = 0;//0 免费,1 限制;
|
||
$scope.ArticleUodataTypeSid = '';//当限制的时候,这个是提交的产品ID
|
||
|
||
$scope.freeCheckedType = function (val) {
|
||
$scope.ArticleUodataType = val;//是否免费
|
||
if ($scope.ArticleUodataType == 0) {
|
||
$scope.ArticleUodataTypeSid = '';
|
||
}
|
||
}
|
||
|
||
$scope.freeCheckedPay = function (val) {
|
||
$scope.ArticleUodataTypeSid = val;//传递的是sid
|
||
|
||
$scope.ArticleUodataType = 1;
|
||
}
|
||
//更新文本提交
|
||
$scope.updateTextFun = function () {//标题 updateTitle 图片 updateImg 正文 updateText 打赏限制 0 免费 1 限制
|
||
if (Check.empty($scope.updateTitle)) {
|
||
layer.msg("标题不能为空");
|
||
return false;
|
||
}
|
||
if (Check.empty($scope.updateText)) {
|
||
layer.msg("内容不能为空")
|
||
return false;
|
||
}
|
||
|
||
Strategy.submitText($scope.updateTitle, $scope.updateText, $scope.ArticleUodataType, $scope.ArticleUodataTypeSid).then(function (data) {
|
||
layer.msg(data.msg);
|
||
$scope.getCurrent(1);
|
||
$scope.updateTitle=$scope.updateText='';
|
||
},function (data) {
|
||
if(data.code==403){
|
||
layer.msg(data.msg);
|
||
$rootScope.loginExit();
|
||
}else{
|
||
layer.msg(data.msg);
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
//首页进来的时候获取心得列表
|
||
if ($scope.currentTap == 1) {
|
||
$scope.getCurrent(1);
|
||
}
|
||
|
||
//新手指南的点击时间
|
||
|
||
$scope.newDirectionFun=function(img){
|
||
layer.msg("小主,数据加载中……请等待");
|
||
$scope.directionImg="assets/img/"+img+'.jpg?'+Math.random();
|
||
|
||
|
||
}
|
||
|
||
|
||
})
|
||
});
|
||
|
||
//帮助中心
|
||
app.controller('helpCtrl', function ($rootScope,$scope, $stateParams,Config,Storage,$state) {
|
||
$(window).scrollTop(0);
|
||
$scope.currentTap = $stateParams.currentTap == undefined ? 0 : $stateParams.currentTap;
|
||
$scope.getCurrent = function (val) {
|
||
$scope.currentTap = val;
|
||
|
||
|
||
}
|
||
|
||
//点击跳转用户中新
|
||
$scope.toUserCenter=function () {
|
||
if(Storage.get("user")==null){
|
||
$state.go("root.auth");
|
||
}else{
|
||
$state.go("root.userCenter");
|
||
}
|
||
}
|
||
|
||
});
|
||
//关于我们
|
||
app.controller('aboutCtrl', function ($rootScope,$scope, Article, $stateParams,Config) {
|
||
$(window).scrollTop(0);
|
||
$scope.curTabs = 0;//当前选中状态
|
||
$scope.getData = function (num) {
|
||
$scope.curTabs = num;
|
||
}
|
||
$scope.curTabs = $stateParams.curTabs == undefined ? 0 : $stateParams.curTabs;
|
||
$scope.pageData = {title: '', content: ''};
|
||
if ($scope.curTabs == 0) {
|
||
$scope.pageData.title = "公司介绍";
|
||
} else if ($scope.curTabs == 2) {
|
||
$scope.pageData.title = "联系我们";
|
||
}
|
||
else if ($scope.curTabs == 3) {
|
||
$scope.pageData.title = "加入我们";
|
||
}
|
||
else if ($scope.curTabs == 4) {
|
||
$scope.pageData.title = "用户协议";
|
||
}
|
||
//获取数据
|
||
$scope.getData = function (type, title) {
|
||
$scope.curTabs = type;
|
||
$scope.pageData.title = title;
|
||
|
||
Article.list(1).then(function (data) {
|
||
for (var i = 0; i < data.length; i++) {
|
||
if (data[i].title == title) {
|
||
$scope.pageData.content = data[i].content;
|
||
}
|
||
}
|
||
});
|
||
}
|
||
$scope.getData($scope.curTabs, $scope.pageData.title);
|
||
|
||
|
||
|
||
});
|
||
|
||
|
||
});
|