# encoding:utf-8 #小程序码 class SignUpChannel < ActiveRecord::Base has_paper_trail self.table_name = "sign_up_channels" belongs_to :parent_signup_channel, :foreign_key => :parent_id rails_admin do navigation_label '用户管理' weight -300 list do filters [:id, :channel_value, :invite_id] field :id field :parent_signup_channel field :qrcode_path field :channel_value field :channel_url field :img do formatted_value do bindings[:view].tag(:img,{:src => bindings[:object].get_img, :style => 'width: 100px;height: 100px;cursor: pointer;display: block;max-width: 100px;', :onClick => "javascript:window.open('#{bindings[:object].get_img}')"}) end end field :invite_id field :qrcode_img_url field :scan_times field :created_at end edit do field :parent_id field :channel_value field :channel_url field :invite_id end end def qrcode_path # url = "#{CONFIG_FILE["api_host"]}/v1/xcx/qrcode/generate" path = "pages/start/start?scene=#{self.id}" return path end def qrcode_img_url # url = "#{CONFIG_FILE["api_host"]}/v1/xcx/qrcode/generate" url = "#{CONFIG_FILE["api_host"]}/v1/xcx/qrcode/channel/#{self.id}" if self.url_image.blank? open(url) end return url end def get_img url = "#{self.url_image}" return url end end