-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ Library-Type: Frontend | |
Metadata-File: usage.json | ||
packages/extension/[email protected]/dist-theme/demo.html: dist-theme/demo.html | ||
packages/extension/[email protected]/dist-theme/index.js: dist-theme/index.js | ||
packages/extension/[email protected]/dist-theme/index.js.map: dist-theme/index.js.map | ||
packages/extension/[email protected]/dist-theme/index.js.map: dist-theme/index.js.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/cw/wechat_sdk_share/logics/sendTemplateMessage/api.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- name: sendTemplateMessage | ||
description: 发送模版消息 | ||
type: both | ||
belong: logic | ||
labels: [Runtime] |
41 changes: 41 additions & 0 deletions
41
packages/cw/wechat_sdk_share/logics/sendTemplateMessage/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* @param {string} options <false> 这是一个描述 | ||
* @returns {string} result | ||
*/ | ||
import wx from 'weixin-js-sdk' | ||
export default (appId, nonceStr, signature, accessToken, openId, templateId, url, pagepath, value ) => { | ||
var timestamp = Math.floor(new Date().getTime() / 1000).toString(); | ||
|
||
wx.config({ | ||
debug: false, | ||
appId, | ||
timestamp, | ||
nonceStr, | ||
signature, | ||
jsApiList: ["chooseWXPay", "sendTemplateMessage"], // 需要使用的JS接口列表 | ||
}); | ||
|
||
wx.ready(function () { | ||
// 在这里调用微信JS-SDK的接口 | ||
wx.sendTemplateMessage({ | ||
touser: openId, | ||
template_id, | ||
url, | ||
miniprogram: { | ||
appid, | ||
pagepath, | ||
}, | ||
data: { | ||
keyword1: { | ||
value, | ||
}, | ||
}, | ||
success: function (res) { | ||
console.log('success', res) | ||
}, | ||
fail: function (error) { | ||
console.error('error', error) | ||
}, | ||
}); | ||
}); | ||
}; |