Merge branch 'weixin_guange' into develop

This commit is contained in:
yuanke 2016-09-14 19:38:19 +08:00
commit c7be9cadf1
11 changed files with 58 additions and 26 deletions

View File

@ -36,7 +36,7 @@ module Mobile
principal_types = "JournalsForMessage" principal_types = "JournalsForMessage"
watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(',')) watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(','))
user_ids = "(" + user.id.to_s + watched_user_ids + ")" user_ids = "(" + user.id.to_s + watched_user_ids + ")"
watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").count == 0 ? " " :Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",") watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").count == 0 ? "-1" :Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",")
blog_ids = "(" + watched_user_blog_ids + ")" blog_ids = "(" + watched_user_blog_ids + ")"
if container_type == "Course" if container_type == "Course"

View File

@ -73,6 +73,12 @@ module Mobile
elsif ac.container_type == "Blog" elsif ac.container_type == "Blog"
"发表博客" "发表博客"
end end
when :syllabus_title
if ac.container_type == "Course"
course = get_course(ac.container_id)
name = course.syllabus.nil? ? "":course.syllabus.title
name
end
when :course_project_id when :course_project_id
if ac.container_type == "Course" if ac.container_type == "Course"
ac.container_id ac.container_id
@ -145,6 +151,7 @@ module Mobile
act_expose :latest_update #最新更新时间 act_expose :latest_update #最新更新时间
act_expose :course_project_id #课程/项目ID act_expose :course_project_id #课程/项目ID
act_expose :course_project_name #课程/项目名字 act_expose :course_project_name #课程/项目名字
act_expose :syllabus_title #课程名字
act_expose :activity_type_name #课程问答区/项目缺陷等 act_expose :activity_type_name #课程问答区/项目缺陷等
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
if instance.act_type == "HomeworkCommon" || instance.act_type == "News" || instance.act_type == "Message" || instance.act_type == "BlogComment" || instance.act_type == "JournalsForMessage" || instance.act_type == "Issue" if instance.act_type == "HomeworkCommon" || instance.act_type == "News" || instance.act_type == "Message" || instance.act_type == "BlogComment" || instance.act_type == "JournalsForMessage" || instance.act_type == "Issue"

View File

@ -107,6 +107,7 @@ module Mobile
course_expose :current_user_is_member course_expose :current_user_is_member
course_expose :current_user_is_teacher course_expose :current_user_is_teacher
course_expose :work_unit course_expose :work_unit
course_expose :syllabus_title
end end
end end
end end

View File

@ -220,7 +220,8 @@ class NewsController < ApplicationController
if count == 0 if count == 0
ws = WechatService.new ws = WechatService.new
content = @news.title content = @news.title
ws.class_notice m.user_id, "course_notice", @news.id, "#{l(:label_new_notice_template)}", @news.course.name, @news.author.show_name, format_time(@news.created_on), content, "点击查看通知详情" name = @news.course.syllabus.nil? ? @news.course.name : @news.course.syllabus.title+""+@news.course.name
ws.class_notice m.user_id, "course_notice", @news.id, "#{l(:label_new_notice_template)}", name, @news.author.show_name, format_time(@news.created_on), content, "点击查看通知详情"
end end
end end
end end

View File

@ -8,13 +8,13 @@ class WechatsController < ActionController::Base
# default text responder when no other match # default text responder when no other match
on :text do |request, content| on :text do |request, content|
#邀请码 #邀请码
if join_class_request(request) # if join_class_request(request)
sendBindClass(request, {invite_code: content}) # sendBindClass(request, {invite_code: content})
elsif join_project_request(request) # elsif join_project_request(request)
sendBindProject(request, {invite_code: content}) # sendBindProject(request, {invite_code: content})
else # else
request.reply.text "您的意见已收到,非常感谢~ \n更多问题可以通过以下方式联系我们:\n官方QQ群173184401\n我们会认真聆听您的意见和建议。" request.reply.text "您的意见已收到,非常感谢~ \n更多问题可以通过以下方式联系我们:\n官方QQ群173184401\n我们会认真聆听您的意见和建议。"
end # end
end end
# When receive 'help', will trigger this responder # When receive 'help', will trigger this responder
@ -456,18 +456,29 @@ class WechatsController < ActionController::Base
session[:wechat_openid] = open_id session[:wechat_openid] = open_id
if params[:code] if params[:code]
# if params[:state].match("review_class_member") || params[:state].match("review_project_member") if !(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")
uw = user_binded?(open_id)
if uw
user = uw.user
lastname = user.lastname
end
end
if lastname && lastname == ""
@path = '/edit_userinfo'
else
@path = params[:state].split('/')[0] @path = params[:state].split('/')[0]
useridstr = params[:state].split('/')[1] useridstr = params[:state].split('/')[1]
# end
if useridstr if useridstr
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}&#{useridstr}" and return redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}&#{useridstr}" and return
elsif params[:id] elsif params[:id]
redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return
else else
redirect_to "/wechat/user_activities##{@path}" and return redirect_to "/wechat/user_activities##{@path}" and return
end
# redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return
end end
# redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return
end end
end end
render 'wechats/user_activities', layout: nil render 'wechats/user_activities', layout: nil

