123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- <!-- 蓝色登录页面2 -->
- <template>
- <view>
- <u-toast ref="uToast"/>
- <view class="img-a">
- <view class="t-b">
- 您好,
- <br/>
- 欢迎使用 开源字节
- </view>
- </view>
- <view class="login-view">
- <view class="t-login">
- <form class="cl">
- <view class="t-a">
- <text class="txt">手机号</text>
- <input v-model="username" maxlength="11" name="phone" placeholder="请输入您的手机号" type="number"/>
- </view>
- <view class="t-a">
- <text class="txt">密码</text>
- <input v-model="password" maxlength="18" name="code" placeholder="请输入您的密码" type="password"/>
- </view>
- <button @tap="login()">登 录</button>
- <view class="reg" @tap="reg()">短信登录</view>
- </form>
- </view>
- </view>
- <!-- #ifdef MP-WEIXIN -->
- <view class="buttom">
- <button class="clearBtn" open-type="getPhoneNumber" @getphonenumber="weChatLogin">
- <view class="loginType">
- <view class="item">
- <view class="icon">
- <u-icon color="rgb(83,194,64)" name="weixin-fill" size="60"></u-icon>
- </view>
- 微信
- </view>
- </view>
- </button>
- <!-- <view class="hint">
- 登录代表同意
- <text class="link">开源字节用户协议、隐私政策,</text>
- 并授权使用您的账号信息(如昵称、头像、收获地址)以便您统一管理
- </view> -->
- </view>
- <!-- #endif -->
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // username: '',
- // password: '',
- username: '18720989281',
- password: '123456',
- }
- },
- // onLoad() {
- // // 在页面中定义激励视频广告
- // let videoAd = null
- // // 在页面onLoad回调事件中创建激励视频广告实例
- // if (wx.createRewardedVideoAd) {
- // videoAd = wx.createRewardedVideoAd({
- // adUnitId: 'adunit-8cd5789a01a51891'
- // })
- // videoAd.onLoad(() => {})
- // videoAd.onError((err) => {})
- // videoAd.onClose((res) => {})
- // }
- // // 用户触发广告后,显示激励视频广告
- // if (videoAd) {
- // videoAd.show().catch(() => {
- // // 失败重试
- // videoAd.load()
- // .then(() => videoAd.show())
- // .catch(err => {
- // console.log('激励视频 广告显示失败')
- // })
- // })
- // }
- // },
- methods: {
- login() {
- if (!this.$u.test.mobile(this.username)) {
- return this.$refs.uToast.show({
- title: '手机号不正确',
- type: 'warning',
- })
- }
- if (!this.password) {
- return this.$refs.uToast.show({
- title: '密码不能为空',
- type: 'warning',
- })
- }
- // 登录json参数,不同于表单参数
- let url = "/api/thirdLogin";
- this.$u.post(url, {
- username: this.username,
- password: this.password
- }).then(data => {
- // 登录成功初始化token与用户信息
- this.$u.vuex('vuex_token', data.token);
- this.$u.vuex('vuex_user', data.loginUser);
- uni.switchTab({
- url: '/pages/index/index'
- })
- });
- },
- weChatLogin(e) {
- let code = e.detail.code;
- if (code) {
- uni.showLoading({title: "登录中....", mask: true})
- let url = "/api/miniWxApi/getPhoneNum?code=" + code;
- this.$u.get(url).then(res => {
- let phoneNum = res.phoneNum
- let weChatUrl = "/api/weChatLogin";
- this.$u.post(weChatUrl, {
- username: phoneNum,
- code: code
- }).then(data => {
- uni.hideLoading();
- // 登录成功初始化token与用户信息
- this.$u.vuex('vuex_token', data.token);
- this.$u.vuex('vuex_user', data.loginUser);
- uni.switchTab({
- url: '/pages/index/index'
- })
- });
- });
- } else {
- this.$mytip.toast('登录失败')
- }
- },
- reg() {
- this.$u.route({
- url: 'pages/login/account'
- })
- }
- }
- };
- </script>
- <style>
- page {
- background-color: #ffffff;
- }
- </style>
- <style lang="scss" scoped>
- .txt {
- font-size: 32 rpx;
- font-weight: bold;
- color: #333333;
- }
- .img-a {
- width: 100%;
- height: 450 rpx;
- background-image: url(https://zhoukaiwen.com/img/loginImg/head.png);
- background-size: 100%;
- }
- .reg {
- font-size: 28 rpx;
- color: #fff;
- height: 90 rpx;
- line-height: 90 rpx;
- border-radius: 50 rpx;
- font-weight: bold;
- background: #f5f6fa;
- color: #000000;
- text-align: center;
- margin-top: 30 rpx;
- }
- .login-view {
- width: 100%;
- position: relative;
- margin-top: -120rpx;
- background-color: #ffffff;
- border-radius: 8% 8% 0% 0;
- }
- .t-login {
- width: 600 rpx;
- margin: 0 auto;
- font-size: 28 rpx;
- padding-top: 80 rpx;
- }
- .t-login button {
- font-size: 28 rpx;
- background: #2796f2;
- color: #fff;
- height: 90 rpx;
- line-height: 90 rpx;
- border-radius: 50 rpx;
- font-weight: bold;
- }
- .t-login input {
- height: 90 rpx;
- line-height: 90 rpx;
- margin-bottom: 50 rpx;
- border-bottom: 1px solid #e9e9e9;
- font-size: 28 rpx;
- }
- .t-login .t-a {
- position: relative;
- }
- .t-b {
- text-align: left;
- font-size: 42 rpx;
- color: #ffffff;
- padding: 130 rpx 0 0 70 rpx;
- font-weight: bold;
- line-height: 70 rpx;
- }
- .t-login .t-c {
- position: absolute;
- right: 22 rpx;
- top: 22 rpx;
- background: #5677fc;
- color: #fff;
- font-size: 24 rpx;
- border-radius: 50 rpx;
- height: 50 rpx;
- line-height: 50 rpx;
- padding: 0 25 rpx;
- }
- .t-login .t-d {
- text-align: center;
- color: #999;
- margin: 80 rpx 0;
- }
- .t-login .t-e {
- text-align: center;
- width: 250 rpx;
- margin: 80 rpx auto 0;
- }
- .t-login .t-g {
- float: left;
- width: 50%;
- }
- .t-login .t-e image {
- width: 50 rpx;
- height: 50 rpx;
- }
- .t-login .t-f {
- text-align: center;
- margin: 150 rpx 0 0 0;
- color: #666;
- }
- .t-login .t-f text {
- margin-left: 20 rpx;
- color: #aaaaaa;
- font-size: 27 rpx;
- }
- .t-login .uni-input-placeholder {
- color: #aeaeae;
- }
- .cl {
- zoom: 1;
- }
- .cl:after {
- clear: both;
- display: block;
- visibility: hidden;
- height: 0;
- content: '\20';
- }
- .buttom {
- .loginType {
- display: flex;
- padding: 140 rpx 0;
- justify-content: center;
- .item {
- display: flex;
- flex-direction: column;
- align-items: center;
- color: $u-tips-color;
- font-size: 22 rpx;
- }
- }
- .hint {
- position: absolute;
- bottom: 0;
- padding: 20 rpx 40 rpx;
- font-size: 20 rpx;
- color: $u-tips-color;
- .link {
- color: #2979ff;
- }
- }
- }
- .clearBtn {
- margin: 0;
- padding: 0;
- line-height: 1;
- background-color: #FFFFFF;
- }
- .clearBtn::after {
- position: unset !important;
- border: unset;
- }
- </style>
|