From da64ab0923bf8817fc8599a6e37b953ce38f64c8 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 27 八月 2023 18:37:36 +0800
Subject: [PATCH] 2023-08-27

---
 src/views/appmanage/index.jsx |  184 ++++++++++++++++++++++++++++++++++-----------
 1 files changed, 138 insertions(+), 46 deletions(-)

diff --git a/src/views/appmanage/index.jsx b/src/views/appmanage/index.jsx
index 3f34590..75206ec 100644
--- a/src/views/appmanage/index.jsx
+++ b/src/views/appmanage/index.jsx
@@ -23,15 +23,6 @@
 const ScriptForm = asyncComponent(() => import('./scriptform'))
 const SubMutilForm = asyncComponent(() => import('./submutilform'))
 
-let base_url = ''
-if (process.env.NODE_ENV === 'production') {
-  base_url = document.location.origin + '/' + window.GLOB.service
-} else {
-  base_url = window.GLOB.location + '/' + window.GLOB.service
-}
-
-sessionStorage.setItem('isEditState', 'true')
-
 const skinStyle = {
   bg_black_style_blue: {name: '钃濊壊', color: '#1890ff'},
   bg_black_style_red: {name: '绾㈣壊', color: '#f5222d'},
@@ -46,7 +37,8 @@
   bg_black_style_purple: {name: '绱壊', color: '#722ed1'},
   bg_black_style_magenta: {name: '娲嬬孩鑹�', color: '#eb2f96'},
   bg_black_style_grass_green: {name: '鑽夌豢鑹�', color: '#aeb303'},
-  bg_black_style_deep_red: {name: '娣辩孩鑹�', color: '#c32539'}
+  bg_black_style_deep_red: {name: '娣辩孩鑹�', color: '#c32539'},
+  bg_black_style_deep_blue: {name: '娣辩孩鑹�', color: '#1d3661'}
 }
 
 class AppManage extends Component {
@@ -118,6 +110,20 @@
   forbid = false
 
   UNSAFE_componentWillMount() {
+    if (sessionStorage.getItem('devError') === 'true') {
+      sessionStorage.clear()
+      window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login')
+      window.location.reload()
+      return
+    }
+
+    if (!sessionStorage.getItem('UserID')) {
+      this.props.history.replace('/login')
+      return
+    }
+
+    window.GLOB.developing = true
+
     document.body.className = ''
     this.getAppList()
     this.getSmStemp()
@@ -467,11 +473,37 @@
               } catch (e) {
                 _param = {}
               }
-              cell.copyright = _param.copyright || ''
-              cell.logo = _param.logo || ''
+              // cell.copyright = _param.copyright || ''
+              // cell.logo = _param.logo || ''
               cell.apptype = _param.apptype || ''
               cell.delay = _param.delay || 0
               cell.statusBarColor = _param.statusBarColor || 'black'
+              cell.sysBgColor = _param.sysBgColor || '#ffffff'
+              cell.direction = _param.direction || 'vertical'
+              cell.adapter = _param.adapter || ''
+              cell.topHeight = _param.topHeight || ''
+              cell.share = _param.share || 'false' // 鍒嗕韩
+              cell.share_des = _param.share_des || '' // 鍒嗕韩鎻忚堪
+              cell.share_url = _param.share_url || '' // 鍒嗕韩鍥剧墖
+              cell.share_link = _param.share_link || '' // 鍒嗕韩閾炬帴
+
+              if (cell.adapter && (cell.adapter === 'true' || cell.adapter === 'false')) {
+                cell.adapter = ''
+              }
+
+              cell.userbind = _param.userbind || ''
+              cell.instantMessage = _param.instantMessage || ''
+            }
+
+            if (cell.user_binding !== 'true') {
+              cell.user_binding = 'false'
+            }
+            if (cell.share !== 'true') {
+              cell.share = 'false'
+            }
+
+            if (!cell.adapter && cell.apptype) {
+              cell.adapter = 'app'
             }
 
             return cell
@@ -483,6 +515,32 @@
 
           return item
         })
