Browse Source

小红点

master
lemon 4 years ago
parent
commit
54dc61fe4b
  1. 15
      app/Admin/Controllers/ProductController.php
  2. 2
      app/Admin/bootstrap.php
  3. 2
      app/Admin/routes.php
  4. 84
      public/js/product.js

15
app/Admin/Controllers/ProductController.php

@ -151,4 +151,19 @@ class ProductController extends AdminController
}
});
}
public function audit()
{
$cloud = \App\Models\Product::query()->where('status',ProductStatus::UNAUDITED)->count();
$industry = \App\Models\IndustryProduct::query()->where('status',ProductStatus::UNAUDITED)->count();
$demand = \App\Models\DemandProduct::query()->where('status',ProductStatus::UNAUDITED)->count();
$total = $cloud + $industry + $demand;
$arr = [
'cloud' => $cloud ?? 0,
'industry' => $industry ?? 0,
'demand' => $demand ?? 0,
'total' => $total ?? 0,
];
return json_encode($arr);
}
}

2
app/Admin/bootstrap.php

@ -25,3 +25,5 @@ use Dcat\Admin\Show;
*
*/
app('view')->prependNamespace('admin', resource_path('views/admin'));
Admin::js('/js/product.js');

2
app/Admin/routes.php

@ -50,4 +50,6 @@ Route::group([
$router->resource('system', 'SystemSettingController');
$router->resource('deposit', 'DepositController');
$router->resource('setting_single', 'ServicePersonsSettingController');
$router->any('product_audit','ProductController@audit');
});

84
public/js/product.js

@ -0,0 +1,84 @@
function workorderNotice()
{
$('.product_badge').remove();
$.ajax({
url: '/'+window.location.pathname.split('/')[1]+'/product_audit',
type: 'POST',
data: {},
dataType: 'json',
success: function (res) {
let total = res.total ? res.total : '';
let cloud = res.cloud ? res.cloud : '';
let industry = res.industry ? res.industry : '';
let demand = res.demand ? res.demand : '';
if (total > 0) {
$('a[href*="product/audit"] p').parent().parent().parent().parent().parent().parent().children("a").append('<span class="product_badge" style="' +
'display: inline-block; ' +
'width: 20px; ' +
'height: 20px; ' +
'border-radius: 20px; ' +
'line-height: 20px; ' +
'text-align: center; ' +
'font-size: 12px; ' +
'background-color: red;' +
'color: white;' +
'">'+total+'</span>');
}
if (cloud > 0) {
$('a[href*="product/audit"] p').parent().parent().parent().parent().parent().parent().children("ul").children(":first-child").children("ul").children("li:eq(1)").children(":first-child").append('<span class="product_badge" style="' +
'display: inline-block; ' +
'width: 20px; ' +
'height: 20px; ' +
'border-radius: 20px; ' +
'line-height: 20px; ' +
'text-align: center; ' +
'font-size: 12px; ' +
'background-color: red;' +
'color: white;' +
'">'+cloud+'</span>');
}
if (industry > 0) {
$('a[href*="product/audit"] p').parent().parent().parent().parent().parent().parent().children("ul").children(":eq(1)").children("ul").children("li:eq(1)").children(":first-child").append('<span class="product_badge" style="' +
'display: inline-block; ' +
'width: 20px; ' +
'height: 20px; ' +
'border-radius: 20px; ' +
'line-height: 20px; ' +
'text-align: center; ' +
'font-size: 12px; ' +
'background-color: red;' +
'color: white;' +
'">'+industry+'</span>');
}
if (demand > 0) {
$('a[href*="product/audit"] p').parent().parent().parent().parent().parent().parent().children("ul").children(":eq(2)").children(':first-child').append('<span class="product_badge" style="' +
'display: inline-block; ' +
'width: 20px; ' +
'height: 20px; ' +
'border-radius: 20px; ' +
'line-height: 20px; ' +
'text-align: center; ' +
'font-size: 12px; ' +
'background-color: red;' +
'color: white;' +
'">'+demand+'</span>');
}
},
error: function (error) {
}
});
}
$(document).ready(function () {
workorderNotice();
});
// const workordertimer = setInterval(function () {
// workorderNotice()
// }, 5000);
Loading…
Cancel
Save