b82f64f3db94c08R477">477
+ return strs[strs.length - 1]
|
|
|
478
|
+ }
|
|
|
479
|
+
|
|
|
480
|
+ // 10 微信支付接口
|
|
|
481
|
+ // 10.1 发起一个支付请求
|
|
|
482
|
+ function chooseWXPay(wxpay_params) {
|
|
|
483
|
+ wx.chooseWXPay({
|
|
|
484
|
+ timestamp: wxpay_params.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
|
|
|
485
|
+ nonceStr: wxpay_params.nonceStr, // 支付签名随机串,不长于 32 位
|
|
|
486
|
+ package: wxpay_params.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***)
|
|
|
487
|
+ signType: wxpay_params.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
|
|
|
488
|
+ paySign: wxpay_params.paySign, // 支付签名
|
|
|
489
|
+ success: function (res) {
|
|
|
490
|
+ // 支付成功后的回调函数
|
|
|
491
|
+ if (JSWE.wxPaySuccess) {JSWE.wxPaySuccess(res)}
|
|
|
492
|
+ }
|
|
|
493
|
+ })
|
|
|
494
|
+ }
|
|
|
495
|
+
|
|
|
496
|
+ // xx 微信原生企业红包接口
|
|
|
497
|
+ // xx.1 发起一个发送原生企业红包请求
|
|
|
498
|
+ function openEnterpriseRedPacket(wxredpack_params) {
|
|
|
499
|
+ wx.openEnterpriseRedPacket({
|
|
|
500
|
+ timeStamp: wxredpack_params.timeStamp, // 红包签名时间戳,注意原生企业红包接口timeStamp字段名需大写其中的S字符,而支付接口timeStamp字段名无需大写其中的S字符。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
|
|
|
501
|
+ nonceStr: wxredpack_params.nonceStr, // 红包签名随机串,不长于 32 位
|
|
|
502
|
+ package: encodeURIComponent(wxredpack_params.package), // 发放红包接口返回的prepay_id参数值,提交格式如:prepay_id=***)
|
|
|
503
|
+ signType: wxredpack_params.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
|
|
|
504
|
+ paySign: wxredpack_params.paySign, // 红包签名
|
|
|
505
|
+ success: function (res) {
|
|
|
506
|
+ // 发送原生企业红包成功后的回调函数
|
|
|
507
|
+ if (JSWE.wxEnterpriseRedPacketSuccess) {JSWE.wxEnterpriseRedPacketSuccess(res)}
|
|
|
508
|
+ }
|
|
|
509
|
+ })
|
|
|
510
|
+ }
|
|
|
511
|
+
|
|
|
512
|
+ var v = {
|
|
|
513
|
+ version: '1.0.5',
|
|
|
514
|
+
|
|
|
515
|
+ // Basic Vars
|
|
|
516
|
+ config: config,
|
|
|
517
|
+ wxData: wxData,
|
|
|
518
|
+ jsApiList: jsApiList,
|
|
|
519
|
+
|
|
|
520
|
+ isEmpty: isEmpty,
|
|
|
521
|
+ isNotEmpty: isNotEmpty,
|
|
|
522
|
+
|
|
|
523
|
+ // Weixin Function
|
|
|
524
|
+ isOpenInWeixin: isOpenInWeixin,
|
|
|
525
|
+ getWeixinVersion: getWeixinVersion,
|
|
|
526
|
+ isWeixinVersion: isWeixinVersion,
|
|
|
527
|
+
|
|
|
528
|
+ // Menu Function
|
|
|
529
|
+ hideOptionMenu: hideOptionMenu,
|
|
|
530
|
+ showOptionMenu: showOptionMenu,
|
|
|
531
|
+ hideMenuItems: hideMenuItems,
|
|
|
532
|
+ showMenuItems: showMenuItems,
|
|
|
533
|
+ hideAllNonBaseMenuItem: hideAllNonBaseMenuItem,
|
|
|
534
|
+ showAllNonBaseMenuItem: showAllNonBaseMenuItem,
|
|
|
535
|
+ closeWindow: closeWindow,
|
|
|
536
|
+
|
|
|
537
|
+ // Share Function
|
|
|
538
|
+ initWxData: initWxData,
|
|
|
539
|
+ changeWxData: changeWxData,
|
|
|
540
|
+ fixedWxData: fixedWxData,
|
|
|
541
|
+
|
|
|
542
|
+ // Voice Function
|
|
|
543
|
+ voice: voice,
|
|
|
544
|
+ translateVoice: translateVoice,
|
|
|
545
|
+ startRecord: startRecord,
|
|
|
546
|
+ stopRecord: stopRecord,
|
|
|
547
|
+ playVoice: playVoice,
|
|
|
548
|
+ pauseVoice: pauseVoice,
|
|
|
549
|
+ stopVoice: stopVoice,
|
|
|
550
|
+ uploadVoice: uploadVoice,
|
|
|
551
|
+ downloadVoice: downloadVoice,
|
|
|
552
|
+
|
|
|
553
|
+ // Image Function
|
|
|
554
|
+ images: images,
|
|
|
555
|
+ chooseImage: chooseImage,
|
|
|
556
|
+ previewImage: previewImage,
|
|
|
557
|
+ uploadImage: uploadImage,
|
|
|
558
|
+ uploadImages: uploadImages,
|
|
|
559
|
+ downloadImage: downloadImage,
|
|
|
560
|
+ downloadImages: downloadImages,
|
|
|
561
|
+ getLocalImgData: getLocalImgData,
|
|
|
562
|
+
|
|
|
563
|
+ // Scan Function
|
|
|
564
|
+ scanQRCode: scanQRCode,
|
|
|
565
|
+ parseScanQRCodeResultStr: parseScanQRCodeResultStr,
|
|
|
566
|
+
|
|
|
567
|
+ // Pay Function
|
|
|
568
|
+ chooseWXPay: chooseWXPay,
|
|
|
569
|
+
|
|
|
570
|
+ // EnterpriseRedPacket Function
|
|
|
571
|
+ openEnterpriseRedPacket: openEnterpriseRedPacket
|
|
|
572
|
+ }
|
|
|
573
|
+ e.JSWE = e.V = v
|
|
|
574
|
+})(window)
|
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+# -*- coding: utf-8 -*-
|
|
|
2
|
+
|
|
|
3
|
+"""tiwen URL Configuration
|
|
|
4
|
+
|
|
|
5
|
+The `urlpatterns` list routes URLs to views. For more information please see:
|
|
|
6
|
+ https://docs.djangoproject.com/en/1.11/topics/http/urls/
|
|
|
7
|
+Examples:
|
|
|
8
|
+Function views
|
|
|
9
|
+ 1. Add an import: from my_app import views
|
|
|
10
|
+ 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
|
|
|
11
|
+Class-based views
|
|
|
12
|
+ 1. Add an import: from other_app.views import Home
|
|
|
13
|
+ 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
|
|
|
14
|
+Including another URLconf
|
|
|
15
|
+ 1. Import the include() function: from django.conf.urls import url, include
|
|
|
16
|
+ 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
|
|
|
17
|
+"""
|
|
|
18
|
+from django.conf import settings
|
|
|
19
|
+from django.conf.urls.static import static
|
|
|
20
|
+from django.contrib import admin
|
|
|
21
|
+from django.urls import include, re_path
|
|
|
22
|
+
|
|
|
23
|
+
|
|
|
24
|
+urlpatterns = [
|
|
|
25
|
+ re_path(r'^admin/', admin.site.urls),
|
|
|
26
|
+]
|
|
|
27
|
+
|
|
|
28
|
+urlpatterns += [
|
|
|
29
|
+ re_path(r'^api/', include(('api.urls', 'api'), namespace='api')),
|
|
|
30
|
+ re_path(r'^uniapi/', include(('django_uniapi.urls', 'uniapi'), namespace='uniapi')),
|
|
|
31
|
+]
|
|
|
32
|
+
|
|
|
33
|
+urlpatterns += [
|
|
|
34
|
+ # url(r'^s/', include(('django_short_url.urls', 'django_short_url'), namespace='django_short_url')),
|
|
|
35
|
+]
|
|
|
36
|
+
|
|
|
37
|
+urlpatterns += [
|
|
|
38
|
+ re_path(r'^w/', include(('django_we.urls', 'shortwechat'), namespace='shortwechat')),
|
|
|
39
|
+ re_path(r'^we/', include(('django_we.urls', 'wechat'), namespace='wechat')),
|
|
|
40
|
+]
|
|
|
41
|
+
|
|
|
42
|
+urlpatterns += [
|
|
|
43
|
+ # re_path(r'^p/', include(('page.urls', 'shortpage'), namespace='shortpage')),
|
|
|
44
|
+ # re_path(r'^page/', include(('page.urls', 'page'), namespace='page')),
|
|
|
45
|
+]
|
|
|
46
|
+
|
|
|
47
|
+if settings.DEBUG:
|
|
|
48
|
+ urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
|
|
49
|
+ urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
|
|
50
|
+
|
|
|
51
|
+# AdminSite
|
|
|
52
|
+admin.site.site_header = 'Django administration'
|
|
|
53
|
+admin.site.site_title = 'Django site admin'
|
|
|
54
|
+# Make site_url/index_title None to hidden
|
|
|
55
|
+admin.site.site_url = '/'
|
|
|
56
|
+admin.site.index_title = 'Site administration'
|
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+"""
|
|
|
2
|
+WSGI config for tiwen project.
|
|
|
3
|
+
|
|
|
4
|
+It exposes the WSGI callable as a module-level variable named ``application``.
|
|
|
5
|
+
|
|
|
6
|
+For more information on this file, see
|
|
|
7
|
+https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
|
|
|
8
|
+"""
|
|
|
9
|
+
|
|
|
10
|
+import os
|
|
|
11
|
+
|
|
|
12
|
+from django.core.wsgi import get_wsgi_application
|
|
|
13
|
+
|
|
|
14
|
+
|
|
|
15
|
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tiwen.settings")
|
|
|
16
|
+
|
|
|
17
|
+application = get_wsgi_application()
|
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+# -*- coding: utf-8 -*-
|
|
|
2
|
+
|
|
|
3
|
+from StatusCode import BaseStatusCode, StatusCodeField
|
|
|
4
|
+
|
|
|
5
|
+
|
|
|
6
|
+class ParamStatusCode(BaseStatusCode):
|
|
|
7
|
+ """ 4000xx 参数相关错误码 """
|
|
|
8
|
+ PARAM_NOT_FOUND = StatusCodeField(400000, 'Param Not Found', description='参数不存在')
|
|
|
9
|
+
|
|
|
10
|
+
|
|
|
11
|
+class ProfileStatusCode(BaseStatusCode):
|
|
|
12
|
+ """ 4001xx 用户相关错误码 """
|
|
|
13
|
+ PROFILE_NOT_FOUND = StatusCodeField(400101, 'Profile Not Found', description='用户不存在')
|
|
|
14
|
+
|
|
|
15
|
+
|
|
|
16
|
+class PhoneStatusCode(BaseStatusCode):
|
|
|
17
|
+ """ 4002xx 手机相关错误码 """
|
|
|
18
|
+ INVALID_PHONE = StatusCodeField(400200, 'Invalid Phone', description='非法手机号')
|
|
|
19
|
+ PHONE_NOT_FOUND = StatusCodeField(400201, 'Phone Not Found', description='手机号不存在')
|
|
|
20
|
+ PHONE_ALREADY_EXISTS = StatusCodeField(400202, 'Phone Already Exists', description='手机号已存在')
|
|
|
21
|
+
|
|
|
22
|
+
|
|
|
23
|
+class OrderStatusCode(BaseStatusCode):
|
|
|
24
|
+ """ 4040xx 订单/支付相关错误码 """
|
|
|
25
|
+ UNIFIED_ORDER_FAIL = StatusCodeField(404000, 'Unified Order Fail', description='统一下单失败')
|
|
|
26
|
+ ORDER_NOT_FOUND = StatusCodeField(404001, 'Order Not Found', description='订单不存在')
|
|
|
27
|
+ # 订单支付状态
|
|
|
28
|
+ ORDER_NOT_PAY = StatusCodeField(404011, 'Order Not Pay', description='订单未支付')
|
|
|
29
|
+ ORDER_PAYING = StatusCodeField(404012, 'Order Paying', description='订单支付中')
|
|
|
30
|
+ ORDER_PAY_FAIL = StatusCodeField(404013, 'Order Pay Fail', description='微信支付失败')
|
|
|
31
|
+ # 通知校验状态
|
|
|
32
|
+ SIGN_CHECK_FAIL = StatusCodeField(404090, 'Sign Check Fail', description='签名校验失败')
|
|
|
33
|
+ FEE_CHECK_FAIL = StatusCodeField(404091, 'FEE Check Fail', description='金额校验失败')
|
|
|
34
|
+
|
|
|
35
|
+
|
|
|
36
|
+class PayStatusCode(BaseStatusCode):
|
|
|
37
|
+ """ 4041xx 支付相关错误码 """
|
|
|
38
|
+
|
|
|
39
|
+
|
|
|
40
|
+class WithdrawStatusCode(BaseStatusCode):
|
|
|
41
|
+ """ 4042xx 提现相关错误码 """
|
|
|
42
|
+ BALANCE_INSUFFICIENT = StatusCodeField(404200, 'Balance Insufficient', description='提现金额不足')
|
|
|
43
|
+
|
|
|
44
|
+
|
|
|
45
|
+class TokenStatusCode(BaseStatusCode):
|
|
|
46
|
+ """ 4090xx 票据相关错误码 """
|
|
|
47
|
+ TOKEN_NOT_FOUND = StatusCodeField(409001, 'Token Not Found', description='票据不存在')
|
|
|
48
|
+
|
|
|
49
|
+
|
|
|
50
|
+class SignatureStatusCode(BaseStatusCode):
|
|
|
51
|
+ """ 4091xx 签名校验错误 """
|
|
|
52
|
+ SIGNATURE_ERROR = StatusCodeField(409101, 'Signature Error', description='签名错误')
|
|
|
53
|
+
|
|
|
54
|
+
|
|
|
55
|
+class GVCodeStatusCode(BaseStatusCode):
|
|
|
56
|
+ """ 4092xx 图形验证码相关错误码 """
|
|
|
57
|
+ GRAPHIC_VCODE_ERROR = StatusCodeField(409201, 'Graphic VCode Error', description='图形验证码错误')
|
|
|
58
|
+
|
|
|
59
|
+
|
|
|
60
|
+class SVCodeStatusCode(BaseStatusCode):
|
|
|
61
|
+ """ 4093xx 短信验证码相关错误码 """
|
|
|
62
|
+ SMS_QUOTA_LIMIT = StatusCodeField(409300, 'SMS Quota Limit', description='短信次数超限')
|
|
|
63
|
+ SMS_VCODE_ERROR = StatusCodeField(409301, 'SMS VCode Error', description='验证码错误,请稍后重试')
|
|
|
64
|
+ SMS_VCODE_HAS_SEND = StatusCodeField(409302, 'SMS VCode Has Send', description='验证码已发送,请勿重复获取')
|
|
|
65
|
+
|
|
|
66
|
+
|
|
|
67
|
+class InsufficientStatusCode(BaseStatusCode):
|
|
|
68
|
+ """ 4095xx 不足相关错误码 """
|
|
|
69
|
+ BALANCE_INSUFFICIENT = StatusCodeField(409501, 'Balance Insufficient', description='余额不足')
|
|
|
70
|
+ INTEGRAL_INSUFFICIENT = StatusCodeField(409502, 'Integral Insufficient', description='积分不足')
|
|
|
71
|
+
|
|
|
72
|
+
|
|
|
73
|
+class PermissionStatusCode(BaseStatusCode):
|
|
|
74
|
+ """ 4099xx 权限相关错误码 """
|
|
|
75
|
+ PERMISSION_DENIED = StatusCodeField(409900, 'Permission Denied', description='权限不足')
|
|
|
76
|
+ UPLOAD_PERMISSION_DENIED = StatusCodeField(409910, 'Upload Permission Denied', description='上传权限不足')
|
|
|
77
|
+ UPDATE_PERMISSION_DENIED = StatusCodeField(409930, 'Update Permission Denied', description='更新权限不足')
|
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+# -*- coding: utf-8 -*-
|
|
|
2
|
+
|
|
|
3
|
+from json_response import JsonpResponse, JsonResponse
|
|
|
4
|
+from StatusCode import StatusCodeField
|
|
|
5
|
+
|
|
|
6
|
+
|
|
|
7
|
+def response_data(status_code=200, message=None, description=None, data={}, **kwargs):
|
|
|
8
|
+ return dict({
|
|
|
9
|
+ 'status': status_code,
|
|
|
10
|
+ 'message': message,
|
|
|
11
|
+ 'description': description,
|
|
|
12
|
+ 'data': data,
|
|
|
13
|
+ }, **kwargs)
|
|
|
14
|
+
|
|
|
15
|
+
|
|
|
16
|
+def response(status_code=200, message=None, description=None, data={}, msg_args=[], msg_kwargs={}, desc_args=[], desc_kwargs={}, request=None, callback=None, **kwargs):
|
|
|
17
|
+ # Final Message and Description
|
|
|
18
|
+ message, description = (message or status_code.message, description or status_code.description) if isinstance(status_code, StatusCodeField) else (message, description)
|
|
|
19
|
+ # Final Response Data
|
|
|
20
|
+ resp_data = response_data(status_code, (message or '').format(*msg_args, **msg_kwargs), (description or '').format(*desc_args, **desc_kwargs), data, **kwargs)
|
|
|
21
|
+ # Assign Callback
|
|
|
22
|
+ callback = callback or (request and request.GET.get('callback'))
|
|
|
23
|
+ # Call JsonResponse or JsonpResponse
|
|
|
24
|
+ return JsonpResponse(callback, resp_data, safe=False) if callback else JsonResponse(resp_data, safe=False)
|
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+# -*- coding: utf-8 -*-
|
|
|
2
|
+
|
|
|
3
|
+from django.conf import settings
|
|
|
4
|
+
|
|
|
5
|
+
|
|
|
6
|
+r = settings.REDIS_CACHE
|
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+# -*- coding: utf-8 -*-
|
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+# -*- coding: utf-8 -*-
|
|
|
2
|
+
|
|
|
3
|
+
|
|
|
4
|
+def userinfo_save(userinfo):
|
|
|
5
|
+ """ Save profile or something else """
|
|
|
6
|
+ # from account.models import UserInfo
|
|
|
7
|
+ # from django.conf import settings
|
|
|
8
|
+ #
|
|
|
9
|
+ # unique_identifier = userinfo.get(settings.WECHAT_UNIQUE_IDENTIFICATION, '')
|
|
|
10
|
+ #
|
|
|
11
|
+ # user, created = UserInfo.objects.select_for_update().get_or_create(**{settings.WECHAT_UNIQUE_IDENTIFICATION: unique_identifier})
|
|
|
12
|
+ # user.unionid = userinfo.get('unionid', '')
|
|
|
13
|
+ # user.openid = userinfo.get('openid', '')
|
|
|
14
|
+ # user.nickname = userinfo.get('nickname', '')
|
|
|
15
|
+ # user.avatar = userinfo.get('headimgurl', '')
|
|
|
16
|
+ # user.save()
|
|
|
17
|
+ #
|
|
|
18
|
+ # return user
|