+
+        if (!selectApp && applist[0]) {
+          let _href = window.location.href.split('#')[0] + 'app_record'
+          let record = localStorage.getItem(_href)
+          record = record ? JSON.parse(record) : null
+
+          if (record && record.dates) {
+            let ids = applist.map(item => item.ID)
+            let reset = false
+
+            Object.keys(record.dates).forEach(key => {
+              if (!ids.includes(key)) {
+                delete record.dates[key]
+                reset = true
+              }
+            })
+
+            applist.sort((a, b) => {
+              return (record.dates[b.ID] || 0) - (record.dates[a.ID] || 0)
+            })
+
+            if (reset) {
+              localStorage.setItem(_href, JSON.stringify(record))
+            }
+          }
+        }
 
         if (!selectApp && applist[0]) {
           selectApp = applist[0]
@@ -507,8 +565,8 @@
   }
 
   getSmStemp = () => {
-    let _sql = `select ID,TemplateCode,SignName from (select * from bd_msn_sms_temp where deleted=0 and status=20 ) a 
-      inner join (select openid from sapp where id='${window.GLOB.appkey}') b
+    let _sql = `select聽ID,TemplateCode,SignName+'_'+describe as SignName from (select * from bd_msn_sms_temp where deleted=0 and status=20 ) a 
+      inner join (select openid from sapp where id='${window.GLOB.appkey}') b 
       on a.openid=b.openid`
 
     _sql = Utils.formatOptions(_sql)
@@ -524,7 +582,7 @@
     param.secretkey = Utils.encrypt(param.LText, param.timestamp)
     param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 浜戠鏁版嵁楠岃瘉
     
-    Api.getSystemConfig(param).then(res => {
+    Api.getCloudConfig(param).then(res => {
       let msgs = []
       if (!res.status) {
         notification.warning({
@@ -567,6 +625,9 @@
               })
               _this.getAppList()
             } else {
+              if (result.message.indexOf('kei_no宸茶鑿滃崟浣跨敤锛屼笉鍙垹闄�') > -1) {
+                result.message = 'kei_no宸茶鑿滃崟浣跨敤锛屼笉鍙垹闄�'
+              }
               notification.warning({
                 top: 92,
                 message: result.message,
@@ -597,14 +658,23 @@
       LText: ''
     }
 
+    param.del_typename = record.typename
+    param.lang = record.lang
     param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
     param.secretkey = Utils.encrypt('', param.timestamp)
 
     let sublist = fromJS(selectApp.sublist).toJS()
     sublist = sublist.filter(item => item.ID !== record.ID)
+    sublist = sublist.map(item => {
+      if (item.typename !== 'pc') {
+        item.userbind = md5(selectApp.kei_no + item.typename + item.lang).replace(/^.{8}/, 'userbind')
+        item.instantMessage = md5(selectApp.kei_no + item.typename + item.lang).replace(/^.{14}/, 'instantmessage')
+      }
+      return item
+    })
 
-    // param.LText = sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','${item.login_types || 'true'}','${item.link_type || 'true'}','${item.role_type || 'true'}','${item.lang || 'zh-CN'}'`)
-    param.LText = sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','false','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || ''}','${item.sms_id || ''}','${window.btoa(window.encodeURIComponent(JSON.stringify({copyright: item.copyright || '', logo: item.logo || '', apptype: item.apptype || '', delay: item.delay || 0, statusBarColor: item.statusBarColor || 'black'})))}'`)
+    // 瀛愬簲鐢↖D銆乼ypename銆佸簲鐢↖D銆丆loudUserID銆乤ppkey銆乴ogin_types(鏄惁闇�瑕佺櫥褰曪紝宸插純鐢�)銆乴ink_type(鏄惁浣跨敤鐭繛鎺ワ紝宸插純鐢�)銆乺ole_type(鏄惁浣跨敤瑙掕壊绠$悊)銆乴ang銆乧ss(鐨偆)銆乼itle(鏍囬)銆乫avicon(鍥炬爣)銆乽ser_binding(鐢ㄦ埛缁戝畾)銆乻ms_id(鐭俊妯℃澘ID)銆佽嚜瀹氫箟
+    param.LText = sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','false','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || 'false'}','','${window.btoa(window.encodeURIComponent(JSON.stringify({userbind: item.userbind || '', instantMessage: item.instantMessage || '', apptype: item.apptype || '', delay: item.delay || 0, statusBarColor: item.statusBarColor || 'black', topHeight: item.topHeight || '', sysBgColor: item.sysBgColor || '#ffffff', direction: item.direction || 'vertical', adapter: item.adapter || '', share: item.share || '', share_des: item.share_des || '', share_url: item.share_url || '', share_link: item.share_link || ''})))}'`)
     param.LText = param.LText.join(' union all ')
     param.LText = Utils.formatOptions(param.LText)
     
