微信修改资料后台代码

This commit is contained in:
yuanke 2016-09-06 14:41:22 +08:00
parent 96e7d14060
commit c9c63eeb85
15 changed files with 220 additions and 51 deletions

View File

@ -313,6 +313,7 @@ module Mobile
end end
present :result, result present :result, result
present :status, status present :status, status
present :act_id, update_id
present :tip, tip present :tip, tip
present :subscribe,subscribe present :subscribe,subscribe
end end

View File

@ -221,6 +221,99 @@ module Mobile
present :data,my_jours,with:Mobile::Entities::Jours present :data,my_jours,with:Mobile::Entities::Jours
present :status,0 present :status,0
end end
desc "我的资料"
params do
requires :token, type: String
end
get 'my_userinfo' do
authenticate!
present :data, current_user, with: Mobile::Entities::User
present :status, 0
end
desc "我的资料"
params do
requires :token, type: String
requires :nickname, type: String
requires :sex, type: Integer
requires :mail, type: String
end
post 'edit_userinfo' do
authenticate!
user = current_user
status = 0
message = ""
#昵称 不能超过30个字符
if params[:nickname].length > 30 then
message = "姓名不能超过30个字符!"
status = -1
end
if params[:mail].length > 60 then
message = "邮箱地址不能超过60个字符!"
status = -1
end
if !(params[:mail].match(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i))
message = "请输入正确的邮箱地址!"
status = -1
end
if status == 0
# 修改邮箱的时候同步修改到gitlab
if user.mail != params[:mail]
g = Gitlab.client
begin
g.edit_user(user.gid, :email => params[:mail])
rescue
logger.error "sync user's email of gitlab failed!"
end
end
user.lastname = params[:nickname]
se = user.extensions
se.gender = params[:sex]
if user.save && se.save
status = 0
else
message = "保存数据失败!"
status = -1
end
end
if status == 0
present :data, current_user, with: Mobile::Entities::User
present :status, 0
else
present :status, -1
present :message, message
end
end
desc "解除绑定"
params do
requires :token, type: String
end
post 'unbind' do
authenticate!
us = UsersService.new
us.wechat_unbind uw
present :status, 0
end
end end
end end
end end

View File

@ -320,8 +320,15 @@ class UsersService
end end
def wechat_unbind uw def wechat_unbind uw
user = uw.user
#发重新绑定的微信模版消息
ws = WechatService.new
ws.rebind_notice user.id, "login", user.id, "尊敬的用户,您已解除绑定。", "个人原因",format_time(Time.now), "点击进入重新绑定"
uw.user_id = nil uw.user_id = nil
uw.delete uw.delete
end end
end end

View File

@ -445,4 +445,41 @@ class WechatService
end end
end end
def rebind_notice(user_id, type, id, first, key1, key2,remark="")
uw = UserWechat.where(user_id: user_id).first
unless uw.nil?
data = {
touser:uw.openid,
template_id:Wechat.config.rebind_notice,
url:Wechat.config.auto_openid_url_1+Wechat.config.auto_openid_url_2+"login"+Wechat.config.auto_openid_url_3,
topcolor:"#FF0000",
data:{
first: {
value:first,
color:"#707070"
},
keyword1:{
value:key1,
color:"#707070"
},
keyword2:{
value:key2,
color:"#707070"
},
remark:{
value:remark,
color:"#707070"
}
}
}
#data = three_keys_template uw.openid,Wechat.config.create_class_notice, type, id, first, key1, key2, key3, remark
begin
req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data)
rescue Exception => e
Rails.logger.error "[rebind_notice] ===> #{e}"
end
Rails.logger.info "send over. #{req}"
end
end
end end

View File

@ -26,6 +26,7 @@ default: &default
join_project_notice: "TtXvy0XMIQyCgpnXHhoB8t-x0QIfy-78gAJXsGf9afg" join_project_notice: "TtXvy0XMIQyCgpnXHhoB8t-x0QIfy-78gAJXsGf9afg"
project_issue_notice: "HP8JejOnkzmvFopTarc0l1Tp4bU9qnxzdH27x3186lI" project_issue_notice: "HP8JejOnkzmvFopTarc0l1Tp4bU9qnxzdH27x3186lI"
at_notice: "U3kqzgriCaqkPI9qX0NDQOInJ5hiwHCz6wgTsPysSx4" at_notice: "U3kqzgriCaqkPI9qX0NDQOInJ5hiwHCz6wgTsPysSx4"
rebind_notice: "OYsiECfqUlHKlzF_X-pz_xsGh_vAAUunX0jYRdHlyFU"
auto_openid_url_1: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=https://www.trustie.net/wechat/user_activities" auto_openid_url_1: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=https://www.trustie.net/wechat/user_activities"
auto_openid_url_2: "&response_type=code&scope=snsapi_base&state=" auto_openid_url_2: "&response_type=code&scope=snsapi_base&state="

