| | |
| | | |
| | | let wxTemps = sessionStorage.getItem('wxTemplates' + appId) |
| | | |
| | | if (appId && window.GLOB.nginx && !wxTemps) { |
| | | this.getTemps(appId) |
| | | if (appId && !wxTemps) { |
| | | if (verify.wxNote === 'true') { |
| | | this.getTemps(appId) |
| | | } |
| | | } else if (wxTemps) { |
| | | wxTemps = JSON.parse(wxTemps) |
| | | |
| | |
| | | } |
| | | |
| | | getTemps = (appId) => { |
| | | Api.wxAccessToken(appId).then(res => { |
| | | if (res.status && res.access_token) { |
| | | Api.wxNginxRequest(`cgi-bin/template/get_all_private_template?access_token=${res.access_token}`, 'get').then(res => { |
| | | let temps = [] |
| | | if (res.template_list) { |
| | | temps = res.template_list.filter(item => { |
| | | if (!item.primary_industry || sysTempsIds.includes(item.template_id)) return false |
| | | if (item.content) { |
| | | item.content = item.content.replace('{{first.DATA}}\n', '').replace('\n{{remark.DATA}}', '') |
| | | } |
| | | |
| | | return true |
| | | }) |
| | | } else if (res.errcode && res.errmsg) { |
| | | message.warning(res.errcode + ': ' + res.errmsg) |
| | | // cgi-bin/template/get_all_private_template |
| | | Api.directRequest({ |
| | | url: window.GLOB.baseurl + 'wechat/get_all_private_template?appid=' + appId, |
| | | method: 'get', |
| | | }).then(res => { |
| | | let temps = [] |
| | | if (res.template_list) { |
| | | temps = res.template_list.filter(item => { |
| | | if (!item.content || item.content.length < 25 || sysTempsIds.includes(item.template_id)) return false |
| | | if (item.content) { |
| | | item.content = item.content.replace('{{first.DATA}}\n', '').replace('\n{{remark.DATA}}', '') |
| | | } |
| | | |
| | | sessionStorage.setItem('wxTemplates' + appId, JSON.stringify(temps)) |
| | | |
| | | this.resetTemps(temps) |
| | | return true |
| | | }) |
| | | } else { |
| | | message.warning(res.message || '微信授权失败!') |
| | | sessionStorage.setItem('wxTemplates' + appId, JSON.stringify([])) |
| | | } else if (res.errcode && res.errmsg) { |
| | | message.warning(res.errcode + ': ' + res.errmsg) |
| | | } |
| | | |
| | | sessionStorage.setItem('wxTemplates' + appId, JSON.stringify(temps)) |
| | | |
| | | this.resetTemps(temps) |
| | | }) |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | this.props.onChange(_verify) |
| | | |
| | | if (key === 'wxNote' && value === 'true' && window.GLOB.WXAppID) { |
| | | let wxTemps = sessionStorage.getItem('wxTemplates' + window.GLOB.WXAppID) |
| | | |
| | | if (wxTemps) { |
| | | wxTemps = JSON.parse(wxTemps) |
| | | |
| | | this.resetTemps(wxTemps) |
| | | } else { |
| | | this.getTemps(window.GLOB.WXAppID) |
| | | } |
| | | } |
| | | } |
| | | |
| | | onNoteCodeChange = (val, option) => { |
| | |
| | | |
| | | let keys = [] |
| | | if (option.props.content) { |
| | | keys = option.props.content.match(/{{[a-zA-Z0-9]+\.DATA}}/g) |
| | | keys = option.props.content.match(/{{[a-zA-Z0-9_]+\.DATA}}/g) |
| | | keys = keys.map(key => key.replace(/{{|\.DATA}}/g, '')) |
| | | } |
| | | |