|
- app.controller('IssueController', ['$scope', '$http', '$routeParams', 'auth', 'common',
- function($scope, $http, $routeParams, auth, common){
-
- var vm = $scope;
- vm.previewImgUrls = [];
-
- common.init({
- id: $routeParams.id,
- scope: $scope,
- at_enabled: true,
- type: 'issues',
- replyType: 'Issue',
- urlName: 'issues',
- loadCallback: function(data){
- console.log(data.data);
-
- if(data.status == -1){
- $scope.showtip = true;
- return;
- }
-
- //回复级别 0 一级回复 1 二级回复
- replytype = data.type;
- page = data.page;
-
-
- var parseImgAttachment = function(attachments){
- var urls = [];
- if(!attachments){
- return urls;
- }
-
- for(var i = attachments.length-1; i>=0; i--){
- if(attachments[i].filename.match('.jpg$')=='.jpg' || attachments[i].filename.match('.png$')=='.png'){
- urls.push(attachments[i].download_url);
- attachments.splice(i, 1);
- }
- }
- return urls;
- };
-
- if (replytype == 0){
- if (page == 0){
- $scope.object = data.data;
- $scope.page = 0;
- $scope.is_public = data.is_public;
- $scope.previewImgUrls = parseImgAttachment($scope.object.attachments);
- }
- else{
- $scope.object.all_children = $scope.object.all_children.concat(data.data.all_children);
- }
- $scope.has_more = $scope.object.all_children.length < $scope.object.comment_count;
- console.log($scope.has_more);
- }
- else{
- comment_id = data.data.id;
- for (var i in $scope.object.all_children) {
- var comment = $scope.object.all_children[i];
- if(comment.id == comment_id){
- // comment.parents_reply_top = comment.parents_reply_top.concat(data.data.parents_reply_top);
- comment.parents_reply_top = data.data.parents_reply_top.concat(comment.parents_reply_top);
- }
- }
- }
- },
- replyCallback: function(){
- }
- });
-
- $scope.previewImg = function(index){
- console.log(index);
- wx.previewImage({
- current: $scope.previewImgUrls[index], // 当前显示图片的http链接
- urls: $scope.previewImgUrls // 需要预览的图片http链接列表
- });
- }
- }]);
|