View File

@ -77,7 +77,8 @@ class HomeworkCommon < ActiveRecord::Base
count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count
if count == 0 if count == 0
ws = WechatService.new ws = WechatService.new
ws.homework_message_notice(m.user_id, "homework", self.id, "#{m.user.show_name}#{l(:label_new_homework_template)}", self.course.name, "新作业:"+ self.name.html_safe, "作业内容请点击“详情”查看。") name = self.course.syllabus.nil? ? self.course.name : self.course.syllabus.title+""+self.course.name
ws.homework_message_notice(m.user_id, "homework", self.id, "#{m.user.show_name}#{l(:label_new_homework_template)}", name, "新作业:"+ self.name.html_safe, "作业内容请点击“详情”查看。")
end end
# end # end
end end

View File

@ -332,7 +332,7 @@ class CoursesService
# unless (course.is_public == 1 || current_user.member_of_course?(course) || current_user.admin?) # unless (course.is_public == 1 || current_user.member_of_course?(course) || current_user.admin?)
# raise '403' # raise '403'
# end # end
{:course => course,:work_unit => work_unit, :img_url => url_to_avatar(course),:current_user_is_member => current_user.nil? ? false : current_user.member_of_course?(course),:current_user_is_teacher => current_user.nil? ? false : is_course_teacher(current_user,course),:course_student_num => course ? course.student.count.to_s : 0} {:course => course,:syllabus_title => course.syllabus.nil? ? "":course.syllabus.title ,:work_unit => work_unit, :img_url => url_to_avatar(course),:current_user_is_member => current_user.nil? ? false : current_user.member_of_course?(course),:current_user_is_teacher => current_user.nil? ? false : is_course_teacher(current_user,course),:course_student_num => course ? course.student.count.to_s : 0}
end end
#创建课程 #创建课程
@ -554,8 +554,10 @@ class CoursesService
uid = user.id uid = user.id
type = "review_class_member" type = "review_class_member"
end end
name = course.syllabus.nil? ? course.name : course.syllabus.title+""+course.name
ws = WechatService.new ws = WechatService.new
ws.class_notice user.id, type, course.id, title, course.name, user.show_name, format_time(Time.now), content, remark,uid ws.class_notice user.id, type, course.id, title,name, user.show_name, format_time(Time.now), content, remark,uid
end end
end end
@ -650,8 +652,9 @@ class CoursesService
rolename = role_ids.include?("7") ? "助教" : "教师" rolename = role_ids.include?("7") ? "助教" : "教师"
content = current_user.show_name + "申请以"+rolename+"身份加入班级,等待您的审批。" content = current_user.show_name + "申请以"+rolename+"身份加入班级,等待您的审批。"
name = course.syllabus.nil? ? course.name : course.syllabus.title+""+course.name
ws = WechatService.new ws = WechatService.new
ws.class_notice tea_user.id, "review_class_member", course.id, "班级成员审批通知。", course.name, tea_user.show_name, format_time(Time.now), content, "点击查看申请详情。",current_user.id ws.class_notice tea_user.id, "review_class_member", course.id, "班级成员审批通知。", name, tea_user.show_name, format_time(Time.now), content, "点击查看申请详情。",current_user.id
end end
end end
#-------------------------------------------- #--------------------------------------------

View File

@ -69,7 +69,8 @@ class SyllabusesService
if count == 0 if count == 0
ws = WechatService.new ws = WechatService.new
title = "恭喜您创建班级成功。" title = "恭喜您创建班级成功。"
ws.create_class_notice user.id, "create_course_notice", course.id,title, course.name, user.show_name, 1, "点击查看班级详情。" name = course.syllabus.nil? ? course.name : course.syllabus.title+""+course.name
ws.create_class_notice user.id, "create_course_notice", course.id,title, name, user.show_name, 1, "点击查看班级详情。"
end end
end end

View File

