| | |
| | | |
| | | let wxTemps = sessionStorage.getItem('wxTemplates' + appId) |
| | | |
| | | if (appId && window.GLOB.nginx && !wxTemps) { |
| | | if (appId && !wxTemps) { |
| | | if (verify.wxNote === 'true') { |
| | | this.getTemps(appId) |
| | | } |
| | |
| | | } |
| | | |
| | | 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.primary_industry || 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 && window.GLOB.nginx) { |
| | | if (key === 'wxNote' && value === 'true' && window.GLOB.WXAppID) { |
| | | let wxTemps = sessionStorage.getItem('wxTemplates' + window.GLOB.WXAppID) |
| | | |
| | | if (wxTemps) { |
| | |
| | | |
| | | setTimeout(() => { |
| | | this.props.onChange(_verify_) |
| | | |
| | | if (!window.GLOB.nginx) { |
| | | message.warning('nginx服务尚未开启,请检查配置文件并在服务器中完成nginx设置。') |
| | | return |
| | | } |
| | | |
| | | let wxTemps = sessionStorage.getItem('wxTemplates' + val) |
| | | |