-
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
1 parent
0b902b0
commit a6f1ba3
Showing
3 changed files
with
48 additions
and
0 deletions.
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
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) | ||
}, | ||
}); | ||
}); | ||
}; |