80学院第十次课
# Gemfile
gem 'weixin_authorize'
# /config/wechat_menu.yml
button:
-
type: "view"
name: "首页"
url: "http://<%= ENV['DOMAIN'] %>/wechat/home"
-
name: "发现"
sub_button:
-
type: "view"
name: "预约"
url: "http://<%= ENV['DOMAIN']%>/wechat/bookings/new?locate=true"
-
type: "view"
name: "门店"
url: "http://<%= ENV['DOMAIN']%>/wechat/stores?locate=true"
-
type: "view"
name: "明星"
url: "http://<%= ENV['DOMAIN']%>/wechat/staffs"
# /lib/tasks/wechat.rake
# 使用: rake wechat:create_menu 订制服务号菜单
namespace :wechat do
desc 'create Wechat menu with "config/wechat_menu.yml"'
task create_menu: :environment do
menu = YAML.load(ERB.new(File.read(Rails.root\
.join('config/wechat_menu.yml'))).result)
if WxAuth.create_menu(menu)
puts 'Menu created.'
end
end
end