class Weapps::BaseController < ApplicationController private def require_wechat_login! return if session_unionid.present? render_error('请先进行微信授权') end def weapp_session_key Wechat::Weapp.session_key(session_openid) end def set_weapp_session_key(session_key) Wechat::Weapp.write_session_key(session_openid, session_key) end def session_openid session[:openid] end def set_session_openid(openid) session[:openid] = openid end def session_unionid session[:unionid] end def set_session_unionid(unionid) session[:unionid] = unionid end end