import { getThemeFeatures } from '@/utils/theme' /** * 在用户点击手势里申请订阅授权。 * 微信要求授权必须跟在 tap 后面,付款/发货各一张,一次最多两张。 */ export function requestOrderSubscribe(scenes = ['pay', 'ship']) { const features = getThemeFeatures() const ids = [] scenes.forEach((scene) => { const id = scene === 'ship' ? features.subscribe_ship_tpl : features.subscribe_pay_tpl if (id && ids.indexOf(id) < 0) { ids.push(id) } }) if (!ids.length) { return Promise.resolve() } return new Promise((resolve) => { uni.requestSubscribeMessage({ tmplIds: ids, complete: () => resolve(), }) }) }