加入项目邀请码
This commit is contained in:
parent
f3ae53dc97
commit
f0cf7adcdf
|
@ -167,12 +167,12 @@ module Mobile
|
|||
post "join" do
|
||||
authenticate!
|
||||
|
||||
# ps = ProjectsService.new
|
||||
# status = ps.join_project({role: "5", openid: params[:openid], invite_code: params[:invite_code]}, current_user)
|
||||
#
|
||||
# present :status, status
|
||||
ps = ProjectsService.new
|
||||
status = ps.join_project({role: "5", openid: params[:openid], invite_code: params[:invite_code]}, current_user)
|
||||
|
||||
{status:-1, message: '该功能将在近日开放,敬请期待!' }
|
||||
{status:status, message:ProjectsService::JoinProjectError.message(status)}
|
||||
|
||||
# {status:-1, message: '该功能将在近日开放,敬请期待!' }
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -4,8 +4,8 @@ module Mobile
|
|||
expose :name
|
||||
expose :id
|
||||
expose :user_id
|
||||
# expose :invite_code
|
||||
# expose :qrcode
|
||||
expose :invite_code
|
||||
expose :qrcode
|
||||
expose :can_setting, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
current_user = options[:user]
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ class WechatsController < ActionController::Base
|
|||
#邀请码
|
||||
if join_class_request(request)
|
||||
sendBindClass(request, {invite_code: content})
|
||||
# elsif join_project_request(request)
|
||||
# sendBindProject(request, {invite_code: content})
|
||||
elsif join_project_request(request)
|
||||
sendBindProject(request, {invite_code: content})
|
||||
else
|
||||
request.reply.text "您的意见已收到,非常感谢~ \n更多问题可以通过以下方式联系我们:\n官方QQ群:173184401\n我们会认真聆听您的意见和建议。"
|
||||
end
|
||||
|
@ -284,7 +284,7 @@ class WechatsController < ActionController::Base
|
|||
content: "项目名称:#{project.name}\n发起人:#{creator.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#/project?id='+project.id.to_s}&response_type=code&scope=snsapi_base&state=myproject#wechat_redirect"
|
||||
pic_url = "#{ROOT_URL}/images/wechat/class.jpg"
|
||||
pic_url = "#{ROOT_URL}/images/wechat/project.jpg"
|
||||
article.item title: "#{n[:title]}",
|
||||
description: n[:content],
|
||||
pic_url: pic_url,
|
||||
|
|
|
@ -928,6 +928,18 @@ class Project < ActiveRecord::Base
|
|||
code
|
||||
end
|
||||
|
||||
def generate_qrcode
|
||||
ticket = self.qrcode
|
||||
if !ticket || ticket.size < 10
|
||||
response = Wechat.api.qrcode_create_scene(invite_code, 2592000)
|
||||
logger.debug "response = #{response}"
|
||||
self.qrcode = response['ticket']
|
||||
save! && reload
|
||||
ticket = qrcode
|
||||
end
|
||||
ticket
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def after_parent_changed(parent_was)
|
||||
|
|
|
@ -114,7 +114,7 @@ class ProjectsService
|
|||
|
||||
def join_project params,current_user
|
||||
status = -1
|
||||
project = project.find_by_invite_code(params[:invite_code]) if params[:invite_code]
|
||||
project = Project.find_by_invite_code(params[:invite_code]) if params[:invite_code]
|
||||
|
||||
if project
|
||||
if project[:is_delete] == 1
|
||||
|
@ -126,10 +126,18 @@ class ProjectsService
|
|||
else
|
||||
if params[:invite_code].present?
|
||||
members = []
|
||||
members << Member.new(:role_ids => [5], :user_id => current_user.id)
|
||||
user_grades = []
|
||||
project_info = []
|
||||
|
||||
user_grades << UserGrade.new(:user_id => current_user.id, :project_id => project.id)
|
||||
project.user_grades << user_grades unless user_grades.first.user_id.nil?
|
||||
|
||||
members << Member.new(:role_ids => ["5"], :user_id => current_user.id)
|
||||
project.members << members
|
||||
projectInfo = ProjectInfo.new(:user_id => current_user.id, :project_id => project.id)
|
||||
projectInfo.save
|
||||
|
||||
projectInfo << ProjectInfo.new(:user_id => current_user.id, :project_id => project.id)
|
||||
project.project_infos << project_info
|
||||
|
||||
status = 0
|
||||
else
|
||||
status = 4
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 126 KiB |
|
@ -25,10 +25,10 @@ app.controller('ProjectController', ['$scope', 'config','$http','$timeout', 'aut
|
|||
|
||||
//跳入邀请界面
|
||||
vm.invite = function(){
|
||||
vm.alertService.showMessage('提示', "该功能将在近日开放,敬请期待!");
|
||||
// vm.alertService.showMessage('提示', "该功能将在近日开放,敬请期待!");
|
||||
|
||||
|
||||
// $location.path("/project_invite_code").search({id: projectid});
|
||||
$location.path("/project_invite_code").search({id: projectid});
|
||||
};
|
||||
|
||||
//获取项目动态
|
||||
|
|
|
@ -45,29 +45,29 @@ app.controller('ProjectListController', ['$scope', 'config', 'auth', '$http', '$
|
|||
};
|
||||
|
||||
vm.joinProject = function () {
|
||||
vm.alertService_1.showMessage('提示', "该功能将在近日开放,敬请期待!");
|
||||
// vm.alertService_1.showMessage('提示', "该功能将在近日开放,敬请期待!");
|
||||
|
||||
// vm.alertService_3.showMessage('提示', '请输入6位项目邀请码(不区分大小写)', function(){
|
||||
// if (vm.alertService_3.invite && vm.alertService_3.invite.length == 6) {
|
||||
// $http.post(config.apiUrl + "projects/join", {
|
||||
// token: auth.token(),
|
||||
// invite_code: vm.alertService_3.invite
|
||||
// }).then(function (response) {
|
||||
// console.log(response.data);
|
||||
// if (response.data.status != 0) {
|
||||
// vm.alertService_1.showMessage('提示', response.data.message);
|
||||
// } else {
|
||||
// vm.alertService_1.showMessage('提示', '加入项目成功');
|
||||
// vm.alertService_3.invite = "";
|
||||
// loadProjectList();
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// if(vm.alertService_3.invite){
|
||||
// vm.alertService_1.showMessage('提示', '邀请码格式不正确');
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
vm.alertService_3.showMessage('提示', '请输入6位项目邀请码(不区分大小写)', function(){
|
||||
if (vm.alertService_3.invite && vm.alertService_3.invite.length == 6) {
|
||||
$http.post(config.apiUrl + "projects/join", {
|
||||
token: auth.token(),
|
||||
invite_code: vm.alertService_3.invite
|
||||
}).then(function (response) {
|
||||
console.log(response.data);
|
||||
if (response.data.status != 0) {
|
||||
vm.alertService_1.showMessage('提示', response.data.message);
|
||||
} else {
|
||||
vm.alertService_1.showMessage('提示', '加入项目成功');
|
||||
vm.alertService_3.invite = "";
|
||||
loadProjectList();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if(vm.alertService_3.invite){
|
||||
vm.alertService_1.showMessage('提示', '邀请码格式不正确');
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
vm.onSetting = function (project) {
|
||||
|
|
Loading…
Reference in New Issue