View File

@ -26,6 +26,7 @@ default: &default
join_project_notice: "3KnMQEMUCmQWkB5JvzrpmguEwnN8bvUHUdpOTudxv_M" join_project_notice: "3KnMQEMUCmQWkB5JvzrpmguEwnN8bvUHUdpOTudxv_M"
project_issue_notice: "HAF2aCta7BtnaOd_cotGvU4tErGWwCd9I9aiClFN7w8" project_issue_notice: "HAF2aCta7BtnaOd_cotGvU4tErGWwCd9I9aiClFN7w8"
at_notice: "p4HfyZQuF8O5bP_44RbbJS30SGojLJAuZEqp34iB4JU" at_notice: "p4HfyZQuF8O5bP_44RbbJS30SGojLJAuZEqp34iB4JU"
rebind_notice: "B97nOiW9cscB_d078I3k0jaPLHeJThTKUuxMoUnWZ2U"
auto_openid_url_1: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities" auto_openid_url_1: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities"
auto_openid_url_2: "&response_type=code&scope=snsapi_base&state=" auto_openid_url_2: "&response_type=code&scope=snsapi_base&state="

View File

@ -79,9 +79,9 @@
<div class="cl"></div> <div class="cl"></div>
<div class="post-input-container ml40 mb10 undis"> <div class="post-input-container ml40 mb10 undis">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" ng-model="formData.comment" placeholder="{{replytip}}" /></textarea> <textarea input-auto type="text" class="post-reply-input" ng-model="journal.comment" placeholder="{{replytip}}" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(journal,1)" ng-disabled="journal.disabled" ng-hide="journal.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="journal.disabled" ng-hide="!journal.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
@ -96,9 +96,9 @@
<div class="post-reply-row border-bottom-none"> <div class="post-reply-row border-bottom-none">
<div class="post-input-container"> <div class="post-input-container">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="formData.comment" placeholder="{{replytip}}" /></textarea> <textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="blog.comment" placeholder="{{replytip}}" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(blog,0)" ng-disabled="blog.disabled" ng-hide="blog.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="blog.disabled" ng-hide="!blog.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>

View File

@ -77,9 +77,9 @@
<div class="cl"></div> <div class="cl"></div>
<div class="post-input-container ml40 mb10 undis"> <div class="post-input-container ml40 mb10 undis">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" ng-model="formData.comment" placeholder="{{replytip}}" /></textarea> <textarea input-auto type="text" class="post-reply-input" ng-model="journal.comment" placeholder="{{replytip}}" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(journal,1)" ng-disabled="journal.disabled" ng-hide="journal.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="journal.disabled" ng-hide="!journal.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
@ -93,9 +93,9 @@
<div class="post-reply-row border-bottom-none"> <div class="post-reply-row border-bottom-none">
<div class="post-input-container"> <div class="post-input-container">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="formData.comment" placeholder="输入回复内容~" /></textarea> <textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="discussion.comment" placeholder="输入回复内容~" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(discussion,0)" ng-disabled="discussion.disabled" ng-hide="discussion.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="discussion.disabled" ng-hide="!discussion.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>

View File

@ -92,9 +92,9 @@
<div class="cl"></div> <div class="cl"></div>
<div class="post-input-container ml40 mb10 undis"> <div class="post-input-container ml40 mb10 undis">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" ng-model="formData.comment" placeholder="{{replytip}}" /></textarea> <textarea input-auto type="text" class="post-reply-input" ng-model="journal.comment" placeholder="{{replytip}}" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(journal,1)" ng-disabled="journal.disabled" ng-hide="journal.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="journal.disabled" ng-hide="!journal.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
@ -108,9 +108,9 @@
<div class="post-reply-row border-bottom-none"> <div class="post-reply-row border-bottom-none">
<div class="post-input-container"> <div class="post-input-container">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="formData.comment" placeholder="输入回复内容~" /></textarea> <textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="news.comment" placeholder="输入回复内容~" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(news,0)" ng-disabled="news.disabled" ng-hide="news.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="news.disabled" ng-hide="!news.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>

