@@ -8,6 +8,7 @@ from message import views as message_views  | 
            ||
| 8 | 8 | 
                from operation import views as op_views  | 
            
| 9 | 9 | 
                from pay import views as pay_views  | 
            
| 10 | 10 | 
                from photo import views as photo_views  | 
            
| 11 | 
                +from wechat import views as wechat_views  | 
            |
| 11 | 12 | 
                 | 
            
| 12 | 13 | 
                 | 
            
| 13 | 14 | 
                # 帐户相关  | 
            
                @@ -90,6 +91,11 @@ urlpatterns += [  | 
            ||
| 90 | 91 | 
                url(r'^wx/notify_url$', pay_views.wx_notify_url_api, name='wx_notify_url_api'), # 支付异步通知回调地址  | 
            
| 91 | 92 | 
                ]  | 
            
| 92 | 93 | 
                 | 
            
| 94 | 
                +# 分享相关  | 
            |
| 95 | 
                +urlpatterns += [  | 
            |
| 96 | 
                + url(r'^wx/jsapi_signature$', wechat_views.wx_jsapi_signature_api, name='wx_jsapi_signature_api'), # jsapi_signature  | 
            |
| 97 | 
                +]  | 
            |
| 98 | 
                +  | 
            |
| 93 | 99 | 
                # 首页相关  | 
            
| 94 | 100 | 
                urlpatterns += [  | 
            
| 95 | 101 | 
                url(r'^pai2/home$', group_views.pai2_home_api, name='pai2_home_api'), # 首页信息  | 
            
                @@ -1013,7 +1013,7 @@ def lensman_photo_bought(request):  | 
            ||
| 1013 | 1013 | 
                 | 
            
| 1014 | 1014 | 
                def group_photo_detail(request, photo_id):  | 
            
| 1015 | 1015 | 
                photo = GroupPhotoInfo.objects.get(pk=photo_id)  | 
            
| 1016 | 
                -    return render(request, 'photo/photo_detail.html', {'photo_url': photo.photo_url})
               | 
            |
| 1016 | 
                +    return render(request, 'photo/photo_detail.html', {'photo_url': photo.photo_url, 'api_domain': settings.API_DOMAIN})
               | 
            |
| 1017 | 1017 | 
                 | 
            
| 1018 | 1018 | 
                 | 
            
| 1019 | 1019 | 
                def group_detail(request, group_id):  | 
            
                @@ -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,31 @@  | 
            ||
| 1 | 
                +# -*- coding: utf-8 -*-  | 
            |
| 2 | 
                +  | 
            |
| 3 | 
                +import time  | 
            |
| 4 | 
                +  | 
            |
| 5 | 
                +import shortuuid  | 
            |
| 6 | 
                +from django.conf import settings  | 
            |
| 7 | 
                +from django.http import HttpResponse  | 
            |
| 8 | 
                +from wechatpy import WeChatClient  | 
            |
| 9 | 
                +  | 
            |
| 10 | 
                +  | 
            |
| 11 | 
                +r = settings.REDIS_CACHE  | 
            |
| 12 | 
                +WECHAT = settings.WECHAT  | 
            |
| 13 | 
                +JSAPI = WECHAT.get('JSAPI', {})
               | 
            |
| 14 | 
                +  | 
            |
| 15 | 
                +  | 
            |
| 16 | 
                +def wx_jsapi_signature_api(request):  | 
            |
| 17 | 
                +    url = request.GET.get('url', '')
               | 
            |
| 18 | 
                +    callback = request.GET.get('callback', '')
               | 
            |
| 19 | 
                +  | 
            |
| 20 | 
                + nonceStr, timestamp = shortuuid.uuid(), int(time.time())  | 
            |
| 21 | 
                +  | 
            |
| 22 | 
                + client = WeChatClient(JSAPI['appID'], JSAPI['appsecret'])  | 
            |
| 23 | 
                + ticket = client.jsapi.get_jsapi_ticket()  | 
            |
| 24 | 
                + signature = client.jsapi.get_jsapi_signature(nonceStr, ticket, timestamp, url)  | 
            |
| 25 | 
                +  | 
            |
| 26 | 
                +    return HttpResponse('{}({})'.format(callback, {
               | 
            |
| 27 | 
                + 'appId': JSAPI['appID'],  | 
            |
| 28 | 
                + 'noncestr': nonceStr,  | 
            |
| 29 | 
                + 'timestamp': timestamp,  | 
            |
| 30 | 
                + 'signature': signature,  | 
            |
| 31 | 
                + }))  |