作者 何书鹏
1 个管道 的构建 通过 耗费 1 秒

测试

@@ -194,7 +194,7 @@ class Cart extends Api @@ -194,7 +194,7 @@ class Cart extends Api
194 $cart = $this->model->get($cart_id); 194 $cart = $this->model->get($cart_id);
195 empty($cart) && $this->error(__('购物车信息不存在')); 195 empty($cart) && $this->error(__('购物车信息不存在'));
196 $goods_num < 1 && $this->error(__('商品数量不能小于1')); 196 $goods_num < 1 && $this->error(__('商品数量不能小于1'));
197 - halt(json($cart['spec']->toArray())); 197 + halt($cart['spec']->toArray());
198 if($cart['goods']['ismake'] == '0' && $cart['spec']['stock_num'] < $goods_num){ 198 if($cart['goods']['ismake'] == '0' && $cart['spec']['stock_num'] < $goods_num){
199 $this->error(__('商品库存不足'.$goods_num.'件')); 199 $this->error(__('商品库存不足'.$goods_num.'件'));
200 } 200 }
@@ -71,22 +71,22 @@ class User extends Api @@ -71,22 +71,22 @@ class User extends Api
71 $code = $this->request->post('code'); 71 $code = $this->request->post('code');
72 $user_info = $this->request->post('user_info'); 72 $user_info = $this->request->post('user_info');
73 $testopenid = $this->request->post('testopenid'); 73 $testopenid = $this->request->post('testopenid');
74 - $session = Wechat::miniProgram()->auth->session($code);  
75 - // 自动注册用户  
76 - $userInfo = json_decode(htmlspecialchars_decode($user_info), true);  
77 - if (!$user = $this->model->get(['openid' => $session['openid']])) {  
78 - $user = $this->model;  
79 - $userInfo['openid'] = $session['openid'];  
80 - }  
81 - $userInfo['nickname'] = preg_replace('/[\xf0-\xf7].{3}/', '', $userInfo['nickName']);  
82 - $userInfo['avatar'] = $userInfo['avatarUrl'];  
83 - if (!$user->allowField(true)->save($userInfo)) {  
84 - $this->error('用户登录失败');  
85 - }  
86 - // $session = [  
87 - // 'openid' => $testopenid ?: 'test',  
88 - // ];  
89 - // $user = $this->model->get(['openid' => $session['openid']]); 74 + // $session = Wechat::miniProgram()->auth->session($code);
  75 + // // 自动注册用户
  76 + // $userInfo = json_decode(htmlspecialchars_decode($user_info), true);
  77 + // if (!$user = $this->model->get(['openid' => $session['openid']])) {
  78 + // $user = $this->model;
  79 + // $userInfo['openid'] = $session['openid'];
  80 + // }
  81 + // $userInfo['nickname'] = preg_replace('/[\xf0-\xf7].{3}/', '', $userInfo['nickName']);
  82 + // $userInfo['avatar'] = $userInfo['avatarUrl'];
  83 + // if (!$user->allowField(true)->save($userInfo)) {
  84 + // $this->error('用户登录失败');
  85 + // }
  86 + $session = [
  87 + 'openid' => $testopenid ?: 'test',
  88 + ];
  89 + $user = $this->model->get(['openid' => $session['openid']]);
90 // 生成token (session3rd) 90 // 生成token (session3rd)
91 $guid = guidv4();// 生成一个不会重复的随机字符串 91 $guid = guidv4();// 生成一个不会重复的随机字符串
92 $timeStamp = microtime(true);// 当前时间戳 (精确到毫秒) 92 $timeStamp = microtime(true);// 当前时间戳 (精确到毫秒)