@@ -645,12 +715,27 @@
   jumpApp = (item) => {
     const { selectApp } = this.state
 
+    let _href = window.location.href.split('#')[0] + 'app_record'
+    let record = localStorage.getItem(_href)
+    record = record ? JSON.parse(record) : null
+
+    if (!record || !record.dates) {
+      localStorage.setItem(_href, JSON.stringify({preId: selectApp.ID, activeId: selectApp.ID, dates: {[selectApp.ID]: new Date().getTime()}}))
+    } else {
+      if (record.preId === selectApp.ID || record.activeId === selectApp.ID) {
+        localStorage.setItem(_href, JSON.stringify({preId: selectApp.ID, activeId: selectApp.ID, dates: {...record.dates, [selectApp.ID]: new Date().getTime()}}))
+      } else {
+        localStorage.setItem(_href, JSON.stringify({...record, preId: selectApp.ID}))
+      }
+    }
+
     let route = 'mobdesign'
     if (item.typename === 'pc') {
       route = 'pcdesign'
     }
+    let param = {...item, kei_no: selectApp.kei_no, remark: selectApp.remark, type: 'app'}
 
-    window.open(window.location.href.replace(/#.+/ig, `#/${route}/${window.btoa(window.encodeURIComponent(JSON.stringify({...item, kei_no: selectApp.kei_no, remark: selectApp.remark, type: 'app'})))}`))
+    window.open(window.location.href.replace(/#.+/ig, `#/${route}/${window.btoa(window.encodeURIComponent(JSON.stringify(param)))}`))
   }
 
   jumpMenu = (item) => {
@@ -827,8 +912,15 @@
       param.secretkey = Utils.encrypt('', param.timestamp)
 
       if (visible === 'edit') {
-        // param.LText = selectApp.sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','${item.login_types || 'true'}','${item.link_type || 'true'}','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}'`)
-        param.LText = selectApp.sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','false','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || ''}','${item.sms_id || ''}','${window.btoa(window.encodeURIComponent(JSON.stringify({copyright: item.copyright || '', logo: item.logo || '', apptype: item.apptype || '', delay: item.delay || 0, statusBarColor: item.statusBarColor || 'black'})))}'`)
+        selectApp.sublist = selectApp.sublist.map(item => {
+          if (item.typename !== 'pc') {
+            item.userbind = md5(selectApp.kei_no + item.typename + item.lang).replace(/^.{8}/, 'userbind')
+            item.instantMessage = md5(selectApp.kei_no + item.typename + item.lang).replace(/^.{14}/, 'instantmessage')
+          }
+          return item
+        })
+
+        param.LText = selectApp.sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','false','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || 'false'}','','${window.btoa(window.encodeURIComponent(JSON.stringify({userbind: item.userbind || '', instantMessage: item.instantMessage || '', apptype: item.apptype || '', delay: item.delay || 0, statusBarColor: item.statusBarColor || 'black', topHeight: item.topHeight || '', sysBgColor: item.sysBgColor || '#ffffff', direction: item.direction || 'vertical', adapter: item.adapter || '', share: item.share || '', share_des: item.share_des || '', share_url: item.share_url || '', share_link: item.share_link || ''})))}'`)
         param.LText = param.LText.join(' union all ')
         param.LText = Utils.formatOptions(param.LText)
       }
@@ -913,8 +1005,15 @@
         })
       }
 
-      // param.LText = sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','${item.login_types || 'true'}','${item.link_type || 'true'}','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}'`)
-      param.LText = sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','false','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || ''}','${item.sms_id || ''}','${window.btoa(window.encodeURIComponent(JSON.stringify({copyright: item.copyright || '', logo: item.logo || '', apptype: item.apptype || '', delay: item.delay || 0, statusBarColor: item.statusBarColor || 'black'})))}'`)
+      sublist = sublist.map(item => {
+        if (item.typename !== 'pc') {
+          item.userbind = md5(selectApp.kei_no + item.typename + item.lang).replace(/^.{8}/, 'userbind')
+          item.instantMessage = md5(selectApp.kei_no + item.typename + item.lang).replace(/^.{14}/, 'instantmessage')
+        }
+        return item
+      })
+
+      param.LText = sublist.map(item => `select '${item.ID}','${item.typename}','${selectApp.ID}','${sessionStorage.getItem('CloudUserID') || ''}','${window.GLOB.appkey || ''}','false','false','${item.role_type || 'true'}','${item.lang || 'zh-CN'}','${item.css || ''}','${item.title || ''}','${item.favicon || ''}','${item.user_binding || 'false'}','','${window.btoa(window.encodeURIComponent(JSON.stringify({userbind: item.userbind || '', instantMessage: item.instantMessage || '', apptype: item.apptype || '', delay: item.delay || 0, statusBarColor: item.statusBarColor || 'black', topHeight: item.topHeight || '', sysBgColor: item.sysBgColor || '#ffffff', direction: item.direction || 'vertical', adapter: item.adapter || '', share: item.share || '', share_des: item.share_des || '', share_url: item.share_url || '', share_link: item.share_link || ''})))}'`)
       param.LText = param.LText.join(' union all ')
       param.LText = Utils.formatOptions(param.LText)
 
@@ -1032,14 +1131,13 @@
                 let css = skinStyle[item.css] ? skinStyle[item.css].name : ''
                 let color = skinStyle[item.css] ? skinStyle[item.css].color : '#e8e8e8'
                 let binding = ''
