微信網頁掃碼登入的實現

2021-10-24 21:30:10 字數 1804 閱讀 8299

public function weixindenglu(

) public function codeinfo(

) else

else

$insert_user

= db::table(

'users'

)->insert(

$data);

$user_id

= db::table(

'users'

)->where(

'username',$infoarray

['nickname'

])->first();

$where

['userid']=

$user_id

['userid'];

$where

['wxunionid']=

$infoarray

['unionid'];

$where

['createtime'

]=date(

'y-m-d h:i:s',time());

$insert_third_user

= db::table(

'third_users'

)->insert(

$where);

$userid

=$where

['userid'];

}

cookie::queue(

'uid', $userid, 60)

;//儲存uid

return back(

)->with(

'userid',$userid

);//帶資料uid返回

}}

步驟2:前端獲取返回的uid,把它放在input裡面;如:

"hidden" class=

"uid" value=

"}">

步驟3:判斷class="uid"是否含有uid

var uid=

$('.uid'

).val();

console.log(uid)

; if(uid!="")

, type:"post",

success:function(res)

$('.logins'

).empty();

$(".logins"

).html(html);},

}) var loginnames=

$('.loginname'

).val();

console.log(loginnames)

; if(loginnames=="")

}步驟4:後台訪問:

public function weixinlogin(

)}

步驟5:用乙個非同步判斷是否登陸:

//檢測是否登陸

$.ajax(

, type:"post",

async : false,

cache : false,

success:function(res)

else

$('.logins'

).empty();

$(".logins"

).html(messages);},

})

微信網頁掃碼登入的實現

文件1 redirect uri urlencode redirect uri 該 需要url編碼 scope snsapi login response type code scope scope.state state wechat redirect 請求返回的結果 實際上是個html的字串 r...

微信網頁掃碼登入的實現

redirect uri urlencode redirect uri 該 需要url編碼 請求返回的結果 實際上是個html的字串 result file get contents url result str replace connect qrcode result return result...

微信網頁掃碼登入的實現

redirect uri urlencode redirect uri 該 需要url編碼 scope snsapi login 請求返回的結果 實際上是個html的字串 result file get contents url result str replace connect qrcode r...