懒得勤快 3 anni fa
parent
commit
3ea5782965

+ 1 - 16
src/Masuit.MyBlogs.Core/Controllers/AdvertisementController.cs

@@ -62,7 +62,7 @@ namespace Masuit.MyBlogs.Core.Controllers
         /// </summary>
         /// <returns></returns>
         [MyAuthorize]
-        public async Task<ActionResult> GetPageData([FromServices] ICategoryService categoryService, [Range(1, int.MaxValue, ErrorMessage = "页数必须大于0")] int page = 1, [Range(1, int.MaxValue, ErrorMessage = "页大小必须大于0")] int size = 10, string kw = "")
+        public ActionResult GetPageData([FromServices] ICategoryService categoryService, [Range(1, int.MaxValue, ErrorMessage = "页数必须大于0")] int page = 1, [Range(1, int.MaxValue, ErrorMessage = "页大小必须大于0")] int size = 10, string kw = "")
         {
             Expression<Func<Advertisement, bool>> where = p => true;
             if (!string.IsNullOrEmpty(kw))
@@ -221,21 +221,6 @@ namespace Masuit.MyBlogs.Core.Controllers
             return View(AdsService[id]);
         }
 
-        /// <summary>
-        /// 一键延期
-        /// </summary>
-        /// <param name="id"></param>
-        /// <param name="days"></param>
-        /// <returns></returns>
-        [HttpPost("/partner/{id}/delay")]
-        public async Task<ActionResult> Delay(int id, float days)
-        {
-            var entity = await AdsService.GetByIdAsync(id) ?? throw new NotFoundException("广告未找到");
-            entity.ExpireTime = entity.ExpireTime.GetValueOrDefault(DateTime.Now).AddDays(days);
-            var b = await AdsService.SaveChangesAsync() > 0;
-            return Ok(b ? $"延期成功,广告【{entity.Title}】有效时间已延期至:{entity.ExpireTime:yyyy-MM-dd}" : "延期失败");
-        }
-
         /// <summary>
         /// 设置分类
         /// </summary>

+ 1 - 1
src/Masuit.MyBlogs.Core/Views/Error/Index.cshtml

@@ -104,7 +104,7 @@
                         <li>将猫困在一个深色圆点围成的圈子里面就算成功了!</li>
                     </ul>
                 </dd>
-                <div id="games"></div>
+                <div id="games" style="z-index: 100"></div>
             </dl>
         </div>
     </div>

+ 1 - 1
src/Masuit.MyBlogs.Core/Views/Error/ServiceUnavailable.cshtml

@@ -104,7 +104,7 @@
                         <li>将猫困在一个深色圆点围成的圈子里面就算成功了!</li>
                     </ul>
                 </dd>
-                <div id="games"></div>
+                <div id="games" style="z-index: 100"></div>
             </dl>
         </div>
     </div>

+ 13 - 22
src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/partner.js

@@ -358,39 +358,30 @@
 
     $scope.delayShow = function (item) {
         $scope.partner=item;
-        $scope.spanDropdown=xmSelect.render({
-            el: '#span',
-            model: {
-                 icon: 'hidden',
-                 label: { type: 'text' }
-            },
-            radio: true,
-            clickClose: true,
-            direction: 'up',
-            data:[{name:"天",value:1},{name:"月",value:30},{name:"年",value:365}],
-            initValue:[1]
-        });
+        $scope.isAdd = false;
+        $scope.partner.ExpireTime=new Date($scope.partner.ExpireTime).Format("yyyy-MM-dd hh:mm:ss");
         layer.open({
             type: 1,
             zIndex: 20,
             title: "延期广告",
-            area:  ['265px','240px'], //宽高
             content: $("#delay"),
             cancel: function(index, layero) {
                 return true;
             }
         });
-    }
-
-    $scope.delay = function (item) {
-        let value = $scope.spanDropdown.getValue()[0].value;
-        let days = item.TimeSpan*value;
-        $http.post(`/partner/${item.Id}/delay?days=`+days).then(function(res) {
-            layer.closeAll();
-            layer.msg(res.data);
+        layui.use('laydate', function(){
+          var laydate = layui.laydate;
+          laydate.render({
+            elem: '.timespan',
+            type: 'datetime',
+            calendar: true,
+            done: function(value, date, endDate) {
+                $scope.partner.ExpireTime=value;
+            }
+          });
         });
     }
-
+    
     $scope.insight= function(row) {
         layer.full(layer.open({
           type: 2,

+ 4 - 9
src/Masuit.MyBlogs.Core/wwwroot/ng-views/controllers/post.js

@@ -36,18 +36,13 @@
         on: function (data) {
             if (data.arr.length>0) {
                 $scope.orderby = data.arr[0].value;
-                self.GetPageData($scope.paginationConf.currentPage||1, $scope.paginationConf.itemsPerPage);
+                self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
             }
         }
     });
 
     function stat() {
-        fetch("/post/Statistic",{
-            headers:{
-                'Accept': 'application/json',
-                'Content-Type': 'application/json'
-            }
-        }).then(function(response) {
+        fetch("/post/Statistic").then(function(response) {
             return response.json();
         }).then(function(res) {
             if(res.Success) {
@@ -105,7 +100,7 @@
                 on: function (data) {
                     if (data.arr.length>0) {
                         $scope.CategoryId = data.arr[0].Id;
-                        self.GetPageData($scope.paginationConf.currentPage||1, $scope.paginationConf.itemsPerPage);
+                        self.GetPageData($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
                     }
                 }
             });
@@ -120,7 +115,7 @@
 
     this.GetPageData = function (page, size) {
         var params = { page, size, kw: $scope.kw, orderby: $scope.orderby, cid: $scope.CategoryId };
-        $http.get(`/post/getpagedata?page=${page}&size=${size}&kw=${$scope.kw}&orderby=${$scope.orderby}&cid=${$scope.CategoryId}`).then(function(res) {
+        $http.get(`/post/getpagedata?page=${page||1}&size=${size}&kw=${$scope.kw}&orderby=${$scope.orderby}&cid=${$scope.CategoryId}`).then(function(res) {
             $scope.paginationConf.totalItems = res.data.TotalCount;
             $("div[ng-table-pagination]").remove();
             self.tableParams = new NgTableParams({ count: 50000 }, {

+ 4 - 7
src/Masuit.MyBlogs.Core/wwwroot/ng-views/views/partner.html

@@ -291,17 +291,14 @@
     </form>
 </div>
 <div id="delay" class="modal">
-    <h3>延期广告:{{partner.Title}}</h3>
-    <hr />
+    <h5>广告:{{partner.Title}}</h5>
+    <h5>当前有效期延期至:</h5>
     <div class="form-group">
         <input type="hidden" ng-model="partner.Id">
         <div class="input-group">
-            <div class="fg-line">
-                <input type="number" class="form-control" placeholder="请输入时间间隔" min="1" max="365" ng-model="partner.TimeSpan" style="width: 120px">
-                <div class="form-control" id="span" style="width: 80px"></div>
-            </div>
+            <input type="datetime" class="timespan form-control" placeholder="请选择过期时间" ng-model="partner.ExpireTime" readonly="">
             <span class="input-group-btn">
-                <button type="button" class="btn btn-primary" ng-click="delay(partner)">确定</button>
+                <button type="button" class="btn btn-primary" ng-click="submit(partner)">确定</button>
             </span>
         </div>
     </div>