| @@ -4,6 +4,7 @@ from django.conf.urls import url | ||
| 4 | 4 |  | 
| 5 | 5 | from account import views as account_views | 
| 6 | 6 | from account import tourguide_views | 
| 7 | +from box import views as box_views | |
| 7 | 8 | from geo import views as geo_views | 
| 8 | 9 | from group import views as group_views | 
| 9 | 10 | from group import (groupuser_views, lensman_views, tourguidegroup_views, tourguidegroupadmin_views, | 
| @@ -195,3 +196,7 @@ urlpatterns += [ | ||
| 195 | 196 | urlpatterns += [ | 
| 196 | 197 | url(r'^mini/userinfo$', mini_views.get_userinfo_api, name='get_userinfo_api'), # 获取用户信息 | 
| 197 | 198 | ] | 
| 199 | + | |
| 200 | +urlpatterns += [ | |
| 201 | + url(r'^box/loginqr$', box_views.login_qrcode_api, name='login_qrcode_api'), # 二维码登录 | |
| 202 | +] | 
| @@ -0,0 +1,4 @@ | ||
| 1 | +from django.contrib import admin | |
| 2 | + | |
| 3 | + | |
| 4 | +# Register your models here. | 
| @@ -0,0 +1,4 @@ | ||
| 1 | +from django.db import models | |
| 2 | + | |
| 3 | + | |
| 4 | +# Create your models here. | 
| @@ -0,0 +1,4 @@ | ||
| 1 | +from django.test import TestCase | |
| 2 | + | |
| 3 | + | |
| 4 | +# Create your tests here. | 
| @@ -0,0 +1,27 @@ | ||
| 1 | +# -*- coding: utf-8 -*- | |
| 2 | + | |
| 3 | +from logit import logit | |
| 4 | + | |
| 5 | +from account.models import UserInfo | |
| 6 | +from utils.error.errno_utils import LensmanStatusCode | |
| 7 | +from utils.error.response_utils import response | |
| 8 | +from utils.redis.connect import r | |
| 9 | + | |
| 10 | + | |
| 11 | +@logit | |
| 12 | +def login_qrcode_api(request): | |
| 13 | +    unionid = request.POST.get('unionid', '') | |
| 14 | +    token = request.POST.get('token', '') | |
| 15 | + | |
| 16 | + if not r.token_exists(unionid, token): | |
| 17 | + return response(LensmanStatusCode.LENSMAN_NOT_FOUND) | |
| 18 | + | |
| 19 | + try: | |
| 20 | + user = UserInfo.objects.get(unionid=unionid, islensman=True, status=True) | |
| 21 | + except UserInfo.DoesNotExist: | |
| 22 | + return response(LensmanStatusCode.LENSMAN_NOT_FOUND) | |
| 23 | + | |
| 24 | + if user.user_status != UserInfo.ACTIVATED: | |
| 25 | + return response(LensmanStatusCode.LENSMAN_NOT_ACTIVATED) | |
| 26 | + | |
| 27 | + return response(200, 'Lensman Login Success', u'摄影师登录成功', user.data) | 
| @@ -0,0 +1,62 @@ | ||
| 1 | +{% load staticfiles %} | |
| 2 | + | |
| 3 | +<!DOCTYPE html> | |
| 4 | +<html lang="zh-CN"> | |
| 5 | + <head> | |
| 6 | + <meta charset="utf-8"> | |
| 7 | + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
| 8 | + <meta name="format-detection" content="telephone=no,email=no,address=no"> | |
| 9 | + <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no"> | |
| 10 | + <title>摄影师授权</title> | |
| 11 | + | |
| 12 | + <link href="https://res.wx.qq.com/open/libs/weui/0.4.3/weui.min.css" rel="stylesheet" type="text/css" /> | |
| 13 | + | |
| 14 | + <style> | |
| 15 | +            input:required:invalid { | |
| 16 | + color: #E64340; | |
| 17 | + } | |
| 18 | +            input:required:valid { | |
| 19 | + color: rgb(0, 0, 0); | |
| 20 | + } | |
| 21 | +            .hidden { | |
| 22 | + display: none; | |
| 23 | + } | |
| 24 | +            .qr { | |
| 25 | + position: fixed; | |
| 26 | + left: 50%; | |
| 27 | + top: 50%; | |
| 28 | + margin-left: -100px; | |
| 29 | + margin-top: -100px; | |
| 30 | + } | |
| 31 | + </style> | |
| 32 | + </head> | |
| 33 | + <body> | |
| 34 | + <div class="container" > | |
| 35 | +            <img id="qr_logo" class="hidden" src="{% static 'pai2/img/paiai_96_96.png' %}"> | |
| 36 | + <div id="qr" class="qr"></div> | |
| 37 | + </div> | |
| 38 | + | |
| 39 | + <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script> | |
| 40 | + <script src="https://cdn.bootcss.com/lrsjng.jquery-qrcode/0.14.0/jquery-qrcode.min.js"></script> | |
| 41 | + <script> | |
| 42 | +            $("#qr").empty().qrcode({ | |
| 43 | + render: 'image', | |
| 44 | + mode: 4, | |
| 45 | +                image: $("#qr_logo")[0], | |
| 46 | +                text: '{{ data }}' | |
| 47 | + }); | |
| 48 | + </script> | |
| 49 | + <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script> | |
| 50 | +        <script type="text/javascript" src="{% static 'pai2/js/jswe.js' %}?v=1"></script> | |
| 51 | + <script> | |
| 52 | +            V.initWxData({ | |
| 53 | + imgUrl: "http://pai.ai/static/pai2/img/paiai_96_96.png", | |
| 54 | + link: 'http://api.pai.ai/wx_oauth2?redirect_url=http://pai.ai/page/lensman&scope=snsapi_base', | |
| 55 | + desc: "摄影师授权", | |
| 56 | + title: "摄影师授权", | |
| 57 | + timeLine: "" | |
| 58 | + }, true); | |
| 59 | + V.hideOptionMenu(); | |
| 60 | + </script> | |
| 61 | + </body> | |
| 62 | +</html> | 
| @@ -1,8 +1,11 @@ | ||
| 1 | 1 | # -*- coding: utf-8 -*- | 
| 2 | 2 |  | 
| 3 | +import json | |
| 4 | + | |
| 3 | 5 | from django.shortcuts import render | 
| 4 | 6 |  | 
| 5 | 7 | from account.models import LensmanInfo, TourGuideInfo | 
| 8 | +from utils.redis.connect import r | |
| 6 | 9 |  | 
| 7 | 10 |  | 
| 8 | 11 | def user_agreement(request): | 
| @@ -43,3 +46,14 @@ def tourguide_oauth(request): | ||
| 43 | 46 | 'tourguide_info': tourguide and tourguide.data, | 
| 44 | 47 | 'modified': bool((not tourguide) or (tourguide and tourguide.user_status in [TourGuideInfo.UNVERIFIED, TourGuideInfo.REFUSED])), # 是否可以更改信息 | 
| 45 | 48 | }) | 
| 49 | + | |
| 50 | + | |
| 51 | +def login_qrcode(request): | |
| 52 | +    unionid = request.GET.get('unionid', '') | |
| 53 | +    data = { | |
| 54 | + 'unionid': unionid, | |
| 55 | + 'token': r.token(unionid) | |
| 56 | + } | |
| 57 | +    return render(request, 'page/login_qrcode.html', { | |
| 58 | + 'data': json.dumps(data) | |
| 59 | + }) | 
| @@ -46,7 +46,7 @@ INSTALLED_APPS = ( | ||
| 46 | 46 | 'django_q', | 
| 47 | 47 | 'api', | 
| 48 | 48 | 'account', | 
| 49 | - 'geo', | |
| 49 | + 'box', | |
| 50 | 50 | 'group', | 
| 51 | 51 | 'message', | 
| 52 | 52 | 'miniapp', | 
| @@ -81,6 +81,8 @@ urlpatterns += [ | ||
| 81 | 81 | url(r'^page/price$', page_views.lensman_price, name='lensman_price'), # 摄影师照片价格和分成规则 | 
| 82 | 82 |  | 
| 83 | 83 | url(r'^page/tourguide$', page_views.tourguide_oauth, name='tourguide_oauth'), # 导游授权页面 | 
| 84 | + | |
| 85 | + url(r'^page/loginqr$', page_views.login_qrcode, name='login_qrcode'), # 登录二维码页面 | |
| 84 | 86 | ] | 
| 85 | 87 |  | 
| 86 | 88 | urlpatterns += [ | 
| @@ -29,7 +29,7 @@ pysnippets==1.0.4 | ||
| 29 | 29 | pywe-miniapp==1.0.0 | 
| 30 | 30 | pywe-oauth==1.0.3 | 
| 31 | 31 | pywe-response==1.0.1 | 
| 32 | -redis-extensions==1.0.49 | |
| 32 | +redis-extensions==1.0.50 | |
| 33 | 33 | requests==2.12.4 | 
| 34 | 34 | rlog==0.2 | 
| 35 | 35 | shortuuid==0.5.0 |