欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

uniapp微信小程序订阅消息

程序员文章站 2022-07-13 21:29:45
...
'use strict';
exports.main = async (event, context) => {
	const token = event.token;
	const openid = event.openid;
	const name = event.custname;
	const phone = event.custphone;
	const dizhi = event.custdizhi;
	const ydate = event.custdate;
	const beizhu = event.custbeizhu;
	const url = `https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=${token}`;
	const res = await uniCloud.httpclient.request(url,{
		method:"POST",
		contentType: 'json',
		dataType:"json",
		data:{
			touser: openid,
			page: 'index',
			lang: 'zh_CN',
			data: {
				  name1: {
					value: name
				  },
				  thing2: {
					value: dizhi
				  },
				  phone_number4:{
					  value:phone
				  },
				  thing7:{
					  value:ydate
				  }
				},
			template_id:'krG6MsATQYYfr2xzXpmoGc4FfQh9MZXCDNoY1aGNxUU',
			miniprogramState:'developer'
		}
	})

	return res;

};

相关标签: 我的编程笔记