angular.module('push') .controller('PublisherCtrl', function ($scope, AccountService, $stateParams, SearchResultService, ConstantService, $ionicPopup,CommentService, UtilService, $ionicHistory, UserService, ConfigService, ScienceCircleService, CommonService, $ionicScrollDelegate) { //记录当前个人主页的用户id UserService.homeUserId = $stateParams.Id; //TODO console.log($stateParams); $scope.id = $stateParams.Id; $scope.userId = UserService.id; $scope.labelLists = []; $scope.stars = 0; $scope.category = ''; // $scope.id = 670; // $scope.userId = 630; // 点赞、收藏、分享的传参 $scope.clickRecord = { targetid: $stateParams.Id, moduleid: ConstantService.TABLE_CODE_30003, userid: UserService.id, clicktype: 1 }; AccountService.getHomeInfo($scope.id, $scope.userId).then(function (response) { console.log(response); var user = response.data; $scope.isfocus = user.isfocus;//当前登录用户是否关注了该主页用户 1:已经关注、2:未关注 $scope.focusNmb = user.focuscount;//关注数 $scope.fansNmb = user.fansNmb;//粉丝数 $scope.name = user.username;//昵称 $scope.orgName = user.orgName;//机构名 $scope.intro = user.intro;//简介 $scope.data = user.data;//资料 $scope.orgType = user.orgType;//机构类型 $scope.region = user.regionname;//所在地区 $scope.linkman = user.linkman;//联系人 $scope.contactnumber = user.contactnumber;//联系方式 $scope.info = user;//用户信息 $scope.labelLists = []; $scope.stars = 0; $scope.category = ''; angular.forEach(response.otherObj, function (val) { switch (val.labelKey) { case 'scoreTotal': $scope.stars = Math.round(val.labelName); break; case 'industry': $scope.category = val.labelName; break; default : $scope.labelLists.push(val); } }) console.log($scope.labelLists); }, function () { }); $scope.range = function (n) { return new Array(n); } // 控制重复点击 var flag = 1; // 关注对方 $scope.A_Concerned = function () { if (flag == 0) { return; } flag = 0; // 关注动作 if ($scope.isfocus == 2) { $scope.clickRecord.clicktype = ConstantService.TRACE_TYPE_2617; } else // 取消关注动作 if ($scope.isfocus == 1) { $scope.clickRecord.clicktype = ConstantService.TRACE_TYPE_2618; } $scope.clickRecord.targetid = $scope.id; $scope.clickRecord.moduleid = ConstantService.TABLE_CODE_30043; CommentService.postClickFavour($scope.clickRecord).then(function (response) { // console.log(response); if (response.code == ConstantService.INTERFACE_STATUS_CODE_3350) { if ($scope.isfocus == 2) { $scope.isfocus = 1; // 关注成功 if ($scope.app) { UtilService.showMess(ConstantService.TRACE_TYPE_STRING_2617); } else { CommonService.showMessage(ConstantService.TRACE_TYPE_STRING_2617, $scope); } } else // 取消关注 if ($scope.isfocus == 1) { $scope.isfocus = 2; // 取消关注成功 if ($scope.app) { UtilService.showMess(ConstantService.TRACE_TYPE_STRING_2618); } else { CommonService.showMessage(ConstantService.TRACE_TYPE_STRING_2618, $scope); } } } // 恢复可用 flag = 1; }, function () { // 恢复可用 flag = 1; if ($scope.app) { UtilService.showMess(ConstantService.INTERFACE_MESSAGE_ERROR); } else { CommonService.showMessage(ConstantService.INTERFACE_MESSAGE_ERROR, $scope); } }); }; $scope.inbox={} // 发送消息 $scope.sendMessage = function () { console.log($scope.id); // ScienceCircleService.createConversation(6202, $scope.id, 20001).then(function (response) { // console.log(response); // if (response.result > 0) { // $scope.go('singleChatMode', { // "topicid": response.topic.topicid, // "topicname": response.topic.topicname, // "username": $scope.name, // "reciverid": response.topic.reciverid, // "isfocus": $scope.isfocus // }); // } else { // if ($scope.app) { // UtilService.showMess("网络不给力,请重试"); // } else { // CommonService.showMessage("网络不给力,请重试", $scope); // } // } // }, function () { // if ($scope.app) { // UtilService.showMess("网络不给力,请重试"); // } else { // CommonService.showMessage("网络不给力,请重试", $scope); // } // }) $ionicPopup.show({ title: '发送留言', template: ``, scope: $scope, buttons: [{ text: "取消", onTap: function () { // console.log('取消') } }, { text: '发送', type: "button-positive", onTap: function (e) { if($scope.inbox.content){ let param={ "content": $scope.inbox.content, "receiveId":$scope.id , "sendId": UserService.id} console.log(param) CommentService.postchatsend(param).then(function (res){ if(res.code==3350){ CommonService.prompt('发送成功'); }else { $ionicPopup.alert({ title: '提示', template: res.message }); } }).catch(function () { $ionicPopup.alert({ title: '提示', template: "服务器错误" }); }) }else { CommonService.prompt('请输入内容'); e.preventDefault(); } } } ] }); }; //删除动态 $scope.item_delectSpan = function () { // console.log("删除"); }; //显示二维码 $scope.showMyMessage = function () { $(".fixedTwo").css("display", "block"); }; //隐藏二维码 $scope.hiddenTwoCode = function () { $(".fixedTwo").css("display", "none"); }; $scope.goNextPage = function () { /* $scope.islogin = ConfigService.islogin; if(!$scope.islogin){ }else{ $scope.go('editdata'); }*/ if ($scope.app) { UtilService.showMess("功能正在完善中,敬请期待!"); } else { CommonService.showMessage("功能正在完善中,敬请期待!", $scope); } }; $scope.gobackpage = function () { $scope.goback(); /*if ($ionicHistory.backView()) { $ionicHistory.backView().go(); } else { $ionicHistory.goBack(-4); }*/ //个人主页是当前的登录用户 /*if(info.userid == UserService.id){ $scope.go('tab.account'); }else{ $ionicHistory.backView().go(); }*/ }; //去完成任务 $scope.gotoFanCenter = function (activityvalue) { $scope.go('fancenter', {act: activityvalue, userid: $scope.id}); }; var getMyRelease = function () { $scope.showLoadingToast(); $scope.otherResource = []; $scope.len = -1; AccountService.releaseResource($scope.id).then(function (res) { // console.log(res); $scope.hideLoadingToast(); if (res.code == 3350) { $scope.allList = res.data; console.log($scope.allList); angular.forEach($scope.allList, function (vv) { if (vv.list && vv.list.length > 0) { vv.shortList = vv.list.slice(0, 3); } if (vv.name == "走访的企业") { $scope.len = vv.list.length; } vv.showList = vv.shortList; }) var temp = $scope.allList.filter(function (value) { return value.name == '发布的资源'; }); console.log($scope.allList); if (temp.length > 0) { angular.forEach(temp[0].typeList, function (val, index) { if (val.list != null && val.list != undefined && val.list.length > 0) { val.active = index == 0; $scope.otherResource.push(val); } }) } } $scope.otherResourceList = $scope.otherResource[0]; document.getElementById('click-button1').style.width = 100 * $scope.otherResource.length + 'px'; }) }; getMyRelease(); var currentIndex = 0; $scope.changeActiveTitle = function (index) { currentIndex = index; angular.forEach($scope.otherResource, function (val) { val.active = false; }); $scope.otherResource[index].active = true; $scope.otherResourceList = $scope.otherResource[index]; } // 进入资源详情 $scope.goResourceDetail = function (resource, type) { //由用户首页的资源列表进入资源详情 UserService.userHomeToResourceFlag = 1; console.log(resource); if (resource.unique !== undefined) { if (resource.type == 1) { if (!ConfigService.islogin) { if (localStorage.wxFlag == "true") { if (localStorage.isUserFocusXW == 0) { var title = localStorage.appidStr; $ionicPopup.alert({ title: '提示', template: '请先关注微信公众号"' + title + '"!' }); 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 if (type == 0) { $scope.go('taskDetail', { resid: resource.unique, node: resource.source, title: resource.title, restype: resource.type, comefrom: 'publisher', ifjoin: resource.otherObj.ifjoin, actions: resource.otherObj.actions, taskstatus: resource.otherObj.taskstatus, taskid: resource.otherObj.id, opentowho: resource.otherObj.opentowho }); } else if (type == 1) { $scope.go('resourceCommonDetailsPage', { recourceid: resource.unique, recourcetype: resource.type, recourcecomefrom: resource.source, creator: resource.clickthrough, title: resource.title, orgtype: 0, pagecode: 0, label: JSON.stringify(resource.otherObj) }); } } else { $scope.go('resourceCommonDetailsPage', { recourceid: resource.unique, recourcetype: resource.type, recourcecomefrom: resource.source, creator: resource.clickthrough, title: resource.title, orgtype: 0, pagecode: 0, label: JSON.stringify(resource.otherObj) }); } } else if (resource.tablename !== undefined && resource.tablename == "activity_info") { //进入活动详情 if (!ConfigService.islogin) { if (localStorage.wxFlag == "true") { if (localStorage.isUserFocusXW == 0) { var title = localStorage.appidStr; $ionicPopup.alert({ title: '提示', template: '请先关注微信公众号"' + title + '"!' }); 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.go('activityDetail', { activityid: resource.id, }); } } else { //进入走访列表 if (!ConfigService.islogin) { if (localStorage.wxFlag == "true") { if (localStorage.isUserFocusXW == 0) { var title = localStorage.appidStr; $ionicPopup.alert({ title: '提示', template: '请先关注微信公众号"' + title + '"!' }); 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 { switch ($scope.act) { case "selfDetailList": $scope.isAllVisitor = 0; break; case "groupDetailList": $scope.isAllVisitor = 1; break; } $scope.go('resourceCommonInfoDetailsPage', { resid: resource.connid, isAllVisitor: $scope.isAllVisitor, pagecode: resource.pagecode, node: resource.node, orgtype: resource.orgtype, templettype: resource.templettype, label: JSON.stringify(resource.otherObj), }); } } }; $scope.showMoreResource = function (mainIndex, index) { $scope.allList[mainIndex].showList = $scope.allList[mainIndex].list } $scope.getPosition = function () { var position = $ionicScrollDelegate.getScrollPosition().top; console.log(position); $scope.showHeader = position > 180; } }) ;