/**
* Created by pushkeji on 2018/10/11.
*/
angular.module('push')
.controller('activityDetailCtrl', ['$scope', 'activitiesModuleService', '$timeout', '$ionicPopup', '$q', 'UserService', '$stateParams', 'ResourceLibraryService', '$ionicSlideBoxDelegate', 'ConfigService',
'ScienceCircleService', 'CommonService', '$ionicScrollDelegate', 'ConstantService', '$ionicActionSheet', 'UtilService', 'ShareService', '$ionicModal', 'CommentService', 'dataToolsService', '$sce',
function ($scope, activitiesModuleService, $timeout, $ionicPopup, $q, UserService, $stateParams, ResourceLibraryService, $ionicSlideBoxDelegate, ConfigService, ScienceCircleService, CommonService, $ionicScrollDelegate, ConstantService,
$ionicActionSheet, UtilService, ShareService, $ionicModal, CommentService, dataToolsService, $sce) {
$scope.hasCollect = false;
$scope.showConsultBox = true;
$scope.showComment = true;
var pagenum = 1;
var pagesize = 15;
var title = '';
var user = "";
console.log($stateParams);
var editTime = function (time) {
var a = time.split(':');
a.pop();
return a.join(':');
}
var recourceid = 0;
// 获取活动详情
var getActivityDetailInfo = function () {
activitiesModuleService.getActivityDetailInfo($stateParams.activityid).then(function (res) {
console.log('res返回参数', res);
$scope.allData = res.data;
recourceid = $scope.allData.activityRecord.otherid;
$scope.paramsForInfoCommentList.infoid = recourceid;
$scope.infoComment.infoid = recourceid;
getInfoCommentList();
$scope.hasCollect = $scope.allData.collect;
$scope.hasFavour = $scope.allData.favour;
$scope.detail = Object.assign({}, res.data.activityInfo);
$scope.detail.content = $sce.trustAsHtml($scope.detail.content);
$scope.poster = '';
$scope.accessory = [];
var images = $scope.detail.images ? JSON.parse($scope.detail.images) : [];
if (images.length > 0) {
angular.forEach(images, function (val) {
if (val.doctype == 4912) {
$scope.poster = val.originalName;
} else {
$scope.accessory.push(val);
}
})
}
document.title = res.data.activityInfo.name;
document.getElementById('shareSourc').setAttribute('src', ConfigService.imgurl + $scope.poster);
// 处理时间
$scope.detail.begintime = editTime($scope.detail.begintime);
$scope.detail.endtime = editTime($scope.detail.endtime);
var bgTime = $scope.detail.begintime.split(' ');
var edTime = $scope.detail.endtime.split(' ');
$scope.organizeTime = '';
if (bgTime[0] === edTime[0]) {
$scope.organizeTime = bgTime[0] + ' ' + bgTime[1] + ' ~ ' + edTime[1];
} else {
$scope.organizeTime = $scope.detail.begintime + ' ~ ' + $scope.detail.endtime;
}
$scope.detail.dealtime = editTime($scope.detail.dealtime);
// 活动地址
$scope.address = $scope.detail.addr ? $scope.detail.addr.replace(/\//g, '') + " " + $scope.detail.addrdetail : $scope.detail.addrdetail;
// 活动数据
$scope.dataItem = res.data.tongjidata;
angular.forEach($scope.dataItem, function (val) {
val.hasList = val.list && val.list.length > 0;
});
$scope.buttonNum = 0;
$scope.canapply = !res.data.ishasedit && res.data.activityInfo.status == 5300 && res.data.canaction != '5905' && ++$scope.buttonNum;
if (ConfigService.islogin) {
$scope.cancelapply = !res.data.ishasedit && res.data.activityInfo.status == 5300 && res.data.canaction == '5905' && ++$scope.buttonNum;
$scope.ishasedit = res.data.ishasedit && ++$scope.buttonNum;
$scope.isCancel = $scope.ishasedit && ++$scope.buttonNum;
$scope.registmanage = res.data.ishasset && ++$scope.buttonNum;
$scope.ishasinput = res.data.activityInfo.status == 5301 && ++$scope.buttonNum;
} else {
}
// angular.forEach(buttons,function(val){
// if(val=='5903'){
// $scope.canapply=!res.data.ishasedit&&res.data.activityInfo.status==5300&&++$scope.buttonNum;
// $scope.ishasedit=res.data.ishasedit&&++$scope.buttonNum;
// $scope.isCancel=$scope.ishasedit&&++$scope.buttonNum;
// $scope.registmanage=(res.data.ishasedit&&++$scope.buttonNum)||(res.data.registmanage&&$scope.buttonNum++);
// $scope.ishasinput=false;
// }else{
// $scope.canapply=false;
// $scope.ishasedit=false;
// $scope.ishasset=false;
// $scope.registmanage=(res.data.ishasedit&&$scope.buttonNum++)||(res.data.registmanage&&$scope.buttonNum++);
// $scope.ishasinput=++$scope.buttonNum;
// }
// })
// 编辑权限
// $scope.ishasedit=res.data.ishasedit?res.data.ishasedit:$scope.buttonNum++;
// 取消权限
// $scope.ishasset=res.data.ishasset&&$scope.buttonNum++;
// 报名管理
// $scope.registmanage=res.data.registmanage&&$scope.buttonNum++;
// $scope.ishasinput=res.data.ishasinput&&$scope.buttonNum++;
})
}
getActivityDetailInfo();
// $scope.detail= {
// addrdetail: "测试活动3地址",
// begintime: "2018-12-11 09:30:00",
// content: "测试活动的简介简介简介简介简介简介简介简介简介简介简介",
// creator: 670,
// dealtime: "2018-12-27 17:00:00",
// district: "甘肃省/白银市/靖远县",
// endtime: "2018-12-28 15:00:00",
// images: '[{"id":0,"title":"","doctype":4912,"isenabled":1,"photoName":"group3/M00/0B/0A/wKjILFv0vBKAeWXUAACkL__E3Tk447.png","originalName":"group3/M00/0B/0A/wKjILFv0vBeAf3TtAAhU-rYzbZ8482.png","sourceName":"group3/M00/0B/0A/wKjILFv0vBiAXaNYABLZCnk8hN4458.png","sourceSize":"1.2MB"},{"id":0,"title":"","doctype":4900,"isenabled":1,"photoName":"","originalName":"group3/M00/0B/0C/wKjILFwhwBWAQWntAAUmgJZfd2Q366.png","sourceName":"group3/M00/0B/0C/wKjILFwhwBWAETT2AAfyBnYTZ6A668.png","sourceSize":"508.5KB"}]',
// minpeople: 0,
// name: "测试活动4",
// orgname: "测试活动单位",
// regionsid: "620421",
// settingItems: '[{"id":1,"linktype":null,"text":"姓名","savekey":"","isfixed":"true","isneed":true,"type":"input","node":"320412000","orgtype":"","pagetitle":"","pagecode":"","pageid":null,"tablename":"activity_setting_item","tablecode":null,"disabled":true},{"id":2,"linktype":null,"text":"电话","savekey":"","isfixed":"true","isneed":true,"type":"input","node":"320412000","orgtype":"","pagetitle":"","pagecode":"","pageid":null,"tablename":"activity_setting_item","tablecode":null,"disabled":true},{"id":5,"linktype":null,"text":"身份证号","savekey":"","isfixed":"false","isneed":false,"type":"","node":"320412000","orgtype":"","pagetitle":"","pagecode":"","pageid":null,"tablename":"activity_setting_item","tablecode":null,"hasChosen":true,"disabled":false,"showButton":true},{"id":4,"linktype":null,"text":"所属行业","savekey":null,"isfixed":"false","isneed":false,"type":"input","node":"320412000","orgtype":"","pagetitle":"","pagecode":"","pageid":null,"tablename":"activity_setting_item","tablecode":null,"hasChosen":true,"disabled":false,"showButton":true},{"id":8,"linktype":null,"text":"需求","savekey":null,"isfixed":"false","isneed":false,"type":"configurablePages","node":"320412000","orgtype":"10104","pagetitle":"新建录入","pagecode":"1000027","pageid":4,"tablename":"activity_setting_item","tablecode":null,"hasChosen":true,"disabled":false,"showButton":true},{"id":3,"linktype":null,"text":"所属机构","savekey":null,"isfixed":"false","isneed":false,"type":"input","node":"320412000","orgtype":"","pagetitle":"","pagecode":"","pageid":null,"tablename":"activity_setting_item","tablecode":null,"hasChosen":true,"disabled":false,"showButton":true},{"id":7,"linktype":null,"text":"成果","savekey":null,"isfixed":"false","isneed":false,"type":"configurablePages","node":"320412000","orgtype":"10104","pagetitle":"新建录入","pagecode":"1000027","pageid":5,"tablename":"activity_setting_item","tablecode":null,"hasChosen":true,"disabled":false,"showButton":true},{"id":9,"linktype":null,"text":"专利","savekey":null,"isfixed":"false","isneed":false,"type":"configurablePages","node":"320412000","orgtype":"10104","pagetitle":"新建录入","pagecode":"1000027","pageid":7,"tablename":"activity_setting_item","tablecode":null,"hasChosen":true,"disabled":false,"showButton":true},{"id":6,"linktype":null,"text":"简介","savekey":null,"isfixed":"false","isneed":false,"type":"input","node":"320412000","orgtype":"","pagetitle":"","pagecode":"","pageid":null,"tablename":"activity_setting_item","tablecode":null,"hasChosen":true,"disabled":false,"showButton":true}]',
// type: 5922,
// }
// var settingItems='[{"id":1,"linktype":null,"text":"姓名","savekey":"","isfixed":"true","isneed":true,"type":"input","node":"320412000","orgtype":"","pagetitle":"","pagecode":"","pageid":null,"tablename":"activity_setting_item","tablecode":null,"disabled":true},{"id":2,"linktype":null,"text":"电话","savekey":"","isfixed":"true","isneed":true,"type":"input","node":"320412000","orgtype":"","pagetitle":"","pagecode":"","pageid":null,"tablename":"activity_setting_item","tablecode":null,"disabled":true},{"id":3,"linktype":null,"text":"身份类别","savekey":null,"isfixed":"true","isneed":true,"type":"input","node":"320412000","orgtype":"","pagetitle":"","pagecode":"","pageid":null,"tablename":"activity_setting_item","tablecode":null,"disabled":true},{"id":4,"linktype":null,"text":"所属机构","savekey":null,"isfixed":"true","isneed":true,"type":"input","node":"320412000","orgtype":"","pagetitle":"","pagecode":"","pageid":null,"tablename":"activity_setting_item","tablecode":null,"disabled":true},{"id":6,"linktype":null,"text":"身份证号","savekey":"","isfixed":"false","isneed":true,"type":"","node":"320412000","orgtype":"","pagetitle":"","pagecode":"","pageid":null,"tablename":"activity_setting_item","tablecode":null,"hasChosen":true,"disabled":false,"showButton":true},{"id":5,"linktype":null,"text":"所属行业","savekey":null,"isfixed":"false","isneed":true,"type":"input","node":"320412000","orgtype":"","pagetitle":"","pagecode":"","pageid":null,"tablename":"activity_setting_item","tablecode":null,"hasChosen":true,"disabled":false,"showButton":true},{"id":9,"linktype":null,"text":"需求","savekey":null,"isfixed":"false","isneed":true,"type":"configurablePages","node":"320412000","orgtype":"10104","pagetitle":"新建录入","pagecode":"1000027","pageid":4,"tablename":"activity_setting_item","tablecode":null,"hasChosen":true,"disabled":false,"showButton":true},{"id":10,"linktype":null,"text":"专利","savekey":null,"isfixed":"false","isneed":true,"type":"configurablePages","node":"320412000","orgtype":"10104","pagetitle":"新建录入","pagecode":"1000027","pageid":7,"tablename":"activity_setting_item","tablecode":null,"hasChosen":true,"disabled":false,"showButton":true},{"id":8,"linktype":null,"text":"成果","savekey":null,"isfixed":"false","isneed":true,"type":"configurablePages","node":"320412000","orgtype":"10104","pagetitle":"新建录入","pagecode":"1000027","pageid":5,"tablename":"activity_setting_item","tablecode":null,"hasChosen":true,"disabled":false,"showButton":true},{"id":7,"linktype":null,"text":"简介","savekey":null,"isfixed":"false","isneed":true,"type":"input","node":"320412000","orgtype":"","pagetitle":"","pagecode":"","pageid":null,"tablename":"activity_setting_item","tablecode":null,"hasChosen":true,"disabled":false,"showButton":true}]';
// $scope.detail.content='
1.简介项目1
这是个很有意思的活动
2.简介项目2
就是这个意思了,真的很好
3.简介项目3
还想说些啥啊?你觉得呢,好的呢是么。解放路打扫房间打脸萨飞机来的肆拾玖坊放假啦时代峰峻多少了房间啊施蒂利克减肥的数量大房间都是拉福建省砥砺奋进收到了经济福利卡萨房价来说大姐夫荆防颗粒打死了附近的撒的拉风
解放垃圾分类撒附件的及复健科打死了附近的萨芬健身房卡萨减肥的金风科技二氢钾而且我两款软件减肥的开始啦积分卡房间打开酸辣粉几十块拉附近的快乐撒房间打开来说房价的快乐撒附近的上课啦惊世毒妃多少克拉放假了SD卡解放路口的积分看了多少积分开了点撒酒疯今飞凯达撒房间打开来说就分开来的撒娇放得开撒酒疯今飞凯达放假啊啊开发建档立卡收费记录卡数据赋雷克萨按揭房可莱丝老司机法拉盛甲方领导萨卡积分卢卡斯解放路
';
$scope.sectionBoxTitle = [
{ name: '图文直播', selected: true },
{ name: '大家说', selected: false }
]
$scope.hasMore = true;
console.log($scope.sectionBoxTitle[0].selected && $scope.hasMore);
$scope.selectSetion = 0;
$scope.changeSectionPart = function (index) {
$scope.selectSetion = index;
angular.forEach($scope.sectionBoxTitle, function (val, indx) {
val.selected = index == indx;
})
$scope.hasMore = false;
if (index == 0) {
pagenum = 1;
$scope.hasMore = true;
$scope.imageTextList = [];
$scope.sectionBoxTitle[0].selected = true;
$scope.getBroadcastList();
}
}
$scope.imageTextList = [
// {
// image:'http://www.runoob.com/try/demo_source/blue-album.jpg',
// title:'图文直播2',
// content:'图文直播1的内容,很好啊,嘿嘿,很多企业,很多搞下,很多人fasfdsafdsaafdsafdasfdsafdsafasfdsafdsafsdafdsfdf'
// },{
// image:'http://www.runoob.com/try/demo_source/siamese-dream.jpg',
// title:'图文直播3',
// content:'图文直播1的内容,很好啊,嘿嘿,很多企业,很多搞下,很多人'
// },{
// image:'http://www.runoob.com/try/demo_source/nevermind.jpg',
// title:'图文直播4',
// content:'图文直播1的内容,很好啊,嘿嘿,很多企业,很多搞下,很多人'
// },{
// image:'http://www.runoob.com/try/demo_source/license-to-ill.jpg',
// title:'图文直播5',
// content:'图文直播1的内容,很好啊,嘿嘿,很多企业,很多搞下,很多人'
// },
]
$scope.goToActivityAction = function () {
if (!ConfigService.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$scope.go('login');
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.go('login');
return;
}
} else {
$scope.go('login');
return;
}
}
} else {
$scope.go('login');
return;
}
return;
}
$scope.go('activityApply', { settingItems: $scope.detail.settingItems, activityid: $scope.detail.id })
}
/****评论*****/
$scope.comment = { content: "" };
// var recourceid='';
var recourcetype = 30124;
// 评论/评论回复的传参
$scope.infoComment =
{
infoid: recourceid,//资源id
infotype: recourcetype,// 资源类别
parentid: 0,// 评论回复时,记录父评论的id
parentuserid: 0,// 评论回复时,记录父评论的创建者
content: "",// 评论/回复内容
//TODO
creator: UserService.id,// 创建者
updater: UserService.id,// 更新者
// creator:1,// 创建者
// updater:1// 更新者
contenttype: '活动详情页'
};
// 获取评论列表的传参
$scope.paramsForInfoCommentList =
{
mode: 1,// 显示样式:1热门 2全部
infoid: recourceid,// 资源id
infotype: recourcetype,// 资源类型
sortkey: 0,// 排序字段
sorttype: "ASC",// 排序方式
moduleid: ConstantService.TABLE_CODE_30002,// 评论表对应的code
//TODO
userid: UserService.id// 登录者id
// userid:1// 登录者id
};
//获取热门评论列表
var getInfoCommentList = function () {
var paramsForInfoCommentList = {
mode: 1,// 显示样式:1热门 2全部
infoid: recourceid,// 资源id
infotype: recourcetype,// 资源类型
sortkey: 0,// 排序字段
sorttype: "ASC",// 排序方式
moduleid: ConstantService.TABLE_CODE_30002,// 评论表对应的code
//TODO
userid: UserService.id// 登录者id
// userid:1// 登录者id
};
CommentService.getInfoCommentList(paramsForInfoCommentList).then(function (response) {
console.log(response);
// 评论列表
$scope.comments = response.data;
}, function () {
})
};
getInfoCommentList();
//发布普通评论
$scope.publishComment = function (type, comment) {
if (!ConfigService.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$scope.go('login');
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.go('login');
return;
}
} else {
$scope.go('login');
return;
}
}
} else {
$scope.go('login');
return;
}
return;
}
var content = $scope.comment.content;
if (content.length == 0) {
if ($scope.app) {
UtilService.showMess("请输入评论内容!");
} else {
CommonService.showMessage("请输入评论内容!", $scope);
}
return;
}
$scope.showComment = true;
$scope.infoComment.content = content;
// 评论
if (type == 1) {
$scope.infoComment.parentid = 0;// 评论回复时,记录父评论的id
$scope.infoComment.parentuserid = 0;// 评论回复时,记录父评论的创建者
}
// 评论回复
else if (type == 2) {
$scope.infoComment.parentid = comment.id;// 评论回复时,记录父评论的id
$scope.infoComment.parentuserid = comment.creator;// 评论回复时,记录父评论的创建者
}
//提交评论信息
$scope.showLoadingToast();
console.log($scope.infoComment);
$scope.infoComment.contenttype = '活动详情页';
CommentService.publishSimpleComment($scope.infoComment).then(function () {
if ($scope.app) {
UtilService.showMess("评论成功");
} else {
CommonService.showMessage("评论成功", $scope);
}
$scope.infoComment.content = "";
getInfoCommentList();
/*if ($scope.comments.length >= 3) {
$timeout(function () {
$scope.getInfoCommentList();
}, 650);
}*/
$scope.hideLoadingToast();
}, function () {
$scope.hideLoadingToast();
});
};
//发表详细评论
$scope.releaseComment = function () {
$scope.go('releaseComment', {
infoid: recourceid,
infotype: recourcetype,
comlen: $scope.commentlist.length,
recourcecomefrom: recourcecomefrom
})
};
//点击抢沙发
$scope.hadSoft = function () {
$scope.showComment = false;
$(".my_comment").focus();
};
$scope.showComment = true;
$scope.focus_write = function () {
scrollToBottom();//滚动至底部
$scope.showComment = false;
$(".my_comment").focus();
};
$scope.hiddenComment = function () {
$scope.showComment = true;
};
//跳转到评论详情页comment
$scope.goComment = function (comment) {
if (!ConfigService.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$scope.go('login');
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.go('login');
return;
}
} else {
$scope.go('login');
return;
}
}
} else {
$scope.go('login');
return;
}
return;
}
$scope.go("Reply", {
comment: comment,
infotype: comment.infotype,
infoid: comment.infoid,
comfrom: '活动详情页'
})
};
// 滚动至底部
var scrollToBottom = function () {
$timeout(function () {
$ionicScrollDelegate.$getByHandle("calenderContent").scrollBottom();
}, 0);
};
//进入评论列表页
$scope.goCommentList = function () {
if (!ConfigService.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$scope.go('login');
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.go('login');
return;
}
} else {
$scope.go('login');
return;
}
}
} else {
$scope.go('login');
return;
}
return;
}
$timeout(function () {
$scope.go('comment', {
mode: 2,
infoid: $scope.detail.id,
infotype: 0,
comfrom: 'task'
});
}, 350);
};
// 弹出简单评论框
$scope.showComment = true;
$scope.focus_write = function () {
$scope.showComment = false;
};
// 隐藏简单评论框
$scope.hiddenComment = function () {
$scope.showComment = true;
};
// 简单评论框内容变更,判断 发表 按钮颜色
$scope.commentValue = function () {
var search_history = angular.element(document.getElementsByClassName("my_comment"));
if (UtilService.isDefined($scope.comment.content) && $scope.comment.content.length > 1000) {
if ($scope.app) {
UtilService.showMess("您的评论已超过1000字!");
} else {
CommonService.showMessage("您的评论已超过1000字!", $scope);
}
$scope.comment.content = $scope.comment.content.substr(0, 1000);
}
if (UtilService.isDefined($scope.comment.content) && $scope.comment.content != 0) {
$scope.commentNotnull = {
"background-color": "#2a90d7",
"text-decoration": "underline"
};
} else {
$scope.commentNotnull = {
"background-color": "#ccc"
};
}
};
var customActionParams = {
clicktype: 0,
moduleid: 0,
targetid: 0,
userid: UserService.id
}
// 收藏页面
$scope.collectResource = function (clicktype, moduleid, targetid) {
if (!ConfigService.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$scope.go('login');
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.go('login');
return;
}
} else {
$scope.go('login');
return;
}
}
} else {
$scope.go('login');
return;
}
return;
}
customActionParams = {
clicktype: clicktype,
moduleid: moduleid,
targetid: targetid,
userid: UserService.id,
content: '活动详情页'
}
console.log(customActionParams);
CommentService.postClickFavour(customActionParams).then(function (res) {
console.log(res);
if (res.code == 3350) {
if (clicktype == 2619 || clicktype == 2620) {
$scope.hasCollect = !$scope.hasCollect;
}
if (clicktype == 2617 || clicktype == 2618) {
$scope.hasFocus = !$scope.hasFocus;
}
if (clicktype == 2615 || clicktype == 2616) {
$scope.hasFavour = !$scope.hasFavour;
}
getActivityDetailInfo();
}
})
}
// 分享页面
$scope.shareRsource = function () {
}
//分享
$scope.shareflg = false;
$scope.openShare = function () {
if ($scope.app) {
$scope.shareflg = true;
} else {
$scope.shareMessage();
}
};
$scope.closeShareBox = function () {
$scope.shareflg = false;
};
//TODO
$scope.showShareWechat = false;
$scope.closeShare = function () {
$scope.showShareWechat = false;
};
var sharelink = "https://blog.csdn.net/molong421/article/details/51586194";
//0:QQ,1:QQ空间,2:微信,3:微信朋友圈,4:新浪微博
$scope.shareMessage = function (type) {
$scope.shareflg = false;
var linkUrl = ConfigService.webserver + '#/activityDetail/' + $stateParams.activityid;
console.log(linkUrl);
var imagurl = $scope.poster ? (ConfigService.imgurl + $scope.poster) : "https://cordova.apache.org/static/img/cordova_bot.png";
var message = {
title: $scope.detail.name,
description: $scope.detail.content.substring(0, 19),
url: linkUrl,
imageurl: imagurl
};
console.log(linkUrl);
if ($scope.app) {
$scope.showLoadingToast();
// var message = {
// title: $scope.resourceDetail.title,
// description: $scope.resourceDetail.title.substring(0,19),
// url: sharelink,
// imageurl: imagurl
// };
switch (type) {
case 0:
case 1:
ShareService.shareToQQ(type, message).then(function () {
$scope.hideLoadingToast();
if ($scope.app) {
UtilService.showMess("QQ分享成功");
} else {
CommonService.showMessage("QQ分享成功", $scope);
}
}, function (error) {
$scope.hideLoadingToast();
if ($scope.app) {
UtilService.showMess(error);
} else {
CommonService.showMessage(error, $scope);
}
});
break;
case 2:
ShareService.shareToWechat(type, message).then(function () {
// UtilService.showMess("微信分享成功");
$scope.hideLoadingToast();
if ($scope.app) {
UtilService.showMess("微信分享成功");
} else {
CommonService.showMessage("微信分享成功", $scope);
}
}, function (error) {
// UtilService.showMess(error);
$scope.hideLoadingToast();
if ($scope.app) {
UtilService.showMess(error);
} else {
CommonService.showMessage(error, $scope);
}
});
break;
case 3:
ShareService.shareToWechat(type, message).then(function () {
// UtilService.showMess("微信分享成功");
$scope.hideLoadingToast();
if ($scope.app) {
UtilService.showMess("微信分享成功");
} else {
CommonService.showMessage("微信分享成功", $scope);
}
}, function (error) {
// UtilService.showMess(error);
$scope.hideLoadingToast();
if ($scope.app) {
UtilService.showMess(error);
} else {
CommonService.showMessage(error, $scope);
}
});
break;
case 4:
ShareService.shareToWeibo(message).then(function () {
// UtilService.showMess("新浪微博分享成功");
$scope.hideLoadingToast();
if ($scope.app) {
UtilService.showMess("新浪微博分享成功");
} else {
CommonService.showMessage("新浪微博分享成功", $scope);
}
}, function (error) {
// UtilService.showMess(error);
$scope.hideLoadingToast();
if ($scope.app) {
UtilService.showMess(error);
} else {
CommonService.showMessage(error, $scope);
}
});
break;
default:
break;
}
$timeout(function () {
$scope.hideLoadingToast();
}, 10000);
} else {
$scope.showShareWechat = true;
var content = document.getElementById('qrcode-dialog2');
console.log(content);
content.innerHTML = '';
var qrcode = new QRCode(content, {
text: $scope.detail.name,
// title: $scope.resourceDetail.baseInfoModel.title,
// description: $scope.resourceDetail.baseInfoModel.title.substring(0,19),
// url: linkUrl,
// imageurl: imagurl,
width: 200,
height: 200
})
qrcode.makeCode(linkUrl);
}
};
// 编辑任务
$scope.editActivityAction = function () {
if (!ConfigService.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$scope.go('login');
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.go('login');
return;
}
} else {
$scope.go('login');
return;
}
}
} else {
$scope.go('login');
return;
}
return;
}
$scope.go('activityRelease', { data: JSON.stringify($scope.allData) });
}
// 取消活动
$scope.cancelActivity = function () {
if (!ConfigService.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$scope.go('login');
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.go('login');
return;
}
} else {
$scope.go('login');
return;
}
}
} else {
$scope.go('login');
return;
}
return;
}
var params = {
data: {
id: $scope.detail.id,
isenabled: 2,
creator: $scope.detail.creator
},
node: UserService.node,
}
activitiesModuleService.releaseOrEditActivity(params).then(function (res) {
if (user == "") {
user = res.user;
}
if (res.code == 3350) {
$scope.canapply = false;
$scope.cancelapply = false;
$scope.ishasedit = false;
$scope.isCancel = false;
$scope.registmanage = false;
$scope.ishasinput = false;
if ($scope.app) {
UtilService.showMess("活动取消成功");
} else {
CommonService.showMessage("活动取消成功", $scope);
}
}
})
}
// 报名管理
$scope.goToParticipantList = function () {
if (!ConfigService.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$scope.go('login');
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.go('login');
return;
}
} else {
$scope.go('login');
return;
}
}
} else {
$scope.go('login');
return;
}
return;
}
// const toStr = window.btoa(unescape(encodeURIComponent($scope.detail.settingItems)))
// console.log(toStr);
$scope.go('participantList', { activityid: $scope.detail.id, status: $scope.detail.status, settingItems: $scope.detail.settingItems });
}
// 现场录入
$scope.liveBroadcast = function () {
if (!ConfigService.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$scope.go('login');
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.go('login');
return;
}
} else {
$scope.go('login');
return;
}
}
} else {
$scope.go('login');
return;
}
}
var isedit = 0;
$scope.go('visitModularForm', {
companyid: $stateParams.activityid,
connid: 0,
pageid: 17,
orgtype: 10104,
pagecode: 1000027,
isedit: isedit,
node: 320412000,
pageTitle: isedit ? '编辑录入' : '新建录入',
comfrom: 'activityDetail',
title: title
});
}
$scope.hasMore = true;
// 现场直播
$scope.getBroadcastList = function () {
// var deferred = $q.defer();
console.log(pagenum);
activitiesModuleService.liveBroadcastList($stateParams.activityid, pagenum, pagesize).then(function (res) {
console.log(res);
if (res.code == 3350) {
angular.forEach(res.data, function (val) {
var images = JSON.parse(val.images);
val.image = images && images.length > 0 ? images[0].photoName : '';
})
$scope.imageTextList = $scope.imageTextList.concat(res.data);
if (pagenum >= res.page.totalPage) {
$scope.hasMore = false;
}
pagenum++;
// deferred.resolve(res.data);
}
}).finally(function () {
$scope.$broadcast('scroll.infiniteScrollComplete');
});
// return deferred.promise;
}
$scope.getBroadcastList();
$scope.loadMoreData = function () {
}
// 删除现场记录
$scope.deleteBroadcast = function (id) {
activitiesModuleService.deleteBroadcast(id, $stateParams.activityid).then(function (res) {
console.log(res);
if (res.code == 3350) {
pagenum = 1;
$scope.hasMore = true;
$scope.imageTextList = [];
$scope.getBroadcastList();
}
})
};
$scope.showModal = false;
// $scope.checkBroadcastDetail=function(index){
// console.log($scope.imageTextList[index]);
// $scope.showModal=true;
// $scope.liveBroadcastMessage=$scope.imageTextList[index];
// $scope.liveBroadcastMessage.images=JSON.parse($scope.liveBroadcastMessage.images);
// };
//点击图片放大
$scope.bigImage = false; //初始默认大图是隐藏的
$scope.hideBigImage = function () {
$timeout(function () {
if ($scope.app) {
$scope.setStatusBar(0);
}
$scope.bigImage = false;
}, 400);
};
$scope.shouBigImage = function (index, type) { //传递一个参数(图片的URl)
if ($scope.app) {
$scope.setStatusBar(1);
}
if (type == 'accessory') {
$scope.imgUrlList = $scope.accessory;
} else {
$scope.imgUrlList = $scope.liveBroadcastMessage.images;
}
console.log($scope.imgUrlList[index]);
var str = $scope.imgUrlList[index].sourceName.split('.');
if (str && str.length > 0 && str[1] != 'jpg' && str[1] != 'gif' && str[1] != 'bmp' && str[1] != 'png' && str[1] != 'jpeg') {
if ($scope.imgUrlList[index]) {
window.open(ConfigService.imgurl + $scope.imgUrlList[index].sourceName);
return;
}
}
$scope.bigImage = true; //显示大图
$(function () {
$('div.pinch-zoom').each(function () {
new RTP.PinchZoom($(this), {});
});
});
$ionicSlideBoxDelegate.update();//重绘,让图片显示出来
//图片总数量
setTimeout(function () {
// console.log(parseInt($ionicSlideBoxDelegate.slidesCount()));
// console.log(parseInt($ionicSlideBoxDelegate.currentIndex()));
$ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, 0);
//获取图片
var imgObj = document.getElementsByClassName('bigimage');
var n;
for (n = 0; n < imgObj.length; n++) {
// 获取图片的原始高度和宽度
var oldWid = imgObj[n].naturalWidth;
var oldHei = imgObj[n].naturalHeight;
var screen = document.body.offsetWidth;
var screenH = window.innerHeight;
// console.log(oldWid/oldHei);
// console.log(screen );
var rate = oldWid / oldHei;
if (oldWid >= screen && oldHei >= screenH) {
var tw = screen;
var th = tw / rate;
if (th < screenH) {
imgObj[n].style.width = tw + 'px';
imgObj[n].style.height = th + 'px';
imgObj[n].style.marginTop = (screenH - th) / 2 + 'px';
} else {
imgObj[n].style.width = screenH * rate + 'px';
imgObj[n].style.height = screenH + 'px';
imgObj[n].style.marginLeft = (screen - screenH * rate) / 2 + 'px';
}
} else if (oldWid >= screen && oldHei <= screenH) {
imgObj[n].style.width = screen + 'px';
imgObj[n].style.height = screen / rate + 'px';
imgObj[n].style.marginTop = (screenH - screen / rate) / 2 + 'px';
} else if (oldWid <= screen && oldHei >= screenH) {
// var hh=screenH;
// var ww=screenH*rate;
imgObj[n].style.width = screenH * rate + 'px';
imgObj[n].style.height = screenH + 'px';
imgObj[n].style.marginLeft = (screen - screenH * rate) / 2 + 'px';
} else {
imgObj[n].style.width = oldWid + 'px';
imgObj[n].style.height = oldHei + 'px';
imgObj[n].style.marginLeft = (screen - oldWid) / 2 + 'px';
imgObj[n].style.marginTop = (screenH - oldHei) / 2 + 'px';
}
}
}, 500);
};
$scope.cancelApplyAction = function () {
if (!ConfigService.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$scope.go('login');
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.go('login');
return;
}
} else {
$scope.go('login');
return;
}
}
} else {
$scope.go('login');
return;
}
}
activitiesModuleService.cancelApply($stateParams.activityid).then(function (res) {
console.log(res);
if (res.code == 3350) {
$scope.cancelapply = false;
$scope.canapply = true;
if ($scope.app) {
UtilService.showMess("取消报名成功");
} else {
CommonService.showMessage("取消报名成功", $scope);
}
getActivityDetailInfo();
}
})
}
$scope.gobackToHoll = function () {
$scope.go('activitiesHoll');
}
$scope.goPublisher = function (id) {
console.log(id);
if (!ConfigService.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$scope.go('login');
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.go('login');
return;
}
} else {
$scope.go('login');
return;
}
}
} else {
$scope.go('login');
return;
}
}
if (id != 0) {
$scope.go('publisher', { Id: id });
}
}
// 统计列表页面
var labelResourceListModal = function () {
$ionicModal.fromTemplateUrl('./modules/common/views/labelResourceListModal.html', {
scope: $scope,
animation: 'slide-in-left'
}).then(function (modal) {
$scope.labelResourceListModal = modal;
});
}
labelResourceListModal();
$scope.openList = function (hasList, item) {
if (hasList) {
$scope.searchtype = 2;
$scope.labelResourceListModal.show();
$scope.labelTitle = '活动 ' + $scope.detail.name + " " + item.name;
$scope.allList = item.list;
angular.forEach($scope.allList, function (val) {
activitiesModuleService.getUsernameByOrgname(val.title).then(function (res) {
val.username = res.data;
})
});
console.log($scope.allList);
}
}
$scope.goResourceDetail = function (resource) {
if (!ConfigService.islogin) {
if (localStorage.wxFlag == "true") {
if (localStorage.isUserFocusXW == 0) {
var title = localStorage.appidStr;
$scope.go('login');
return;
} else {
if (localStorage.isUserBindWx == 0) {
var wxFlag = JSON.parse(localStorage.params);
if (wxFlag.weChatModel) {
$scope.go('bindPhone', {
params: localStorage.params,
comfrom: 'maincontroller',
url: window.location.href.split('#/')[1]
});
} else {
$scope.go('login');
return;
}
} else {
$scope.go('login');
return;
}
}
} else {
$scope.go('login');
return;
}
} else {
$scope.labelResourceListModal.hide();
$scope.go('resourceCommonDetailsPage', {
recourceid: resource.id,
recourcetype: resource.restype,
recourcecomefrom: resource.comefrom,
creator: resource.creator,
title: resource.title
});
}
}
//微信分享时自定义标题和描述
var wechatInit = function () {
var url = encodeURIComponent(window.location.href.split("#")[0]);
dataToolsService.getWechatConfig(UserService.node, url).then(function (res) {
if (res.code == 3350) {
activitiesModuleService.getActivityDetailInfo($stateParams.activityid).then(function (res1) {
if (res1.code == 3350) {
$scope.wechattitle = res1.data.activityInfo.name;
$scope.wechatdesc = res1.data.activityInfo.remark;
$scope.wechatlink = res.data[3] + "#/activityDetail/" + $stateParams.activityid + "";
$scope.wechatimg = $scope.poster ? ($scope.poster | imgfilter) : './img/2018/activity-3.jpg';
wx.config({
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
appId: res.data[4], // 必填,公众号的唯一标识
timestamp: res.data[0], // 必填,生成签名的时间戳
nonceStr: res.data[1], // 必填,生成签名的随机串
signature: res.data[2],// 必填,签名
jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'] // 必填,需要使用的JS接口列表
});
wx.ready(function () {
wx.onMenuShareTimeline({
title: $scope.wechattitle, // 分享标题
desc: $scope.wechatdesc, // 分享描述
link: $scope.wechatlink, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: $scope.wechatimg,
});
wx.onMenuShareAppMessage({
title: $scope.wechattitle, // 分享标题
desc: $scope.wechatdesc, // 分享描述
link: $scope.wechatlink, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: $scope.wechatimg,
});
});
wx.error(function (res) {
// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
console.log(JSON.stringify(res));
});
}
})
}
})
};
wechatInit();
}]);