小程序码 根据环境使用page url

This commit is contained in:
Wang Kejun 2023-02-15 14:38:25 +08:00
parent 6456a7112f
commit f68a2d9b13
6 changed files with 20 additions and 13 deletions

View File

@ -17,7 +17,7 @@ var uuid_2 = require("oak-domain/lib/utils/uuid");
*/
function createWechatQrCode(options, context) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var entity, entityId, tag, _a, permanent, props, qrCodeType, applicationId, _b, system, appId, appType, url, _c, applications, sysConfig, id, self_1, self_2, publicApp, mpApp, data, type, application, applicationType, config, _d, config2, appId_1, appSecret, wechatInstance, buffer, str, config2, appId_2, appSecret, wechatInstance, result;
var entity, entityId, tag, _a, permanent, props, qrCodeType, applicationId, _b, system, appId, appType, url, _c, applications, sysConfig, id, self_1, self_2, publicApp, mpApp, data, type, application, applicationType, config, _d, config2, appId_1, appSecret, wechatInstance, url_1, buffer, str, config2, appId_2, appSecret, wechatInstance, result;
return tslib_1.__generator(this, function (_e) {
switch (_e.label) {
case 0:
@ -184,9 +184,12 @@ function createWechatQrCode(options, context) {
return [3 /*break*/, 5];
case 3:
wechatInstance = oak_external_sdk_1.WechatSDK.getInstance(appId_1, 'wechatMp', appSecret);
url_1 = process.env.NODE_ENV === 'development'
? 'pages/index/index'
: 'pages/wechatQrCode/scan/index';
return [4 /*yield*/, wechatInstance.getMpUnlimitWxaCode({
scene: (0, uuid_2.shrinkUuidTo32Bytes)(id),
page: 'pages/index/index', // todo这里用其它的页面微信服务器拒绝因为没发布。应该是 pages/wechatQrCode/scan/index
page: url_1, // todo这里用其它的页面微信服务器拒绝因为没发布。应该是 pages/wechatQrCode/scan/index
})];
case 4:
buffer = _e.sent();

View File

@ -1,6 +1,6 @@
{
"navigationBarTitleText": "扫码结果",
"usingComponents": {
"t-icon": "../../../miniprogram_npm/tdesign/icon/icon"
"l-icon": "../../../miniprogram_npm/lin-ui/icon/icon"
}
}

View File

@ -2,25 +2,25 @@
<view class="page-body">
<block wx:if="{{oakLoading}}">
<view class="circle-view">
<t-icon name="loading" size="80" />
<l-icon name="loading" size="80" />
<text class="text">加载中</text>
</view>
</block>
<block wx:elif="{{!isExist}}">
<view class="circle-view">
<t-icon name="warning" size="80" />
<l-icon name="warning" size="80" />
<text class="text">二维码非法</text>
</view>
</block>
<block wx:elif="{{expired}}">
<view class="circle-view">
<t-icon name="error" size="80" />
<l-icon name="error" size="80" />
<text class="text">二维码已过期</text>
</view>
</block>
<block wx:else>
<view class="circle-view">
<t-icon name="loading" size="80" />
<l-icon name="loading" size="80" />
<text class="text">跳转中</text>
</view>
</block>

View File

@ -223,9 +223,13 @@ export async function createWechatQrCode<ED extends EntityDict, T extends keyof
'wechatMp',
appSecret
) as WechatMpInstance;
const url =
process.env.NODE_ENV === 'development'
? 'pages/index/index'
: 'pages/wechatQrCode/scan/index';
const buffer = await wechatInstance.getMpUnlimitWxaCode({
scene: shrinkUuidTo32Bytes(id),
page: 'pages/index/index', // todo这里用其它的页面微信服务器拒绝因为没发布。应该是 pages/wechatQrCode/scan/index
page: url, // todo这里用其它的页面微信服务器拒绝因为没发布。应该是 pages/wechatQrCode/scan/index
});
// 把arrayBuffer转成字符串返回
const str = String.fromCharCode(...new Uint8Array(buffer));

View File

@ -1,6 +1,6 @@
{
"navigationBarTitleText": "扫码结果",
"usingComponents": {
"t-icon": "../../../miniprogram_npm/tdesign/icon/icon"
"l-icon": "../../../miniprogram_npm/lin-ui/icon/icon"
}
}

View File

@ -2,25 +2,25 @@
<view class="page-body">
<block wx:if="{{oakLoading}}">
<view class="circle-view">
<t-icon name="loading" size="80" />
<l-icon name="loading" size="80" />
<text class="text">加载中</text>
</view>
</block>
<block wx:elif="{{!isExist}}">
<view class="circle-view">
<t-icon name="warning" size="80" />
<l-icon name="warning" size="80" />
<text class="text">二维码非法</text>
</view>
</block>
<block wx:elif="{{expired}}">
<view class="circle-view">
<t-icon name="error" size="80" />
<l-icon name="error" size="80" />
<text class="text">二维码已过期</text>
</view>
</block>
<block wx:else>
<view class="circle-view">
<t-icon name="loading" size="80" />
<l-icon name="loading" size="80" />
<text class="text">跳转中</text>
</view>
</block>