Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit cb20edb

Browse files
committed
小程序跳转链接方式修改为url scheme
1 parent 9974fa8 commit cb20edb

10 files changed

Lines changed: 110 additions & 80 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cloudbase-cms",
3-
"version": "2.12.3",
3+
"version": "2.13.10",
44
"private": true,
55
"scripts": {
66
"dev": "lerna run dev --stream",

packages/admin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cloudbase-cms-admin",
3-
"version": "2.13.9",
3+
"version": "2.13.10",
44
"private": true,
55
"description": "An out-of-box UI solution for enterprise applications",
66
"scripts": {

packages/admin/src/components/QrCode/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ export default (props: {
115115
{smsPageUrl}
116116
</Paragraph>
117117

118-
{!disableChannel && (
118+
{/* 说明:这里需要从url link方式转为url schema,并在预览链接页面做schema本地缓存,为了将缓存缩减到统一地方,这里的预览按钮屏蔽掉。(屏蔽前该按钮逻辑为url link跳转方式) */}
119+
{/* {!disableChannel && (
119120
<Button type="primary" size="small" loading={loading} onClick={() => generateUrlLink()}>
120121
短链生成
121122
</Button>
122-
)}
123+
)} */}
123124
</div>
124125
</Space>
125126
</Modal>

packages/admin/src/pages/project/operation/Message/TaskCreator.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,17 @@ const getMessageTemplate = (params: {
4949
const { miniappName = '', content = '', miniappShortname = '', templateSignValue = '' } = params
5050
// 存在环境变量,优先使用
5151
if (templateSignValue) {
52-
return `【${templateSignValue}${content},跳转小程序 wxaurl.cn/xxxxxxxxxxx
52+
return `【${templateSignValue}${content},跳转小程序 https://tcbe/xxxxxxxxxxx
5353
回T退订`
5454
}
5555

56-
let finalTempStr = `【${miniappName || '小程序名称'}${content},跳转小程序 wxaurl.cn/xxxxxxxxxxx
56+
let finalTempStr = `【${
57+
miniappName || '小程序名称'
58+
}${content},跳转小程序 https://tcbe/xxxxxxxxxxx
5759
回T退订`
5860
if (miniappName.length > 12) {
5961
if (miniappShortname) {
60-
finalTempStr = `【${miniappShortname}${content},跳转小程序 wxaurl.cn/xxxxxxxxxxx
62+
finalTempStr = `【${miniappShortname}${content},跳转小程序 https://tcbe/xxxxxxxxxxx
6163
回T退订`
6264
}
6365
}

packages/cms-openapi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cloudbase-cms-openapi",
3-
"version": "2.13.8",
3+
"version": "2.13.10",
44
"description": "CloudBase content manager system service restful api",
55
"author": "cwuyiqing@gmail.com",
66
"private": true,

packages/cms-openapi/src/api/api.service.ts

Lines changed: 58 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -91,40 +91,45 @@ export class ApiService {
9191

9292
console.log(phoneNumberList)
9393

94-
const activityPath = process.env.TCB_CMS ? 'tcb-cms-activities' : 'cms-activities'
94+
// const activityPath = process.env.TCB_CMS ? 'tcb-cms-activities' : 'cms-activities'
9595

9696
// 查询活动信息,获取小程序 path 和 query
9797
const {
9898
data: [activity],
9999
} = await this.collection(Collection.MessageActivity).doc(task.activityId).get()
100100

101101
// 生成短链
102-
let { urlLink } = await wxCloudApp.openapi.urllink.generate({
103-
// 小程序 query path
104-
path: activity?.appPath || '',
105-
query: activity?.appPathQuery || '',
106-
isExpire: true,
107-
expireType: 1,
108-
expireInterval: 30,
109-
cloudBase: {
110-
path: `/${activityPath}/index.html`,
111-
query: `source=_cms_sms_&activityId=${task.activityId}`,
112-
env: ENV,
113-
domain: '',
114-
},
115-
})
116-
117-
urlLink = urlLink.replace(/https:\/\/|http:\/\//, '')
102+
// let { urlLink } = await wxCloudApp.openapi.urllink.generate({
103+
// // 小程序 query path
104+
// path: activity?.appPath || '',
105+
// query: activity?.appPathQuery || '',
106+
// isExpire: true,
107+
// expireType: 1,
108+
// expireInterval: 30,
109+
// cloudBase: {
110+
// path: `/${activityPath}/index.html`,
111+
// query: `source=_cms_sms_&activityId=${task.activityId}`,
112+
// env: ENV,
113+
// domain: '',
114+
// },
115+
// })
116+
// urlLink = urlLink.replace(/https:\/\/|http:\/\//, '')
117+
118+
const jumpPath = this.getSmsPagePath(task.activityId)
118119

119120
// 下发短信
120-
const result = await wxCloudApp.openapi.cloudbase.sendSmsV2({
121+
const result = await wxCloudApp.openapi.cloudbase.sendSms({
121122
env: ENV,
122123
phoneNumberList,
124+
125+
content: task.content,
126+
path: jumpPath,
127+
123128
// https 的链接才有效
124-
urlLink: urlLink,
125-
templateParamList: [task.content],
126-
templateId: process.env.SMS_TEMPLATE_ID || '844110',
127-
use_short_name: !!useShortname,
129+
// urlLink: urlLink,
130+
// templateParamList: [task.content],
131+
// templateId: process.env.SMS_TEMPLATE_ID || '844110',
132+
// use_short_name: !!useShortname,
128133
})
129134

130135
// 上报短信下发任务
@@ -221,12 +226,19 @@ export class ApiService {
221226
}
222227

223228
// 创建发送任务
229+
// const result = await wxCloudApp.openapi.cloudbase.createSendSmsTask({
230+
// env: envId,
231+
// is_url_link: true,
232+
// file_url: fileUri,
233+
// template_id: process.env.SMS_TEMPLATE_ID || '844110',
234+
// use_short_name: useShortname,
235+
// })
224236
const result = await wxCloudApp.openapi.cloudbase.createSendSmsTask({
225237
env: envId,
226-
is_url_link: true,
227-
file_url: fileUri,
228-
template_id: process.env.SMS_TEMPLATE_ID || '844110',
229-
use_short_name: useShortname,
238+
// is_url_link: true,
239+
fileUrl: fileUri,
240+
templateId: process.env.SMS_TEMPLATE_ID || '844110',
241+
useShortName: useShortname,
230242
})
231243

232244
console.log('发送结果', result)
@@ -564,37 +576,39 @@ export class ApiService {
564576
}
565577

566578
// 生成跳转路径
567-
const activityPath = process.env.TCB_CMS ? 'tcb-cms-activities' : 'cms-activities'
579+
// const activityPath = process.env.TCB_CMS ? 'tcb-cms-activities' : 'cms-activities'
568580

569581
// 查询活动信息,获取小程序 path 和 query
570582
const {
571583
data: [activity],
572584
} = await this.collection(Collection.MessageActivity).doc(activityId).get()
573585

574586
// 生成短链
575-
let { urlLink } = await wxCloudApp.openapi.urllink.generate({
576-
// 小程序 query path
577-
path: activity?.appPath || '',
578-
query: activity?.appPathQuery || '',
579-
isExpire: true,
580-
expireType: 1,
581-
expireInterval: 30,
582-
cloudBase: {
583-
path: `/${activityPath}/index.html`,
584-
query: `source=_cms_sms_&activityId=${activityId}`,
585-
env: envId,
586-
domain: '',
587-
},
588-
})
589-
590-
urlLink = urlLink.replace(/https:\/\/|http:\/\//, '')
587+
// let { urlLink } = await wxCloudApp.openapi.urllink.generate({
588+
// // 小程序 query path
589+
// path: activity?.appPath || '',
590+
// query: activity?.appPathQuery || '',
591+
// isExpire: true,
592+
// expireType: 1,
593+
// expireInterval: 30,
594+
// cloudBase: {
595+
// path: `/${activityPath}/index.html`,
596+
// query: `source=_cms_sms_&activityId=${activityId}`,
597+
// env: envId,
598+
// domain: '',
599+
// },
600+
// })
601+
// urlLink = urlLink.replace(/https:\/\/|http:\/\//, '')
602+
603+
const jumpPath = this.getSmsPagePath(activityId)
591604

592605
const supplementData = data.map((line: string[], index) => {
593606
if (isFirstLineTitle && index === 0) return line
594607
// 补充 +86
595608
line[0] = /^\+86/.test(line[0]) ? line[0] : `+86${line[0]}`
596609
// 替换为新的链接
597-
line[2] = line[2] ? line[2] : urlLink
610+
// line[2] = line[2] ? line[2] : urlLink
611+
line[2] = jumpPath
598612
return line
599613
})
600614

packages/cms-sms-page/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sms-page",
3-
"version": "2.13.6",
3+
"version": "2.13.10",
44
"private": true,
55
"scripts": {
66
"dev": "vue-cli-service serve",

packages/cms-sms-page/src/App.vue

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -195,27 +195,41 @@ export default {
195195
// 触发云函数的名称
196196
const functionName = WX_MP ? 'wx-ext-cms-sms' : 'tcb-ext-cms-sms'
197197
198-
// 查询活动信息
199-
const res = await this.cloudApp.callFunction({
200-
name: functionName,
201-
data: {
202-
channelId,
203-
sessionId,
204-
activityId,
205-
referer: document.referrer,
206-
action: 'getUrlScheme',
207-
},
208-
})
209-
210-
const { result } = res
198+
// 查询本地缓存数据,如果有就不用重复发包了,微信有效scheme数量有上限
199+
const schemeKey = `ext_cms_sms_url_scheme_key_${channelId}_${sessionId}_${activityId}`
200+
const localResStr = sessionStorage.getItem(schemeKey)
201+
let res
202+
if (!!localResStr) {
203+
try {
204+
res = JSON.parse(localResStr)
205+
} catch (e) {}
206+
}
207+
if (!res || !res?.result) {
208+
// 查询活动信息
209+
res = await this.cloudApp.callFunction({
210+
name: functionName,
211+
data: {
212+
channelId,
213+
sessionId,
214+
activityId,
215+
referer: document.referrer,
216+
action: 'getUrlScheme',
217+
},
218+
})
219+
}
220+
221+
const { result } = res || {}
211222
212223
// 函数执行错误
213-
if (result.error) {
224+
if (!result || !!result?.error) {
214225
this.generateSchemaError = true
215-
this.showDialog(result.error.message)
226+
this.showDialog(result?.error?.message || '未知错误')
216227
return
217228
}
218229
230+
//缓存scheme数据,方便下次直接获取
231+
sessionStorage.setItem(schemeKey, JSON.stringify(res))
232+
219233
this.openlink = res.result.openlink
220234
221235
// 活动信息

sam-wx.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TCBSAMFormatVersion: '2020-10-20'
22
Name: wx-ext-cms
33
SpecVersion: v1beta
4-
Version: 2.13.7
4+
Version: 2.13.10
55
License: Apache-2.0
66
Category: CloudApp
77
DisplayName: 内容管理(CMS)
@@ -19,9 +19,9 @@ IconUrl: https://main.qcloudimg.com/raw/f87b49914efe502722f9aa128f5d8865/hello_w
1919
IntroUrl: https://docs.cloudbase.net/cms/intro.html
2020
# 更新日志
2121
ChangeLog:
22-
- Title: 2.13.7
22+
- Title: 2.13.10
2323
Content:
24-
- 修复短信签名环境注入bug
24+
- 优化运营活动短信策略
2525
Author:
2626
AuthorName: TCB
2727
Email: cloudbase@tencent.com
@@ -39,7 +39,7 @@ Resources:
3939
Type: CloudBase::Function
4040
Properties:
4141
FunctionName: wx-ext-cms-service
42-
CodeUri: extension://99f837b4a53a460590ec32440cc00d96.zip
42+
CodeUri: extension://1f9f05f5541641eab68b6f7dd2ed7870.zip
4343
InstallDependency: true
4444
Description: 提供 CMS 管理服务,所有对内容的操作和管理都会经过此函数调用,内容操作会根据用户权限来进行数据库操作
4545
MemorySize: 256
@@ -58,7 +58,7 @@ Resources:
5858
Type: CloudBase::Function
5959
Properties:
6060
FunctionName: wx-ext-cms-init
61-
CodeUri: extension://ad4719221db948c1b72fc7366b47e717.zip
61+
CodeUri: extension://8d709e3a52f749b7900802ed8b47c319.zip
6262
InstallDependency: true
6363
Description: 提供初始化应用功能,安装扩展后,会通过该函数来进行静态资源的部署和密码的生成和设置,修改账号密码或者部署路径等扩展参数都会再次执行该函数来进行更新
6464
MemorySize: 256
@@ -80,7 +80,7 @@ Resources:
8080
Type: CloudBase::Function
8181
Properties:
8282
FunctionName: wx-ext-cms-api
83-
CodeUri: extension://a6b0abcf28034d76a5b4b98dd63edaa8.zip
83+
CodeUri: extension://4f58d4c613114d628378722c8f65a4b1.zip
8484
InstallDependency: true
8585
Description: 提供 CMS RESTful API 访问能力,所有 RESTful API 请求都会经过此函数调用
8686
MemorySize: 256
@@ -97,7 +97,7 @@ Resources:
9797
Type: CloudBase::Function
9898
Properties:
9999
FunctionName: wx-ext-cms-sms
100-
CodeUri: extension://bd3c016d21984738ac8a545143a8f20d.zip
100+
CodeUri: extension://6b902674646d44688eb49c700c3e1a6d.zip
101101
InstallDependency: true
102102
Description: 提供短信发送、生成 url schema 功能
103103
MemorySize: 256
@@ -114,7 +114,7 @@ Resources:
114114
Type: CloudBase::Function
115115
Properties:
116116
FunctionName: wx-ext-cms-openapi
117-
CodeUri: extension://208b697e638943338c863f540f6b8636.zip
117+
CodeUri: extension://b52048d8c3ea4d048e06e49f44d63084.zip
118118
InstallDependency: true
119119
Description: 提供调用微信 Openapi 接口的能力
120120
MemorySize: 2048
@@ -132,7 +132,7 @@ Resources:
132132
Type: CloudBase::Function
133133
Properties:
134134
FunctionName: wx-ext-cms-fx-openapi
135-
CodeUri: extension://a7e62b09d3bc4e51967515346c69b58f.zip
135+
CodeUri: extension://c80f6c7623b94a6da03db15968655428.zip
136136
InstallDependency: true
137137
Description: 提供调用微信 Openapi 接口的能力
138138
MemorySize: 1024

sam.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ IconUrl: https://main.qcloudimg.com/raw/f87b49914efe502722f9aa128f5d8865/hello_w
1919
IntroUrl: https://docs.cloudbase.net/cms/intro.html
2020
# 更新日志
2121
ChangeLog:
22-
- Title: 2.13.6
22+
- Title: 2.13.10
2323
Content:
24-
- 修复生成短链缺appPath问题
25-
- 修复营销活动中间页跳转拼接参数缺&问题
24+
- 优化运营活动短信策略
2625
Author:
2726
AuthorName: TCB
2827
Email: cloudbase@tencent.com

0 commit comments

Comments
 (0)