123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <template>
- <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
- <cus-header title='AI玩具' :showback="false"></cus-header>
- <div class="content">
- <button class="zt_btn" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">手机号一键登录</button>
- <div class="qx_btn" @click="cancelLogin">取消</div>
- </div>
- </view>
- </template>
- <script>
- export default {
- data(){
- return {
-
- }
- },
- onShow() {
- if(uni.getStorageSync('userInfo')){
- uni.redirectTo({
- url:'/pages/home'
- })
- }
- },
- methods:{
- decryptPhoneNumber(e){
- if(e.detail.code) this.wxLogin(e.detail.code);
- },
- wxLogin(code){
- uni.showLoading({ title:'登录中' });
- let that = this;
- wx.login({
- success(res){
- that.$api.get('/sys/wx/login',{
- code:res.code,
- phoneCode:code
- },false).then(res=>{
- if(res.data.code===0){
- uni.setStorageSync('token',res.data.data.token);
- uni.setStorageSync('userInfo',JSON.stringify({
- id:res.data.data.id,
- mobile:res.data.data.mobile,
- username:res.data.data.username
- }));
-
- uni.hideLoading();
- that.$showToast('登录成功');
- setTimeout(()=>{
- uni.reLaunch({ url:'/pages/home' })
- },1500)
- }else that.$showToast(res.data.msg)
- })
- }
- })
- },
- cancelLogin(){
- uni.exitMiniProgram();
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .page{
- background: #FFFFFF;
- display: flex;
- flex-direction: column;
- box-sizing: border-box;
- .content{
- padding: 0 45rpx;
- flex: 1;
- overflow-y: auto;
- .zt_btn{
- margin-top: 216rpx;
- }
- .qx_btn{
- margin-top: 36rpx;
- }
- }
- }
- </style>
|