View File

@ -81,9 +81,9 @@
<div class="cl"></div> <div class="cl"></div>
<div class="post-input-container ml40 mb10 undis"> <div class="post-input-container ml40 mb10 undis">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" ng-model="formData.comment" placeholder="{{replytip}}" /></textarea> <textarea input-auto type="text" class="post-reply-input" ng-model="journal.comment" placeholder="{{replytip}}" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(journal,1)" ng-disabled="journal.disabled" ng-hide="journal.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="journal.disabled" ng-hide="!journal.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
@ -97,9 +97,9 @@
<div class="post-reply-row border-bottom-none"> <div class="post-reply-row border-bottom-none">
<div class="post-input-container"> <div class="post-input-container">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="formData.comment" placeholder="{{replytip}}" /></textarea> <textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="homework.comment" placeholder="{{replytip}}" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(homework,0)" ng-disabled="homework.disabled" ng-hide="homework.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="homework.disabled" ng-hide="!homework.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>

View File

@ -98,9 +98,9 @@
<div class="cl"></div> <div class="cl"></div>
<div class="post-input-container ml40 mb10 undis"> <div class="post-input-container ml40 mb10 undis">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" ng-model="formData.comment" placeholder="{{replytip}}" /></textarea> <textarea input-auto type="text" class="post-reply-input" ng-model="journal.comment" placeholder="{{replytip}}" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(journal,1)" ng-disabled="journal.disabled" ng-hide="journal.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="journal.disabled" ng-hide="!journal.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
@ -114,9 +114,9 @@
<div class="post-reply-row border-bottom-none"> <div class="post-reply-row border-bottom-none">
<div class="post-input-container"> <div class="post-input-container">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="formData.comment" placeholder="输入回复内容~" /></textarea> <textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="issue.comment" placeholder="输入回复内容~" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(issue,0)" ng-disabled="issue.disabled" ng-hide="issue.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="issue.disabled" ng-hide="!issue.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>

View File

@ -76,9 +76,9 @@
<div class="cl"></div> <div class="cl"></div>
<div class="post-input-container ml40 mb10 undis"> <div class="post-input-container ml40 mb10 undis">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" ng-model="formData.comment" placeholder="{{replytip}}" /></textarea> <textarea input-auto type="text" class="post-reply-input" ng-model="journal.comment" placeholder="{{replytip}}" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(journal,1)" ng-disabled="journal.disabled" ng-hide="journal.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="journal.disabled" ng-hide="!journal.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
@ -92,9 +92,9 @@
<div class="post-reply-row border-bottom-none"> <div class="post-reply-row border-bottom-none">
<div class="post-input-container"> <div class="post-input-container">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="formData.comment" placeholder="输入回复内容~" /></textarea> <textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="message.comment" placeholder="输入回复内容~" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(message,0)" ng-disabled="message.disabled" ng-hide="message.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="message.disabled" ng-hide="!message.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>

View File

@ -77,9 +77,9 @@
<div class="cl"></div> <div class="cl"></div>
<div class="post-input-container ml40 mb10 undis"> <div class="post-input-container ml40 mb10 undis">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" ng-model="formData.comment" placeholder="{{replytip}}" /></textarea> <textarea input-auto type="text" class="post-reply-input" ng-model="journal.comment" placeholder="{{replytip}}" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(journal,1)" ng-disabled="journal.disabled" ng-hide="journal.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="journal.disabled" ng-hide="!journal.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>
@ -92,9 +92,9 @@
<div class="post-reply-row border-bottom-none"> <div class="post-reply-row border-bottom-none">
<div class="post-input-container"> <div class="post-input-container">
<div class="copy-input-container"><textarea class="copy-input"></textarea></div> <div class="copy-input-container"><textarea class="copy-input"></textarea></div>
<textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="formData.comment" placeholder="输入回复内容~" /></textarea> <textarea input-auto type="text" class="post-reply-input" id="postInput1" ng-model="discussion.comment" placeholder="输入回复内容~" /></textarea>
<button ng-click="addReply(formData)" ng-disabled="formData.disabled" ng-hide="formData.disabled" class="post-reply-submit fr border-radius">提交</button> <button ng-click="addReply(discussion,0)" ng-disabled="discussion.disabled" ng-hide="discussion.disabled" class="post-reply-submit fr border-radius">提交</button>
<button ng-disabled="formData.disabled" ng-hide="!formData.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button> <button ng-disabled="discussion.disabled" ng-hide="!discussion.disabled" class="post-reply-submit bg-grey fr border-radius">提交</button>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,25 @@
app.directive('inputOnChange', function(){
return{
restrict: 'A',
scope: {},
link: function (scope, element, attrs) {
var onChangeFunc = scope.$eval(attrs.inputOnChange);
element.bind('change', onChangeFunc);
scope.uploadDown = function () {
var file = event.target.files[0];
//判断类型是不是图片
if (!/image\/\w+/.test(file.type)) {
alert("非图片");
return;
}
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function (e) {
alert(this.result);//base64
}
}
}
}
});