@ -11,7 +11,7 @@
<form name="regFrm" novalidate> <form name="regFrm" novalidate>
<div class="course-list-row f13 c-grey3 mt10"><span class="fl ml15 c-grey3">姓名</span><input class="new-class-input ml25" ng-model="lastname" placeholder="请输入您的姓名全称" maxlength="30" /></div> <div class="course-list-row f13 c-grey3 mt10"><span class="fl ml15 c-grey3">姓名</span><input class="new-class-input ml25" ng-model="lastname" placeholder="请输入您的真实姓名" maxlength="30" /></div>
<div class="course-list-row f13 c-grey3 mt10" style="height:auto;"> <div class="course-list-row f13 c-grey3 mt10" style="height:auto;">
<div class="mt5" style="line-height:20px"> <div class="mt5" style="line-height:20px">
<span class="ml15 c-grey3">性别</span> <span class="ml15 c-grey3">性别</span>
@ -33,6 +33,12 @@
<span class="f12 c-red fl ml15" ng-show="regFrm.email.$error.email">电子邮箱地址不合法</span> <span class="f12 c-red fl ml15" ng-show="regFrm.email.$error.email">电子邮箱地址不合法</span>
</div> </div>
</div> </div>
<div ng-show="lastname == '' " class="f12 c-grey6 mt10 ml15">
<span class="f13 c-grey3">提示</span>
<ul class="mb15 mt5 ml10 new-tip">
<li><span class="project-intro-dot"></span>您尚未完善您的基本资料,完善后可使用更多功能</li>
</ul>
</div>
<div class="bottom-tab-wrap mt10"> <div class="bottom-tab-wrap mt10">
<a ng-click="cancel()" class="weixin-tab c-grey border-top">取消</a> <a ng-click="cancel()" class="weixin-tab c-grey border-top">取消</a>
<a ng-click="confirm(regFrm)" ng-class="[{'btn-disabled':!regFrm.$valid} ]" class="weixin-tab link-blue2 border-top">确定</a> <a ng-click="confirm(regFrm)" ng-class="[{'btn-disabled':!regFrm.$valid} ]" class="weixin-tab link-blue2 border-top">确定</a>

View File

@ -4,13 +4,13 @@
<form name="loginFrm" novalidate> <form name="loginFrm" novalidate>
<div class="blue-title">绑定<span class="f13 blue-title-sub" ng-click="goReg()">注册</span></div> <div class="blue-title">绑定<span class="f13 blue-title-sub" ng-click="goReg()">注册</span></div>
<div class="input-box-wrap login-wrap mt30"> <div class="input-box-wrap login-wrap mt30">
<input name="login" ng-model="user.login" required class="input-box" placeholder="请输入电子邮箱地址或登录名" /> <input name="login" ng-model="user.login" required class="input-box" placeholder="请输入平台上的注册邮箱或登录名" />
<div ng-show="loginFrm.$submitted || loginFrm.login.$touched"> <div ng-show="loginFrm.$submitted || loginFrm.login.$touched">
<span ng-show="loginFrm.login.$error.required" class="c-red fl f12">电子邮箱地址或登录名不能为空</span> <span ng-show="loginFrm.login.$error.required" class="c-red fl f12">电子邮箱地址或登录名不能为空</span>
</div> </div>
</div> </div>
<div class="input-box-wrap login-wrap mt10 mb20"> <div class="input-box-wrap login-wrap mt10 mb20">
<input class="input-box" placeholder="请输入密码" name="password" type="password" ng-model="user.password" required /> <input class="input-box" placeholder="请输入帐号的登录密码" name="password" type="password" ng-model="user.password" required />
<div ng-show="loginFrm.$submitted || loginFrm.password.$touched"> <div ng-show="loginFrm.$submitted || loginFrm.password.$touched">
<span ng-show="loginFrm.password.$error.required" class="c-red fl f12">密码不能为空</span> <span ng-show="loginFrm.password.$error.required" class="c-red fl f12">密码不能为空</span>
</div> </div>

View File

@ -36,7 +36,8 @@ app.controller('RegController', ['$scope', '$http', '$location', 'alertService',
vm.successDialog.showMessage("提示","注册且绑定微信成功", function(){ vm.successDialog.showMessage("提示","注册且绑定微信成功", function(){
// $location.path("/activities"); // $location.path("/activities");
// window.WeixinJSBridge.call('closeWindow'); // window.WeixinJSBridge.call('closeWindow');
wx.closeWindow(); // wx.closeWindow();
$location.path("/edit_userinfo");
}); });
} }
}, function (response) { }, function (response) {