...
|
...
|
@@ -32,7 +32,7 @@ class IndexController extends HomeBaseController |
|
|
} else {
|
|
|
$code = request()->param('code');
|
|
|
$info = $wx->getOpenid($code);
|
|
|
if(Db::name('user')->where(['openid'=>$info['openid']])->count() == 0) {
|
|
|
if (Db::name('user')->where(['openid' => $info['openid']])->count() == 0) {
|
|
|
//注册新用户
|
|
|
//拉去用户信息
|
|
|
$return = $wx->getUserInfo($info);
|
...
|
...
|
@@ -44,19 +44,19 @@ class IndexController extends HomeBaseController |
|
|
'avatar' => $return['headimgurl'],
|
|
|
'openid' => $info['openid']
|
|
|
];
|
|
|
if(Db::name('user')->insert($data)) {
|
|
|
if (Db::name('user')->insert($data)) {
|
|
|
$userId = Db::name('user')->getLastInsID();
|
|
|
session('user.id', $userId);
|
|
|
session('user.openid', $info['openid']);
|
|
|
}
|
|
|
}else {
|
|
|
$userId = Db::name('user')->where(['openid'=>$info['openid']])->value('id');
|
|
|
} else {
|
|
|
$userId = Db::name('user')->where(['openid' => $info['openid']])->value('id');
|
|
|
session('user.id', $userId);
|
|
|
session('user.openid', $info['openid']);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
} else {
|
|
|
$this->error('请从微信浏览器打开');
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -149,19 +149,24 @@ class IndexController extends HomeBaseController |
|
|
}
|
|
|
|
|
|
//更新用户经纬度
|
|
|
public function updatePosition() {
|
|
|
public function updatePosition()
|
|
|
{
|
|
|
$position = [
|
|
|
'id' => session('user.id'),
|
|
|
'lat' => request()->param('lat'),
|
|
|
'lng' => request()->param('lng')
|
|
|
];
|
|
|
if(Db::name('user')->update($position)) {
|
|
|
if (Db::name('user')->update($position)) {
|
|
|
$this->success('', '', true);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public function alipay() {
|
|
|
echo '支付宝';
|
|
|
public function alipay()
|
|
|
{
|
|
|
require_once EXTEND_PATH . '/alipay/wappay/service/AlipayTradeService.php';
|
|
|
$alipay = new \AlipayTradeService();
|
|
|
$return = $alipay->wapPay('', '', '');
|
|
|
print_r($return);
|
|
|
}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|