r105/manage.html · 约 3288 字符
1<!doctype html>2<html lang="zh-CN">3<head>4<meta charset="utf-8">5<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">6<title>小草快批下单 · 商品管理</title>7<link rel="stylesheet" href="style.css">8</head>9<body>10<div class="app">11 <div class="navbar"><a class="back" href="my.html">‹</a><span class="ttl">商品管理</span>12 <span style="margin-left:auto;font-size:13px;color:var(--green-d);font-weight:600" onclick="lock()">退出管理</span></div>1314 <div id="mg"></div>15 <div id="tab-holder"></div>16</div>1718<!-- 密码弹窗 -->19<div class="mask" id="pwMask">20 <div class="modal">21 <h3>🔐 商品管理</h3>22 <div class="sub" style="text-align:center">请输入管理密码进入</div>23 <input id="pw" type="password" placeholder="管理密码">24 <div class="macts">25 <button class="btn btn-ghost btn-block" onclick="location.href='my.html'">返回</button>26 <button class="btn btn-green btn-block" onclick="tryUnlock()">进入</button>27 </div>28 </div>29</div>3031<script src="data.js"></script>32<script src="cart.js"></script>33<script>34function unlocked(){ return localStorage.getItem(XC_K.mg) === '1'; }35function tryUnlock(){36 var v = document.getElementById('pw').value;37 if (v === XC_MG_PASS){38 localStorage.setItem(XC_K.mg, '1');39 render();40 } else {41 xcToast('密码错误,请重试');42 }43}44function lock(){ localStorage.removeItem(XC_K.mg); location.href='my.html'; }4546function render(){47 if (!unlocked()){48 document.getElementById('pwMask').style.display='flex';49 document.getElementById('tab-holder').innerHTML = '';50 return;51 }52 document.getElementById('pwMask').style.display='none';53 var h = '<div class="sect" style="margin-top:10px"><div class="lab">商品定价管理(共 '+XC_PRODUCTS.length+' 个)</div>';54 h += '<div style="overflow:auto"><table class="mg-table"><tr><th>商品</th><th>分类</th><th>小包价</th><th>中包价</th><th>操作</th></tr>';55 XC_PRODUCTS.forEach(function(p){56 var os = XC_OVERRIDE[p.id] ? XC_OVERRIDE[p.id].small : p.small.price;57 var om = XC_OVERRIDE[p.id] ? XC_OVERRIDE[p.id].medium : p.medium.price;58 h += '<tr><td>'+p.emoji+' '+p.name+'</td><td>'+xcGetCatName(p.cat)+'</td>'+59 '<td><input class="upd" id="ps_'+p.id+'" value="'+os+'"></td>'+60 '<td><input class="upd" id="pm_'+p.id+'" value="'+om+'"></td>'+61 '<td><button class="btn btn-green" onclick="saveRow(\''+p.id+'\')">保存</button></td></tr>';62 });63 h += '</table></div></div>';64 h += '<div class="sub" style="padding:10px 14px">提示:修改价格后将在「选购 / 详情 / 购物车」中即时生效(本地演示)。</div>';65 document.getElementById('mg').innerHTML = h;66 document.getElementById('tab-holder').innerHTML = xcTabbar('my');67 xcUpdateTabBadge();68}69function saveRow(pid){70 var s = parseFloat(document.getElementById('ps_'+pid).value);71 var m = parseFloat(document.getElementById('pm_'+pid).value);72 if (isNaN(s) || isNaN(m)){ xcToast('请输入有效价格'); return; }73 if (!XC_OVERRIDE[pid]) XC_OVERRIDE[pid] = {};74 XC_OVERRIDE[pid].small = s; XC_OVERRIDE[pid].medium = m;75 xcSaveOverride();76 xcToast('已保存:'+xcGetProduct(pid).name);77}78render();79</script>80</body>81</html>82