king
2022-08-02 8d66ff34fae5b048a6b7923cc75d34f13a08be9d
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,39 @@
class Design extends Component {
  componentDidMount() {
    setGLOBFuncs()
    // 获取微信公众号及小程序消息模板
    if (window.GLOB.systemType !== 'production' && window.GLOB.WXAppID && !sessionStorage.getItem('wxTemplates')) {
      Api.wxAccessToken().then(res => {
        let wxtoken = res.oa_access_token || ''
        wxtoken = '59_DH0hrAp0B8jtdJvU-7BV_-nG01qh2rUU1L8ihj-2pMWlUFLE2eEtVv4zZYAUIKcxCit4SgOTwxvUGdYHltaha3RmgnZqkQSgkxXRm9hz18kGbGhMc5r11W5Iv9Xr50Pz-Sz7FUVHCM-6GZLXJPIjAIAVBU'
        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 if (res.errcode === 0) {
              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 () {