diff --git a/Gemfile b/Gemfile index a690b224b..d1993359e 100644 --- a/Gemfile +++ b/Gemfile @@ -28,6 +28,7 @@ gem 'ruby-ole' gem 'rails_kindeditor',path:'lib/rails_kindeditor' #gem "rmagick", ">= 2.0.0" gem 'binding_of_caller' +gem 'chinese_pinyin' group :development do gem 'grape-swagger' diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 9728ddf11..16d516f82 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -126,11 +126,13 @@ class MyController < ApplicationController end @se = @user.extensions - if params[:occupation].to_i.to_s == params[:occupation] - @se.school_id = params[:occupation] - else - @se.occupation = params[:occupation] - end + # if params[:occupation].to_i.to_s == params[:occupation] + # @se.school_id = params[:occupation] + # else + # @se.occupation = params[:occupation] + # end + @se.school_id = params[:occupation] + @se.gender = params[:gender] @se.location = params[:province] if params[:province] @se.location_city = params[:city] if params[:city] diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index 3e0c280ac..5e68dc2bd 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -105,4 +105,31 @@ class SchoolController < ApplicationController render :text => options end + + #根据学校名字或者拼音来查询 + def on_search + condition = "#{params[:name].strip}".gsub(" ","") + #将条件截断为汉字和拼音(全汉字 或者 全拼音 或者 汉字和拼音), + #获取拼音的第一次出现的位置 + chinese = [] + pinyin = [] + condition.scan(/./).each_with_index do |char,index| + if char =~ /[a-zA-Z0-9]/ + pinyin << char + else + chinese << char + end + end + if(condition == '') + @school = School.all + else + @school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").all + end + + result = [] + # @school.each do |sc| + # result << {:value=>sc.name,:data=>sc.id} + # end + render :json => @school.to_json + end end diff --git a/app/models/school.rb b/app/models/school.rb index a180eefbe..6cafb0473 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -1,5 +1,5 @@ class School < ActiveRecord::Base - attr_accessible :name, :province + attr_accessible :name, :province,:pinyin has_many :courses def to_s diff --git a/app/views/courses/_join_private_course.html.erb b/app/views/courses/_join_private_course.html.erb index 4cc8b9fbf..8e1e1c421 100644 --- a/app/views/courses/_join_private_course.html.erb +++ b/app/views/courses/_join_private_course.html.erb @@ -11,10 +11,10 @@ ul,li{ list-style-type:none} .cl{ clear:both; overflow:hidden; } a{ text-decoration:none; } - a:hover{ } + a:hover{} .alert_box {width:488px;height:550px;position:fixed;z-index:1002;left:50%;top:40%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; padding:5px; overflow:auto; } - #popbox{width:488px;height:308px;} + #popbox{width:488px;height:368px;} .alert .C{width:476px;height:296px;position:absolute;left:5px;top:5px; } .C_top{ margin-top:20px; width:368px; height:100px; background:#e9e9e9; padding:0px 60px; } .C_top h2{ color:#1c1d1d; font-size:24px; font-style:normal; font-weight:normal;} @@ -22,12 +22,15 @@ .C_form{ margin:20px 0 0 60px;} .C_form ul li{ font-size:14px; color:#3f3a39; line-height:30px; } .C_form ul li input{ margin-left:20px; border:0px; border:1px solid #e1e1e1; color:#898989; padding-left:5px; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; padding: 0 !important; } - .C_form ul li.mB5{ color:#898989; font-size:12px; padding-left:90px;} + .C_form ul li.mB5{ color:#898989; font-size:12px; padding-left:97px;} .width190{ width:190px; height:26px; border-color:#e1e1e1;} .C_form a{ font-size:12px; color:#15bccf; float:left; display:block; height:40px; width:200px; margin-top:25px;} .C_form a:hover{ text-decoration:underline;} - .C_form a.btn{ display:block; width:100px; height:36px; padding-top:4px; text-align: center; background:#15bccf; color:#fff; font-size:14px; margin:20px 20px 0 95px;} - .C_form a.btn:hover{ background:#ff821d;} + .C_form a.btn_join{ display:block; width:100px; height:36px; padding-top:4px; text-align: center; background:#269ac9; color:#fff; font-size:14px; margin:20px 20px 0 95px;} + .C_form a.btn_join:hover{ background:#297fb8; text-decoration: none;} + .C_form a.btn_cancel{ display:block; width:100px; height:36px; padding-top:4px; text-align: center; background:#c1c1c1; color:#fff; font-size:14px; margin:20px 20px 0 95px;} + .C_form a.btn_cancel:hover{ background:#717171; text-decoration: none;} + .IDType {border:1px solid #e1e1e1; outline: none; width: 65px; height: 25px;}