View File

@ -94,7 +94,7 @@ app.factory('rms', function(){
}); });
app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$location', function($http, auth, $routeParams,rms,config,wx,$location){ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$location', function($http, auth, $routeParams,rms,config,wx,$location){
var addCommonReply = function(id, type, data,args, cb){ var addCommonReply = function(id, type, data,args,reply_type, cb){
//先判断有没有绑定 //先判断有没有绑定
// $http.post( // $http.post(
// '/wechat/is_bind', // '/wechat/is_bind',
@ -116,7 +116,8 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc
var userInfo = { var userInfo = {
type: type, type: type,
content: temp, content: temp,
token: auth.token() token: auth.token(),
reply_type:reply_type
}; };
//回复按钮禁用 //回复按钮禁用
data.disabled = true; data.disabled = true;
@ -146,24 +147,26 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc
cb(response.data.subscribe); cb(response.data.subscribe);
} }
var act_id = response.data.act_id;
//保证内外回复数一致 //保证内外回复数一致
activities = rms.get("activities") || []; activities = rms.get("activities") || [];
course_activities = rms.get("course_activities") || []; course_activities = rms.get("course_activities") || [];
project_activities = rms.get("project_activities") || []; project_activities = rms.get("project_activities") || [];
for(var i in activities){ for(var i in activities){
if(activities[i].act_id == id){ if(activities[i].act_id == act_id){
activities[i].reply_count += 1; activities[i].reply_count += 1;
break; break;
} }
} }
for(var i in course_activities){ for(var i in course_activities){
if(course_activities[i].act_id == id){ if(course_activities[i].act_id == act_id){
course_activities[i].reply_count += 1; course_activities[i].reply_count += 1;
break; break;
} }
} }
for(var i in project_activities){ for(var i in project_activities){
if(project_activities[i].act_id == id){ if(project_activities[i].act_id == act_id){
project_activities[i].reply_count += 1; project_activities[i].reply_count += 1;
break; break;
} }
@ -222,7 +225,7 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc
var init = function(args){ var init = function(args){
args.scope.replytip = "输入回复内容~"; args.scope.replytip = "输入回复内容~";
args.scope.formData = {comment: ''}; // args.scope.formData = {comment: ''};
var loadData = function(id,replytype,page){ var loadData = function(id,replytype,page){
loadCommonData(id, args.type,replytype,page).then(function successCallback(response) { loadCommonData(id, args.type,replytype,page).then(function successCallback(response) {
console.log(response.data); console.log(response.data);
@ -304,10 +307,10 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc
}; };
loadData(args.id,0,0); loadData(args.id,0,0);
args.scope.addReply = function(data){ args.scope.addReply = function(data,reply_type){
console.log(data.comment); console.log(data.comment);
addCommonReply(args.id, args.replyType, data,args, function(subscribe){ addCommonReply(data.act_id, args.replyType, data,args,reply_type, function(subscribe){
args.scope.formData = {comment: ''}; // args.scope.formData = {comment: ''};
if(subscribe == 0){ if(subscribe == 0){
$location.path("/login_tip"); $location.path("/login_tip");
return; return;
@ -322,6 +325,7 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc
}); });
}; };
// 动态详情界面点赞与动态界面的数据要同步 保证进入详情点赞后出来显示一致 // 动态详情界面点赞与动态界面的数据要同步 保证进入详情点赞后出来显示一致
args.scope.addPraise = function(act){ args.scope.addPraise = function(act){
activities = rms.get("activities") || []; activities = rms.get("activities") || [];