Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
This commit is contained in:
commit
f8fc656920
6
Gemfile
6
Gemfile
|
@ -50,16 +50,16 @@ gem 'elasticsearch-model'
|
||||||
gem 'elasticsearch-rails'
|
gem 'elasticsearch-rails'
|
||||||
|
|
||||||
#rails 3.2.22.2 bug
|
#rails 3.2.22.2 bug
|
||||||
# gem "test-unit", "~>3.0"
|
gem "test-unit", "~>3.0"
|
||||||
|
|
||||||
### profile
|
### profile
|
||||||
# gem 'oneapm_rpm'
|
gem 'oneapm_rpm'
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem 'grape-swagger'
|
gem 'grape-swagger'
|
||||||
gem 'better_errors', '~> 1.1.0'
|
gem 'better_errors', '~> 1.1.0'
|
||||||
# gem "query_reviewer"
|
# gem "query_reviewer"
|
||||||
# gem 'rack-mini-profiler', '~> 0.9.3'
|
gem 'rack-mini-profiler', '~> 0.9.3'
|
||||||
if RUBY_PLATFORM =~ /w32/
|
if RUBY_PLATFORM =~ /w32/
|
||||||
gem 'win32console'
|
gem 'win32console'
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,8 +23,22 @@ module Mobile
|
||||||
refresh_token = session[:refresh_token]
|
refresh_token = session[:refresh_token]
|
||||||
|
|
||||||
if access_token.present? && refresh_token.present?
|
if access_token.present? && refresh_token.present?
|
||||||
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
|
begin
|
||||||
|
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
|
||||||
|
rescue
|
||||||
|
info = Wechat.api.web_access_token(session[:wechat_code])
|
||||||
|
openid =info["openid"]
|
||||||
|
access_token =info["access_token"]
|
||||||
|
if access_token
|
||||||
|
session[:access_token] = access_token
|
||||||
|
end
|
||||||
|
refresh_token = info["refresh_token"]
|
||||||
|
if refresh_token
|
||||||
|
session[:refresh_token] = refresh_token
|
||||||
|
end
|
||||||
|
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
|
||||||
|
end
|
||||||
|
|
||||||
access_token = refreshinfo["access_token"]
|
access_token = refreshinfo["access_token"]
|
||||||
refresh_token = refreshinfo["refresh_token"]
|
refresh_token = refreshinfo["refresh_token"]
|
||||||
session[:access_token] = access_token
|
session[:access_token] = access_token
|
||||||
|
@ -42,9 +56,16 @@ module Mobile
|
||||||
user = us.register ({:login=>openid, :mail=>"#{openid}@163.com",
|
user = us.register ({:login=>openid, :mail=>"#{openid}@163.com",
|
||||||
:password=>"12345678", :password_confirmation=>"12345678",
|
:password=>"12345678", :password_confirmation=>"12345678",
|
||||||
:should_confirmation_password => true})
|
:should_confirmation_password => true})
|
||||||
user.update_attributes(:lastname=>name)
|
|
||||||
|
|
||||||
raise user.errors.full_messages.first if user.new_record?
|
raise user.errors.full_messages.first if user.new_record?
|
||||||
|
user.update_attributes(:lastname=>name)
|
||||||
|
#自动激活
|
||||||
|
if Setting.self_registration != '3'
|
||||||
|
user.activate
|
||||||
|
user.last_login_on = Time.now
|
||||||
|
if user.save
|
||||||
|
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
UserWechat.create!(
|
UserWechat.create!(
|
||||||
openid: openid,
|
openid: openid,
|
||||||
user: user,
|
user: user,
|
||||||
|
|
|
@ -47,7 +47,7 @@ module Mobile
|
||||||
end
|
end
|
||||||
|
|
||||||
ws = WechatService.new
|
ws = WechatService.new
|
||||||
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.login+"("+user.show_name+")", Time.now.strftime("%Y-%m-%d"))
|
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.show_name+"("+user.login+")", Time.now.strftime("%Y-%m-%d"))
|
||||||
present status: 0, message: '您已成功绑定Trustie平台'
|
present status: 0, message: '您已成功绑定Trustie平台'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -68,6 +68,15 @@ module Mobile
|
||||||
user = us.register params.merge(:password_confirmation => params[:password],
|
user = us.register params.merge(:password_confirmation => params[:password],
|
||||||
:should_confirmation_password => true)
|
:should_confirmation_password => true)
|
||||||
raise user.errors.full_messages.first if user.new_record?
|
raise user.errors.full_messages.first if user.new_record?
|
||||||
|
#自动激活
|
||||||
|
if Setting.self_registration != '3'
|
||||||
|
# user = automatically_register(user)
|
||||||
|
user.activate
|
||||||
|
user.last_login_on = Time.now
|
||||||
|
if user.save
|
||||||
|
UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if uw && !uw.real?
|
if uw && !uw.real?
|
||||||
user.update_attributes(:lastname=>uw.user[:lastname])
|
user.update_attributes(:lastname=>uw.user[:lastname])
|
||||||
|
@ -80,7 +89,7 @@ module Mobile
|
||||||
end
|
end
|
||||||
|
|
||||||
ws = WechatService.new
|
ws = WechatService.new
|
||||||
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.login+"("+user.show_name+")", Time.now.strftime("%Y-%m-%d"))
|
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台。", user.show_name+"("+user.login+")", Time.now.strftime("%Y-%m-%d"))
|
||||||
present :data, user, with: Mobile::Entities::User
|
present :data, user, with: Mobile::Entities::User
|
||||||
present :status, 0
|
present :status, 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -386,7 +386,7 @@ class WechatsController < ActionController::Base
|
||||||
user: user
|
user: user
|
||||||
)
|
)
|
||||||
ws = WechatService.new
|
ws = WechatService.new
|
||||||
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台!", user.login+"("+user.show_name+")", format_time(Time.now))
|
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台!", user.show_name+"("+user.login+")", format_time(Time.now))
|
||||||
render :json => {status:0, msg: "绑定成功"}
|
render :json => {status:0, msg: "绑定成功"}
|
||||||
rescue Exception=>e
|
rescue Exception=>e
|
||||||
render :json => {status: -1, msg: e.message}
|
render :json => {status: -1, msg: e.message}
|
||||||
|
@ -415,8 +415,11 @@ class WechatsController < ActionController::Base
|
||||||
unless open_id
|
unless open_id
|
||||||
render 'wechats/open_wechat', layout: nil and return
|
render 'wechats/open_wechat', layout: nil and return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
logger.info "user_activities!!!!!!!!!!!!!!"
|
||||||
|
logger.info params
|
||||||
|
|
||||||
# unless user_binded?(open_id)
|
# unless (user_binded?(open_id) || params[:state] == "invite_code" || params[:state] == "project_invite_code" || params[:state] == "blog_comment" || params[:state] == "course_notice" || params[:state] == "project_discussion" || params[:state] == "course_discussion" || params[:state] == "homework" || params[:state] == "issues" || params[:state] == "journal_for_message")
|
||||||
# @path = '/login'
|
# @path = '/login'
|
||||||
# else
|
# else
|
||||||
if params[:state] == 'myclass'
|
if params[:state] == 'myclass'
|
||||||
|
@ -470,7 +473,11 @@ class WechatsController < ActionController::Base
|
||||||
|
|
||||||
def user_binded?(openid)
|
def user_binded?(openid)
|
||||||
uw = UserWechat.where(openid: openid).first
|
uw = UserWechat.where(openid: openid).first
|
||||||
uw && uw.bindtype == 0
|
if uw && uw.bindtype == 0
|
||||||
|
uw
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_url
|
def current_url
|
||||||
|
|
|
@ -22,5 +22,6 @@ class UserWechat < ActiveRecord::Base
|
||||||
Comment.where(author_id: old_user).update_all(author_id: u.id)
|
Comment.where(author_id: old_user).update_all(author_id: u.id)
|
||||||
Message.where(author_id: old_user).update_all(author_id: u.id)
|
Message.where(author_id: old_user).update_all(author_id: u.id)
|
||||||
BlogComment.where(author_id: old_user).update_all(author_id: u.id)
|
BlogComment.where(author_id: old_user).update_all(author_id: u.id)
|
||||||
|
UserActivity.where(user_id: old_user).update_all(user_id: u.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<div class="member-banner f13 c-grey3">授课老师</div>
|
<div class="member-banner f13 c-grey3">授课老师</div>
|
||||||
|
|
||||||
<div class="class-member-row f13 c-grey3" ng-repeat="teacher in teachers|filter:searchText">
|
<div class="class-member-row f13 c-grey3" ng-repeat="teacher in teachers|filter:searchText">
|
||||||
<img ng-src="{{teacher.img_url}}" width="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{teacher.name}}</span><img ng-src="/images/wechat/{{teacher.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
<img ng-src="{{teacher.img_url}}" width="30" height="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{teacher.name}}</span><img ng-src="/images/wechat/{{teacher.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
||||||
<img src="/images/wechat/setting.png" ng-show = "course.is_creator && teacher.id != course.tea_id" width="15" class="fr mr10" style="margin-top:7px;" ng-click="onSetting(teacher)" />
|
<img src="/images/wechat/setting.png" ng-show = "course.is_creator && teacher.id != course.tea_id" width="15" class="fr mr10" style="margin-top:7px;" ng-click="onSetting(teacher)" />
|
||||||
<span class = "fr mr25 mt5" ng-show ="teacher.id == course.tea_id">管理员</span>
|
<span class = "fr mr25 mt5" ng-show ="teacher.id == course.tea_id">管理员</span>
|
||||||
<span ng-class="['fr','mt5',{'mr10': course.is_creator,'mr25': !course.is_creator}]" ng-show ="teacher.id != course.tea_id && teacher.roles_id == 7">助教</span>
|
<span ng-class="['fr','mt5',{'mr10': course.is_creator,'mr25': !course.is_creator}]" ng-show ="teacher.id != course.tea_id && teacher.roles_id == 7">助教</span>
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-show ="course.is_creator" class="class-member-row f13 c-grey3" ng-repeat="reviewer in reviewers|filter:searchText">
|
<div ng-show ="course.is_creator" class="class-member-row f13 c-grey3" ng-repeat="reviewer in reviewers|filter:searchText">
|
||||||
<img ng-src="{{reviewer.img_url}}" width="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{reviewer.name}}</span><img ng-src="/images/wechat/{{reviewer.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
<img ng-src="{{reviewer.img_url}}" width="30" height="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{reviewer.name}}</span><img ng-src="/images/wechat/{{reviewer.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
||||||
<span ng-click="review(reviewer)" class = "fr mr10 mt5 c-red">待审批 ▶</span>
|
<span ng-click="review(reviewer)" class = "fr mr10 mt5 c-red">待审批 ▶</span>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
<div class="member-banner f13 mt10 c-grey3">我的同学</div>
|
<div class="member-banner f13 mt10 c-grey3">我的同学</div>
|
||||||
<div class="class-member-row f13 c-grey3" ng-repeat="student in students|filter:searchText">
|
<div class="class-member-row f13 c-grey3" ng-repeat="student in students|filter:searchText">
|
||||||
<img ng-src="{{student.img_url}}" width="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{student.name}}</span><img ng-src="/images/wechat/{{student.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
<img ng-src="{{student.img_url}}" width="30" height="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{student.name}}</span><img ng-src="/images/wechat/{{student.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
||||||
<img src="/images/wechat/setting.png" ng-show = "course.is_creator" width="15" class="class-list-setting" ng-click="onSetting(student)" />
|
<img src="/images/wechat/setting.png" ng-show = "course.is_creator" width="15" class="class-list-setting" ng-click="onSetting(student)" />
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -108,30 +108,30 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="member-banner f13 c-grey3">管理人员({{project_master_members.length}})</div>
|
<div class="member-banner f13 c-grey3">管理人员({{project_master_members.length}})</div>
|
||||||
<div class="class-member-row f13 c-grey3" ng-repeat="master in project_master_members|filter:searchText">
|
<div class="class-member-row f13 c-grey3" ng-repeat="master in project_master_members|filter:searchText">
|
||||||
<img ng-src="{{master.user.img_url}}" width="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{master.user.real_name == "" ? master.user.name : master.user.real_name }}</span><img ng-src="/images/wechat/{{master.user.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
<img ng-src="{{master.user.img_url}}" width="30" height="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{master.user.real_name == "" ? master.user.name : master.user.real_name }}</span><img ng-src="/images/wechat/{{master.user.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
||||||
<img src="/images/wechat/setting.png" ng-show = "master.user.id != project.user_id && project.can_setting" width="15" class="class-list-setting" ng-click="onSetting(master)" />
|
<img src="/images/wechat/setting.png" ng-show = "master.user.id != project.user_id && project.can_setting" width="15" class="class-list-setting" ng-click="onSetting(master)" />
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-show="project.can_setting" class="class-member-row f13 c-grey3" ng-repeat="user in review_master_members|filter:searchText">
|
<div ng-show="project.can_setting" class="class-member-row f13 c-grey3" ng-repeat="user in review_master_members|filter:searchText">
|
||||||
<img ng-src="{{user.img_url}}" width="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{user.real_name == "" ? user.name : user.real_name }}</span><span class="fr mr10 c-grey2"></span><img ng-src="/images/wechat/{{user.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
<img ng-src="{{user.img_url}}" width="30" height="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{user.real_name == "" ? user.name : user.real_name }}</span><span class="fr mr10 c-grey2"></span><img ng-src="/images/wechat/{{user.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
||||||
<span ng-click="review(user)" class = "fr mr10 mt5 c-red">待审批 ▶</span>
|
<span ng-click="review(user)" class = "fr mr10 mt5 c-red">待审批 ▶</span>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="member-banner f13 mt10 c-grey3">开发人员({{project_develop_members.length}})</div>
|
<div class="member-banner f13 mt10 c-grey3">开发人员({{project_develop_members.length}})</div>
|
||||||
<div class="class-member-row f13 c-grey3" ng-repeat="develop in project_develop_members|filter:searchText">
|
<div class="class-member-row f13 c-grey3" ng-repeat="develop in project_develop_members|filter:searchText">
|
||||||
<img ng-src="{{develop.user.img_url}}" width="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{develop.user.real_name == "" ? develop.user.name : develop.user.real_name}}</span><img ng-src="/images/wechat/{{develop.user.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
<img ng-src="{{develop.user.img_url}}" width="30" height="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{develop.user.real_name == "" ? develop.user.name : develop.user.real_name}}</span><img ng-src="/images/wechat/{{develop.user.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
||||||
<img src="/images/wechat/setting.png" ng-show = "master.user.id != project.user_id && project.can_setting " width="15" class="class-list-setting" ng-click="onSetting(develop)" />
|
<img src="/images/wechat/setting.png" ng-show = "master.user.id != project.user_id && project.can_setting " width="15" class="class-list-setting" ng-click="onSetting(develop)" />
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-show="project.can_setting" class="class-member-row f13 c-grey3" ng-repeat="user in review_develop_members|filter:searchText">
|
<div ng-show="project.can_setting" class="class-member-row f13 c-grey3" ng-repeat="user in review_develop_members|filter:searchText">
|
||||||
<img ng-src="{{user.img_url}}" width="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{user.real_name == "" ? user.name : user.real_name}}</span><img ng-src="/images/wechat/{{user.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
<img ng-src="{{user.img_url}}" width="30" height="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{user.real_name == "" ? user.name : user.real_name}}</span><img ng-src="/images/wechat/{{user.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
||||||
<span ng-click="review(user)" class = "fr mr10 mt5 c-red">待审批 ▶</span>
|
<span ng-click="review(user)" class = "fr mr10 mt5 c-red">待审批 ▶</span>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="member-banner f13 mt10 c-grey3">报告人员({{project_report_members.length}})</div>
|
<div class="member-banner f13 mt10 c-grey3">报告人员({{project_report_members.length}})</div>
|
||||||
<div class="class-member-row f13 c-grey3" ng-repeat="report in project_report_members|filter:searchText">
|
<div class="class-member-row f13 c-grey3" ng-repeat="report in project_report_members|filter:searchText">
|
||||||
<img ng-src="{{report.user.img_url}}" width="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{report.user.real_name == "" ? report.user.name : report.user.real_name}}</span><img ng-src="/images/wechat/{{report.user.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
<img ng-src="{{report.user.img_url}}" width="30" height="30" class="fl ml10 img-circle" /><span class="fl ml10 mt5">{{report.user.real_name == "" ? report.user.name : report.user.real_name}}</span><img ng-src="/images/wechat/{{report.user.gender==0 ? 'male' : 'female'}}.png" width="15" class="fl ml10 mt5" />
|
||||||
<img src="/images/wechat/setting.png" ng-show = "master.user.id != project.user_id && project.can_setting " width="15" class="class-list-setting" ng-click="onSetting(report)" />
|
<img src="/images/wechat/setting.png" ng-show = "master.user.id != project.user_id && project.can_setting " width="15" class="class-list-setting" ng-click="onSetting(report)" />
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -13,7 +13,7 @@ app.controller('InviteCodeController', ['$scope','$http', '$routeParams','config
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
vm.course = response.data.data;
|
vm.course = response.data.data;
|
||||||
|
|
||||||
var desc = "您的好友邀请您加入班级:\n"+vm.course.name+"\n和小伙伴一起踏上便捷的学习之旅吧!";
|
var desc = "您的好友邀请您加入班级:【"+vm.course.name+"】,和小伙伴一起踏上便捷的学习之旅吧!";
|
||||||
var link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid+
|
var link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid+
|
||||||
"&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+vm.course.id+
|
"&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+vm.course.id+
|
||||||
"&response_type=code&scope=snsapi_base&state=invite_code&connect_redirect=1#wechat_redirect";
|
"&response_type=code&scope=snsapi_base&state=invite_code&connect_redirect=1#wechat_redirect";
|
||||||
|
|
|
@ -13,7 +13,7 @@ app.controller('ProjectInviteCodeController', ['$scope','$http', '$routeParams',
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
vm.project = response.data.data;
|
vm.project = response.data.data;
|
||||||
|
|
||||||
var desc = "您的好友邀请您加入项目:\n"+vm.project.name+"\n和小伙伴一起踏上便捷的研发之旅吧!";
|
var desc = "您的好友邀请您加入项目:【"+vm.project.name+"】,和小伙伴一起踏上便捷的研发之旅吧!";
|
||||||
var link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid+
|
var link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid+
|
||||||
"&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+vm.project.id+
|
"&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+vm.project.id+
|
||||||
"&response_type=code&scope=snsapi_base&state=project_invite_code&connect_redirect=1#wechat_redirect";
|
"&response_type=code&scope=snsapi_base&state=project_invite_code&connect_redirect=1#wechat_redirect";
|
||||||
|
|
|
@ -1,466 +1,466 @@
|
||||||
app.factory('alertService', function(){
|
app.factory('alertService', function(){
|
||||||
function Alert(){
|
function Alert(){
|
||||||
this.title = null;
|
this.title = null;
|
||||||
this.message = null;
|
this.message = null;
|
||||||
this.visible = null;
|
this.visible = null;
|
||||||
this.cb = null;
|
this.cb = null;
|
||||||
this.invite = "";
|
this.invite = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Alert.prototype.showMessage = function(title, msg, cb){
|
Alert.prototype.showMessage = function(title, msg, cb){
|
||||||
this.message = msg;
|
this.message = msg;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
this.cb = cb;
|
this.cb = cb;
|
||||||
this.invite = "";
|
this.invite = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Alert.prototype.dismiss = function(){
|
Alert.prototype.dismiss = function(){
|
||||||
this.message = null;
|
this.message = null;
|
||||||
this.title = null;
|
this.title = null;
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
this.invite = "";
|
this.invite = "";
|
||||||
if(this.cb) {this.cb();}
|
if(this.cb) {this.cb();}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
create: function(){
|
create: function(){
|
||||||
return new Alert();
|
return new Alert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.factory('wx', ['$window', function($window){
|
app.factory('wx', ['$window', function($window){
|
||||||
var wechat = $window.wx;
|
var wechat = $window.wx;
|
||||||
return wechat;
|
return wechat;
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
app.factory('auth', ['$http','$routeParams', '$q', 'session', 'config',function($http,$routeParams, $q, session,config){
|
app.factory('auth', ['$http','$routeParams', '$q', 'session', 'config',function($http,$routeParams, $q, session,config){
|
||||||
//是否已经绑定
|
//是否已经绑定
|
||||||
var isBind = function(){
|
var isBind = function(){
|
||||||
var defer = $q.defer();
|
var defer = $q.defer();
|
||||||
|
|
||||||
var token = getToken();
|
var token = getToken();
|
||||||
if(token && token.length>10){
|
if(token && token.length>10){
|
||||||
defer.resolve(token);
|
defer.resolve(token);
|
||||||
} else {
|
} else {
|
||||||
var code = window.g_code || $routeParams.code || session.get("code");
|
var code = window.g_code || $routeParams.code || session.get("code");
|
||||||
$http.post(
|
$http.post(
|
||||||
'/wechat/get_bind',
|
'/wechat/get_bind',
|
||||||
{} ///不用传code了,都由服务器来处理
|
{} ///不用传code了,都由服务器来处理
|
||||||
).then(function(response){
|
).then(function(response){
|
||||||
if(response.data.status!=0){
|
if(response.data.status!=0){
|
||||||
defer.reject(response.data.message);
|
defer.reject(response.data.message);
|
||||||
}else {
|
}else {
|
||||||
session.save("token", response.data.token);
|
session.save("token", response.data.token);
|
||||||
defer.resolve(response.data.token);
|
defer.resolve(response.data.token);
|
||||||
}
|
}
|
||||||
}).catch(function(e){
|
}).catch(function(e){
|
||||||
defer.reject(e);
|
defer.reject(e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return defer.promise;
|
return defer.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
var getToken = function(){
|
var getToken = function(){
|
||||||
return 'token';//session.get("token");
|
return 'token';//session.get("token");
|
||||||
}
|
}
|
||||||
return {get_bind: isBind, token: getToken};
|
return {get_bind: isBind, token: getToken};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
app.factory("session", function(){
|
app.factory("session", function(){
|
||||||
return {
|
return {
|
||||||
save: function(key,value){
|
save: function(key,value){
|
||||||
sessionStorage.setItem(key,value);
|
sessionStorage.setItem(key,value);
|
||||||
},
|
},
|
||||||
get: function(key){
|
get: function(key){
|
||||||
return sessionStorage.getItem(key);
|
return sessionStorage.getItem(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.factory('rms', function(){
|
app.factory('rms', function(){
|
||||||
var _saveStorage = {};
|
var _saveStorage = {};
|
||||||
var save = function(key, value){
|
var save = function(key, value){
|
||||||
_saveStorage[key] = value;
|
_saveStorage[key] = value;
|
||||||
};
|
};
|
||||||
|
|
||||||
var get = function(key){
|
var get = function(key){
|
||||||
return _saveStorage[key];
|
return _saveStorage[key];
|
||||||
};
|
};
|
||||||
|
|
||||||
return {save: save, get: get};
|
return {save: save, get: get};
|
||||||
});
|
});
|
||||||
|
|
||||||
app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$location', function($http, auth, $routeParams,rms,config,wx,$location){
|
app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$location', function($http, auth, $routeParams,rms,config,wx,$location){
|
||||||
var addCommonReply = function(id, type, data,args, cb){
|
var addCommonReply = function(id, type, data,args, cb){
|
||||||
//先判断有没有绑定
|
//先判断有没有绑定
|
||||||
// $http.post(
|
// $http.post(
|
||||||
// '/wechat/is_bind',
|
// '/wechat/is_bind',
|
||||||
// {} ///不用传code了,都由服务器来处理
|
// {} ///不用传code了,都由服务器来处理
|
||||||
// ).then(function(response){
|
// ).then(function(response){
|
||||||
// console.log(response.data);
|
// console.log(response.data);
|
||||||
// if(response.data.status != 0){
|
// if(response.data.status != 0){
|
||||||
// $location.path("/login_tip");
|
// $location.path("/login_tip");
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
if(!data.comment || data.comment.length<=0){
|
if(!data.comment || data.comment.length<=0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var temp = data.comment.replace(/\n/g,'<br/>');
|
var temp = data.comment.replace(/\n/g,'<br/>');
|
||||||
|
|
||||||
var userInfo = {
|
var userInfo = {
|
||||||
type: type,
|
type: type,
|
||||||
content: temp,
|
content: temp,
|
||||||
token: auth.token()
|
token: auth.token()
|
||||||
};
|
};
|
||||||
//回复按钮禁用
|
//回复按钮禁用
|
||||||
data.disabled = true;
|
data.disabled = true;
|
||||||
|
|
||||||
$http({
|
$http({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: apiUrl+ "new_comment/"+id,
|
url: apiUrl+ "new_comment/"+id,
|
||||||
data: userInfo
|
data: userInfo
|
||||||
}).then(function successCallback(response) {
|
}).then(function successCallback(response) {
|
||||||
//alert("提交成功");
|
//alert("提交成功");
|
||||||
//数据提交完成,回复按钮启用
|
//数据提交完成,回复按钮启用
|
||||||
console.log(response);
|
console.log(response);
|
||||||
if(response.data.status == -1){
|
if(response.data.status == -1){
|
||||||
console.log("回复失败!");
|
console.log("回复失败!");
|
||||||
data.comment = "";
|
data.comment = "";
|
||||||
if(response.data.tip == 0){
|
if(response.data.tip == 0){
|
||||||
args.scope.replytip = "您不是该私有班级成员,不能回复";
|
args.scope.replytip = "您不是该私有班级成员,不能回复";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
args.scope.replytip = "您不是该私有项目成员,不能回复";
|
args.scope.replytip = "您不是该私有项目成员,不能回复";
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.disabled = false;
|
data.disabled = false;
|
||||||
if(typeof cb === 'function'){
|
if(typeof cb === 'function'){
|
||||||
cb(response.data.subscribe);
|
cb(response.data.subscribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
//保证内外回复数一致
|
//保证内外回复数一致
|
||||||
activities = rms.get("activities") || [];
|
activities = rms.get("activities") || [];
|
||||||
course_activities = rms.get("course_activities") || [];
|
course_activities = rms.get("course_activities") || [];
|
||||||
project_activities = rms.get("project_activities") || [];
|
project_activities = rms.get("project_activities") || [];
|
||||||
for(var i in activities){
|
for(var i in activities){
|
||||||
if(activities[i].act_id == id){
|
if(activities[i].act_id == id){
|
||||||
activities[i].reply_count += 1;
|
activities[i].reply_count += 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(var i in course_activities){
|
for(var i in course_activities){
|
||||||
if(course_activities[i].act_id == id){
|
if(course_activities[i].act_id == id){
|
||||||
course_activities[i].reply_count += 1;
|
course_activities[i].reply_count += 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(var i in project_activities){
|
for(var i in project_activities){
|
||||||
if(project_activities[i].act_id == id){
|
if(project_activities[i].act_id == id){
|
||||||
project_activities[i].reply_count += 1;
|
project_activities[i].reply_count += 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rms.save("activities",activities);
|
rms.save("activities",activities);
|
||||||
rms.save("course_activities",course_activities);
|
rms.save("course_activities",course_activities);
|
||||||
rms.save("project_activities",project_activities);
|
rms.save("project_activities",project_activities);
|
||||||
|
|
||||||
}, function errorCallback(response) {
|
}, function errorCallback(response) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// var loadCommonData = function(id, type,replytype,page){
|
// var loadCommonData = function(id, type,replytype,page){
|
||||||
// return $http({
|
// return $http({
|
||||||
// method: 'GET',
|
// method: 'GET',
|
||||||
// url: apiUrl+ type + "/" + id+"?token="+auth.token(),
|
// url: apiUrl+ type + "/" + id+"?token="+auth.token(),
|
||||||
// })
|
// })
|
||||||
// };
|
// };
|
||||||
|
|
||||||
var loadCommonData = function(id, type,replytype,page){
|
var loadCommonData = function(id, type,replytype,page){
|
||||||
return $http({
|
return $http({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: apiUrl+ type + "/" + id,
|
url: apiUrl+ type + "/" + id,
|
||||||
dataType: 'jsonp',
|
dataType: 'jsonp',
|
||||||
data:{token:auth.token(),type:replytype,page:page}
|
data:{token:auth.token(),type:replytype,page:page}
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
var addCommonPraise = function(act){
|
var addCommonPraise = function(act){
|
||||||
// act.praise_count += 1;
|
// act.praise_count += 1;
|
||||||
// act.has_praise = true;
|
// act.has_praise = true;
|
||||||
|
|
||||||
$http({
|
$http({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: apiUrl + "praise/" + act.act_id,
|
url: apiUrl + "praise/" + act.act_id,
|
||||||
data:{token:auth.token(),type:act.act_type}
|
data:{token:auth.token(),type:act.act_type}
|
||||||
}).then(function successCallback(response) {
|
}).then(function successCallback(response) {
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
}, function errorCallback(response) {
|
}, function errorCallback(response) {
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var decreaseCommonPraise = function(act){
|
var decreaseCommonPraise = function(act){
|
||||||
// act.praise_count -= 1;
|
// act.praise_count -= 1;
|
||||||
// act.has_praise = false;
|
// act.has_praise = false;
|
||||||
$http({
|
$http({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: apiUrl + "praise/" + act.act_id,
|
url: apiUrl + "praise/" + act.act_id,
|
||||||
data:{token:auth.token(),type:act.act_type}
|
data:{token:auth.token(),type:act.act_type}
|
||||||
}).then(function successCallback(response) {
|
}).then(function successCallback(response) {
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
}, function errorCallback(response) {
|
}, function errorCallback(response) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var init = function(args){
|
var init = function(args){
|
||||||
args.scope.replytip = "输入回复内容~";
|
args.scope.replytip = "输入回复内容~";
|
||||||
args.scope.formData = {comment: ''};
|
args.scope.formData = {comment: ''};
|
||||||
var loadData = function(id,replytype,page){
|
var loadData = function(id,replytype,page){
|
||||||
loadCommonData(id, args.type,replytype,page).then(function successCallback(response) {
|
loadCommonData(id, args.type,replytype,page).then(function successCallback(response) {
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
//--------------分享内容定制-------------
|
//--------------分享内容定制-------------
|
||||||
var tmptile = "分享动态";
|
var tmptile = "分享动态";
|
||||||
var imgUrl = "";
|
var imgUrl = "";
|
||||||
|
|
||||||
if(response.data.data.title){
|
if(response.data.data.title){
|
||||||
tmptile = response.data.data.title;
|
tmptile = response.data.data.title;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tmpname = "匿名用户";
|
var tmpname = "匿名用户";
|
||||||
|
|
||||||
if(response.data.data.user){
|
if(response.data.data.user){
|
||||||
tmpname = response.data.data.user.realname;
|
tmpname = response.data.data.user.realname;
|
||||||
imgUrl = window.g_localhost+response.data.data.user.img_url;
|
imgUrl = window.g_localhost+response.data.data.user.img_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(response.data.data.author){
|
if(response.data.data.author){
|
||||||
tmpname = response.data.data.author.realname;
|
tmpname = response.data.data.author.realname;
|
||||||
imgUrl = window.g_localhost+response.data.data.author.img_url;
|
imgUrl = window.g_localhost+response.data.data.author.img_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
var desc = ""
|
var desc = ""
|
||||||
if(response.data.data.content){
|
if(response.data.data.content){
|
||||||
desc = response.data.data.content.replace(/<[^>]+>/g,"").replace(/\s*/g,"").replace(/ /g,"");
|
desc = response.data.data.content.replace(/<[^>]+>/g,"").replace(/\s*/g,"").replace(/ /g,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(response.data.data.description){
|
if(response.data.data.description){
|
||||||
desc = response.data.data.description.replace(/<[^>]+>/g,"").replace(/\s*/g,"").replace(/ /g,"");
|
desc = response.data.data.description.replace(/<[^>]+>/g,"").replace(/\s*/g,"").replace(/ /g,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(desc.length > 30){
|
if(desc.length > 30){
|
||||||
desc = desc.substring(0,30)+"...";
|
desc = desc.substring(0,30)+"...";
|
||||||
}
|
}
|
||||||
|
|
||||||
var title = tmpname+":"+tmptile;
|
var title = tmpname+":"+tmptile;
|
||||||
console.log("desc = "+desc);
|
console.log("desc = "+desc);
|
||||||
console.log("imgUrl= "+imgUrl);
|
console.log("imgUrl= "+imgUrl);
|
||||||
|
|
||||||
var link = "";
|
var link = "";
|
||||||
|
|
||||||
if(args.urlName == "discussion"){
|
if(args.urlName == "discussion"){
|
||||||
var urlName = response.data.type_name + "_discussion";
|
var urlName = response.data.type_name + "_discussion";
|
||||||
link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid +
|
link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid +
|
||||||
"&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+response.data.data.act_id+
|
"&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+response.data.data.act_id+
|
||||||
"&response_type=code&scope=snsapi_userinfo&state="+urlName+"&connect_redirect=1#wechat_redirect";
|
"&response_type=code&scope=snsapi_userinfo&state="+urlName+"&connect_redirect=1#wechat_redirect";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid +
|
link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+window.g_appid +
|
||||||
"&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+response.data.data.act_id+
|
"&redirect_uri="+window.g_localhost+"/wechat/user_activities?id="+response.data.data.act_id+
|
||||||
"&response_type=code&scope=snsapi_userinfo&state="+args.urlName+"&connect_redirect=1#wechat_redirect";
|
"&response_type=code&scope=snsapi_userinfo&state="+args.urlName+"&connect_redirect=1#wechat_redirect";
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(args.urlName == "discussion"){
|
// if(args.urlName == "discussion"){
|
||||||
// var urlName = response.data.type_name + "_discussion";
|
// var urlName = response.data.type_name + "_discussion";
|
||||||
// link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d" +
|
// link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d" +
|
||||||
// "&redirect_uri=https://test.forge.trustie.net/wechat/user_activities?id="+response.data.data.act_id+
|
// "&redirect_uri=https://test.forge.trustie.net/wechat/user_activities?id="+response.data.data.act_id+
|
||||||
// "&response_type=code&scope=snsapi_base&state="+urlName+"&connect_redirect=1#wechat_redirect";
|
// "&response_type=code&scope=snsapi_base&state="+urlName+"&connect_redirect=1#wechat_redirect";
|
||||||
// }
|
// }
|
||||||
// else{
|
// else{
|
||||||
// link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d" +
|
// link = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d" +
|
||||||
// "&redirect_uri=https://test.forge.trustie.net/wechat/user_activities?id="+response.data.data.act_id+
|
// "&redirect_uri=https://test.forge.trustie.net/wechat/user_activities?id="+response.data.data.act_id+
|
||||||
// "&response_type=code&scope=snsapi_base&state="+args.urlName+"&connect_redirect=1#wechat_redirect";
|
// "&response_type=code&scope=snsapi_base&state="+args.urlName+"&connect_redirect=1#wechat_redirect";
|
||||||
// }
|
// }
|
||||||
|
|
||||||
console.log("link= "+link);
|
console.log("link= "+link);
|
||||||
|
|
||||||
wxConfig(title,desc,imgUrl,link);
|
wxConfig(title,desc,imgUrl,link);
|
||||||
|
|
||||||
//--------------分享内容定制-------------
|
//--------------分享内容定制-------------
|
||||||
args.loadCallback(response.data);
|
args.loadCallback(response.data);
|
||||||
}, function errorCallback(response) {
|
}, function errorCallback(response) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
loadData(args.id,0,0);
|
loadData(args.id,0,0);
|
||||||
args.scope.addReply = function(data){
|
args.scope.addReply = function(data){
|
||||||
console.log(data.comment);
|
console.log(data.comment);
|
||||||
addCommonReply(args.id, args.replyType, data,args, function(subscribe){
|
addCommonReply(args.id, args.replyType, data,args, function(subscribe){
|
||||||
args.scope.formData = {comment: ''};
|
args.scope.formData = {comment: ''};
|
||||||
if(subscribe == 0){
|
if(subscribe == 0){
|
||||||
$location.path("/login_tip");
|
$location.path("/login_tip");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
loadData(args.id,0,0);
|
loadData(args.id,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof args.replyCallback === 'function'){
|
if(typeof args.replyCallback === 'function'){
|
||||||
args.replyCallback();
|
args.replyCallback();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 动态详情界面点赞与动态界面的数据要同步 保证进入详情点赞后出来显示一致
|
// 动态详情界面点赞与动态界面的数据要同步 保证进入详情点赞后出来显示一致
|
||||||
args.scope.addPraise = function(act){
|
args.scope.addPraise = function(act){
|
||||||
activities = rms.get("activities") || [];
|
activities = rms.get("activities") || [];
|
||||||
course_activities = rms.get("course_activities") || [];
|
course_activities = rms.get("course_activities") || [];
|
||||||
project_activities = rms.get("project_activities") || [];
|
project_activities = rms.get("project_activities") || [];
|
||||||
for(var i in activities){
|
for(var i in activities){
|
||||||
if(activities[i].act_id == act.act_id){
|
if(activities[i].act_id == act.act_id){
|
||||||
activities[i].praise_count += 1;
|
activities[i].praise_count += 1;
|
||||||
activities[i].has_praise = true;
|
activities[i].has_praise = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(var i in course_activities){
|
for(var i in course_activities){
|
||||||
if(course_activities[i].act_id == act.act_id){
|
if(course_activities[i].act_id == act.act_id){
|
||||||
course_activities[i].praise_count += 1;
|
course_activities[i].praise_count += 1;
|
||||||
course_activities[i].has_praise = true;
|
course_activities[i].has_praise = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(var i in project_activities){
|
for(var i in project_activities){
|
||||||
if(project_activities[i].act_id == act.act_id){
|
if(project_activities[i].act_id == act.act_id){
|
||||||
project_activities[i].praise_count += 1;
|
project_activities[i].praise_count += 1;
|
||||||
project_activities[i].has_praise = true;
|
project_activities[i].has_praise = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rms.save("activities",activities);
|
rms.save("activities",activities);
|
||||||
rms.save("course_activities",course_activities);
|
rms.save("course_activities",course_activities);
|
||||||
rms.save("project_activities",project_activities);
|
rms.save("project_activities",project_activities);
|
||||||
|
|
||||||
act.praise_count += 1;
|
act.praise_count += 1;
|
||||||
act.has_praise = true;
|
act.has_praise = true;
|
||||||
addCommonPraise(act);
|
addCommonPraise(act);
|
||||||
};
|
};
|
||||||
|
|
||||||
args.scope.decreasePraise = function(act){
|
args.scope.decreasePraise = function(act){
|
||||||
activities = rms.get("activities") || [];
|
activities = rms.get("activities") || [];
|
||||||
course_activities = rms.get("course_activities") || [];
|
course_activities = rms.get("course_activities") || [];
|
||||||
project_activities = rms.get("project_activities") || [];
|
project_activities = rms.get("project_activities") || [];
|
||||||
for(var i in activities){
|
for(var i in activities){
|
||||||
if(activities[i].act_id == act.act_id){
|
if(activities[i].act_id == act.act_id){
|
||||||
activities[i].praise_count -= 1;
|
activities[i].praise_count -= 1;
|
||||||
activities[i].has_praise = false;
|
activities[i].has_praise = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(var i in course_activities){
|
for(var i in course_activities){
|
||||||
if(course_activities[i].act_id == act.act_id){
|
if(course_activities[i].act_id == act.act_id){
|
||||||
course_activities[i].praise_count -= 1;
|
course_activities[i].praise_count -= 1;
|
||||||
course_activities[i].has_praise = false;
|
course_activities[i].has_praise = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(var i in project_activities){
|
for(var i in project_activities){
|
||||||
if(project_activities[i].act_id == act.act_id){
|
if(project_activities[i].act_id == act.act_id){
|
||||||
project_activities[i].praise_count -= 1;
|
project_activities[i].praise_count -= 1;
|
||||||
project_activities[i].has_praise = false;
|
project_activities[i].has_praise = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rms.save("activities",activities);
|
rms.save("activities",activities);
|
||||||
rms.save("course_activities",course_activities);
|
rms.save("course_activities",course_activities);
|
||||||
rms.save("project_activities",project_activities);
|
rms.save("project_activities",project_activities);
|
||||||
|
|
||||||
act.praise_count -= 1;
|
act.praise_count -= 1;
|
||||||
act.has_praise = false;
|
act.has_praise = false;
|
||||||
decreaseCommonPraise(act);
|
decreaseCommonPraise(act);
|
||||||
};
|
};
|
||||||
|
|
||||||
args.scope.showMoreReply = function(replytype,data){
|
args.scope.showMoreReply = function(replytype,data){
|
||||||
if(!data.page){
|
if(!data.page){
|
||||||
data.page = 1;
|
data.page = 1;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
data.page = data.page + 1;
|
data.page = data.page + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadCommonData(data.id, args.type,replytype,data.page).then(function successCallback(response) {
|
loadCommonData(data.id, args.type,replytype,data.page).then(function successCallback(response) {
|
||||||
args.loadCallback(response.data);
|
args.loadCallback(response.data);
|
||||||
}, function errorCallback(response) {
|
}, function errorCallback(response) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
args.scope.commentreply_path = config.rootPath+ 'templates/comment_reply.html';
|
args.scope.commentreply_path = config.rootPath+ 'templates/comment_reply.html';
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var wxConfig = function(title,desc,imgUrl,link){
|
var wxConfig = function(title,desc,imgUrl,link){
|
||||||
|
|
||||||
if(title == null || title == ""){
|
if(title == null || title == ""){
|
||||||
title = 'Trustie创新实践平台';
|
title = 'Trustie创新实践平台';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(desc == null || desc == ""){
|
if(desc == null || desc == ""){
|
||||||
desc = 'Trustie创新实践平台';
|
desc = 'Trustie创新实践平台';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(imgUrl == null || imgUrl == ""){
|
if(imgUrl == null || imgUrl == ""){
|
||||||
imgUrl = window.g_localhost+'/images/wechat/wx_logo.jpg';
|
imgUrl = window.g_localhost+'/images/wechat/wx_logo.jpg';
|
||||||
}
|
}
|
||||||
|
|
||||||
wx.ready(function(){
|
wx.ready(function(){
|
||||||
wx.onMenuShareTimeline({
|
wx.onMenuShareTimeline({
|
||||||
title: title, // 分享标题
|
title: title, // 分享标题
|
||||||
link: link, // 分享链接
|
link: link, // 分享链接
|
||||||
imgUrl: imgUrl, // 分享图标
|
imgUrl: imgUrl, // 分享图标
|
||||||
success: function () {
|
success: function () {
|
||||||
console.log("share successed.");
|
console.log("share successed.");
|
||||||
},
|
},
|
||||||
cancel: function () {
|
cancel: function () {
|
||||||
console.log("share canceled.");
|
console.log("share canceled.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
wx.onMenuShareAppMessage({
|
wx.onMenuShareAppMessage({
|
||||||
title: title, // 分享标题
|
title: title, // 分享标题
|
||||||
desc: desc, // 分享描述
|
desc: desc, // 分享描述
|
||||||
link: link, // 分享链接
|
link: link, // 分享链接
|
||||||
// imgUrl: '', // 分享图标
|
// imgUrl: '', // 分享图标
|
||||||
imgUrl: imgUrl, // 分享图标
|
imgUrl: imgUrl, // 分享图标
|
||||||
// type: '', // 分享类型,music、video或link,不填默认为link
|
// type: '', // 分享类型,music、video或link,不填默认为link
|
||||||
// dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
|
// dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
|
||||||
success: function () {
|
success: function () {
|
||||||
// 用户确认分享后执行的回调函数
|
// 用户确认分享后执行的回调函数
|
||||||
},
|
},
|
||||||
cancel: function () {
|
cancel: function () {
|
||||||
// 用户取消分享后执行的回调函数
|
// 用户取消分享后执行的回调函数
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var checkLogin = function(){
|
var checkLogin = function(){
|
||||||
$http.post(
|
$http.post(
|
||||||
'/wechat/is_bind',
|
'/wechat/is_bind',
|
||||||
{} ///不用传code了,都由服务器来处理
|
{} ///不用传code了,都由服务器来处理
|
||||||
).then(function(response){
|
).then(function(response){
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
if(response.data.status != 0){
|
if(response.data.status != 0){
|
||||||
$location.path("/login");
|
$location.path("/login");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise, wxConfig: wxConfig, checkLogin: checkLogin};
|
return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise, wxConfig: wxConfig, checkLogin: checkLogin};
|
||||||
}]);
|
}]);
|
||||||
|
|
Loading…
Reference in New Issue