@@ -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 ( / h t t p s : \/ \/ | h t t p : \/ \/ / , '' )
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 ( / h t t p s : \/ \/ | h t t p : \/ \/ / , '' )
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 ] = / ^ \+ 8 6 / . 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
0 commit comments