From 4313d9ccea6534b1da71baa1bf499f045d3c1f0b Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 08 七月 2022 00:57:55 +0800 Subject: [PATCH] 2022-07-08 --- src/views/design/index.jsx | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/src/views/design/index.jsx b/src/views/design/index.jsx index 8942896..049b7da 100644 --- a/src/views/design/index.jsx +++ b/src/views/design/index.jsx @@ -3,6 +3,7 @@ import enUS from 'antd/es/locale/en_US' import zhCN from 'antd/es/locale/zh_CN' +import Api from '@/api' import asyncComponent from '@/utils/asyncComponent' import Header from './header' import { setGLOBFuncs } from '@/utils/utils.js' @@ -16,6 +17,38 @@ class Design extends Component { componentDidMount() { setGLOBFuncs() + + // 鑾峰彇寰俊鍏紬鍙峰強灏忕▼搴忔秷鎭ā鏉� + if (!sessionStorage.getItem('wxTemplates')) { + Api.wxRequest('wxpay/getaccesstoken', 'get').then(res => { + let wxtoken = res.oa_access_token || '' + let minitoken = res.mini_access_token || '' + + if (wxtoken) { + Api.wxNginxRequest(`cgi-bin/template/get_all_private_template?access_token=${wxtoken}`, 'get').then(res => { + if (res.template_list) { + let temps = res.template_list.filter(item => item.primary_industry) + sessionStorage.setItem('wxTemplates', JSON.stringify(temps)) + } else { + sessionStorage.setItem('wxTemplates', JSON.stringify([])) + } + }) + } else { + sessionStorage.setItem('wxTemplates', JSON.stringify([])) + } + if (minitoken) { + Api.wxNginxRequest(`wxaapi/newtmpl/gettemplate?access_token=${minitoken}`, 'get').then(res => { + if (res.errmsg === 'ok' && res.data) { + sessionStorage.setItem('wxMiniTemplates', JSON.stringify(res.data)) + } else { + sessionStorage.setItem('wxMiniTemplates', JSON.stringify([])) + } + }) + } else { + sessionStorage.setItem('wxMiniTemplates', JSON.stringify([])) + } + }) + } } render () { -- Gitblit v1.8.0