Эх сурвалжийг харах

Revert "二次确认,后端验证存储状态"

This reverts commit 9dc318146c460d85ae0e4b9146adc021a8dd4083.
董荣正 1 сар өмнө
parent
commit
ca59a6b048

+ 5 - 15
application/admin/controller/user/Userpledge.php

@@ -91,7 +91,7 @@ class Userpledge extends Backend
             ->field('order_no, status') // 指定字段
             ->select();
         $status_txt=['已下单','支付','转让','提货','取消','关闭','存储中'];
-        // 合并 status 到主数据
+        // 3. 合并 status 到主数据
         foreach ($details as &$item_outside) {
             foreach ($orderData as &$item_inside) {
                 if($item_outside['order_no']==$item_inside['order_no']){
@@ -105,7 +105,6 @@ class Userpledge extends Backend
         $userpledge_status=$row['status'];
         
         $this->view->assign("userpledge_status", $userpledge_status);
-        $this->view->assign("userpledge_id", $ids);
         $this->view->assign("row", $details);
         return $this->view->fetch();
     }
@@ -115,19 +114,10 @@ class Userpledge extends Backend
      */
     public function cancelStorage(){
         $id = $this->request->param('id');
-        $userpledgeId = $this->request->param('userpledgeId');
-        $row = $this->model->get(['id' => $userpledgeId]);
-        $userpledge_status=$row['status'];
-        if($userpledge_status==0){
-            $resp=$this->product_order_model->where('id', $id)->update(['status' => 0]);
-            if($resp){
-                $this->success(__('取消成功'), '');
-            }
-            
-        }
-        $this->error(__('操作失败'));
-        
-       
+        $resp=$this->product_order_model->where('id', $id)
+                ->update(['status' => 5]);
+        return $resp;
+        // $this->success('取消存储', $resp);
         
     }
     /**

+ 20 - 56
application/admin/view/user/userpledge/detail.html

@@ -1,13 +1,9 @@
 <!-- <link href="__CDN__/assets/libs/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> -->
 <script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
 <script src="__CDN__/assets/libs/bootstrap/dist/js/bootstrap.min.js"></script>
-<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
-<style>
-    .confirm-btn {
-        background-color: #f75444 !important;
-        color: white !important;
-    }
-</style>
+
+
+
 <table class="table table-striped">
 
     <thead>
@@ -50,11 +46,9 @@
                 {case value="6"}
                 <span class="label label-success">{$vo.status_txt}</span>
                 {eq name="userpledge_status" value="0"}
-                <a href="javascript:;" class="btn btn-xs btn-danger cancelStorage" data-id="{$vo.id}"
-                    data-userpledge_id="{$userpledge_id}">{:__('Cancel storage')}</a>
-                {$userpledge_id}
+                <a href="javascript:;" class="btn btn-xs btn-danger cancelStorage" data-id="{$vo.id}">{:__('Cancel storage')}</a>
                 {/eq}
-
+                
                 {/case}
                 {default /}
                 {/switch}
@@ -75,53 +69,23 @@
     $(function () {
         $(".cancelStorage").click(function () {
             var id = $(this).data('id');
-            var userpledgeId = $(this).data('userpledge_id');
-
-            swal({
-                title: "确认取消存储",
-                icon: "warning",
-                buttons: {
-                    cancel: "取消",
-                    catch: {
-                        text: "确认",
-                        value: "catch",
-                        className: "confirm-btn"
+            $.ajax({
+                url: "user/Userpledge/cancelStorage",  
+                type: "POST",          
+                data: { id: id },
+                dataType: "json",
+                success: function(response) {
+                    if(response==1){
+                        window.location.reload(); // 刷新父页面
                     }
                 },
-                dangerMode: true,
-            }
-
-            )
-                .then((willDelete) => {
-                    if (willDelete) {
-                        $.ajax({
-                        url: "user/Userpledge/cancelStorage",
-                        type: "POST",
-                        data: { id: id, userpledgeId: userpledgeId },
-                        dataType: "json",
-                        success: function (response) {
-                            let code = response.code;
-                            if (code == 1) {
-                                window.location.reload(); // 刷新父页面
-                            }
-                        },
-                        error: function (xhr, status, error) {
-                            console.error("请求失败", error);
-                        },
-                        complete: function () {
-                            console.log("请求完成(无论成功/失败)");
-                        }
-                    });
-                    } else {
-                        // console.log("取消")
-                    }
-                });
-            
+                error: function(xhr, status, error) {
+                    console.error("请求失败", error);
+                },
+                complete: function() {
+                    console.log("请求完成(无论成功/失败)");
+                }
+            });
         })
-
-
-
     })
-
-
 </script>

+ 1 - 1
public/assets/js/backend/user/userpledge.js

@@ -79,7 +79,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 
             }
             
-        },
+        }
     };
     return Controller;
 });