This commit is contained in:
@@ -1455,6 +1455,7 @@ class DistributorViewSet(viewsets.GenericViewSet):
|
||||
@action(detail=False, methods=['post'])
|
||||
def invite(self, request):
|
||||
"""生成小程序码"""
|
||||
try:
|
||||
user = get_current_wechat_user(request)
|
||||
if not user or not hasattr(user, 'distributor'):
|
||||
return Response({'error': 'Unauthorized'}, status=401)
|
||||
@@ -1475,7 +1476,6 @@ class DistributorViewSet(viewsets.GenericViewSet):
|
||||
"width": 430
|
||||
}
|
||||
|
||||
try:
|
||||
res = requests.post(url, json=data)
|
||||
# 微信返回图片时 Content-Type 包含 image/jpeg 或 image/png
|
||||
if res.status_code == 200 and 'image' in res.headers.get('Content-Type', ''):
|
||||
@@ -1492,7 +1492,9 @@ class DistributorViewSet(viewsets.GenericViewSet):
|
||||
# 如果是 JSON 错误信息
|
||||
return Response({'error': 'WeChat API error', 'detail': res.json()}, status=500)
|
||||
except Exception as e:
|
||||
return Response({'error': str(e)}, status=500)
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return Response({'error': str(e), 'traceback': traceback.format_exc()}, status=500)
|
||||
|
||||
@action(detail=False, methods=['post'])
|
||||
def withdraw(self, request):
|
||||
|
||||
Reference in New Issue
Block a user