1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- // 云函数入口文件
- const cloud = require('wx-server-sdk')
- cloud.init()
- // 云函数入口函数
- exports.main = async (event, context) => {
- const wxContext = cloud.getWXContext()
- switch (event.action) {
- case 'getUrlScheme': {
- return getUrlScheme(event.query)
- }
- case 'getOpenWxJoin':
- return openWxJoin(event.query)
- case 'douyinCoupon':
- return douyinCoupon(event.query);
- }
- return 'action not found'
- }
- //抖音券兑换
- async function douyinCoupon(query){
- return cloud.openapi.urlscheme.generate({
- jumpWxa: {
- path: '/pages/ucenter/couponList/couponList',
- query:query
- },
- // 如果想不过期则置为 false,并可以存到数据库
- isExpire: false,
- })
- }
- async function openWxJoin(query) {
- return cloud.openapi.urlscheme.generate({
- jumpWxa: {
- path: '/pages/ucenter/wx/join',
- query:query
- },
- // 如果想不过期则置为 false,并可以存到数据库
- isExpire: false,
- // 一分钟有效期
- expireTime: parseInt(Date.now() / 1000 + 60),
- })
- }
- async function getUrlScheme(query) {
- return cloud.openapi.urlscheme.generate({
- jumpWxa: {
- path: '/pages/ucenter/couponList/couponList', // <!-- replace -->
- query: query,
- },
- // 如果想不过期则置为 false,并可以存到数据库
- isExpire: false,
- // 一分钟有效期
- expireTime: parseInt(Date.now() / 1000 + 60),
- })
- }
|