Exemplo n.º 1
0
 def get_wlannotify():
     articles =[]
     article1=ObjectDict()
     article1.title=u"无线上网"
     article1.description=u"当您已经连接Wi-Fi信号时,点击即可免费联入网络。"
     article1.url = "%s/mplogin?mp_openid=%s&product_id=%s&node_id=%s" % (
         config.get('mps','server_base'),
         msg.fromuser,
         config.get('mps','wlan_product_id'),
         config.get('mps','wlan_node_id')
     )
     article1.picurl = '%s/static/img/wlan.jpg' % config.get('mps','server_base')
     articles.append(article1)
     return articles
Exemplo n.º 2
0
def parse_msg(xml):
    if not xml:
        return None
    parser = ElementTree.fromstring(xml)
    msg_id = parse_node(parser, 'MsgId', get_uuid())
    msg_type = parse_node(parser, 'MsgType')
    touser = parse_node(parser, 'ToUserName')
    fromuser = parse_node(parser, 'FromUserName')
    create_at = int(parse_node(parser, 'CreateTime', 0))
    msg = ObjectDict(
        mid=msg_id,
        type=msg_type,
        touser=touser,
        fromuser=fromuser,
        time=create_at
    )
    if msg_type == MSG_TYPE_TEXT:
        msg.content = parse_node(parser, 'Content')
    elif msg_type == MSG_TYPE_LOCATION:
        msg.location_x = parse_node(parser, 'Location_X')
        msg.location_y = parse_node(parser, 'Location_Y')
        msg.scale = int(parse_node(parser, 'Scale'))
        msg.label = parse_node(parser, 'Label')
    elif msg_type == MSG_TYPE_IMAGE:
        msg.picurl = parse_node(parser, 'PicUrl')
    elif msg_type == MSG_TYPE_VOICE:
        msg.media_id = parse_node(parser, 'MediaId')
        msg.format = parse_node(parser, 'Format')
    elif msg_type == MSG_TYPE_VIDEO:
        msg.media_id = parse_node(parser, 'MediaId')
        msg.thumb = parse_node(parser, 'ThumbMediaId')
    elif msg_type == MSG_TYPE_LINK:
        msg.title = parse_node(parser, 'Title')
        msg.description = decode(parser.find('Description').text)
        msg.url = parse_node(parser, 'Url')
    elif msg_type == MSG_TYPE_EVENT:
        msg.event = parse_node(parser, 'Event')
        msg.event_key = parse_node(parser, 'EventKey')
        msg.ticket = parse_node(parser, 'Ticket')
        if msg.event == u'LOCATION':
            msg.latitude = parse_node(parser, 'Latitude')
            msg.longitude = parse_node(parser, 'Longitude')
            msg.precision = parse_node(parser, 'Precision')
    return msg
Exemplo n.º 3
0
def respond(data, msg=None,db=None,config=None,mpsapi=None,**kwargs):
    products = db.query(models.SlcRadProduct).filter(
        models.SlcRadProduct.mps_flag == 1,
        models.SlcRadProduct.product_status == 0
    ).limit(7)

    articles =[]
    for item in products:
        article=ObjectDict()
        article.title= item.product_name
        article.description = ''
        article.url = "%s/order?openid=%s&product_id=%s" % (
            config.get('mps','server_base'),
            msg.fromuser,
            item.id
        )
        article.picurl = '%s/static/img/mps/order_online.jpg' % config.get('mps','server_base')
        articles.append(article)
    return articles
Exemplo n.º 4
0
def respond(data, msg=None,db=None,config=None,mpsapi=None,**kwargs):
    member = db.query(models.SlcMember).filter(
        models.SlcMember.weixin_id==msg.fromuser).first()

    if not member:
        return u"您当前还未绑定账号"


    articles =[]
    article=ObjectDict()
    article.title= u"我的工单"
    article.description = ''
    article.url = "%s/issues?openid=%s&member_id=%s" % (
        config.get('mps','server_base'),
        msg.fromuser,
        member.member_id
    )
    article.picurl = '%s/static/img/mps/issues_query.jpg' % config.get('mps','server_base')
    articles.append(article)
    return articles