微信菜单集成

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

Break time

任务安排

  • 微信服务菜单的订制

问题答疑

Thx

80academy-lession-10

By Li Yafei

80academy-lession-10

  • 2,187