| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- <template>
- <view>
- <u-modal :show="showAuthorizeUser" title="提示" confirmColor="#181a82" @confirm="confirm" @cancel='cancel'
- confirmText="立即登录" cancelText="暂不登录" showConfirmButton="true" showCancelButton="true">
- <view style="text-align: center;padding: 20rpx;">您还没有登录哦</view>
- </u-modal>
- <wxinfo ref="wxinfo" v-on:loginback="loginback"></wxinfo>
- </view>
- </template>
- <script>
- import loginApi from '@/api/login/login.js';
- import mineApi from '@/api/mine/index.js';
- import wxinfo from '@/components/wxinfo/wxinfo.vue';
- export default {
- name: "nologin",
- props: [],
- components: {
- wxinfo
- },
- data() {
- return {
- user: {
- headimgurl: 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0',
- nickname: '',
- },
- hasUserInfo: false,
- logo: '',
- // 用户基本信息
- userInfo: null,
- // 微信,支付宝用户code
- code: '',
- // 是否弹出登录注册授权弹窗
- showAuthorizeUser: false,
- showAuthorizePhone: false,
- };
- },
- methods: {
- loginback() {
- //登录回调
- this.$emit('loginback');
- },
- open() {
- let that = this;
- uni.login({
- provider: 'weixin',
- success: loginRes => {
- that.code = loginRes.code;
- }
- });
- that.showAuthorizeUser = true
- },
- cancel() {
- this.showAuthorizeUser = false
- },
- close() {
- this.showAuthorizeUser = false
- },
- getInitInfo() {
- let that = this;
- that.$emit('getInitInfo');
- },
- confirm() {
- let that = this;
- uni.showLoading({
- title: '登录中...'
- });
- // 获取用户基本信息
- uni.getUserProfile({
- desc: '登陆',
- success: function(infoRes) {
- let userInfo = JSON.parse(infoRes.rawData);
- let logdata = {
- type: 1,
- code: that.code,
- pid: uni.getStorageSync('sys_pid'),
- ...userInfo
- };
- loginApi
- .wxlogin_v2(logdata)
- .then(res => {
- if (res.status == 200) {
- that.close();
- that.$store.commit('login', res.data.userinfo);
- that.$emit('loginback');
- if (!res.data.userinfo.nickname || !res.data.userinfo.headimgurl) {
- that.$refs.wxinfo.open();
- } else{
- that.$api.msg('登录成功');
- }
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- }
- });
- },
- fail: err => {
- uni.showToast({
- title: '授权失败',
- icon: 'none'
- });
- return false;
- }
- });
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .auth-btncard {
- .btn-unok {
- width: 50%;
- float: left;
- }
- .btn-ok {
- width: 50%;
- float: left;
- margin: 0;
- padding: 0;
- border: 0px solid transparent; //自定义边框
- outline: none; //消除默认点击蓝色边框效果
- u-button {
- margin: 0;
- padding: 0;
- border: 0px solid transparent; //自定义边框
- outline: none; //消除默认点击蓝色边框效果
- }
- }
- }
- .auth-card {
- text-align: center;
- .avatar-img {
- width: 150rpx;
- height: 150rpx;
- overflow: hidden;
- border-radius: 100%;
- margin-top: 30rpx;
- }
- .title {
- font-size: 20rpx;
- }
- .content {
- margin-top: 10rpx;
- }
- }
- .mine_box {
- height: 360upx;
- color: #fff;
- // background-color: $primarycolor;
- .avatar-img {
- width: 150rpx;
- height: 150rpx;
- overflow: hidden;
- border-radius: 100%;
- /*margin-right: 40rpx;*/
- }
- .avatar_box {
- position: relative;
- width: 150rpx;
- height: 150rpx;
- overflow: hidden;
- border-radius: 100%;
- margin-right: 40rpx;
- .avatar-img {
- width: 100%;
- height: 100%;
- /* #ifdef MP-WEIXIN*/
- width: 150rpx;
- height: 150rpx;
- /* #endif */
- }
- .get_user_data {
- z-index: 11;
- opacity: 0;
- width: 100%;
- height: 100%;
- position: absolute;
- left: 0;
- top: 0;
- }
- }
- .nick-name-box {
- height: 100%;
- }
- .user-nickName {
- font-size: 40rpx;
- color: #fff;
- margin-bottom: 20rpx;
- }
- .shiming_box {
- border-radius: 10upx;
- font-size: 28upx;
- padding: 10upx 20upx;
- background-color: rgba(15, 77, 139, 0.5);
- .icon-shezhi {
- margin-right: 10rpx;
- margin-top: 5rpx;
- }
- }
- }
- .authorize-box {
- background-color: transparent;
- text-align: center;
- .authorize-avatar {
- width: 200rpx;
- height: 200rpx;
- }
- .authorize-btn {
- position: relative;
- top: 40rpx;
- }
- }
- /deep/.u-mode-center-box {
- background-color: transparent !important;
- }
- </style>
- <style>
- .avatar-wrapper {
- width: 150rpx;
- height: 100rpx;
- color: #333 !important;
- text-align: center !important;
- border: none !important;
- border-radius: 0 !important;
- background-color: transparent !important;
- }
- .avatar-wrapper::after {
- border: none !important;
- }
- .avatar {
- margin-right: 50rpx;
- width: 100rpx;
- height: 100rpx;
- overflow: hidden;
- border-radius: 100%;
- }
- </style>
|