-                if (item.user_binding) {
-                  if (item.user_binding.indexOf('uname_pwd') > -1) {
-                    binding = '鐢ㄦ埛鍚�'
-                  }
-                  if (item.user_binding.indexOf('sms_vcode') > -1) {
-                    binding = binding ? binding + '锛屾墜鏈哄彿' : '鎵嬫満鍙�'
-                  }
+                if (item.user_binding === 'true') {
+                  binding = '鐢ㄦ埛缁戝畾'
                 }
+                if (item.share === 'true') {
+                  binding = binding ? binding + '銆佸垎浜�' : '鍒嗕韩'
+                }
+
                 return (
                   <div className="sub-app" key={index} style={{borderColor: color}}>
                     <Row>
@@ -1075,10 +1173,16 @@
                       </Col>
                       <Col span={12}>
                         <div className="app-item">
-                          {binding ? <div className="label">
+                          {/* {binding ? <div className="label">
                             <Tooltip placement="topLeft" title="寰俊鍏紬鍙风櫥褰曟椂锛岀郴缁熺敤鎴蜂笌寰俊鐢ㄦ埛鐨勭粦瀹氭柟寮忋��">
                               <QuestionCircleOutlined className="mk-form-tip" />
                               鐢ㄦ埛缁戝畾:
+                            </Tooltip>
+                          </div> : null} */}
+                          {binding ? <div className="label">
+                            <Tooltip placement="topLeft" title="寰俊鍏紬鍙锋垨灏忕▼搴忎腑锛岀粦瀹氱郴缁熺敤鎴枫�佽嚜瀹氫箟鍒嗕韩绛夊姛鑳姐��">
+                              <QuestionCircleOutlined className="mk-form-tip" />
+                              鎵╁睍鍔熻兘:
                             </Tooltip>
                           </div> : null}
                           <div className="content">{binding}</div>
@@ -1093,19 +1197,7 @@
                       <Col span={12}>
                         <div className="app-item">
                           <div className="label">缃戠珯澶村儚:</div>
-                          <div className="content">{item.favicon ? <img style={{width: '18px', height: '18px'}} src={item.favicon} alt="" /> : '鏃�'}</div>
-                        </div>
-                      </Col>
-                      <Col span={12}>
-                        <div className="app-item">
-                          <div className="label">鐗堟潈:</div>
-                          <div className="content">{item.copyright || '鏃�'}</div>
-                        </div>
-                      </Col>
-                      <Col span={12}>
-                        <div className="app-item">
-                          <div className="label">LOGO:</div>
-                          <div className="content">{item.logo ? <img style={{height: '18px'}} src={item.logo} alt="" /> : '鏃�'}</div>
+                          <div className="content">{item.favicon ? <img style={{width: '18px', height: '18px', borderRadius: '4px'}} src={item.favicon} alt="" /> : '鏃�'}</div>
                         </div>
                       </Col>
                     </Row>
@@ -1114,7 +1206,7 @@
                       <Button type="link" onClick={() => this.setState({ selectSubApp: item, subVisible: 'edit' })} style={{color: '#8E44AD'}}>淇敼</Button>
                       <Button type="link" onClick={() => this.deleteSubApp(item)} style={{color: '#ff4d4f'}}>鍒犻櫎</Button>
                       <Button type="link" onClick={() => this.jumpApp(item)}>缂栬緫搴旂敤</Button>
-                      <Paragraph style={{display: 'inline-block', margin: 0}} copyable={{ text: `${base_url}${item.typename === 'pad' ? 'mob' : item.typename}/index.html#/index/${this.state.selectApp.kei_no}/${item.typename !== 'pc' ? item.typename + '/' : ''}${item.lang}` }}></Paragraph>
+                      <Paragraph style={{display: 'inline-block', margin: 0}} copyable={{ text: `${window.GLOB.baseurl}${item.typename === 'pad' ? 'mob' : item.typename}/index.html#/index/${this.state.selectApp.kei_no}/${item.typename !== 'pc' ? item.typename + '/' : ''}${item.lang}` }}></Paragraph>
                     </div>
                   </div>
                 )
@@ -1151,7 +1243,7 @@
           </Modal>
           <Modal
             title={'娣诲姞鑴氭湰'}
-            width={750}
+            width={900}
             maskClosable={false}
             visible={scriptVisible}
             onCancel={() => this.setState({scriptVisible: false, confirmloading: false})}
@@ -1164,7 +1256,7 @@
             <ScriptForm applist={applist} wrappedComponentRef={(inst) => this.scriptRef = inst} inputSubmit={this.submitScript} />
           </Modal>
           <Modal
-            title={'缂栬緫瀛愬簲鐢�'}
+            title={subVisible === 'plus' ? '娣诲姞瀛愬簲鐢�' : '缂栬緫瀛愬簲鐢�'}
             width={'850px'}
             maskClosable={false}
             visible={subVisible !== false}

--
Gitblit v1.8.0