diff --git a/.gitignore b/.gitignore index ba7890841..dbc349c80 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ vendor/cache /config/initializers/gitlab_config.rb 1234567 public/javascripts/wechat/node_modules/ +.ruby-version diff --git a/Gemfile b/Gemfile index d392c6561..a8131fb3f 100644 --- a/Gemfile +++ b/Gemfile @@ -81,7 +81,7 @@ group :assets do gem 'coffee-rails', '~> 3.2.1' # See https://github.com/sstephenson/execjs#readme for more supported runtimes - gem 'therubyracer', :platforms => :ruby + # gem 'therubyracer', :platforms => :ruby gem 'uglifier', '>= 1.0.3' end diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index c86a36d05..9ffac4e10 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -23,6 +23,7 @@ module Mobile version 'v1', using: :path format :json content_type :json, "application/json;charset=UTF-8" + use ActionDispatch::Session::CookieStore use Mobile::Middleware::ErrorHandler helpers do @@ -34,6 +35,10 @@ module Mobile raise('Unauthorized. 用户认证失败.') unless current_user end + def session + env['rack.session'] + end + def current_user openid = params[:openid] if openid @@ -67,8 +72,7 @@ module Mobile mount Apis::NewComment mount Apis::Praise - #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) - #add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? + add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? end end diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index 49fdaff8f..661925012 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -9,7 +9,7 @@ module Mobile params do requires :page, type: Integer - requires :openid, type: String + requires :token, type: String end post do authenticate! diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index 3a36a9e37..58d4a4f8c 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -97,25 +97,20 @@ module Mobile desc "加入课程" params do - requires :course_password, type: String + requires :token, type: String + requires :invite_code, type: String, desc: '邀请码' end - post ":id" do + post "join" do authenticate! cs = CoursesService.new - status = cs.join_course({:object_id => params[:id],:course_password => params[:course_password]},current_user) - out = {status: status[:state]} - message = case status[:state] - when 0; "加入成功" - when 1; "密码错误" - when 2; "课程已过期 请联系课程管理员重启课程。(在配置课程处)" - when 3; "您已经加入了课程" - when 4; "您加入的课程不存在" - when 5; "您还未登录" - else; "未知错误,请稍后再试" - end - out.merge(message: message) + status = cs.join_course({openid: params[:openid], invite_code: params[:invite_code]}, current_user) + { + status: status[:state], + messsge:CoursesService::JoinCourseError.message(status[:state]) + } end + desc "退出课程" params do requires :token, type: String @@ -201,6 +196,7 @@ module Mobile end route_param :id do get do + authenticate! cs = CoursesService.new course = cs.show_course(params,(current_user.nil? ? User.find(2):current_user)) #course = Course.find(params[:id]) diff --git a/app/api/mobile/apis/issues.rb b/app/api/mobile/apis/issues.rb index b767bd768..4a6417cb4 100644 --- a/app/api/mobile/apis/issues.rb +++ b/app/api/mobile/apis/issues.rb @@ -8,7 +8,8 @@ module Mobile desc "get special issuse" get ':id' do - user = UserWechat.find_by_openid(params[:openid]).user + authenticate! + user = current_user issue = Issue.find params[:id] present :data, issue, with: Mobile::Entities::Issue,user: user present :status, 0 diff --git a/app/api/mobile/apis/journal_for_messages.rb b/app/api/mobile/apis/journal_for_messages.rb index 15a571a82..5f2d01185 100644 --- a/app/api/mobile/apis/journal_for_messages.rb +++ b/app/api/mobile/apis/journal_for_messages.rb @@ -7,7 +7,8 @@ module Mobile desc "get special journal" get ':id' do - user = UserWechat.find_by_openid(params[:openid]).user + authenticate! + user = current_user jour = JournalsForMessage.find params[:id] present :data, jour, with: Mobile::Entities::Jours,user: user present :status, 0 diff --git a/app/api/mobile/apis/messages.rb b/app/api/mobile/apis/messages.rb index ae2f9a39c..bab82de8d 100644 --- a/app/api/mobile/apis/messages.rb +++ b/app/api/mobile/apis/messages.rb @@ -7,7 +7,8 @@ module Mobile desc "get special topic" get ':id' do - user = UserWechat.find_by_openid(params[:openid]).user + authenticate! + user = current_user message = Message.find params[:id] present :data, message, with: Mobile::Entities::Message,user: user present :status, 0 diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 694ec0613..5b7159301 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -11,12 +11,12 @@ module Mobile params do requires :type, type: String requires :content, type: String - requires :openid, type: String + requires :token, type: String end post ':id' do + authenticate! type = params[:type] result = 1 - current_user = UserWechat.find_by_openid(params[:openid]).user if params[:content]!="" && current_user case type when "HomeworkCommon" diff --git a/app/api/mobile/apis/newss.rb b/app/api/mobile/apis/newss.rb index 8bdd460cc..d42177783 100644 --- a/app/api/mobile/apis/newss.rb +++ b/app/api/mobile/apis/newss.rb @@ -7,7 +7,8 @@ module Mobile desc "get special news" get ':id' do - user = UserWechat.find_by_openid(params[:openid]).user + authenticate! + user = current_user news = News.find params[:id] present :data, news, with: Mobile::Entities::News,user: user present :status, 0 diff --git a/app/api/mobile/apis/praise.rb b/app/api/mobile/apis/praise.rb index 57dbd0729..834d1195b 100644 --- a/app/api/mobile/apis/praise.rb +++ b/app/api/mobile/apis/praise.rb @@ -9,12 +9,13 @@ module Mobile params do requires :type, type: String - requires :openid, type: String + requires :token, type: String end post ':id' do + authenticate! obj_id = params[:id] obj_type = params[:type] - user = UserWechat.find_by_openid(params[:openid]).user + user = current_user pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",obj_id,obj_type.to_s,user.id).first if pts.blank? praise_or_cancel(obj_type,obj_id,user,1) diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 6ce3cacbb..b5ee14d19 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -4,6 +4,48 @@ module Mobile class Users < Grape::API resource :users do + desc "查询是否已绑定" + params do + requires :openid, type: String, desc: 'wechat openid' + end + post 'isbind' do + openid = params[:openid] + uw = UserWechat.where(openid: openid).first + raise "还未绑定trustie帐户" unless uw + + user = uw.user + ::ApiKey.delete_all(user_id: user.id) + key = ::ApiKey.create!(user_id: user.id) + present status: 0, token: key.access_token + end + + desc "绑定微信用户" + params do + requires :login, type: String, desc: 'username' + requires :password, type: String, desc: 'password' + end + post 'wxbind' do + openid = session[:wechat_openid] + logger.debug "openid ============== #{openid}" + raise "无法获取到openid,请在微信中打开本页面" unless openid + uw = UserWechat.where(openid: openid).first + raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw + + user, last_login_on = User.try_to_login(params[:login], params[:password]) + raise "用户名或密码错误,请重新输入" unless user + #补全用户信息 + + raise "此用户已经绑定过公众号, 请换一个帐户试试" if user.user_wechat + + UserWechat.create!( + openid: openid, + user: user + ) + # ws = WechatService.new + # ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台", user.login, format_time(Time.now)) + present status: 0, message: '您已成功绑定Trustie平台' + end + desc "注册用户" params do requires :login, type: String, desc: 'username' diff --git a/app/api/mobile/apis/whomeworks.rb b/app/api/mobile/apis/whomeworks.rb index a88d509a3..c8377aa0d 100644 --- a/app/api/mobile/apis/whomeworks.rb +++ b/app/api/mobile/apis/whomeworks.rb @@ -7,7 +7,8 @@ module Mobile desc "get one homework" get ':id' do - user = UserWechat.find_by_openid(params[:openid]).user + authenticate! + user = current_user homework = HomeworkCommon.find params[:id] present :data, homework, with: Mobile::Entities::Whomework,user: user present :status, 0 diff --git a/app/api/mobile/entities/course.rb b/app/api/mobile/entities/course.rb index 50812b349..487a75c4d 100644 --- a/app/api/mobile/entities/course.rb +++ b/app/api/mobile/entities/course.rb @@ -45,6 +45,8 @@ module Mobile course_expose :tea_id course_expose :term course_expose :time + course_expose :invite_code + course_expose :qrcode course_expose :updated_at course_expose :course_student_num expose :teacher, using: Mobile::Entities::User do |c, opt| diff --git a/app/api/mobile/entities/user.rb b/app/api/mobile/entities/user.rb index 8c6a839b3..2eb20f0db 100644 --- a/app/api/mobile/entities/user.rb +++ b/app/api/mobile/entities/user.rb @@ -26,6 +26,8 @@ module Mobile u.nil? || u.user_extensions.nil? ? "" : u.user_extensions.student_id when :realname u.nil? ? "" : get_user_realname(u) + when :name + u.nil? ? "" : u.show_name end end end @@ -57,6 +59,11 @@ module Mobile user_expose :student_num # 活跃值 user_expose :active_count + + user_expose :role_name + + user_expose :name + end end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e421b8c69..43b488e96 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -74,7 +74,7 @@ class CoursesController < ApplicationController else @state = 5 #未登录 end - @object_id = params[:object_id] + @object_id = @course.id if @course respond_to do |format| format.js #{ render :partial => 'set_join', :locals => {:user => @user, :course => @course, :object_id => params[:object_id]} } end @@ -1224,7 +1224,7 @@ class CoursesController < ApplicationController def member_to_xls homeworks, course, members,groups xls_report = StringIO.new book = Spreadsheet::Workbook.new - sheet1 = book.create_worksheet :name => "student" + sheet1 = book.create_worksheet :name => "总成绩" blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 #sheet1.row(0).default_format = blue #sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_class),l(:excel_f_score),l(:excel_commit_time)]) @@ -1268,6 +1268,121 @@ class CoursesController < ApplicationController count_row += 1 end + homeworks.each_with_index do |home, i| + sheet = book.create_worksheet :name => "第#{i+1}次作业" + sheet[0,0] = "课程编号" + sheet[0,1] = course.id + sheet[1,0] = "课程学期" + sheet[1,1] = course.time.to_s+"年"+course.term + sheet[2,0] = "课程名称" + sheet[2,1] = course.name + sheet[3,0] = "教师团队" + sheet[3,1] = (searchTeacherAndAssistant course).map{|member| member.user.show_name}.join('、') + sheet[4,0] = "主讲教师" + sheet[4,1] = course.teacher.show_name + sheet[4,0] = "作业批次" + sheet[4,1] = "第#{i+1}次作业" + sheet[4,0] = "作业名称" + sheet[4,1] = home.name + if home.homework_type == 1 #普通作业 + if home.anonymous_comment ==0 + sheet.row(5).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(5).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + count_row = 6 + items = home.student_works.order("work_score desc") + items.each_with_index do |stu, j| + sheet[count_row,0]= j + 1 + sheet[count_row,1] = stu.user.show_name + sheet[count_row,2] = stu.user.login + sheet[count_row,3] = stu.user.user_extensions.student_id + sheet[count_row,4] = stu.name + sheet[count_row,5] = strip_html stu.description + sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) + sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2) + if home.anonymous_comment ==0 + sheet[count_row,8] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) + sheet[count_row,9] = home.teacher_priority == 1 ? 0 : stu.absence_penalty + sheet[count_row,10] = home.teacher_priority == 1 ? 0 : stu.late_penalty + sheet[count_row,11] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,12] = format_time(stu.created_at) + else + sheet[count_row,8] = home.teacher_priority == 1 ? 0 : stu.late_penalty + sheet[count_row,9] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,10] = format_time(stu.created_at) + end + count_row += 1 + end + elsif home.homework_type == 2 #编程作业 + if home.anonymous_comment ==0 + sheet.row(5).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(5).concat([l(:excel_rank),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + count_row = 6 + items = home.student_works.order("work_score desc") + items.each_with_index do |stu, j| + sheet[count_row,0]= j + 1 + sheet[count_row,1] = stu.user.show_name + sheet[count_row,2] = stu.user.login + sheet[count_row,3] = stu.user.user_extensions.student_id + sheet[count_row,4] = stu.name + sheet[count_row,5] = stu.description + sheet[count_row,6] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) + sheet[count_row,7] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2) + sheet[count_row,8] = stu.system_score.nil? ? l(:label_without_score) : stu.system_score.round(2) + if home.anonymous_comment ==0 + sheet[count_row,9] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) + sheet[count_row,10] = home.teacher_priority == 1 ? 0 : stu.absence_penalty + sheet[count_row,11] = home.teacher_priority == 1 ? 0 : stu.late_penalty + sheet[count_row,12] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,13] = format_time(stu.created_at) + else + sheet[count_row,9] = home.teacher_priority == 1 ? 0 : stu.late_penalty + sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,11] = format_time(stu.created_at) + end + count_row += 1 + end + elsif home.homework_type == 3 #分组作业 + if home.anonymous_comment ==0 + sheet.row(5).concat([l(:excel_rank),l(:excel_group_member),l(:excel_homework_name),l(:excel_homework_project),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet.row(5).concat([l(:excel_rank),l(:excel_group_member),l(:excel_homework_name),l(:excel_homework_project),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + count_row = 6 + items = home.student_works.order("work_score desc") + items.each_with_index do |stu, j| + sheet[count_row,0] = j + 1 + sheet[count_row,1] = get_group_member_names stu + sheet[count_row,2] = stu.name + sheet[count_row,3] = (stu.project_id == 0 || stu.project_id.nil?) ? l(:excel_no_project) : stu.project.name + sheet[count_row,4] = strip_html stu.description + sheet[count_row,5] = stu.teacher_score.nil? ? l(:label_without_score) : stu.teacher_score.round(2) + sheet[count_row,6] = stu.teaching_asistant_score.nil? ? l(:label_without_score) : stu.teaching_asistant_score.round(2) + if home.anonymous_comment ==0 + sheet[count_row,7] = stu.student_score.nil? ? l(:label_without_score) : stu.student_score.round(2) + sheet[count_row,8] = home.teacher_priority == 1 ? 0 : stu.absence_penalty + sheet[count_row,9] = home.teacher_priority == 1 ? 0 : stu.late_penalty + sheet[count_row,10] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,11] = format_time(stu.created_at) + else + sheet[count_row,7] = home.teacher_priority == 1 ? 0 : stu.late_penalty + sheet[count_row,8] = stu.work_score.nil? ? l(:label_without_score) : stu.work_score.round(2) + sheet[count_row,9] = format_time(stu.created_at) + end + count_row += 1 + end + end + end + =begin group0 = CourseGroup.new(); group0.id = 0; diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index d478b4d63..3a72ba55e 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -1209,13 +1209,18 @@ class StudentWorkController < ApplicationController sheet1 = book.create_worksheet :name => "homework" blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 sheet1.row(0).default_format = blue - if @homework.homework_type == 1 #匿评作业 - sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), - l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)]) + if @homework.homework_type == 1 #普通作业 + if @homework.anonymous_comment ==0 + sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end count_row = 1 items.each do |homework| sheet1[count_row,0]=homework.user.id - sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s + sheet1[count_row,1] = homework.user.show_name sheet1[count_row,2] = homework.user.login sheet1[count_row,3] = homework.user.user_extensions.student_id sheet1[count_row,4] = homework.user.mail @@ -1223,18 +1228,31 @@ class StudentWorkController < ApplicationController sheet1[count_row,6] = strip_html homework.description sheet1[count_row,7] = homework.teacher_score.nil? ? l(:label_without_score) : homework.teacher_score.round(2) sheet1[count_row,8] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2) - sheet1[count_row,9] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) - sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) - sheet1[count_row,11] = format_time(homework.created_at) + if @homework.anonymous_comment ==0 + sheet1[count_row,9] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) + sheet1[count_row,10] = @homework.teacher_priority == 1 ? 0 : homework.absence_penalty + sheet1[count_row,11] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty + sheet1[count_row,12] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,13] = format_time(homework.created_at) + else + sheet1[count_row,9] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty + sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,11] = format_time(homework.created_at) + end count_row += 1 end elsif @homework.homework_type == 2 #编程作业 - sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), - l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)]) + if @homework.anonymous_comment ==0 + sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end count_row = 1 items.each do |homework| sheet1[count_row,0]=homework.user.id - sheet1[count_row,1] = homework.user.lastname.to_s + homework.user.firstname.to_s + sheet1[count_row,1] = homework.user.show_name sheet1[count_row,2] = homework.user.login sheet1[count_row,3] = homework.user.user_extensions.student_id sheet1[count_row,4] = homework.user.mail @@ -1243,11 +1261,48 @@ class StudentWorkController < ApplicationController sheet1[count_row,7] = homework.teacher_score.nil? ? l(:label_without_score) : homework.teacher_score.round(2) sheet1[count_row,8] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2) sheet1[count_row,9] = homework.system_score.nil? ? l(:label_without_score) : homework.system_score.round(2) - sheet1[count_row,10] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) - sheet1[count_row,11] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) - sheet1[count_row,12] = format_time(homework.created_at) + if @homework.anonymous_comment ==0 + sheet1[count_row,10] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) + sheet1[count_row,11] = @homework.teacher_priority == 1 ? 0 : homework.absence_penalty + sheet1[count_row,12] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty + sheet1[count_row,13] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,14] = format_time(homework.created_at) + else + sheet1[count_row,10] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty + sheet1[count_row,11] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,12] = format_time(homework.created_at) + end count_row += 1 end + elsif @homework.homework_type == 3 #分组作业 + if @homework.anonymous_comment ==0 + sheet1.row(0).concat([l(:excel_group_member),l(:excel_homework_name),l(:excel_homework_project),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_n_score),l(:excel_a_penalty),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + else + sheet1.row(0).concat([l(:excel_group_member),l(:excel_homework_name),l(:excel_homework_project),l(:excel_homework_des), + l(:excel_t_score),l(:excel_ta_score),l(:excel_l_penalty),l(:excel_f_score),l(:excel_commit_time)]) + end + count_row = 1 + items.each do |homework| + sheet1[count_row,0] = get_group_member_names homework + sheet1[count_row,1] = homework.name + sheet1[count_row,2] = (homework.project_id == 0 || homework.project_id.nil?) ? l(:excel_no_project) : homework.project.name + sheet1[count_row,3] = strip_html homework.description + sheet1[count_row,4] = homework.teacher_score.nil? ? l(:label_without_score) : homework.teacher_score.round(2) + sheet1[count_row,5] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2) + if @homework.anonymous_comment ==0 + sheet1[count_row,6] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) + sheet1[count_row,7] = @homework.teacher_priority == 1 ? 0 : homework.absence_penalty + sheet1[count_row,8] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty + sheet1[count_row,9] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,10] = format_time(homework.created_at) + else + sheet1[count_row,6] = @homework.teacher_priority == 1 ? 0 : homework.late_penalty + sheet1[count_row,7] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,8] = format_time(homework.created_at) + end + count_row += 1 + end end book.write xls_report xls_report.string diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ba1a51343..b7972ff6f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -87,7 +87,10 @@ class UsersController < ApplicationController #展开所有回复 def show_all_replies - @comment = JournalsForMessage.find params[:comment].to_i + case params[:type] + when 'JournalsForMessage' + @comment = JournalsForMessage.find params[:comment].to_i + end end #二级回复 @@ -95,6 +98,7 @@ class UsersController < ApplicationController case params[:type] when 'HomeworkCommon' @reply = JournalsForMessage.find params[:reply_id] + @type = 'HomeworkCommon' if params[:user_activity_id] @user_activity_id = params[:user_activity_id] else @@ -102,6 +106,11 @@ class UsersController < ApplicationController end @is_in_course = params[:is_in_course].to_i @course_activity = params[:course_activity].to_i + when 'JournalsForMessage' + @reply = JournalsForMessage.find params[:reply_id] + @user_activity_id = params[:user_activity_id] + @activity_id = params[:activity_id] + @type = 'JournalsForMessage' end respond_to do |format| format.js @@ -3261,7 +3270,11 @@ class UsersController < ApplicationController @journals = obj.comments.reorder("created_on desc") when 'JournalsForMessage' obj = JournalsForMessage.where('id = ?', params[:id].to_i).first - @journals = obj.children.reorder("created_on desc") + journals = [] + @journals = get_all_children(journals, obj) + @type = 'JournalsForMessage' + @user_activity_id = params[:div_id].to_i if params[:div_id] + @allow_delete = params[:allow_delete] when 'Issue' obj = Issue.where('id = ?', params[:id].to_i).first @journals = obj.journals.reorder("created_on desc") diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 169a33fce..15d4ab2e1 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -3,10 +3,23 @@ class WechatsController < ActionController::Base wechat_responder include ApplicationHelper - + # ROOT_URL = "#{Setting.protocol}://#{Setting.host_name}/" + ROOT_URL = "http://wechat.trustie.net" # default text responder when no other match on :text do |request, content| - request.reply.text "您的意见已收到,感谢您的反馈!" # Just echo + #邀请码 + begin + uw = user_binded?(request[:FromUserName]) + if !uw + return sendBind() + else + return join_class({invite_code: content}, uw.user) + end + rescue => e + logger.error e.inspect + logger.error e.backtrace.join("\n") + return request.reply.text e + end end # When receive 'help', will trigger this responder @@ -35,7 +48,18 @@ class WechatsController < ActionController::Base # When subscribe user scan scene_id in public account on :scan, with: 'scene_id' do |request, ticket| - request.reply.text "Subscribe user #{request[:FromUserName]} Ticket #{ticket}" + begin + uw = user_binded?(request[:FromUserName]) + if !uw + return sendBind() + else + return join_class({ticket: ticket}, uw.user) + end + rescue => e + logger.error e.inspect + logger.error e.backtrace.join("\n") + return request.reply.text e + end end # When no any on :scan responder can match subscribe user scaned scene_id @@ -128,6 +152,15 @@ class WechatsController < ActionController::Base default_msg(request) end + on :click, with: 'JOIN_CLASS' do |request, key| + uw = user_binded?(request[:FromUserName]) + unless uw + sendBind(request) + else + request.reply.text "请直接回复6位班级邀请码\n(不区分大小写):" + end + end + def default_msg(request) uw = user_binded?(request[:FromUserName]) if uw && uw.user @@ -145,8 +178,8 @@ class WechatsController < ActionController::Base 您还未绑定确实的用户,请先绑定,谢谢!" } } request.reply.news(news) do |article, n, index| # article is return object - url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{login_wechat_url}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect" - pic_url = "#{Setting.protocol}://#{Setting.host_name}/images/weixin_pic.jpg" + url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities'}&response_type=code&scope=snsapi_base&state=login#wechat_redirect" + pic_url = "#{ROOT_URL}/images/weixin_pic.jpg" article.item title: "#{n[:title]}", description: n[:content], pic_url: pic_url, @@ -154,18 +187,53 @@ class WechatsController < ActionController::Base end end + def join_class(params, user) + course = nil + course = Course.where(qrcode: params[:ticket]) if params[:ticket] + course = Course.where(invite_code: params[:invite_code]) if params[:invite_code] + raise "课程不存在" if course.blank? + + cs = CoursesService.new + status = cs.join_course(course.invite_code, user) + logger.info status + if status[:state] != 0 + raise CoursesService::JoinCourseError.message(status[:state]) + end + + course = status[:course] + news = (1..1).each_with_object([]) { |n, memo| memo << { title: '恭喜您成功加入班级,开始学习吧!', + content: "课程名称: #{course.name}\n班级名称: #{course.name}\n任课老师: #{course.teacher.show_name}\n进入班级,和小伙伴愉快的学习吧!"} } + return request.reply.news(news) do |article, n, index| # article is return object + url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities?id='+course.id.to_s}&response_type=code&scope=snsapi_base&state=myclass#wechat_redirect" + pic_url = "#{ROOT_URL}/images/wechat/class.jpg" + article.item title: "#{n[:title]}", + description: n[:content], + pic_url: pic_url, + url: url + end + + end + ### controller method module Controllers - def get_open_id + def get_bind begin - code = params[:code] || session[:wechat_code] openid = get_openid_from_code(code) raise "无法获取到微信openid" unless openid - render :json => {status:0, openid: openid} + + uw = UserWechat.where(openid: openid).first + raise "还未绑定trustie帐户" unless uw + logger.debug "get_bind ============= #{uw}" + + user = uw.user + ::ApiKey.delete_all(user_id: user.id) + key = ::ApiKey.create!(user_id: user.id) + + render :json =>{status: 0, token: key.access_token} rescue Exception=>e - render :json => {status: -1, msg: e.message} + render :json => {status: -1, message: e.message} end end @@ -175,7 +243,7 @@ class WechatsController < ActionController::Base code = params[:code] || session[:wechat_code] openid = get_openid_from_code(code) - raise "无法获取到openid" unless openid + raise "无法获取到openid,请在微信中打开本页面" unless openid raise "此微信号已绑定用户, 不能重复绑定" if user_binded?(openid) user, last_login_on = User.try_to_login(params[:username], params[:password]) @@ -206,19 +274,26 @@ class WechatsController < ActionController::Base def user_activities session[:wechat_code] = params[:code] if params[:code] - code = params[:code] || session[:wechat_code] - openid = get_openid_from_code(code) - @wechat_user = user_binded?(openid) - unless @wechat_user - redirect_to login_wechat_path - return + @path = '/'+(params[:state] || '') + open_id = get_openid_from_code(params[:code]) rescue + unless open_id + render 'wechats/open_wechat', layout: nil and return + end + if params[:state] == 'myclass' + @course_id = params[:id]; end + session[:wechat_openid] = open_id + if params[:code] + redirect_to "/wechat/user_activities##{@path}?id=#{params[:id]}" and return + end render 'wechats/user_activities', layout: nil end + private def get_openid_from_code(code) + return 'oCnvgvz8R7QheXE-R9Kkr39j8Ndg' if code =='only-for-test' openid = session[:wechat_openid] unless openid diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 22b7f1f52..668269a26 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -54,15 +54,16 @@ class WordsController < ApplicationController :reply_id => reply_user_id, :notes => content, :is_readed => false} - @jfm = add_reply_adapter options + @activity = params[:activity_id].nil? ? JournalsForMessage.find(parent_id) : JournalsForMessage.find(params[:activity_id].to_i) + @jfm = add_reply_adapter(@activity, options) @save_succ = true if @jfm.errors.empty? if @save_succ - update_course_activity('JournalsForMessage',parent_id) - update_user_activity('JournalsForMessage',parent_id) - update_forge_activity('JournalsForMessage',parent_id) - update_org_activity('JournalsForMessage',parent_id) - update_principal_activity('JournalsForMessage',parent_id) - (JournalsForMessage.find parent_id).update_attribute(:updated_on,Time.now) + update_course_activity('JournalsForMessage',@activity.id) + update_user_activity('JournalsForMessage',@activity.id) + update_forge_activity('JournalsForMessage',@activity.id) + update_org_activity('JournalsForMessage',@activity.id) + update_principal_activity('JournalsForMessage',@activity.id) + @activity.update_attribute(:updated_on,Time.now) end respond_to do |format| # format.html { @@ -76,8 +77,6 @@ class WordsController < ApplicationController format.js { #@reply_type = params[:reply_type] @user_activity_id = params[:user_activity_id] - @activity = JournalsForMessage.find(parent_id) - @is_activity = params[:is_activity] if params[:is_activity] } end @@ -92,13 +91,14 @@ class WordsController < ApplicationController elsif @journal_destroyed.jour_type == "Course" @course = Course.find @journal_destroyed.jour_id @jours_count = @course.journals_for_messages.where('m_parent_id IS NULL').count + @user_activity_id = params[:user_activity_id] if params[:user_activity_id] + @activity = JournalsForMessage.where("id = #{params[:activity_id].to_i}").first if params[:activity_id] elsif @journal_destroyed.jour_type == "Principal" @user = User.find(@journal_destroyed.jour_id) @jours_count = @user.journals_for_messages.where('m_parent_id IS NULL').count @is_user = true @user_activity_id = params[:user_activity_id] if params[:user_activity_id] - @is_activity = params[:is_activity].to_i if params[:is_activity] - @activity = @journal_destroyed.parent if @journal_destroyed.parent + @activity = JournalsForMessage.where("id = #{params[:activity_id].to_i}").first if params[:activity_id] unless @activity redirect_to feedback_path(@user) return @@ -374,28 +374,44 @@ class WordsController < ApplicationController obj end - def add_reply_adapter options + def add_reply_adapter obj, options #modify by nwb #添加对课程留言的支持 #留言回复应该不关系其所属的Class,而关心的是其所属的父留言 - obj = obj_distinguish_url_origin || User.find_by_id(2) - if obj.kind_of? User - obj.add_jour(nil, nil, nil, options) - elsif obj.kind_of? Project - Project.add_new_jour(nil, nil, obj.id, options) - elsif obj.kind_of? Course - Course.add_new_jour(nil, nil, obj.id, options) - elsif obj.kind_of? Bid - obj.add_jour(nil, nil, nil, options) - elsif obj.kind_of? Contest - obj.add_jour(nil, nil, obj.id, options) #new added - elsif obj.kind_of? Softapplication - obj.add_jour(nil, nil, obj.id, options) #new added - elsif obj.kind_of? HomeworkAttach - obj.add_jour(nil, nil, obj.id, options) #new added - else - raise "create reply obj unknow type.#{obj.class}" + case obj.jour_type + when 'Principal' + obj.jour.add_jour(nil, nil, nil, options) + when 'Project' + Project.add_new_jour(nil, nil, obj.jour_id, options) + when 'Course' + Course.add_new_jour(nil, nil, obj.jour_id, options) + when 'Bid' + obj.jour.add_jour(nil, nil, nil, options) + when 'Contest' + obj.jour.add_jour(nil, nil, obj.jour_id, options) + when 'Softapplication' + obj.jour.add_jour(nil, nil, obj.jour_id, options) + when 'HomeworkAttach' + obj.jour.add_jour(nil, nil, obj.jour_id, options) end + # obj = obj_distinguish_url_origin || User.find_by_id(2) + # if obj.kind_of? User + # obj.add_jour(nil, nil, nil, options) + # elsif obj.kind_of? Project + # Project.add_new_jour(nil, nil, obj.id, options) + # elsif obj.kind_of? Course + # Course.add_new_jour(nil, nil, obj.id, options) + # elsif obj.kind_of? Bid + # obj.add_jour(nil, nil, nil, options) + # elsif obj.kind_of? Contest + # obj.add_jour(nil, nil, obj.id, options) #new added + # elsif obj.kind_of? Softapplication + # obj.add_jour(nil, nil, obj.id, options) #new added + # elsif obj.kind_of? HomeworkAttach + # obj.add_jour(nil, nil, obj.id, options) #new added + # else + # raise "create reply obj unknow type.#{obj.class}" + # end end #######end of message end diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index fb1231287..e993b120f 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -489,4 +489,26 @@ module ApiHelper self.update_attribute(:praise_num, self.praise_num.to_i - num) end + + class Errors + def self.define_error(arr) + @errors = {} + arr.each_with_index { |item, index| + if index %2 == 1 + @errors[arr[index-1]] = item + end + } + if arr.count % 2== 1 + @default_error = arr.last + else + @default_error = "未知错误" + end + + end + + def self.message(msg_id) + @errors[msg_id] || @default_error + end + end + end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 46fdb02f3..ee2e2d74a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3127,6 +3127,26 @@ def get_reply_parents parents_rely, comment parents_rely end +#获取回复的所有父节点(不包括根节点) +def get_reply_parents_no_root parents_rely, comment + if !comment.parent.nil? && !comment.parent.parent.nil? + parents_rely << comment.parent + get_reply_parents_no_root parents_rely, comment.parent + end + parents_rely +end + +#获取留言的所有子节点 +def get_all_children result, jour + if jour.kind_of? JournalsForMessage + jour.children.each do |jour_child| + result << jour_child + get_all_children result, jour_child + end + end + result.sort! { |a,b| b.created_on <=> a.created_on } +end + #将有置顶属性的提到数组前面 def sort_by_sticky topics tmpTopics = [] @@ -3283,3 +3303,20 @@ def get_hw_index(hw,is_teacher) index = hw_ids.index(hw.id) return index end + +def get_group_member_names work + result = "" + unless work.nil? + work.student_work_projects.each do |member| + user = User.where(:id => member.user_id).first + unless user.nil? + if result != "" + result += "、#{user.show_name}" + else + result += user.show_name + end + end + end + end + result +end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index c10652c6f..47d343e8f 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -270,13 +270,22 @@ module CoursesHelper # ===================================================================================== # return people list + def searchPeopleByName(course, role_name) + course.members.select{|m| + m.roles.any?{|r|r.name == role_name} + } + end + def searchTeacherAndAssistant project - #searchPeopleByRoles(project, TeacherRoles) - members = [] - project.members.includes(:user).each do |m| - members << m if m && m.user && m.user.allowed_to?(:as_teacher,project) - end - members + searchPeopleByName(project, 'Manager').concat( + searchPeopleByName(project, 'Teacher') + ).concat( + searchPeopleByName(project, 'TeachingAsistant') + ) + end + + def searchStudent project + searchPeopleByName(project, 'Student') end def TeacherAndAssistantCount course @@ -293,19 +302,6 @@ module CoursesHelper members end - def searchStudent project - #searchPeopleByRoles(project, StudentRoles) - members = [] - project.members.each do |m| - if m && m.user && m.user.allowed_to?(:as_student,project) - members << m - end - end - members - end - - - def searchStudent_by_name project, name #searchPeopleByRoles(project, StudentRoles) members = [] diff --git a/app/models/course.rb b/app/models/course.rb index e3a845b11..195e7cf9f 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -1,3 +1,5 @@ +#coding=utf-8 + require 'elasticsearch/model' class Course < ActiveRecord::Base include Redmine::SafeAttributes @@ -65,7 +67,7 @@ class Course < ActiveRecord::Base acts_as_attachable :view_permission => :view_course_files, :delete_permission => :manage_files - validates_presence_of :password, :term,:name + validates_presence_of :term,:name validates_format_of :class_period, :with =>/^[1-9]\d*$/ validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/ validates_length_of :description, :maximum => 10000 @@ -405,6 +407,7 @@ class Course < ActiveRecord::Base self.course_messages << CourseMessage.new(:user_id => self.tea_id, :course_id => self.id, :viewed => false) end + #项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题 #def name # read_attribute('name') || Project.find_by_identifier(self.extra).try(:name) @@ -422,12 +425,14 @@ class Course < ActiveRecord::Base # __elasticsearch__.delete_document # end def create_course_ealasticsearch_index + return if Rails.env.development? if self.is_public == 1 and self.is_delete == 0 #公开 和 没有被删除的课程才被索引 self.__elasticsearch__.index_document end end def update_course_ealasticsearch_index + return if Rails.env.development? if self.is_public == 1 and self.is_delete == 0 #如果是初次更新成为公开或者恢复被删除的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性 begin self.__elasticsearch__.update_document @@ -444,6 +449,7 @@ class Course < ActiveRecord::Base end def delete_course_ealasticsearch_index + return if Rails.env.development? begin self.__elasticsearch__.delete_document rescue => e @@ -451,6 +457,31 @@ class Course < ActiveRecord::Base end end + # 生成邀请码 + CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) + def generate_invite_code + code = invite_code + if !invite_code || invite_code.size <5 + self.invite_code = CODES.sample(5).join + return generate_invite_code if Course.where(invite_code: invite_code).present? + save! && reload + code = invite_code + end + code + end + + + def generate_qrcode + ticket = self.qrcode + if !ticket || ticket.size < 10 + response = Wechat.api.qrcode_create_scene(invite_code) + logger.debug "response = #{response}" + self.qrcode = response['ticket'] + save! && reload + ticket = qrcode + end + ticket + end end diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 2c8387349..41fb18b61 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -68,7 +68,6 @@ class CoursesService if current_user.nil? || !(current_user.admin? || c.is_public == 1 || (c.is_public == 0 && current_user.member_of_course?(c))) raise '403' end - @teachers= searchTeacherAndAssistant(c) #@canShowCode = isCourseTeacher(User.current.id,course) && params[:role] != '1' case params[:role] when '1' @@ -87,7 +86,11 @@ class CoursesService gender = m.user.user_extensions.gender.nil? ? 0 : m.user.user_extensions.gender work_unit = get_user_work_unit m.user location = get_user_location m.user - users << {:id => m.user.id, :img_url => img_url, :nickname => m.user.login, :gender => gender, :work_unit => work_unit, :mail => m.user.mail, :location => location, :brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname} + users << {:id => m.user.id, :img_url => img_url, :nickname => m.user.login, :gender => gender, + :work_unit => work_unit, :mail => m.user.mail, :location => location, + role_name: m.roles.first.name, + name: m.user.show_name, + :brief_introduction => m.user.user_extensions.brief_introduction,:realname=>m.user.realname} end users end @@ -162,6 +165,9 @@ class CoursesService #显示课程 def show_course(params,current_user) course = Course.find(params[:id]) + course.generate_invite_code + course.generate_qrcode + if course.school work_unit = course.school.name else @@ -193,7 +199,7 @@ class CoursesService @course.extra = 'course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s @course.send(:safe_attributes=, params[:course], current_user) #@course.safe_attributes(current_user,params[:course]) - @course.password = params[:course][:password] + #@course.password = params[:course][:password] @course.tea_id = current_user.id @course.term = params[:term] @course.time = params[:time] @@ -252,7 +258,7 @@ class CoursesService def edit_course(params,course,current_user) course.send(:safe_attributes=, params[:course], current_user) #course.safe_attributes = params[:course] - course.password = params[:course][:password] + #course.password = params[:course][:password] course.time = params[:time] course.term = params[:term] course.end_time = params[:end_time] @@ -300,23 +306,27 @@ class CoursesService @state end + class JoinCourseError < Errors + define_error [ + 0, '加入成功', + 1, '密码错误', + 2, '课程已过期 请联系课程管理员重启课程。', + 3, '您已经加入了课程', + 4, '您加入的课程不存在', + 5, '您还未登录', + 6, '申请成功,请等待审核完毕', + 7, '您已经发送过申请了,请耐心等待', + 8, '您已经是该课程的教师了', + 9, '您已经是该课程的教辅了', + 10, '您已经是该课程的管理员了', + '未知错误,请稍后再试' + ] + end #加入课程 #object_id:课程id #course_password :加入课程的密码 - #@state == 0 加入成功 - #@state == 1 密码错误 - #@state == 2 课程已过期 请联系课程管理员重启课程。(在配置课程处) - #@state == 3 您已经加入了课程 - #@state == 4 您加入的课程不存在 - #@state == 5 您还未登录 - #@state == 6 申请成功,请等待审核完毕 - #@state == 7 您已经发送过申请了,请耐心等待 - #@state == 8 您已经是该课程的教师了 - #@state == 9 您已经是该课程的教辅了 - #@state == 10 您已经是该课程的管理员了 - #@state 其他 未知错误,请稍后再试 def join_course params,current_user - course = Course.find_by_id params[:object_id] + course = Course.find_by_invite_code(params[:invite_code]) if params[:invite_code] @state = 10 if course @@ -326,7 +336,7 @@ class CoursesService if current_user.member_of_course?(course) #如果已经是成员 member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0] roleName = member.roles[0].name if member - if params[:course_password] == course.password + if params[:invite_code].present? #如果加入角色为学生 并且当前是学生 if params[:role] == "10" && roleName == "Student" @state = 3 @@ -352,19 +362,19 @@ class CoursesService elsif params[:role] == "10" && roleName != "Student" member.role_ids = [params[:role]] member.save - StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) + StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id) @state = 0 end else @state = 1 end else - if params[:course_password] == course.password + if params[:invite_code].present? if params[:role] == "10" || params[:role] == nil members = [] members << Member.new(:role_ids => [10], :user_id => current_user.id) course.members << members - StudentsForCourse.create(:student_id => current_user.id, :course_id => params[:object_id]) + StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id) @state = 0 else #如果已经发送过消息了,那么就要给个提示 diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index 9617b7f76..7d8aaed86 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -87,11 +87,7 @@
- <% if @article.try(:author).try(:realname) == ' ' %> - <%= link_to @article.try(:author), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> - <% else %> - <%= link_to @article.try(:author).try(:realname), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> - <% end %> + <%= link_to @article.author.show_name, user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
<%= format_time( @article.created_on)%>
@@ -126,11 +122,6 @@
-
<%@article.children.reorder('created_on desc').each_with_index do |reply,i| %> @@ -146,11 +137,7 @@
- <% if reply.try(:author).try(:realname) == ' ' %> - <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% else %> - <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> - <% end %> + <%= link_to reply.author.show_name, user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
<%= reply.content.html_safe%> diff --git a/app/views/courses/_copy_course.html.erb b/app/views/courses/_copy_course.html.erb index 3b6d55d96..dbe03d67f 100644 --- a/app/views/courses/_copy_course.html.erb +++ b/app/views/courses/_copy_course.html.erb @@ -1,6 +1,6 @@ +
  • +
    + <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %> +
    +
    +
    + <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %> + <%= time_from_now(comment.created_on) %> +
    + <% if !comment.parent.nil? && !comment.parent.parent.nil? %> + <% parents_rely = [] %> + <% parents_rely = get_reply_parents_no_root parents_rely, comment %> + <% length = parents_rely.length %> +
    + <% if length <= 3 %> + <%=render :partial => 'users/journal_comment_reply', :locals => {:comment => comment.parent} %> + <% else %> +
    +
    +
    + <%=render :partial => 'users/journal_comment_reply', :locals => {:comment => parents_rely[length - 1]} %> +
    + <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[length - 2]} %> +
    +
    + + + <%= link_to '点击展开隐藏楼层', show_all_replies_users_path(:comment => comment, :type => comment.class),:remote=>true %> +
    + <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[0]} %> +
    + <% end %> +
    + <% end %> + <% if !comment.content_detail.blank? || comment.class == Journal %> +
    + <% if comment.class == Journal %> + <% if comment.details.any? %> + <% details_to_strings(comment.details).each do |string| %> +

    <%= string %>

    + <% end %> + <% end %> +

    <%= comment.notes.html_safe %>

    + <% else %> + <%= comment.content_detail.html_safe %> + <% end %> +
    +
    +
    + + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + + + <%= link_to( + l(:button_reply), + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_id}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> + + + <% if allow_delete %> + <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user, :user_activity_id => user_activity_id, :activity_id => activity_id}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %> + <% end %> + +
    +
    +
    +

    + <% end %> +
    +
    +
  • + <% end %> + \ No newline at end of file diff --git a/app/views/users/_journal_reply_banner.html.erb b/app/views/users/_journal_reply_banner.html.erb new file mode 100644 index 000000000..c231f473d --- /dev/null +++ b/app/views/users/_journal_reply_banner.html.erb @@ -0,0 +1,18 @@ +
    +
    + 回复 + ︿ + <%= count>0 ? "(#{count})" : "" %> + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + +
    +
    <%#= format_date(activity.updated_on) %>
    + <%if count>3 %> + + <% end %> +
    \ No newline at end of file diff --git a/app/views/users/_project_issue_reply.html.erb b/app/views/users/_project_issue_reply.html.erb index d1f7363a7..3dac8026a 100644 --- a/app/views/users/_project_issue_reply.html.erb +++ b/app/views/users/_project_issue_reply.html.erb @@ -1,21 +1,6 @@ <% count = activity.journals.count %>
    -
    -
    回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
    -
    <%#= format_date(activity.updated_on) %>
    - <% if count > 3 %> - - <% end %> -
    + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% comments = activity.journals.includes(:user, :details).reorder("created_on desc").limit(3) %> <% if count > 0 %> diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb index 502706289..1abc36a31 100644 --- a/app/views/users/_project_message.html.erb +++ b/app/views/users/_project_message.html.erb @@ -6,11 +6,7 @@
    - <% if activity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% end %> + <%= link_to activity.author.show_name, user_path(activity.author_id), :class => "newsBlue mr15" %> TO <%= link_to activity.project.name.to_s+" | 项目讨论区",project_boards_path(activity.project), :class => "newsBlue ml15 mr5"%> @@ -88,18 +84,7 @@ <% count=activity.children.count%> <% end %>
    -
    -
    回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
    -
    <%#=format_date(activity.updated_on)%>
    - <%if count>3 %> - - <% end %> -
    + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% activity= activity.parent_id.nil? ? activity : activity.parent %> <% comments = activity.children.reorder("created_on desc").limit(3) %> diff --git a/app/views/users/_project_news.html.erb b/app/views/users/_project_news.html.erb index 04edc05e0..cdceb490d 100644 --- a/app/views/users/_project_news.html.erb +++ b/app/views/users/_project_news.html.erb @@ -6,11 +6,8 @@
    - <% if @ctivity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% end %> TO + <%= link_to activity.author.show_name, user_path(activity.author_id), :class => "newsBlue mr15" %> + TO <%= link_to activity.project.name.to_s+" | 新闻", project_news_index_path(activity.project), :class => "newsBlue ml15" %>
    <% count=activity.comments.count %>
    -
    -
    回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
    -
    <%#= format_date(activity.updated_on) %>
    - <%if count>3 %> - - <% end %> -
    - + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> + <% comments = activity.comments.reorder("created_on desc").limit(3) %> <% if count > 0 %>
    diff --git a/app/views/users/_reply_banner.html.erb b/app/views/users/_reply_banner.html.erb new file mode 100644 index 000000000..0d7e0b2bd --- /dev/null +++ b/app/views/users/_reply_banner.html.erb @@ -0,0 +1,18 @@ +
    +
    + 回复 + ︿ + <%= count>0 ? "(#{count})" : "" %> + + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> + +
    +
    <%#= format_date(activity.updated_on) %>
    + <%if count>3 %> + + <% end %> +
    \ No newline at end of file diff --git a/app/views/users/_reply_to.html.erb b/app/views/users/_reply_to.html.erb index a7034ffc7..4d5030f8f 100644 --- a/app/views/users/_reply_to.html.erb +++ b/app/views/users/_reply_to.html.erb @@ -3,17 +3,32 @@
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
    - <%= form_for('new_form',:url => {:controller => 'words', :action => 'reply_to_homework', :id => reply.id},:method => "post", :remote => true) do |f| %> - > - > - > - -
    - - -
    -

    - <% end%> + <% if @type == 'HomeworkCommon' %> + <%= form_for('new_form',:url => {:controller => 'words', :action => 'reply_to_homework', :id => reply.id},:method => "post", :remote => true) do |f| %> + > + > + > + +
    + + +
    +

    + <% end%> + <% elsif @type == 'JournalsForMessage' %> + <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => reply.id}, :method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'reference_id', params[:reference_id], :value => reply.id %> + <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => reply.user.id %> + <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => reply.id %> + <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %> + <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>@user_activity_id %> + <%= hidden_field_tag 'activity_id',params[:activity_id],:value =>@activity_id %> +
    + + +
    + <% end%> + <% end %>
    <% else %> <%= render :partial => "users/show_unlogged_reply" %> diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 3b327c080..5d06a7001 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -86,7 +86,7 @@ <% case user_activity.act_type.to_s %> <% when 'JournalsForMessage' %> <% unless act.private == 1 && (!User.current || (User.current && act.jour_id != User.current.id && act.user_id != User.current.id)) %> - <%= render :partial => 'user_journalsformessage', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_activity=>1} %> + <%= render :partial => 'user_journalsformessage', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> <% end %> <% end %> <% when 'Blog'%> diff --git a/app/views/users/_user_blog.html.erb b/app/views/users/_user_blog.html.erb index f0761ff78..77510c858 100644 --- a/app/views/users/_user_blog.html.erb +++ b/app/views/users/_user_blog.html.erb @@ -6,11 +6,8 @@
    - <% if @ctivity.try(:author).try(:realname) == ' ' %> - <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% else %> - <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% end %> TO + <%= link_to activity.author.show_name, user_path(activity.author_id), :class => "newsBlue mr15" %> + TO <%= link_to activity.author.name.to_s+" | 博客", user_blogs_path(:user_id=>activity.author_id), :class => "newsBlue ml15" %>
    @@ -46,22 +43,7 @@
    <% count=activity.children.count %>
    -
    -
    回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
    -
    <%#= format_date(activity.updated_on) %>
    - <%if count>3 %> - - <% end %> -
    + <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %> <% comments = activity.children.reorder("created_on desc").limit(3) %> <% if count > 0 %> diff --git a/app/views/users/_user_journalsformessage.html.erb b/app/views/users/_user_journalsformessage.html.erb index b84adf5fe..4fb79ee2d 100644 --- a/app/views/users/_user_journalsformessage.html.erb +++ b/app/views/users/_user_journalsformessage.html.erb @@ -50,7 +50,7 @@
    • <%= link_to(l(:label_bid_respond_delete), - {:controller => 'words', :action => 'destroy', :object_id => activity, :user_id => activity.user,:user_activity_id => user_activity_id,:is_activity=>is_activity}, + {:controller => 'words', :action => 'destroy', :object_id => activity, :user_id => activity.user,:user_activity_id => user_activity_id, :activity_id => activity.id}, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "postOptionLink", :title => l(:button_delete)) %>
    • @@ -62,29 +62,17 @@
    - <% count=fetch_user_leaveWord_reply(activity).count %> + <% all_comments = []%> + <% count=get_all_children(all_comments, activity).count %> + <% allow_delete = (activity.user == User.current || User.current.admin?) %>
    -
    -
    回复 - <%= count>0 ? "(#{count})" : "" %> - - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%> - -
    -
    - <%if count>3 %> - - <% end %> -
    + <%= render :partial => 'users/journal_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id, :allow_delete => allow_delete} %> - <% comments = activity.children.reorder("created_on desc").limit(3) %> + <% all_comments = []%> + <% comments = get_all_children(all_comments, activity)[0..2] %> <% if count > 0 %>
    - <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%> + <%= render :partial => 'users/journal_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'JournalsForMessage', :allow_delete => allow_delete, :activity_id =>activity.id}%>
    <% end %> @@ -99,7 +87,6 @@ <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %> <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %> <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> - <%= hidden_field_tag 'is_activity',params[:is_activity],:value =>is_activity %>
    diff --git a/app/views/users/_user_jours_list.html.erb b/app/views/users/_user_jours_list.html.erb index 6211aac7d..517d66038 100644 --- a/app/views/users/_user_jours_list.html.erb +++ b/app/views/users/_user_jours_list.html.erb @@ -11,7 +11,7 @@ sd_create_editor_from_data(<%= jour.id%>, null, "100%", "<%=jour.class.to_s%>"); }); - <%= render :partial => 'user_journalsformessage', :locals => {:activity => jour,:user_activity_id =>jour.id,:is_activity=>0} %> + <%= render :partial => 'user_journalsformessage', :locals => {:activity => jour,:user_activity_id =>jour.id} %> <%#= render :partial => 'user_jours_new', :locals => {:jour => jour} %> <% end %> <%end%> diff --git a/app/views/users/all_journals.js.erb b/app/views/users/all_journals.js.erb index c18c6aae4..6d227e93b 100644 --- a/app/views/users/all_journals.js.erb +++ b/app/views/users/all_journals.js.erb @@ -1,5 +1,7 @@ <% if params[:type] == 'HomeworkCommon' %> $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/homework_replies', :locals => {:comments => @journals, :is_in_course =>@is_in_course,:course_activity=>@course_activity, :is_teacher => @is_teacher, :user_activity_id => @user_activity_id}) %>'); +<% elsif params[:type] == 'JournalsForMessage' %> +$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/journal_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :allow_delete => @allow_delete, :activity_id =>params[:id].to_i}) %>'); <% else %> $('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/all_replies', :locals => {:comments => @journals}) %>'); <% end %> diff --git a/app/views/users/show_all_replies.js.erb b/app/views/users/show_all_replies.js.erb index 99ab73b46..5f5ea6c3f 100644 --- a/app/views/users/show_all_replies.js.erb +++ b/app/views/users/show_all_replies.js.erb @@ -1,3 +1,7 @@ <% unless @comment.parent.nil? %> -$('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/comment_reply', :locals => {:comment => @comment.parent})%>"); + <% if params[:type] == 'JournalsForMessage' && (@comment.jour_type == 'Principal' || @comment.jour_type == 'Course') %> + $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/journal_comment_reply', :locals => {:comment => @comment.parent})%>"); + <% else %> + $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/comment_reply', :locals => {:comment => @comment.parent})%>"); + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/wechats/open_wechat.html.erb b/app/views/wechats/open_wechat.html.erb new file mode 100644 index 000000000..4584e81b5 --- /dev/null +++ b/app/views/wechats/open_wechat.html.erb @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/app/views/wechats/user_activities.html.erb b/app/views/wechats/user_activities.html.erb index 3d61d8fcf..2b4ebc703 100644 --- a/app/views/wechats/user_activities.html.erb +++ b/app/views/wechats/user_activities.html.erb @@ -9,10 +9,16 @@ + @@ -20,8 +26,29 @@
    - + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/views/words/create_reply.js.erb b/app/views/words/create_reply.js.erb index ded05887f..9f3b0164e 100644 --- a/app/views/words/create_reply.js.erb +++ b/app/views/words/create_reply.js.erb @@ -1,8 +1,8 @@ <% if @save_succ %> <% if @user_activity_id %> - <% if @is_activity %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id,:is_activity=>@is_activity}) %>"); - <% else %> + <% if @activity.jour_type == 'Principal' %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); + <% elsif @activity.jour_type == 'Course' %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); <% end %> //init_activity_KindEditor_data('<%#= @user_activity_id%>', "", "87%", "UserActivity"); diff --git a/app/views/words/destroy.js.erb b/app/views/words/destroy.js.erb index a2d606e76..c527474cd 100644 --- a/app/views/words/destroy.js.erb +++ b/app/views/words/destroy.js.erb @@ -3,8 +3,7 @@ <% elsif (['Principal','Project','Course', 'Bid', 'Contest', 'Softapplication','HomeworkCommon'].include? @journal_destroyed.jour_type)%> <% if @is_user%> <% if @activity %> - $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id,:is_activity=>@is_activity}) %>"); - //init_activity_KindEditor_data('<%#= @user_activity_id%>', "", "87%", "UserActivity"); + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); sd_create_editor_from_data('<%= @user_activity_id%>', "", "100%", "UserActivity"); <% else %> $("#user_activity_<%= @user_activity_id%>").hide(); @@ -20,7 +19,12 @@ <% if @bid && @jours_count %> $('#jours_count').html("<%= @jours_count %>"); <% elsif @course && @jours_count%> - $('#course_jour_count').html("(<%= @jours_count %>)"); + <% if @user_activity_id %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>"); + sd_create_editor_from_data('<%= @user_activity_id%>', "", "100%", "UserActivity"); + <% else %> + $('#course_jour_count').html("(<%= @jours_count %>)"); + <% end %> <% elsif @user && @jours_count%> $('#jour_count').html("<%= @jours_count %>"); <% elsif @homework%> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 94be8af6d..5d9b3c2a1 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1864,12 +1864,18 @@ zh: excel_nickname: 登录名 excel_student_id: 学号 excel_mail: 电子邮箱 + excel_rank: 排名 excel_homework_name: 作品名 excel_homework_des: 作品描述 + excel_homework_project: 关联项目 + excel_no_project: 无关联项目 + excel_group_member: 组员 excel_t_score: 教师评分 excel_ta_score: 教辅评分 excel_n_score: 匿名评分 excel_s_score: 系统评分 + excel_a_penalty: 缺评扣分 + excel_l_penalty: 迟交扣分 excel_f_score: 成绩 excel_commit_time: 提交时间 excel_homework_score: 作业积分 diff --git a/config/routes.rb b/config/routes.rb index ec8fa2337..bc2be6a30 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1253,7 +1253,7 @@ RedmineApp::Application.routes.draw do get :login get :user_activities post :bind - post :get_open_id + post :get_bind end end diff --git a/config/wechat.yml b/config/wechat.yml index cf5be1f2b..711f2f1f8 100644 --- a/config/wechat.yml +++ b/config/wechat.yml @@ -5,11 +5,11 @@ default: &default # Or if using public account, only need above two line # guange test - #appid: "wxf694495398c7d470" - #secret: "743e038392f1d89540e95f8f7645849a" + appid: "wxf694495398c7d470" + secret: "743e038392f1d89540e95f8f7645849a" - appid: "wx8e1ab05163a28e37" - secret: "beb4d3bc4b32b3557811680835357841" +# appid: "wx8e1ab05163a28e37" +# secret: "beb4d3bc4b32b3557811680835357841" token: "123456" access_token: "1234567" diff --git a/db/migrate/20160614072229_add_invite_code_to_course.rb b/db/migrate/20160614072229_add_invite_code_to_course.rb new file mode 100644 index 000000000..8f7bb8da1 --- /dev/null +++ b/db/migrate/20160614072229_add_invite_code_to_course.rb @@ -0,0 +1,5 @@ +class AddInviteCodeToCourse < ActiveRecord::Migration + def change + add_column :courses, :invite_code, :string + end +end diff --git a/db/migrate/20160624032138_add_index_to_invite_code.rb b/db/migrate/20160624032138_add_index_to_invite_code.rb new file mode 100644 index 000000000..420951874 --- /dev/null +++ b/db/migrate/20160624032138_add_index_to_invite_code.rb @@ -0,0 +1,6 @@ +class AddIndexToInviteCode < ActiveRecord::Migration + def change + add_column :courses, :qrcode, :string + add_index :courses, :invite_code, unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 95ffceef1..148a6e21b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160612043259) do +ActiveRecord::Schema.define(:version => 20160624032138) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -550,8 +550,14 @@ ActiveRecord::Schema.define(:version => 20160612043259) do t.integer "excellent_option", :default => 0 t.integer "is_copy", :default => 0 t.integer "visits", :default => 0 + t.integer "syllabus_id" + t.string "invite_code" + t.string "qrcode" end + add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true + add_index "courses", ["syllabus_id"], :name => "index_courses_on_syllabus_id" + create_table "custom_fields", :force => true do |t| t.string "type", :limit => 30, :default => "", :null => false t.string "name", :limit => 30, :default => "", :null => false @@ -1119,6 +1125,23 @@ ActiveRecord::Schema.define(:version => 20160612043259) do t.integer "viewed_count", :default => 0 end + create_table "mess", :id => false, :force => true do |t| + t.string "课程名" + t.integer "课程ID", :default => 0, :null => false + t.string "教师姓", :default => "", :null => false + t.string "教师名", :limit => 30, :default => "", :null => false + t.string "主贴名", :default => "", :null => false + t.integer "主贴或回帖ID", :default => 0, :null => false + t.integer "回帖对应主贴ID" + t.integer "帖子点赞数" + t.integer "主贴回复数", :default => 0, :null => false + t.text "主贴或回帖内容" + t.datetime "发帖时间", :null => false + t.integer "发帖或回帖用户ID", :default => 0, :null => false + t.string "发帖或回帖用户姓", :default => "", :null => false + t.string "发帖或回帖用户名", :limit => 30, :default => "", :null => false + end + create_table "message_alls", :force => true do |t| t.integer "user_id" t.integer "message_id" @@ -1826,6 +1849,16 @@ ActiveRecord::Schema.define(:version => 20160612043259) do t.datetime "updated_at", :null => false end + create_table "syllabuses", :force => true do |t| + t.string "title" + t.text "description" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "syllabuses", ["user_id"], :name => "index_syllabuses_on_user_id" + create_table "system_messages", :force => true do |t| t.integer "user_id" t.string "content" diff --git a/public/assets/wechat/activities.html b/public/assets/wechat/activities.html index 69ea8f1fa..f042daba7 100644 --- a/public/assets/wechat/activities.html +++ b/public/assets/wechat/activities.html @@ -20,23 +20,25 @@
    -
    +
    迟交扣分:{{act.homework_common_detail.late_penalty}}分 匿评开启时间:{{act.homework_common_detail.evaluation_start}}
    缺评扣分:{{act.homework_common_detail.absence_penalty}}分/作品 匿评关闭时间:{{act.homework_common_detail.evaluation_end}}
    - 普通作业 - 编程作业 - 分组作业 - {{act.latest_update}} - 回复 - {{act.reply_count}} -
    -
    {{act.praise_count}}
    -
    {{act.praise_count}}
    -
    +
    + 普通作业 + 编程作业 + 分组作业 + {{act.latest_update}} + 回复 + {{act.reply_count}} +
    +
    {{act.praise_count}}
    +
    {{act.praise_count}}
    +
    +
    @@ -58,14 +60,16 @@
    - {{act.activity_type_name}} - {{act.latest_update}} - 回复 - {{act.reply_count}} -
    -
    {{act.praise_count}}
    -
    {{act.praise_count}}
    -
    +
    + {{act.activity_type_name}} + {{act.latest_update}} + 回复 + {{act.reply_count}} +
    +
    {{act.praise_count}}
    +
    {{act.praise_count}}
    +
    +
    @@ -87,14 +91,16 @@
    - {{act.activity_type_name}} - {{act.latest_update}} - 回复 - {{act.reply_count}} -
    -
    {{act.praise_count}}
    -
    {{act.praise_count}}
    -
    +
    + {{act.activity_type_name}} + {{act.latest_update}} + 回复 + {{act.reply_count}} +
    +
    {{act.praise_count}}
    +
    {{act.praise_count}}
    +
    +
    @@ -127,21 +133,23 @@
    -
    +
    状态:{{act.issue_detail.issue_status}} 优先级:{{act.issue_detail.issue_priority}}
    指派给:{{act.issue_detail.issue_assigned_to}} 完成度:{{act.issue_detail.done_ratio}}%
    - {{act.activity_type_name}} - {{act.latest_update}} - 回复 - {{act.reply_count}} -
    -
    {{act.praise_count}}
    -
    {{act.praise_count}}
    -
    +
    + {{act.activity_type_name}} + {{act.latest_update}} + 回复 + {{act.reply_count}} +
    +
    {{act.praise_count}}
    +
    {{act.praise_count}}
    +
    +
    @@ -164,14 +172,16 @@
    - {{act.activity_type_name}} - {{act.latest_update}} - 回复 - {{act.reply_count}} -
    -
    {{act.praise_count}}
    -
    {{act.praise_count}}
    -
    +
    + {{act.activity_type_name}} + {{act.latest_update}} + 回复 + {{act.reply_count}} +
    +
    {{act.praise_count}}
    +
    {{act.praise_count}}
    +
    +
    @@ -208,13 +218,15 @@
    - {{act.latest_update}} - 回复 - {{act.reply_count}} -
    -
    {{act.praise_count}}
    -
    {{act.praise_count}}
    -
    +
    + {{act.latest_update}} + 回复 + {{act.reply_count}} +
    +
    {{act.praise_count}}
    +
    {{act.praise_count}}
    +
    +
    @@ -237,13 +249,15 @@
    - {{act.latest_update}} - 回复 - {{act.reply_count}} -
    -
    {{act.praise_count}}
    -
    {{act.praise_count}}
    -
    +
    + {{act.latest_update}} + 回复 + {{act.reply_count}} +
    +
    {{act.praise_count}}
    +
    {{act.praise_count}}
    +
    +
    @@ -254,6 +268,7 @@
    更多
    + diff --git a/public/assets/wechat/add_class.html b/public/assets/wechat/add_class.html new file mode 100644 index 000000000..2543d5cc4 --- /dev/null +++ b/public/assets/wechat/add_class.html @@ -0,0 +1,13 @@ +
    +
    +

    输入班级邀请码,即刻加入班级!

    +
    + +
    + 取消 +
    +
    +
    + 确定 +
    +
    diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index 5059c41ab..a3977ec5c 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -2,7 +2,7 @@ - 我的动态 + 仅供本地调试使用 @@ -10,6 +10,7 @@ + @@ -17,8 +18,38 @@
    + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 509e0171a..762bd090e 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -39,7 +39,7 @@ - +
    diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index 2e7ed3151..cc188f978 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -15,7 +15,7 @@ 来   源: {{discussion.course_project_name}}  |  课程问答区 -
    +
    {{discussion.created_on}}
    @@ -46,7 +46,7 @@ - +
    diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index cca135681..e3346ea93 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -14,7 +14,7 @@ 来   源: {{news.course_name}}  |  课程通知 -
    +
    {{news.created_on}}
    @@ -45,7 +45,7 @@ - +
    diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index 0fc39c735..387b69867 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -18,13 +18,13 @@ 类   别: - 普通作业 - 编程作业 - 分组作业 + 普通作业 + 编程作业 + 分组作业 -
    +
    迟交扣分:{{homework.late_penalty}}分
    缺评扣分:{{homework.absence_penalty}}分/作品
    匿评开启时间:{{homework.evaluation_start}}
    @@ -59,7 +59,7 @@ - +
    diff --git a/public/assets/wechat/invite_code.html b/public/assets/wechat/invite_code.html new file mode 100644 index 000000000..6f56f7e86 --- /dev/null +++ b/public/assets/wechat/invite_code.html @@ -0,0 +1,15 @@ +
    +
    +
    + +
    +
    邀请码:{{course.invite_code}}
    +
    +
    +
    + + +
    +
    \ No newline at end of file diff --git a/public/assets/wechat/issue.html b/public/assets/wechat/issue.html deleted file mode 100644 index 558496ef0..000000000 --- a/public/assets/wechat/issue.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - react js - - - - - - - - - - - -
    - - - - - - - - - - \ No newline at end of file diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 1d7f9a536..4fc085b7e 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -14,7 +14,7 @@ 来   源: {{issue.project_name}}  |  项目问题 -
    +
    状   态:{{issue.issue_status}}
    优先级:{{issue.issue_priority}}
    指派给:{{issue.issue_assigned_to}}
    @@ -49,7 +49,7 @@ - +
    diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index dc6b1409f..9fd09de2c 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -37,7 +37,7 @@ - +
    diff --git a/public/assets/wechat/login.html b/public/assets/wechat/login.html new file mode 100644 index 000000000..309db29de --- /dev/null +++ b/public/assets/wechat/login.html @@ -0,0 +1,25 @@ +
    +
    + +
    +
    绑定注册
    + + + + + +
    +
    + + \ No newline at end of file diff --git a/public/assets/wechat/myclass.html b/public/assets/wechat/myclass.html new file mode 100644 index 000000000..30a8b9083 --- /dev/null +++ b/public/assets/wechat/myclass.html @@ -0,0 +1,32 @@ +
    +
    +
    {{course.name}}邀请码
    +
    + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    {{r.filename}}
    +
    +
    +
    授课老师
    + +
    + {{teacher.name}}{{teacher.role_name|identify}} +
    +
    我的同学
    +
    + {{student.name}} +
    + +
    +
    diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index 4831e1521..8be12c403 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -14,7 +14,7 @@ 来   源: {{discussion.course_project_name}}  |  项目讨论区 -
    +
    {{discussion.created_on}}
    @@ -45,7 +45,7 @@ - +
    diff --git a/public/assets/wechat/reg.html b/public/assets/wechat/reg.html new file mode 100644 index 000000000..9184fd0ed --- /dev/null +++ b/public/assets/wechat/reg.html @@ -0,0 +1,43 @@ +
    +
    +
    注册登录
    + + + + + + + + + +
    +
    + + \ No newline at end of file diff --git a/public/assets/wechat/templates/alert.html b/public/assets/wechat/templates/alert.html new file mode 100644 index 000000000..b59a1b87f --- /dev/null +++ b/public/assets/wechat/templates/alert.html @@ -0,0 +1,12 @@ + +
    +
    +
    +
    {{title}}
    +
    {{message}}
    +
    + 确定 +
    +
    +
    + \ No newline at end of file diff --git a/public/images/wechat/QR-code.jpg b/public/images/wechat/QR-code.jpg new file mode 100644 index 000000000..ba2a9e6a3 Binary files /dev/null and b/public/images/wechat/QR-code.jpg differ diff --git a/public/images/wechat/arrow.png b/public/images/wechat/arrow.png new file mode 100644 index 000000000..f9f9b18c5 Binary files /dev/null and b/public/images/wechat/arrow.png differ diff --git a/public/images/wechat/checked.png b/public/images/wechat/checked.png new file mode 100644 index 000000000..77986d62e Binary files /dev/null and b/public/images/wechat/checked.png differ diff --git a/public/images/wechat/class.jpg b/public/images/wechat/class.jpg new file mode 100644 index 000000000..e3eebb977 Binary files /dev/null and b/public/images/wechat/class.jpg differ diff --git a/public/images/wechat/dot.png b/public/images/wechat/dot.png new file mode 100644 index 000000000..bf1c0104e Binary files /dev/null and b/public/images/wechat/dot.png differ diff --git a/public/images/wechat/female.jpg b/public/images/wechat/female.jpg new file mode 100644 index 000000000..219865572 Binary files /dev/null and b/public/images/wechat/female.jpg differ diff --git a/public/images/wechat/female.png b/public/images/wechat/female.png new file mode 100644 index 000000000..a13733ffc Binary files /dev/null and b/public/images/wechat/female.png differ diff --git a/public/images/wechat/male.jpg b/public/images/wechat/male.jpg new file mode 100644 index 000000000..46d58f26e Binary files /dev/null and b/public/images/wechat/male.jpg differ diff --git a/public/images/wechat/male.png b/public/images/wechat/male.png new file mode 100644 index 000000000..9f1214a4c Binary files /dev/null and b/public/images/wechat/male.png differ diff --git a/public/images/wechat/minus.png b/public/images/wechat/minus.png new file mode 100644 index 000000000..32d82ea84 Binary files /dev/null and b/public/images/wechat/minus.png differ diff --git a/public/images/wechat/plus.png b/public/images/wechat/plus.png new file mode 100644 index 000000000..e5d83d212 Binary files /dev/null and b/public/images/wechat/plus.png differ diff --git a/public/images/wechat/post-avatar.jpg b/public/images/wechat/post-avatar.jpg new file mode 100644 index 000000000..bd2597dd2 Binary files /dev/null and b/public/images/wechat/post-avatar.jpg differ diff --git a/public/images/wechat/search.png b/public/images/wechat/search.png new file mode 100644 index 000000000..a04c1496c Binary files /dev/null and b/public/images/wechat/search.png differ diff --git a/public/images/wechat/setting.png b/public/images/wechat/setting.png new file mode 100644 index 000000000..3c1159fc9 Binary files /dev/null and b/public/images/wechat/setting.png differ diff --git a/public/images/wechat/tr-like.png b/public/images/wechat/tr-like.png new file mode 100644 index 000000000..9d9d38dc3 Binary files /dev/null and b/public/images/wechat/tr-like.png differ diff --git a/public/images/wechat/tr-reply.png b/public/images/wechat/tr-reply.png new file mode 100644 index 000000000..aef9cffcf Binary files /dev/null and b/public/images/wechat/tr-reply.png differ diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 22483c1d5..66ead54ba 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1322,6 +1322,40 @@ function expand_reply(container, btnid, id, type, div_id) { } } +function expand_journal_reply(container, btnid, id, type, div_id, allow_delete) { + var target = $(container); + var btn = $(btnid); + if (btn.data('init') == '0') { + btn.data('init', 1); + $.get( + '/users/all_journals', + { + type: type, + id: id, + div_id: div_id, + allow_delete: allow_delete + }, + function(data) { + + } + ); + btn.html('收起回复'); + //target.show(); + } else if(btn.data('init') == '1') { + btn.data('init', 3); + btn.html('展开更多'); + target.hide(); + target.eq(0).show(); + target.eq(1).show(); + target.eq(2).show(); + } + else { + btn.data('init', 1); + btn.html('收起回复'); + target.show(); + } +} + function expand_reply_homework(container, btnid, id, type, div_id, is_in_course, course_activity, user_activity_id) { var target = $(container); var btn = $(btnid); diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 6fbf9f8c4..8b5e58618 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -185,7 +185,7 @@ function regex_course_password(str) //提交新建课程 function submit_new_course() { - if(regex_course_name('new')&®ex_course_class_period('new')&®ex_time_term('new')&®ex_course_password('new')) + if(regex_course_name('new')&®ex_course_class_period('new')&®ex_time_term('new')) { $("#new_course").submit(); } @@ -193,7 +193,7 @@ function submit_new_course() function submit_edit_course(id) { - if(regex_course_name('edit')&®ex_course_class_period('edit')&®ex_time_term('edit')&®ex_course_password('edit')) + if(regex_course_name('edit')&®ex_course_class_period('edit')&®ex_time_term('edit')) { $("#edit_course_"+id).submit(); } diff --git a/public/javascripts/resizeable_table.js b/public/javascripts/resizeable_table.js index a43078dee..e5b57844a 100644 --- a/public/javascripts/resizeable_table.js +++ b/public/javascripts/resizeable_table.js @@ -1,7 +1,7 @@ /** * Created by ttang on 2016/5/24. */ - /*$(document).ready(function(){ + /* $(document).ready(function(){ $("th").each(function(){ $(this).css("width",$(this).width()-1); }); @@ -38,7 +38,7 @@ if (mousedown == true){ var width = (tdWidth + (evt.screenX - screenXStart)) - p1 + "px";//计算后的新的宽度 var width2 = (tdWidth2 - (evt.screenX - screenXStart)) - p2 + "px"; - if (parseInt(width)<0 || parseInt(width2)<0 || tdWidth > totalWidth || tdWidth2 > totalWidth){ + if (parseInt(width)<5 || parseInt(width2)<5 || tdWidth > totalWidth || tdWidth2 > totalWidth){ tartgetTd = null; resizeable = false; mousedown = false; diff --git a/public/javascripts/wechat/CommentBox.jsx b/public/javascripts/wechat/CommentBox.jsx deleted file mode 100644 index 7f30b38b1..000000000 --- a/public/javascripts/wechat/CommentBox.jsx +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Created by guange on 16/3/19. - */ - - - - -var CommentBox = React.createClass({ - - loadFromServer: function(){ - $.ajax({ - url: this.props.url, - dataType: 'json', - success: function(data){ - this.setState({data: data}); - }.bind(this), - error: function(xhr,status,err){ - console.error(this.props.url, status, err.toString()); - }.bind(this) - }); - }, - onCommentSubmit: function(comment){ - console.log(comment); - }, - getInitialState: function(){ - return {data: []}; - }, - componentDidMount: function(){ - this.loadFromServer(); - setInterval(this.loadFromServer, 2000); - }, - render: function(){ - return( -
    - - -
    - ); - } -}); - -var CommentList = React.createClass({ - render: function(){ - - var commentNodes = this.props.data.map(function(comment){ - return ( - - {comment.text} - - ) - }); - - return ( -
    - {commentNodes} -
    - ); - } -}); - -var CommentForm = React.createClass({ - handleSubmit: function(e){ - e.preventDefault(); - - var author = this.refs.author.value.trim(); - var text = this.refs.text.value.trim(); - if(!text || !author){ - return; - } - - this.props.onCommentSubmit({author: author, text: text}); - - this.refs.author.value = ''; - this.refs.text.value = ''; - return; - }, - render: function(){ - return ( -
    - - - -
    - ); - } -}); - - -var Comment = React.createClass({ - - rawMarkup: function() { - var rawMarkup = marked(this.props.children.toString(), {sanitize: true}); - return { __html: rawMarkup }; - }, - - render: function(){ - return ( -
    -

    - {this.props.author} -

    - -
    - ) - } -}) - -React.render(, document.getElementById("example")); \ No newline at end of file diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index ca9682db2..00d6bf3bc 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,546 +1,29 @@ var app = angular.module('wechat', ['ngRoute']); -var apiUrl = '/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true -if(debug===true){ - //apiUrl = 'http://localhost:3000/api/v1/'; - apiUrl = 'http://www.trustie.net/api/v1/'; +app.constant('config', { + rootPath: '/assets/wechat/', + rootUrl: '/', + apiUrl: '/api/v1/' +}); + + +app.run(['$rootScope', 'auth', '$location', '$routeParams', function($rootScope, auth, $location, $routeParams){ + + if(g_redirect_path && g_redirect_path.length>1){ + $location.path(g_redirect_path); + g_redirect_path = null; + } + + $rootScope.$on('$routeChangeError', function(event, next, current){ + + if(next && next.templateUrl){ + if(!next.templateUrl.endsWith("login.html") && !next.templateUrl.endsWith("reg.html")){ + $location.path("/login"); + } + } + }); + + $rootScope.$on('$routeChangeStart', function(event, next, current){ + }); } - - -app.factory('auth', function($http,$routeParams, $q){ - var _openid = ''; - - if(typeof g_openid !== 'undefined'){ - _openid = g_openid; - } - - if(debug===true){ - _openid = "orgVLv8TlS6e7FDiI6xdTGHRaaRo"; //guange的帐号 - } - - var getOpenId = function() { - var deferred = $q.defer(); - if (typeof _openid !== 'undefined' && _openid.length > 0){ - deferred.resolve(_openid); - } else { - var code = $routeParams.code; - $http({ - url: '/wechat/get_open_id', - data: {code: code}, - method: 'POST' - }).then(function successCallback(response) { - _openid = response.data.openid; - deferred.resolve(_openid); - }, function errorCallback(response) { - deferred.reject(response); - }); - } - return deferred.promise; - }; - var openid = function(){ - return _openid; - }; - return {getOpenId: getOpenId, openid: openid}; -}); - - -app.factory('rms', function(){ - var _saveStorage = {}; - var save = function(key, value){ - _saveStorage[key] = value; - }; - - var get = function(key){ - return _saveStorage[key]; - }; - - return {save: save, get: get}; -}); - -app.controller('ActivityController',function($anchorScroll, $location,$scope, $http, $timeout, auth, rms, common){ - $scope.replaceUrl = function(url){ - return url; - }; - - console.log("ActivityController load"); - - $scope.page = rms.get('page') || 0; - $scope.activities = rms.get("activities") || []; - $scope.has_more = rms.get("has_more"); - - $scope.loadActData = function(page){ - - $scope.page = page; - $http({ - method: 'POST', - url: apiUrl+ "activities", - data: {openid: auth.openid(), page: page} - }).then(function successCallback(response) { - if(response.data.page >0) { - $scope.activities = $scope.activities.concat(response.data.data); - } else { - $scope.activities = response.data.data; - } - - rms.save("activities", $scope.activities); - $scope.has_more = (response.data.count + response.data.page * 10) < response.data.all_count; - rms.save('has_more', $scope.has_more); - rms.save('page', response.data.page); - - console.log(response.data); - - }, function errorCallback(response) { - }); - }; - - if($scope.activities.length<=0){ - auth.getOpenId().then( - function successCallback(response){ - $scope.loadActData(0); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); - } else { - $timeout(function(){ - window.scrollTo(0, rms.get("yoffset")); - }); - - } - - //跳到详情页 - $scope.goDetail = function(type, act_id,id){ - rms.save("yoffset", window.document.body.scrollTop); - $location.path('/'+type+'/'+act_id); - } - - $scope.addPraise = function(act){ - common.addCommonPraise(act); - }; - - $scope.decreasePraise = function(act){ - common.decreaseCommonPraise(act); - }; -}); - -app.factory('common', function($http, auth, $routeParams){ - var addCommonReply = function(id, type, data, cb){ - - if(!data.comment || data.comment.length<=0){ - return; - } - - var temp = data.comment.replace(/\n/g,'
    '); - - var userInfo = { - type: type, - content: temp, - openid: auth.openid() - }; - //回复按钮禁用 - data.disabled = true; - - $http({ - method: 'POST', - url: apiUrl+ "new_comment/"+id, - data: userInfo - }).then(function successCallback(response) { - //alert("提交成功"); - //数据提交完成,回复按钮启用 - data.disabled = false; - if(typeof cb === 'function'){ - cb(); - } - }, function errorCallback(response) { - }); - }; - - var loadCommonData = function(id, type){ - return $http({ - method: 'GET', - url: apiUrl+ type + "/" + id+"?openid="+auth.openid() - }) - }; - - var addCommonPraise = function(act){ - act.praise_count += 1; - act.has_praise = true; - - $http({ - method: 'POST', - url: apiUrl + "praise/" + act.act_id, - data:{openid:auth.openid(),type:act.act_type} - }).then(function successCallback(response) { - console.log(response.data); - }, function errorCallback(response) { - }); - - }; - - var decreaseCommonPraise = function(act){ - act.praise_count -= 1; - act.has_praise = false; - - $http({ - method: 'POST', - url: apiUrl + "praise/" + act.act_id, - data:{openid:auth.openid(),type:act.act_type} - }).then(function successCallback(response) { - console.log(response.data); - }, function errorCallback(response) { - }); - }; - - return {addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise}; -}); - -app.controller('IssueController', function($scope, $http, $routeParams, auth, common){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - common.loadCommonData(id, 'issues').then(function successCallback(response) { - console.log(response.data); - $scope.issue = response.data.data; - }, function errorCallback(response) { - }); - }; - - auth.getOpenId().then( - function successCallback(response){ - loadData($routeParams.id); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); - - $scope.addIssueReply = function(data){ - console.log(data.comment); - common.addCommonReply($routeParams.id, 'Issue', data, function(){ - $scope.formData = {comment: ''}; - loadData($routeParams.id); - }); - - }; - - $scope.addPraise = function(act){ - common.addCommonPraise(act); - }; - - $scope.decreasePraise = function(act){ - common.decreaseCommonPraise(act); - }; -}); - -app.controller('HomeworkController', function($scope, $http, $routeParams, auth, common){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - common.loadCommonData(id, 'whomeworks').then(function successCallback(response) { - console.log(response.data); - $scope.homework = response.data.data; - }, function errorCallback(response) { - }); - }; - - auth.getOpenId().then( - function successCallback(response){ - loadData($routeParams.id); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); - - $scope.addHomeworkReply = function(data){ - console.log(data.comment); - common.addCommonReply($routeParams.id, 'HomeworkCommon', data, function(){ - $scope.formData = {comment: ''}; - loadData($routeParams.id); - }); - }; - - $scope.addPraise = function(act){ - common.addCommonPraise(act); - }; - - $scope.decreasePraise = function(act){ - common.decreaseCommonPraise(act); - }; -}); - -app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth, common){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - common.loadCommonData(id, 'newss').then(function successCallback(response) { - console.log(response.data); - $scope.news = response.data.data; - }, function errorCallback(response) { - }); - }; - - auth.getOpenId().then( - function successCallback(response){ - loadData($routeParams.id); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); - - $scope.addNoticeReply = function(data){ - console.log(data.comment); - common.addCommonReply($routeParams.id, 'News', data, function(){ - $scope.formData = {comment: ''}; - loadData($routeParams.id); - }); - }; - - $scope.addPraise = function(act){ - common.addCommonPraise(act); - }; - - $scope.decreasePraise = function(act){ - common.decreaseCommonPraise(act); - }; -}); - -app.controller('DiscussionController', function($scope, $http, $routeParams, auth, common){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - common.loadCommonData(id, 'messages').then(function successCallback(response) { - console.log(response.data); - $scope.discussion = response.data.data; - }, function errorCallback(response) { - }); - }; - - auth.getOpenId().then( - function successCallback(response){ - loadData($routeParams.id); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); - - $scope.addDiscussionReply = function(data){ - console.log(data.comment); - common.addCommonReply($routeParams.id, 'Message', data, function(){ - $scope.formData = {comment: ''}; - loadData($routeParams.id); - }); - }; - - $scope.addPraise = function(act){ - common.addCommonPraise(act); - }; - - $scope.decreasePraise = function(act){ - common.decreaseCommonPraise(act); - }; -}); - -app.controller('JournalsController', function($scope, $http, $routeParams, auth, common){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - common.loadCommonData(id, 'journal_for_messages').then(function successCallback(response) { - console.log(response.data); - $scope.message = response.data.data; - }, function errorCallback(response) { - }); - }; - - auth.getOpenId().then( - function successCallback(response){ - loadData($routeParams.id); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); - - $scope.addJournalReply = function(data){ - console.log(data.comment); - common.addCommonReply($routeParams.id, 'JournalsForMessage', data, function(){ - $scope.formData = {comment: ''}; - loadData($routeParams.id); - }); - }; - - $scope.addPraise = function(act){ - console.log(act); - common.addCommonPraise(act); - }; - - $scope.decreasePraise = function(act){ - console.log(act); - common.decreaseCommonPraise(act); - }; -}); - -app.controller('BlogController', function($scope, $http, $routeParams, auth, common){ - $scope.formData = {comment: ''}; - - var loadData = function(id){ - common.loadCommonData(id, 'blog_comments').then(function successCallback(response) { - console.log(response.data); - $scope.blog = response.data.data; - }, function errorCallback(response) { - }); - }; - - auth.getOpenId().then( - function successCallback(response){ - loadData($routeParams.id); - }, function errorCallback(response) { - alert("获取openid出错:"+response); - } - ); - - $scope.addBlogReply = function(data){ - console.log(data.comment); - common.addCommonReply($routeParams.id, 'BlogComment', data, function(){ - $scope.formData = {comment: ''}; - loadData($routeParams.id); - }); - }; - - $scope.addPraise = function(act){ - console.log(act); - common.addCommonPraise(act); - }; - - $scope.decreasePraise = function(act){ - console.log(act); - common.decreaseCommonPraise(act); - }; -}); - -app.filter('safeHtml', function ($sce) { - return function (input) { - return $sce.trustAsHtml(input); - } -}); - -//app.directive('textAutoHeight', function($timeout){ -// return { -// restrict: 'A', -// scope: {}, -// link: function(scope, element, attr){ -// scope.text = '点击展开'; -// $timeout(function(){ -// var e = element.parent().children().eq(5); -// var height = e[0].scrollHeight; -// if(height>90){ -// element.css('display', 'block'); -// element.on('click', function(){ -// if(element.text() == "点击展开"){ -// e.css("height", height+'px'); -// element.text("点击隐藏"); -// } else { -// e.css("height", '90px'); -// element.text("点击展开"); -// } -// -// }); -// } -// }, false); -// -// } -// } -//}); - -app.directive('inputAuto',function(){ - return{ - restrict: 'A', - scope: {}, - link: function(scope, element){ - var copyContainer = element.parent().children().eq(0); - var sendButton = element.parent().next(); - element.on('input',function(){ - console.log(sendButton); - copyContainer.html(element[0].value); - var textHeight = copyContainer[0].scrollHeight; - element.css('height', textHeight + 'px'); - }); - sendButton.on('click',function(){ - element.css('height','28px'); - }); - } - } -}); - -app.directive('loadingSpinner', ['$http', function ($http) { - return { - restrict: 'A', - replace: true, - template: '
    加载中...
    ', - }; -}]); - -app.config(['$routeProvider',"$httpProvider", "$locationProvider",function ($routeProvider, $httpProvider, $locationProvider) { - var rootPath = '/assets/wechat/' - //$locationProvider.html5Mode(true); - $routeProvider - .when('/activites', { - templateUrl: rootPath + 'activities.html', - controller: 'ActivityController' - }) - .when('/issues/:id', { - templateUrl: rootPath + 'issue_detail.html', - controller: 'IssueController' - }) - .when('/project_discussion/:id', { - templateUrl: rootPath + 'project_discussion.html', - controller: 'DiscussionController' - }) - .when('/homework/:id', { - templateUrl: rootPath + 'homework_detail.html', - controller: 'HomeworkController' - }) - .when('/course_notice/:id', { - templateUrl: rootPath + 'course_notice.html', - controller: 'CourseNoticeController' - }) - .when('/course_discussion/:id', { - templateUrl: rootPath + 'course_discussion.html', - controller: 'DiscussionController' - }) - .when('/journal_for_message/:id', { - templateUrl: rootPath + 'jour_message_detail.html', - controller: 'JournalsController' - }) - .when('/blog_comment/:id', { - templateUrl: rootPath + 'blog_detail.html', - controller: 'BlogController' - }) - .otherwise({ - redirectTo: '/activites' - }); - - //监听异步请求,实现加载中显隐标记 - $httpProvider.interceptors.push(function ($q, $rootScope) { - if ($rootScope.activeCalls == undefined) { - $rootScope.activeCalls = 0; - } - - return { - request: function (config) { - $rootScope.activeCalls += 1; - return config; - }, - requestError: function (rejection) { - $rootScope.activeCalls -= 1; - return rejection; - }, - response: function (response) { - $rootScope.activeCalls -= 1; - return response; - }, - responseError: function (rejection) { - $rootScope.activeCalls -= 1; - return rejection; - } - }; - }); -}]); +]); \ No newline at end of file diff --git a/public/javascripts/wechat/auth.js b/public/javascripts/wechat/auth.js deleted file mode 100644 index f9c2917fc..000000000 --- a/public/javascripts/wechat/auth.js +++ /dev/null @@ -1,36 +0,0 @@ -$(function(){ - //获取url中的参数 - function getUrlParam(name) { - var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象 - var r = window.location.search.substr(1).match(reg); //匹配目标参数 - if (r != null) return unescape(r[2]); return null; //返回参数值 - } - - - var debug = false; - - var g_openid = ""; - if(debug){ - g_openid = "填写要调试的openid即可"; - } - - window.getOpenId = function(cb){ - if (g_openid.length>0){ - cb(g_openid); - } - var code = getUrlParam("code"); - $.ajax({ - url: '/wechat/get_open_id', - data: {code: code}, - type: 'post', - dataType: 'json', - success: function(data){ - g_openid = data.openid; - cb(g_openid); - }, - error: function(xhr,err){ - alert("认证失败: "+err); - } - }); - } -}); \ No newline at end of file diff --git a/public/javascripts/wechat/blog_detail.js b/public/javascripts/wechat/blog_detail.js deleted file mode 100644 index 44121f83c..000000000 --- a/public/javascripts/wechat/blog_detail.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Created by root on 4/1/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:blog-detail',{blog: data}); - $('#blog-container').prepend(html); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - $('post-interactive-praise').click(function(){ - praiseClick(); - }); - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'blog_comments/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var homeworkUrl = window.location.search; - var homeworkID = homeworkUrl.split("=")[1]; - - loadDataFromServer(homeworkID); - - //点击回复按钮,插入回复内容 - var replyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - //将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date()); - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - //获取并传送回复用户数据 - var userInfo = { - "replyType" : "homework_assignment", - "replyContent" : postInput - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: "前台地址/后台方法", //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }); - } - - } - - //点赞效果 - var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - } - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/build/app.min.js b/public/javascripts/wechat/build/app.min.js new file mode 100644 index 000000000..365ed28c0 --- /dev/null +++ b/public/javascripts/wechat/build/app.min.js @@ -0,0 +1,19 @@ +var app=angular.module("wechat",["ngRoute"]);app.constant("config",{rootPath:"/assets/wechat/",rootUrl:"/",apiUrl:"/api/v1/"}),app.run(["$rootScope","auth","$location","$routeParams",function(t,a,e,r){g_redirect_path&&g_redirect_path.length>0&&(e.path(g_redirect_path),g_redirect_path=null),t.$on("$routeChangeError",function(t,a,r){a&&a.templateUrl&&(a.templateUrl.endsWith("login.html")||a.templateUrl.endsWith("reg.html")||e.path("/login"))}),t.$on("$routeChangeStart",function(t,a,e){})}]); +app.factory("alertService",function(){function t(){this.title=null,this.message=null,this.visible=null,this.cb=null}return t.prototype.showMessage=function(t,e,n){this.message=e,this.title=t,this.visible=!0,this.cb=n},t.prototype.dismiss=function(){this.message=null,this.title=null,this.visible=!1,this.cb&&this.cb()},{create:function(){return new t}}}),app.factory("auth",["$http","$routeParams","$q","session","config",function(t,e,n,o,a){var i=function(){var a=n.defer(),i=c();if(i&&i.length>10)a.resolve(i);else{window.g_code||e.code||o.get("code");t.post("/wechat/get_bind",{}).then(function(t){0!=t.data.status?a.reject(t.data.message):(o.save("token",t.data.token),a.resolve(t.data.token))})["catch"](function(t){a.reject(t)})}return a.promise},c=function(){return o.get("token")};return{get_bind:i,token:c}}]),app.factory("session",function(){return{save:function(t,e){sessionStorage.setItem(t,e)},get:function(t){return sessionStorage.getItem(t)}}}),app.factory("rms",function(){var t={},e=function(e,n){t[e]=n},n=function(e){return t[e]};return{save:e,get:n}}),app.factory("common",["$http","auth","$routeParams",function(t,e,n){var o=function(n,o,a,i){if(a.comment&&!(a.comment.length<=0)){var c=a.comment.replace(/\n/g,"
    "),s={type:o,content:c,token:e.token()};a.disabled=!0,t({method:"POST",url:apiUrl+"new_comment/"+n,data:s}).then(function(t){a.disabled=!1,"function"==typeof i&&i()},function(t){})}},a=function(n,o){return t({method:"GET",url:apiUrl+o+"/"+n+"?token="+e.token()})},i=function(n){n.praise_count+=1,n.has_praise=!0,t({method:"POST",url:apiUrl+"praise/"+n.act_id,data:{token:e.token(),type:n.act_type}}).then(function(t){console.log(t.data)},function(t){})},c=function(n){n.praise_count-=1,n.has_praise=!1,t({method:"POST",url:apiUrl+"praise/"+n.act_id,data:{token:e.token(),type:n.act_type}}).then(function(t){console.log(t.data)},function(t){})},s=function(t){t.scope.formData={comment:""};var e=function(e){a(e,t.type).then(function(e){t.loadCallback(e.data)},function(t){})};e(t.id),t.scope.addReply=function(n){console.log(n.comment),o(t.id,t.replyType,n,function(){t.scope.formData={comment:""},e(t.id),"function"==typeof t.replyCallback&&t.replyCallback()})},t.scope.addPraise=i,t.scope.decreasePraise=c};return{init:s,addCommonReply:o,loadCommonData:a,addCommonPraise:i,decreaseCommonPraise:c}}]); +app.filter("safeHtml",["$sce",function(t){return function(n){return t.trustAsHtml(n)}}]); +app.controller("ActivityController",["$anchorScroll","$location","$scope","$http","$timeout","auth","rms","common","alertService",function(a,t,e,o,i,c,n,r,s){e.replaceUrl=function(a){return a},e.alertService=s.create(),console.log("ActivityController load"),e.page=n.get("page")||0,e.activities=n.get("activities")||[],e.has_more=n.get("has_more"),e.loadActData=function(a){e.page=a,o({method:"POST",url:apiUrl+"activities",data:{token:c.token(),page:a}}).then(function(a){a.data.page>0?e.activities=e.activities.concat(a.data.data):e.activities=a.data.data,n.save("activities",e.activities),e.has_more=a.data.count+10*a.data.page
    加载中...
    '}}]); +app.config(["$routeProvider","$httpProvider","$locationProvider","config",function(e,o,r,t){var l=t.rootPath,n={delay:["auth",function(e){return e.get_bind()}]},s=function(e,o){return{templateUrl:l+e,controller:o,resolve:n}};e.when("/login",{templateUrl:l+"login.html",controller:"LoginController"}).when("/reg",{templateUrl:l+"reg.html",controller:"RegController"}).when("/activites",s("activities.html","ActivityController")).when("/issues/:id",s("issue_detail.html","IssueController")).when("/project_discussion/:id",s("project_discussion.html","DiscussionController")).when("/homework/:id",s("homework_detail.html","HomeworkController")).when("/course_notice/:id",s("course_notice.html","CourseNoticeController")).when("/course_discussion/:id",s("course_discussion.html","DiscussionController")).when("/journal_for_message/:id",s("jour_message_detail.html","JournalsController")).when("/blog_comment/:id",s("blog_detail.html","BlogController")).when("/add_class",s("add_class.html","AddClassController")).when("/myclass",s("myclass.html","MyClassController")).otherwise({redirectTo:"/activites"}),o.interceptors.push(["$q","$rootScope",function(e,o){return void 0==o.activeCalls&&(o.activeCalls=0),{request:function(e){return o.activeCalls+=1,e},requestError:function(e){return o.activeCalls-=1,e},response:function(e){return o.activeCalls-=1,e},responseError:function(e){return o.activeCalls-=1,e}}}])}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/activity.js b/public/javascripts/wechat/controllers/activity.js new file mode 100644 index 000000000..73bd09f26 --- /dev/null +++ b/public/javascripts/wechat/controllers/activity.js @@ -0,0 +1,62 @@ + +app.controller('ActivityController', + ['$anchorScroll', '$location','$scope', '$http', '$timeout', 'auth', 'rms', 'common','alertService', + function($anchorScroll, $location,$scope, $http, $timeout, auth, rms, common, alertService){ + $scope.replaceUrl = function(url){ + return url; + }; + + $scope.alertService = alertService.create(); + console.log("ActivityController load"); + + $scope.page = rms.get('page') || 0; + $scope.activities = rms.get("activities") || []; + $scope.has_more = rms.get("has_more"); + + $scope.loadActData = function(page){ + + $scope.page = page; + $http({ + method: 'POST', + url: apiUrl+ "activities", + data: {token: auth.token(), page: page} + }).then(function successCallback(response) { + if(response.data.page >0) { + $scope.activities = $scope.activities.concat(response.data.data); + } else { + $scope.activities = response.data.data; + } + + rms.save("activities", $scope.activities); + $scope.has_more = (response.data.count + response.data.page * 10) < response.data.all_count; + rms.save('has_more', $scope.has_more); + rms.save('page', response.data.page); + + console.log(response.data); + + }, function errorCallback(response) { + }); + }; + + if($scope.activities.length<=0){ + $scope.loadActData(0); + } else { + $timeout(function(){ + window.scrollTo(0, rms.get("yoffset")); + }); + } + + //跳到详情页 + $scope.goDetail = function(type, act_id,id){ + rms.save("yoffset", window.document.body.scrollTop); + $location.path('/'+type+'/'+act_id); + } + + $scope.addPraise = function(act){ + common.addCommonPraise(act); + }; + + $scope.decreasePraise = function(act){ + common.decreaseCommonPraise(act); + }; +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/add_class.js b/public/javascripts/wechat/controllers/add_class.js new file mode 100644 index 000000000..099bb8e8e --- /dev/null +++ b/public/javascripts/wechat/controllers/add_class.js @@ -0,0 +1,4 @@ + +app.controller('AddClassController', ['$scope',function($scope){ + +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/blog.js b/public/javascripts/wechat/controllers/blog.js new file mode 100644 index 000000000..4c2403944 --- /dev/null +++ b/public/javascripts/wechat/controllers/blog.js @@ -0,0 +1,16 @@ +app.controller('BlogController', + ['$scope', '$http', '$routeParams', 'auth', 'common', + function($scope, $http, $routeParams, auth, common){ + + common.init({ + id: $routeParams.id, + scope: $scope, + type: 'blog_comments', + replyType: 'BlogComment', + loadCallback: function(data){ + $scope.blog = data.data; + }, + replyCallback: function(){ + } + }); +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/course_notice.js b/public/javascripts/wechat/controllers/course_notice.js new file mode 100644 index 000000000..77d2e6ab0 --- /dev/null +++ b/public/javascripts/wechat/controllers/course_notice.js @@ -0,0 +1,16 @@ +app.controller('CourseNoticeController', ['$scope', '$http', '$routeParams', 'auth', 'common', + function($scope, $http, $routeParams, auth, common){ + + common.init({ + id: $routeParams.id, + scope: $scope, + type: 'newss', + replyType: 'News', + loadCallback: function(data){ + $scope.news = data.data; + }, + replyCallback: function(){ + } + }); + +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/discussion.js b/public/javascripts/wechat/controllers/discussion.js new file mode 100644 index 000000000..7e0811a0d --- /dev/null +++ b/public/javascripts/wechat/controllers/discussion.js @@ -0,0 +1,14 @@ + +app.controller('DiscussionController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){ + common.init({ + id: $routeParams.id, + scope: $scope, + type: 'messages', + replyType: 'Message', + loadCallback: function(data){ + $scope.discussion = data.data; + }, + replyCallback: function(){ + } + }); +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/homework.js b/public/javascripts/wechat/controllers/homework.js new file mode 100644 index 000000000..58f70db5a --- /dev/null +++ b/public/javascripts/wechat/controllers/homework.js @@ -0,0 +1,16 @@ + +app.controller('HomeworkController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){ + common.init({ + id: $routeParams.id, + scope: $scope, + type: 'whomeworks', + replyType: 'HomeworkCommon', + loadCallback: function(data){ + console.log(data); + $scope.homework = data.data; + }, + replyCallback: function(){ + } + }); + +}]); diff --git a/public/javascripts/wechat/controllers/invite_code.js b/public/javascripts/wechat/controllers/invite_code.js new file mode 100644 index 000000000..1b92f592c --- /dev/null +++ b/public/javascripts/wechat/controllers/invite_code.js @@ -0,0 +1,34 @@ +/** + * Created by guange on 16/6/22. + */ + + +app.controller('InviteCodeController', ['$scope','$http', '$routeParams','config','auth', function($scope, $http, $routeParams, config, auth){ + var vm = $scope; + + vm.course = {}; + var courseid = $routeParams.id; + $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( + function(response){ + console.log(response.data); + vm.course = response.data.data; + } + ); + + vm.share = function(){ + window.WeixinJSBridge.invoke('sendAppMessage',{ + 'appid': 'wxf694495398c7d470', // 公众号appID + 'type': 'link', // 非必填,music,vido或link,默认为link。 + 'data_url': '', // 非必填,连接地址,如音乐的mp3数据地址,供内置播放器使用 + 'img_url': 'http://pnewsapp.tc.qq.com/newsapp_bt/0/9963967/640', // 缩略图地址 + 'img_height':370, // 缩略图高度 + 'img_width':550, // 缩略图宽度 + 'link':'http://view.inews.qq.com/a/WXN2013101101385701', // 链接地址 + 'desc':'desc', // 描述 + 'title':'title' // 标题 + },function(res){ + //alert(res.err_msg); + }); + } + +}]); diff --git a/public/javascripts/wechat/controllers/issue.js b/public/javascripts/wechat/controllers/issue.js new file mode 100644 index 000000000..ae0cc4450 --- /dev/null +++ b/public/javascripts/wechat/controllers/issue.js @@ -0,0 +1,15 @@ +app.controller('IssueController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){ + + common.init({ + id: $routeParams.id, + scope: $scope, + type: 'issues', + replyType: 'Issue', + loadCallback: function(data){ + console.log(data); + $scope.issue = data.data; + }, + replyCallback: function(){ + } + }); +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/journals.js b/public/javascripts/wechat/controllers/journals.js new file mode 100644 index 000000000..76b4f8cf6 --- /dev/null +++ b/public/javascripts/wechat/controllers/journals.js @@ -0,0 +1,13 @@ +app.controller('JournalsController', ['$scope', '$http', '$routeParams', 'auth', 'common', function($scope, $http, $routeParams, auth, common){ + common.init({ + id: $routeParams.id, + scope: $scope, + type: 'journal_for_messages', + replyType: 'JournalsForMessage', + loadCallback: function(data){ + $scope.message = data.data; + }, + replyCallback: function(){ + } + }); +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/login.js b/public/javascripts/wechat/controllers/login.js new file mode 100644 index 000000000..1dbf804ed --- /dev/null +++ b/public/javascripts/wechat/controllers/login.js @@ -0,0 +1,53 @@ +app.controller('LoginController', ['$scope', '$http', '$location', '$routeParams', 'alertService', 'config','auth','session', + function ($scope, $http, $location, $routeParams, alertService, config, auth,session) { + if(auth.get_bind().then(function(){ + $location.path("/activities"); + })); + + if($routeParams.code){ + session.save('code', $routeParams.code); + } + + var vm = $scope; + vm.loginFailed = false; + vm.alertService = alertService.create(); + vm.findPwdDialog = alertService.create(); + + vm.login = function (frm, user) { + frm.$setSubmitted(); + console.log(user); + + if (!frm.$valid) { + console.log(frm.$error); + return; + } + + console.log(apiUrl + "auth"); + + $http.post( + config.apiUrl + "users/wxbind", + {login: user.login, password: user.password} + ).then( + function(response) { + console.log(response.data); + vm.loginFailed = (response.data.status != 0); + if (!$scope.loginFailed) { //绑定成功 + vm.alertService.showMessage('提示', response.data.message, function(){ + $location.path("/activities"); + }); + } else { + vm.alertService.showMessage('出错了', response.data.message); + } + } + ).catch(function(e){ + vm.alertService.showMessage('出错了', e); + }); + }; + + vm.showBox = function () { + vm.findPwdDialog.showMessage("提示", "请访问www.trustie.net获取密码,谢谢!"); + } + vm.goReg = function () { + $location.path('/reg'); + } + }]); diff --git a/public/javascripts/wechat/controllers/myclass.js b/public/javascripts/wechat/controllers/myclass.js new file mode 100644 index 000000000..b689e0f55 --- /dev/null +++ b/public/javascripts/wechat/controllers/myclass.js @@ -0,0 +1,54 @@ +app.controller('MyClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams', function($scope, config, $http, auth, $location, $routeParams){ + + var vm = $scope; + var courseid = $routeParams.id; + + vm.currentTab = 1; + vm.tab = function(index){ + vm.currentTab = index; + vm.searchText = ''; + console.log(vm.currentTab); + if(index == 2){ + if(vm.students.length<=0){ + $http.get(config.apiUrl + 'courses/students?token='+auth.token()+'&course_id='+courseid).then( + function(response) { + console.log(response.data); + vm.students = response.data.data; + } + ) + } + } + } + vm.course = {}; + vm.students = []; + vm.teachers = []; + vm.resources = []; + + vm.invite = function(){ + $location.path("/invite_code").search({id: courseid}); + }; + + $http.post(config.apiUrl + "courses/"+courseid+"/attachments", + {token: auth.token(), name: ''} + ).then(function(response){ + vm.resources = response.data.data; + }); + + $http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then( + function(response){ + console.log(response.data); + vm.course = response.data.data; + } + ); + + + if(vm.teachers.length<=0){ + $http.get(config.apiUrl + 'courses/teachers?token='+auth.token()+'&course_id='+courseid).then( + function(response) { + console.log(response.data); + vm.teachers = response.data.data; + } + ) + } + +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/reg.js b/public/javascripts/wechat/controllers/reg.js new file mode 100644 index 000000000..dfa010ad7 --- /dev/null +++ b/public/javascripts/wechat/controllers/reg.js @@ -0,0 +1,42 @@ +app.controller('RegController', ['$scope', '$http', '$location', 'alertService', + function ($scope, $http, $location, alertService) { + + var vm = $scope; + vm.errDialog = alertService.create(); + + vm.goLogin = function () { + $location.path("/login"); + } + + vm.isagreed = true; + vm.agreed = function (_isagreed) { + vm.isagreed = !_isagreed; + }; + + vm.reg = function (frm, user) { + + frm.$setSubmitted(); + + console.log(frm); + if (!frm.$valid) { + console.log(frm.$error); + return; + } + + console.log(user); + + $http.post( + apiUrl + "users", + {login: user.username, password: user.password, mail: user.email} + ).then(function (response) { + if (response.data.status != 0) { + vm.errDialog.showMessage('出错了',response.data.message); + } else { + vm.errDialog.showMessage("提示","注册且绑定微信成功"); + } + }, function (response) { + vm.errDialo.showMessage('出错了',response.data); + }); + } + + }]); \ No newline at end of file diff --git a/public/javascripts/wechat/course_discussion.js b/public/javascripts/wechat/course_discussion.js deleted file mode 100644 index e01b6b451..000000000 --- a/public/javascripts/wechat/course_discussion.js +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Created by root on 4/1/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setReplyTemplate = function(data){ - console.log(data); - var html=bt('t:c-message-detail-reply',{reply: data}); - $('#all_course_message_reply').prepend(html); - }; - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:course-discussion',{discussion: data}); - $('#c-discussion-container').prepend(html); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - /*$('post-interactive-praise').click(function(){ - praiseClick(); - });*/ - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'messages/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var homeworkUrl = window.location.search; - var homeworkID = homeworkUrl.split("=")[1]; - - loadDataFromServer(homeworkID); - - //点击回复按钮,插入回复内容 - var replyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - //将用户输入内容插入最后一条回复 - /*$(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date());*/ - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - //获取并传送回复用户数据 - var userInfo = { - "Type" : "Message", - "Content" : postInput - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - setReplyTemplate(data.data); - alert("6"); - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }); - } - - } - - /*//点赞效果 - var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - }*/ - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/course_notice.js b/public/javascripts/wechat/course_notice.js deleted file mode 100644 index 546aac385..000000000 --- a/public/javascripts/wechat/course_notice.js +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Created by root on 4/1/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setReplyTemplate = function(data){ - console.log(data); - var html=bt('t:news-detail-reply',{reply: data}); - $('#all_news_reply').prepend(html); - }; - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:course-notice',{course: data}); - $('#c-notice-container').prepend(html); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - /*$('post-interactive-praise').click(function(){ - praiseClick(); - });*/ - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'newss/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var homeworkUrl = window.location.search; - var homeworkID = homeworkUrl.split("=")[1]; - - loadDataFromServer(homeworkID); - - //点击回复按钮,插入回复内容 - var replyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - //将用户输入内容插入最后一条回复 - /*$(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date());*/ - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - //获取并传送回复用户数据 - var userInfo = { - "type" : "News", - "content" : postInput - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - setReplyTemplate(data.data); - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }); - } - - } - - //点赞效果 - var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - } - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/directives/alert.js b/public/javascripts/wechat/directives/alert.js new file mode 100644 index 000000000..f53ecdb5a --- /dev/null +++ b/public/javascripts/wechat/directives/alert.js @@ -0,0 +1,19 @@ +app.directive('myAlert', ['config', function(config){ + return { + templateUrl: config.rootPath+ 'templates/alert.html', + scope: { + title: "=", + message: "=", + visible: "=", + cb: "=" + }, + link: function(scope){ + scope.dismiss = function(){ + scope.visible = false; + if(typeof scope.cb === 'function'){ + scope.cb(); + } + }; + } + } +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/directives/form_validate.js b/public/javascripts/wechat/directives/form_validate.js new file mode 100644 index 000000000..553560c56 --- /dev/null +++ b/public/javascripts/wechat/directives/form_validate.js @@ -0,0 +1,10 @@ +app.directive('pwdconfirm', function(){ + return { + require: 'ngModel', + link: function(scope, elm, attrs, ctrl){ + ctrl.$validators.pwdconfirm = function(modelValue, viewValue) { + return scope.user && scope.user.password == viewValue; + } + } + } +}); \ No newline at end of file diff --git a/public/javascripts/wechat/directives/input_auto.js b/public/javascripts/wechat/directives/input_auto.js new file mode 100644 index 000000000..bcb44141e --- /dev/null +++ b/public/javascripts/wechat/directives/input_auto.js @@ -0,0 +1,19 @@ +app.directive('inputAuto',function(){ + return{ + restrict: 'A', + scope: {}, + link: function(scope, element){ + var copyContainer = element.parent().children().eq(0); + var sendButton = element.parent().next(); + element.on('input',function(){ + console.log(sendButton); + copyContainer.html(element[0].value); + var textHeight = copyContainer[0].scrollHeight; + element.css('height', textHeight + 'px'); + }); + sendButton.on('click',function(){ + element.css('height','28px'); + }); + } + } +}); \ No newline at end of file diff --git a/public/javascripts/wechat/directives/loading_spinner.js b/public/javascripts/wechat/directives/loading_spinner.js new file mode 100644 index 000000000..780056828 --- /dev/null +++ b/public/javascripts/wechat/directives/loading_spinner.js @@ -0,0 +1,7 @@ +app.directive('loadingSpinner', ['$http', function ($http) { + return { + restrict: 'A', + replace: true, + template: '
    加载中...
    ', + }; +}]); diff --git a/public/javascripts/wechat/gulpfile.js b/public/javascripts/wechat/gulpfile.js index 439b6ae5d..ea0649376 100644 --- a/public/javascripts/wechat/gulpfile.js +++ b/public/javascripts/wechat/gulpfile.js @@ -8,3 +8,10 @@ gulp.task('minify', function () { .pipe(concat('angular.all.min.js')) .pipe(gulp.dest('build')) }); + +gulp.task("default", function(){ + gulp.src(['app.js','others/factory.js','others/filter.js', 'controllers/*.js', 'directives/*.js', 'others/routes.js']) + .pipe(uglify()) + .pipe(concat('app.min.js')) + .pipe(gulp.dest('build')) +}); diff --git a/public/javascripts/wechat/homework_detail.js b/public/javascripts/wechat/homework_detail.js deleted file mode 100644 index 166ed20bf..000000000 --- a/public/javascripts/wechat/homework_detail.js +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Created by root on 3/31/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setReplyTemplate = function(data){ - console.log(data); - var html=bt('t:homework-detail-reply',{reply: data}); - $('#all_homework_reply').prepend(html); - }; - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:homework-detail',{homework: data}); - $('#homework-container').prepend(html); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - /*$('post-interactive-praise').click(function(){ - praiseClick(); - });*/ - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'whomeworks/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var homeworkUrl = window.location.search; - var homeworkID = homeworkUrl.split("=")[1]; - - loadDataFromServer(homeworkID); - - //点击回复按钮,插入回复内容 - var replyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - /*//将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date());*/ - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - getOpenId(function(openid) { - //获取并传送回复用户数据 - var userInfo = { - "type": "HomeworkCommon", - "content": postInput, - openid: openid - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - setReplyTemplate(data.data); - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }) - }); - } - - }; - - //点赞效果 - /*var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - };*/ - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/issue_detail.js b/public/javascripts/wechat/issue_detail.js deleted file mode 100644 index 2b2766d29..000000000 --- a/public/javascripts/wechat/issue_detail.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Created by root on 4/1/16. - */ -/** - * Created by root on 3/31/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setReplyTemplate = function(data){ - console.log(data); - var html=bt('t:issue-detail-reply',{issue_reply: data}); - $('#all_issue_reply').prepend(html); - }; - - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:issue-detail',{issues: data}); - $('#issue-container').prepend(html); - $('.post-reply-submit').click(function(){ - IssueReplyInsert(); - }); - /*$('post-interactive-praise').click(function(){ - praiseClick(); - });*/ - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'issues/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var IssueUrl = window.location.search; - var IssueID = IssueUrl.split("=")[1]; - - loadDataFromServer(IssueID); - - //点击回复按钮,插入回复内容 - var IssueReplyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - //将用户输入内容插入最后一条回复 - /*$(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date());*/ - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - getOpenId(function(openid) { - //获取并传送回复用户数据 - var userInfo = { - "type": "Issue", - "content": postInput, - openid: openid, - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: apiUrl + 'new_comment/' + IssueID, //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - setReplyTemplate(data.data); - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }) - }); - } - - }; - - //点赞效果 - /*var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - };*/ - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/message_detail.js b/public/javascripts/wechat/message_detail.js deleted file mode 100644 index 279da05d9..000000000 --- a/public/javascripts/wechat/message_detail.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Created by root on 4/1/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:message-detail',{message: data}); - $('#message-container').prepend(html); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - $('post-interactive-praise').click(function(){ - praiseClick(); - }); - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'journal_for_messages/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var homeworkUrl = window.location.search; - var homeworkID = homeworkUrl.split("=")[1]; - - loadDataFromServer(homeworkID); - - //点击回复按钮,插入回复内容 - var replyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - //将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date()); - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - //获取并传送回复用户数据 - var userInfo = { - "replyType" : "homework_assignment", - "replyContent" : postInput - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: "前台地址/后台方法", //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - alert(data.d); //用data.d来获取后台传过来的json语句,或者是单纯的语句 - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }); - } - - } - - //点赞效果 - var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - } - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js new file mode 100644 index 000000000..6acf25c59 --- /dev/null +++ b/public/javascripts/wechat/others/factory.js @@ -0,0 +1,182 @@ +app.factory('alertService', function(){ + function Alert(){ + this.title = null; + this.message = null; + this.visible = null; + this.cb = null; + } + + Alert.prototype.showMessage = function(title, msg, cb){ + this.message = msg; + this.title = title; + this.visible = true; + this.cb = cb; + } + + Alert.prototype.dismiss = function(){ + this.message = null; + this.title = null; + this.visible = false; + if(this.cb) {this.cb();} + } + + return { + create: function(){ + return new Alert(); + } + } +}); + + +app.factory('auth', ['$http','$routeParams', '$q', 'session', 'config',function($http,$routeParams, $q, session,config){ + //是否已经绑定 + var isBind = function(){ + var defer = $q.defer(); + + var token = getToken(); + if(token && token.length>10){ + defer.resolve(token); + } else { + var code = window.g_code || $routeParams.code || session.get("code"); + $http.post( + '/wechat/get_bind', + {} ///不用传code了,都由服务器来处理 + ).then(function(response){ + if(response.data.status!=0){ + defer.reject(response.data.message); + }else { + session.save("token", response.data.token); + defer.resolve(response.data.token); + } + }).catch(function(e){ + defer.reject(e); + }); + } + + return defer.promise; + } + + var getToken = function(){ + return session.get("token"); + } + return {get_bind: isBind, token: getToken}; +}]); + +app.factory("session", function(){ + return { + save: function(key,value){ + sessionStorage.setItem(key,value); + }, + get: function(key){ + return sessionStorage.getItem(key); + } + } +}); + +app.factory('rms', function(){ + var _saveStorage = {}; + var save = function(key, value){ + _saveStorage[key] = value; + }; + + var get = function(key){ + return _saveStorage[key]; + }; + + return {save: save, get: get}; +}); + +app.factory('common', ['$http', 'auth', '$routeParams', function($http, auth, $routeParams){ + var addCommonReply = function(id, type, data, cb){ + + if(!data.comment || data.comment.length<=0){ + return; + } + + var temp = data.comment.replace(/\n/g,'
    '); + + var userInfo = { + type: type, + content: temp, + token: auth.token() + }; + //回复按钮禁用 + data.disabled = true; + + $http({ + method: 'POST', + url: apiUrl+ "new_comment/"+id, + data: userInfo + }).then(function successCallback(response) { + //alert("提交成功"); + //数据提交完成,回复按钮启用 + data.disabled = false; + if(typeof cb === 'function'){ + cb(); + } + }, function errorCallback(response) { + }); + }; + + var loadCommonData = function(id, type){ + return $http({ + method: 'GET', + url: apiUrl+ type + "/" + id+"?token="+auth.token() + }) + }; + + var addCommonPraise = function(act){ + act.praise_count += 1; + act.has_praise = true; + + $http({ + method: 'POST', + url: apiUrl + "praise/" + act.act_id, + data:{token:auth.token(),type:act.act_type} + }).then(function successCallback(response) { + console.log(response.data); + }, function errorCallback(response) { + }); + + }; + + var decreaseCommonPraise = function(act){ + act.praise_count -= 1; + act.has_praise = false; + + $http({ + method: 'POST', + url: apiUrl + "praise/" + act.act_id, + data:{token:auth.token(),type:act.act_type} + }).then(function successCallback(response) { + console.log(response.data); + }, function errorCallback(response) { + }); + }; + + var init = function(args){ + args.scope.formData = {comment: ''}; + var loadData = function(id){ + loadCommonData(id, args.type).then(function successCallback(response) { + args.loadCallback(response.data); + }, function errorCallback(response) { + }); + }; + + loadData(args.id); + args.scope.addReply = function(data){ + console.log(data.comment); + addCommonReply(args.id, args.replyType, data, function(){ + args.scope.formData = {comment: ''}; + loadData(args.id); + if(typeof args.replyCallback === 'function'){ + args.replyCallback(); + } + }); + }; + args.scope.addPraise = addCommonPraise; + args.scope.decreasePraise = decreaseCommonPraise; + } + + return {init: init, addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise}; +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/others/filter.js b/public/javascripts/wechat/others/filter.js new file mode 100644 index 000000000..96007958d --- /dev/null +++ b/public/javascripts/wechat/others/filter.js @@ -0,0 +1,14 @@ +app.filter('safeHtml', ['$sce',function ($sce) { + return function (input) { + return $sce.trustAsHtml(input); + } +}]); + +app.filter('identify', function () { + return function(input){ + if (input == 'TeachingAsistant'){ + return '教辅' + } + return ''; + } +}) \ No newline at end of file diff --git a/public/javascripts/wechat/others/routes.js b/public/javascripts/wechat/others/routes.js new file mode 100644 index 000000000..3fa7ca6df --- /dev/null +++ b/public/javascripts/wechat/others/routes.js @@ -0,0 +1,65 @@ +app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', function ($routeProvider, $httpProvider, $locationProvider, config) { + var rootPath = config.rootPath; + var resolve = { + delay: ['auth',function(auth){ + return auth.get_bind(); + }] + }; + var makeRoute = function(path, ctrl){ + return { + templateUrl: rootPath + path, + controller: ctrl, + resolve: resolve + } + } + //$locationProvider.html5Mode(true); + $routeProvider + .when('/login', { + templateUrl: rootPath + 'login.html', + controller: 'LoginController' + }) + .when('/reg', { + templateUrl: rootPath + 'reg.html', + controller: 'RegController' + }) + .when('/activites', makeRoute('activities.html', 'ActivityController')) + .when('/issues/:id', makeRoute('issue_detail.html', 'IssueController')) + .when('/project_discussion/:id', makeRoute('project_discussion.html', 'DiscussionController')) + .when('/homework/:id', makeRoute('homework_detail.html', 'HomeworkController')) + .when('/course_notice/:id', makeRoute('course_notice.html', 'CourseNoticeController')) + .when('/course_discussion/:id', makeRoute('course_discussion.html', 'DiscussionController')) + .when('/journal_for_message/:id', makeRoute('jour_message_detail.html', 'JournalsController')) + .when('/blog_comment/:id', makeRoute('blog_detail.html', 'BlogController')) + .when('/add_class', makeRoute('add_class.html', 'AddClassController')) + .when('/myclass', makeRoute('myclass.html', 'MyClassController')) + .when('/invite_code', makeRoute('invite_code.html', 'InviteCodeController')) + .otherwise({ + redirectTo: '/activites' + }); + + //监听异步请求,实现加载中显隐标记 + $httpProvider.interceptors.push(['$q', '$rootScope', function ($q, $rootScope) { + if ($rootScope.activeCalls == undefined) { + $rootScope.activeCalls = 0; + } + + return { + request: function (config) { + $rootScope.activeCalls += 1; + return config; + }, + requestError: function (rejection) { + $rootScope.activeCalls -= 1; + return rejection; + }, + response: function (response) { + $rootScope.activeCalls -= 1; + return response; + }, + responseError: function (rejection) { + $rootScope.activeCalls -= 1; + return rejection; + } + }; + }]); +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/project_discussion.js b/public/javascripts/wechat/project_discussion.js deleted file mode 100644 index 94cdcea10..000000000 --- a/public/javascripts/wechat/project_discussion.js +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Created by root on 4/1/16. - */ -/** - * Created by root on 4/1/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - - var apiUrl = '/api/v1/'; - - var setReplyTemplate = function(data){ - console.log(data); - var html=bt('t:homework-detail-reply',{reply: data}); - $('#all_homework_reply').prepend(html); - }; - - - var setTemplate = function(data){ - console.log(data); - var html=bt('t:project-discussion',{discussion: data}); - $('#p-discussion-container').prepend(html); - $('.post-reply-submit').click(function(){ - replyInsert(); - }); - /*$('post-interactive-praise').click(function(){ - praiseClick(); - });*/ - }; - - var loadDataFromServer = function(id){ - //getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'messages/' + id, - dataType: 'json', - success: function(data){ - setTemplate(data.data); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - //}) - - - }; - - var homeworkUrl = window.location.search; - var homeworkID = homeworkUrl.split("=")[1]; - - loadDataFromServer(homeworkID); - - //点击回复按钮,插入回复内容 - var replyInsert = function(){ - var replyContent = $("#postInput").val(); - if (!replyContent){ - alert("请输入回复"); - }else{ - - /*//将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
    回复
    '); - $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date());*/ - var postInput = $("#postInput").val(); - $("#postInput").val(""); - //回复数目+1 - var replyNum = $(".post-interactive-reply").text().match(/\d+/g); - replyNum++; - $(".reply-num").text("(" + replyNum + ")"); - - //获取并传送回复用户数据 - var userInfo = { - "type" : "Message", - "content" : postInput - }; - - $.ajax({ - type: "POST", //提交方式 - dataType: "json", //类型 - url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 - data: userInfo, //参数,如果没有,可以为null - success: function (data) { //如果执行成功,那么执行此方法 - setReplyTemplate(data.data); //用data.d来获取后台传过来的json语句,或者是单纯的语句 - }, - error: function (err) { //如果执行不成功,那么执行此方法 - alert("err:" + err); - } - }); - } - - } - - //点赞效果 - /*var praiseClick = function(){ - var praiseNum = $(".post-interactive-praise").text().match(/\d+/g); - praiseNum++; - $(".praise-num").text("(" + praiseNum + ")"); - }*/ - - -}); \ No newline at end of file diff --git a/public/javascripts/wechat/wechat_dev.js b/public/javascripts/wechat/wechat_dev.js deleted file mode 100644 index 36529e0b8..000000000 --- a/public/javascripts/wechat/wechat_dev.js +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Created by root on 3/25/16. - */ -$(document).ready(function(){ - - var bt=baidu.template; - bt.LEFT_DELIMITER=''; - - var apiUrl = '/api/v1/'; - var loadDataFromServer = function(id, page){ - getOpenId(function(openid){ - $.ajax({ - url: apiUrl + 'activities', - data: {openid: openid, page: page}, - type: 'POST', - dataType: 'json', - success: function(data){ - setTemplate(data.data, data.all_count, data.count, data.page); - }, - error: function(xhr,status,err){ - console.log(err); - } - }); - }) - - }; - var setTemplate = function(data, all_count, count, page){ - console.log(data); - var html=bt('t:result-list',{activities: data, all_count: all_count, count: count, page: page}); - if (page == 0) { - $('#container').prepend(html); - } else { - $("#more_activities").remove(); - $('#container').append(html); - } - descToggle(); - }; - //内容全部显示与部分隐藏 - var descToggle = function(){ - $(".post-all-content").each(function(){ - var postHeight = $(this).height(); - if (postHeight > 90){ - $(this).parent().next().css("display","block"); - $(this).parent().next().toggle(function(){ - $(this).text("点击隐藏"); - $(this).prev().css("height",postHeight); - },function(){ - $(this).text("点击展开"); - $(this).prev().css("height",90); - }); - } - }); - } - - loadDataFromServer(8686, 0); -}); diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index ed99217b8..d0a5e7ab3 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -109,7 +109,7 @@ a.hworkSearchIcon:hover {background:url(../images/nav_icon.png) -49px -1px no-re /*20160520作品列表table*/ .hwork-table-wrap {width:720px; border-collapse:collapse; vertical-align:middle; table-layout:fixed;} -.hwork-table-wrap th {font-size:14px; color:#2d2d2d; border-bottom:1px solid #e1e1e1;} +.hwork-table-wrap th {font-size:14px; color:#2d2d2d; border-bottom:1px solid #e1e1e1; text-align:center;} /*作业信息*/ .mt-2 {margin-top:-2px;} @@ -1426,4 +1426,4 @@ a.pages-big{ width:50px;} .H60 {height:60px !important;} .W420 {width:420px;} .W300 {width:300px !important;} -.W600{ width:600px;} \ No newline at end of file +.W600{ width:600px;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 6c7bde896..74cbff5dd 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -1166,3 +1166,5 @@ a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px; /*未登录回复提示*/ .visitor-box {width:620px; height:33px; line-height:33px; text-align:center; vertical-align: middle; border:1px solid #ccc; background-color: #fff;} + +.reply_iconup{ position:absolute; top:21px; left:13px; color:#d4d4d4; font-size:16px; background:#f1f1f1; line-height:13px;} \ No newline at end of file diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 6cccb3615..955a7ab73 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -2,8 +2,10 @@ /* CSS Document */ /*基本样式*/ -body,table,input,textarea,select,button { font-family: "微软雅黑","宋体";} -h1,h2,h3,h4,h5,p,pre {padding:0px; margin:0px;} +body,table,input,textarea,select,button { font-family: "微软雅黑","宋体","Helvetica Neue", Helvetica, Arial, sans-serif;} +body, ul, h1,h2,h3,h4,h5,p,pre,input {padding:0px; margin:0px;} +body{background-color: #EFEFF4;} +ul li {list-style:none;} img {max-width:100%;} blockquote {border:1px solid #d4d4d4; padding: 0.6em; margin-left: 1.4em; margin-right: 0.4em; border-radius: 4px; font-family: "Microsoft YaHei"; background-size: 100% 100%; margin-top:5px;} .text-control {word-break:normal; word-wrap:break-word;} @@ -12,29 +14,43 @@ blockquote {border:1px solid #d4d4d4; padding: 0.6em; margin-left: 1.4em; margin .f15 {font-size:15px;} .fb {font-weight:bold;} .mt2 {margin-top:2px;} +.mt3 {margin-top:3px;} +.mt4 {margin-top:4px;} .mt5 {margin-top:5px;} .mt10 {margin-top:10px;} +.mt11 {margin-top:11px;} +.mt15 {margin-top:15px;} +.mt30 {margin-top:30px;} +.mt70 {margin-top:70px;} .mb5 {margin-bottom:5px;} .mb10 {margin-bottom:10px;} +.mb20 {margin-bottom:20px;} .ml10 {margin-left:10px;} .mr5 {margin-right:5px;} .mr10 {margin-right:10px;} .ml15 {margin-left:15px;} .mr15 {margin-right:15px;} .mr20 {margin-right:20px;} +.ml25 {margin-left:25px;} .mr25 {margin-right:25px;} .ml55 {margin-left:55px;} .mr55 {margin-right:55px;} +.c-red {color:#e81a1a;} .c-blue {color:#269ac9;} .c-grey {color:#9a9a9a;} .c-grey2 {color:#707070;} .c-grey3 {color:#555555;} +.c-grey4 {color:#888888;} +.c-grey5 {color:#aaaaaa;} +.c-grey6 {color:#777777;} +.c-blue {color:#3b94d6;} a {color:#707070;} a.c-grey {color:#707070;} a.c-grey2 {color:#9a9a9a;} a:link,a:visited{text-decoration:none;} a:hover,a:active{cursor:pointer;} a.link-blue {color:#269ac9;} +a.link-blue2 {color:#3b94d6;} a.underline {text-decoration:underline;} .border-radius {border-radius:5px;} .w36 {width:36px;} @@ -42,9 +58,23 @@ a.underline {text-decoration:underline;} .max-width-130 {max-width:130px;} .hidden {overflow:hidden; white-space:nowrap; text-overflow:ellipsis;} .inline-block {display:inline-block;} +.dis {display:block;} .undis {display:none;} .text-nowrap {white-space:nowrap;} .v-top {vertical-align:top;} +.tac {text-align:center;} +.block-center {margin-left:auto; margin-right:auto; display:block;} + +/*背景色*/ +.bg-grey {background-color:#c1c1c1 !important;} +.bg-blue {background-color:#3b94d6;} + +/*按钮样式*/ +.btn1 {width:100%; height:40px; line-height:40px; vertical-align:middle; text-align:center; color:#fff; display:block; border-radius:5px;} +.bg-blue:not(.btn-disabled):active {background-color:#2780c2;} +.btn-disabled {background-color:#ccc;} + +/*背景色*/ /*动态样式*/ .post-container {width:100%;} @@ -56,7 +86,8 @@ a.underline {text-decoration:underline;} .fl {float:left;} .fr {float:right;} .cl {clear:both; overflow:hidden;} -.post-content {width:100%; font-size:13px; line-height:18px; height:95px; overflow:hidden; word-break:break-all; word-wrap:break-word;} +.post-content {width:100%; font-size:13px; line-height:18px; height:90px; overflow:hidden; word-break:break-all; word-wrap:break-word;} +.post-all-content a {color:#136ec2;} .post-interactive {width:100%; height:35px; line-height:35px; vertical-align:middle; border-top:1px solid #e6e6e6; background-color:#f8f9fb;} .post-interactive-column, .post-interactive-reply, @@ -78,6 +109,8 @@ a.underline {text-decoration:underline;} .reply-icon {background:url(/images/wechat/icon_list.gif) -150px -155px no-repeat; width:20px; height:20px; display:inline-block; vertical-align:middle;} .praise-icon {background:url(/images/wechat/icon_list.gif) -36px -88px no-repeat; width:20px; height:20px; display:inline-block; vertical-align:middle;} .praised-icon {background:url(/images/wechat/icon_list.gif) -152px -86px no-repeat; width:20px; height:20px; display:inline-block; vertical-align:middle;} +.num-block {display:inline-block; vertical-align:top;} +.post-op-banner {height:20px; line-height:20px; vertical-align:middle;} /* loading 弹框*/ .loading-bg {position:fixed; width:100%; height:100%; left:0; top:0; z-index:99; background:rgba(206, 206, 206, 0.3); overflow:hidden;} @@ -86,6 +119,67 @@ a.underline {text-decoration:underline;} .loading-box span {display: block; font-size:12px;} /*帖子锁定样式*/ -.locked_btn_cir {background: url("/images/locked.png") 0 0 no-repeat; cursor: default;} +.locked_btn_cir {background: url("/images/wechat/locked.png") 0 0 no-repeat; cursor: default;} -.bg-grey {background-color:#c1c1c1;} +/*20150612加入班级样式*/ +.add-class-box {width:80%; max-width:300px; min-width:240px; height:150px; font-size:15px; color:#444; background-color:#fff; margin:0 auto; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); border-radius:5px; margin-top:100px;} +.add-class-tip {padding-top:20px; padding-bottom:20px;} +.class-number-input {width:80%; max-width:240px; height:28px; border:1px solid #ccc; padding-left:5px; margin:0 auto; display:block;} +.cancel-btn {width:49%; height:37px; line-height:37px; text-align:center; vertical-align:middle; border-top:1px solid #ccc;} +.submit-btn {width:49%; height:37px; line-height:37px; text-align:center; vertical-align:middle; border-top:1px solid #ccc;} +.slice {width:2%; text-align:center; border-top:1px solid #ccc;} +.slice-line {width:1px; height:37px; margin:auto; background:#ccc;} + +/*20160613邀请码样式*/ +.qr-code-wrap {width:100%; padding:40px 0; background-color:#3b94d6;} +.qr-code-box {width:225px; background-color:#fff; border-radius:3px; margin:0 auto;} +.share-class-name {font-size:18px; color:#3b3b3b; text-align:center; padding:12px; border-bottom:1px solid #cccccc;} +.qr-img-wrap {width:100%; border-bottom:1px dashed #ccc;} +.qr-code-img {margin:36px auto; display:block;} +.invitation-code-wrap {text-align:center; font-size:18px; color:#3b3b3b; padding:16px;} +.share-code-wrap {width:100%; background-color:#efeff4;} +.share-code-btn, .finish-btn {width:145px; height:35px; color:#fff; font-size:15px; line-height:35px; text-align:center; vertical-align:middle; background-color:#ff7239; margin:18px auto 20px auto; border-radius:50px; display:block;} +.share-code-instruction {max-width:228px; font-size:12px; color:#666; line-height:20px; margin:0 auto;} + +/*20160613班级详情*/ +.class-detail-name, .blue-title {width:100%; height:45px; line-height:45px; vertical-align:middle; background-color:#3b94d6; color:#fff; font-size:18px; text-align:center;} +.blue-title-sub {position:absolute; right:10px;} +.slice2 {width:2%; text-align:center; background-color:#fff; border-bottom:1px solid #ccc;} +.slice3 {width:1%; height:38px; text-align:center; background-color:#fff; border-bottom:1px solid #ccc;} +.slice-line2 {width:1px; height:38px; margin:auto; background:#ccc;} +.class-detail-tab {width:23%; height:38px; line-height:38px; font-size:13px; color:#444; background-color:#fff; float:left; text-align:center; vertical-align:middle; border-bottom:1px solid #ccc;} +.class-detail-tab2 {width:32%; height:38px; line-height:38px; font-size:13px; color:#444; background-color:#fff; float:left; text-align:center; vertical-align:middle; border-bottom:1px solid #ccc;} +.class-detail-tab3 {width:48%; height:38px; line-height:38px; font-size:13px; color:#444; background-color:#fff; float:left; text-align:center; vertical-align:middle; border-bottom:1px solid #ccc;} +.class-tab-active {border-bottom:1px solid #3b94d6;} +.class-search-wrap {padding:8px 12px; position:relative;} +.class-search-inner {padding:0 30px; background-color:#fff;} +.class-search-icon {position:absolute; top:16px; left:16px;} +.class-detail-search {width:100%; height:33px; color:#999; background-color:#fff; border:none; outline:none;} +.border-top {border-top:1px solid #ccc;} +.class-detail-row {width:100%; height:38px; line-height:38px; vertical-align:middle; border-bottom:1px solid #ccc; background-color:#fff;} +.class-test-tip {text-align:center; font-size:13px; color:#444; padding-top:40px;} +.img-circle {border-radius:50%;} +.member-banner {height:24px; line-height:24px; text-align:center; vertical-align:middle; background-color:#dfdfdf;} + +/*20160614班级列表*/ +.course-list-row {width:100%; height:38px; line-height:38px; vertical-align:middle; border-top:1px solid #ccc; border-bottom:1px solid #ccc; background-color:#fff;} +.class-list {width:100%; border-bottom:1px solid #ccc;} +.class-list li {height:40px; line-height:40px; vertical-align:middle; margin:0 25px; border-left:1px solid #ccc; border-bottom:1px solid #ccc; position:relative;} +.class-list-name {max-width:75%; display:inline-block;} +.class-list-dot {position:absolute; top:13px; left:-8px;} +.border-bottom-none {border-bottom:none !important;} +.students-amount {height:14px; line-height:14px; vertical-align:middle; padding:2px 5px; background-color:#e6e6e6; border-radius:10px;} +.new-class-btn {font-size:15px; color:#fff; background-color:#3b94d6; padding:10px 40px; border-radius:20px; display:inline-block; margin:0 auto;} +.join-class-btn {font-size:15px; color:#444; background-color:#ccc; padding:10px 40px; border-radius:20px; display:inline-block; margin:0 auto;} +.new-class-input {width:60%; color:#aaa; height:35px; line-height:35px; vertical-align:middle; border:none; outline:none;} + +/*20160616登录注册*/ +.login-wrap {padding:0 10px;} +.input-box-wrap {padding-right:17px;} +.input-box { -webkit-appearance: none; font-size: 16px;width:100%; height:16px; padding: 10px 0px 10px 5px; line-height:16px; border:1px solid #ccc; border-radius:5px;} +.login-op-wrap {height:30px; line-height:30px; vertical-align:middle;} +.login-box{display:inline-block; width:14px; height:14px; line-height:14px; text-align:center; vertical-align:middle; border:1px solid #ccc; background:#fff; border-radius:3px; color:#fff; cursor:pointer;} +.login-box.checked{background:#63c360;} +.login-box.checked:after{content:url(/images/wechat/checked.png);} +.forget-psw-wrap {width:60px; margin:0 auto;} +.forget-psw {position:fixed; bottom:10px;} diff --git a/script/assets b/script/assets new file mode 100644 index 000000000..bf4501127 --- /dev/null +++ b/script/assets @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +cd public/javascripts/wechat && gulp && gulp minify