123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <template>
- <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
- <image class="topbg" src="http://106.54.209.120:8188/static/login_top.png" mode="widthFix"></image>
- <div class="content adffcacjc">
- <button class="zt_btn" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">快速登录</button>
- <div class="agree adfacjc" @tap="changeAgree">
- <image src="http://106.54.209.120:8188/static/selected_not.png" v-if="!agree"></image>
- <image src="http://106.54.209.120:8188/static/selected.png" v-else></image>
- <div class="a_text">已阅读并同意 <span>《用户协议》</span><span>《隐私政策》</span></div>
- </div>
- </div>
- </view>
- </template>
- <script>
- export default {
- data(){
- return {
- agree:false
- }
- },
- onShow: () => {
- if(uni.getStorageSync('userInfo')){
- uni.reLaunch({
- url:'/pages/home'
- })
- }
- },
- methods:{
- changeAgree(){
- this.agree = !this.agree;
- },
- decryptPhoneNumber(e){
- if(!this.agree) return this.$showToast('请勾选协议和政策');
- 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)
- })
- }
- })
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .page{
- background: #FFFFFF;
- display: flex;
- flex-direction: column;
- box-sizing: border-box;
-
- .topbg{
- width: 100%;
- position: fixed;
- top: 0;
- left: 0;
- z-index: 0;
- }
-
-
- .content{
- position: relative;
- display: flex;
- flex: 1;
- width: calc(100% - 140rpx);
- margin: 307rpx 70rpx 0;
-
- .agree{
- margin-top: 50rpx;
- &>image{
- width: 32rpx;
- height: 32rpx;
- margin-right: 10rpx;
- }
- .a_text{
- font-family: PingFangSC, PingFang SC;
- font-weight: 400;
- font-size: 24rpx;
- color: #A6A6A6;
- line-height: 33rpx;
- span{
- color: #72832B;
- }
- }
- }
- }
- }
- </style>
|