51 lines
2.4 KiB
Python
51 lines
2.4 KiB
Python
from rest_framework import status
|
|
from rest_framework.decorators import action
|
|
from rest_framework.request import Request
|
|
from rest_framework.response import Response
|
|
from rest_framework.viewsets import ViewSet
|
|
|
|
from sixGuoDjango import BaseResponse, ResData
|
|
|
|
|
|
class 主页分享页面接口ViewSets(ViewSet):
|
|
img_主页面分享时的图片 = "https://hudie.sixgou.com/six/aa35a95a5be61ba1bc38f856fabf3978.png"
|
|
|
|
@action(detail=False, methods=["post", ], url_path="onShareAppMessage")
|
|
def 主页群分享接口(self, request: Request):
|
|
""""""
|
|
self_mini_openid = request.data.get("self_mini_openid", None)
|
|
self_mini_unionid = request.data.get("self_mini_unionid", None)
|
|
page_path = request.data.get("page_path", None)
|
|
# 如果需要携带参数, 需要在路由的后面 ? 添加 key=value的格式;
|
|
分享参数 = {
|
|
"superior_unionid": self_mini_unionid,
|
|
"shareType": "小程序推荐",
|
|
}
|
|
print(分享参数)
|
|
result = "&".join([f"{key}={value}" for key, value in 分享参数.items()])
|
|
print("================", result, self_mini_openid, "炎什么值拿不到了呢?")
|
|
messageData = {
|
|
"title": "🧧🧧🧧无门槛代金券,快来领!!!",
|
|
"path": f"{page_path}?{result}",
|
|
"imageUrl": self.img_主页面分享时的图片,
|
|
}
|
|
httpResData = BaseResponse(resData=ResData(listData=[""], dictData=messageData), ).model_dump()
|
|
return Response(data=httpResData, status=status.HTTP_200_OK)
|
|
|
|
@action(detail=False, methods=["post"], url_path="onShareTimeline")
|
|
def 主页朋友圈分享的功能接口(self, request: Request):
|
|
""""""
|
|
self_mini_openid = request.data.get("self_mini_openid", None)
|
|
self_mini_unionid = request.data.get("self_mini_unionid", None)
|
|
|
|
page_path = request.data.get("page_path", None)
|
|
# 如果需要携带参数, 需要在路由的后面 ? 添加 key=value的格式
|
|
messageData = {
|
|
"title": "🧧🧧🧧无门槛代金券,快来领!!!",
|
|
"path": f"{page_path}",
|
|
"imageUrl": self.img_主页面分享时的图片,
|
|
"query": f"superior_unionid={self_mini_unionid}&shareType=小程序推荐",
|
|
}
|
|
httpResData = BaseResponse(resData=ResData(listData=[""], dictData=messageData), ).model_dump()
|
|
return Response(data=httpResData, status=status.HTTP_200_OK)
|