Просмотр исходного кода

Merge branch 'dev-xpy' into dev

xupuyuan месяцев назад: 11
Родитель
Сommit
af6f13fc6e
2 измененных файлов с 25 добавлено и 0 удалено
  1. 22 0
      app/controller/api/user/User.php
  2. 3 0
      route/api.php

+ 22 - 0
app/controller/api/user/User.php

@@ -857,6 +857,28 @@ class User extends BaseController
857
     }
857
     }
858
 
858
 
859
     /**
859
     /**
860
+     * 查询商品浏览记录以及删除
861
+     */
862
+    public function productHistory(){
863
+        $uid = $this->request->uid();
864
+        $list = Db::name('third_history')->where('uid', $uid)->order('create_time', 'desc')->limit(20)->column('keyword','id');
865
+        return app('json')->success(['count' => count($list), 'list'  => $list]);
866
+    }
867
+    public function deleteProductHistory(){
868
+        $uid = $this->request->uid();
869
+        $id = $this->request->post('id');
870
+        $deleted = Db::name('third_history')
871
+            ->where('id', $id)
872
+            ->where('uid', $uid)
873
+            ->delete();
874
+        if ($deleted) {
875
+            return app('json')->success('删除成功');
876
+        } else {
877
+            return app('json')->fail('删除失败');
878
+        }
879
+    }
880
+
881
+    /**
860
      * 签到  获取积分
882
      * 签到  获取积分
861
      * @return mixed
883
      * @return mixed
862
      * @throws \think\db\exception\DataNotFoundException
884
      * @throws \think\db\exception\DataNotFoundException

+ 3 - 0
route/api.php

@@ -226,6 +226,9 @@ Route::group('api/', function () {
226
             //浏览记录
226
             //浏览记录
227
             Route::get('history', 'User/history');
227
             Route::get('history', 'User/history');
228
             Route::post('history/delete/:id', 'User/deleteHistory');
228
             Route::post('history/delete/:id', 'User/deleteHistory');
229
+            //商品浏览记录以及删除
230
+            Route::post('productHistory', 'User/productHistory');
231
+            Route::post('deleteProductHistory', 'User/deleteProductHistory');
229
             //获取用户签到记录
232
             //获取用户签到记录
230
             Route::get('get_signin', 'User/get_signin');
233
             Route::get('get_signin', 'User/get_signin');
231
             //签到
234
             //签到