123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424 |
- <template>
- <view class="app-user-center-top cross-center" :style="{'background-image': 'url('+topPicUrl+')'}">
- <!-- style 3 start -->
- <view class="style-3 box-grow-1 main-center" v-if="topStyle == '3'">
- <view class="style-3-container dir-left-nowrap cross-center"
- :style="userCenter.style_bg_pic_url?`background-image: url(${userCenter.style_bg_pic_url})`:``">
- <view class="box-grow-0 avatar-container">
- <image :src="avatar" :class="[userInfo.is_vip_card_user && is_icon_super_vip == '1' ? 'avatar is_vip' : 'avatar']"></image>
- <image v-if="userInfo.is_vip_card_user && is_icon_super_vip == '1'" src="/static/image/vip_icon.png" class="vip_icon"></image>
- </view>
- <view class="box-grow-1 info-container">
- <template v-if="isLogin">
- <view class="dir-left-nowrap cross-center">
- <view class="nickname t-omit">{{userInfo.nickname}}</view>
- <!--#ifdef MP-WEIXIN-->
- <button class="u-refresh dir-left-nowrap main-between cross-center member-margin"
- open-type="getUserInfo"
- scope="userInfo"
- @getAuthorize="getUserInfo"
- @getuserinfo="getUserInfo"
- >
- <icon class="u-icon"></icon>
- <text>刷新</text>
- </button>
- <!-- #endif-->
- </view>
- <app-form-id @click="goMember" v-if="mall.setting.is_icon_members_grade == 1">
- <view class="member-info inline-flex cross-center dir-left-nowrap">
- <view>
- <image :src="getMemberPicUrl" class="member-icon" mode="aspectFill"></image>
- </view>
- <view class="t-omit">{{userInfo.identity.level_name}}</view>
- </view>
- </app-form-id>
- </template>
- <template v-else>
- <app-form-id>
- <view class="login-btn" @click="callLogin">点击登录</view>
- </app-form-id>
- </template>
- </view>
- <view class="box-grow-0 address-container">
- <app-jump-button form url="/pages/address/address">
- <view class="address-btn-3" >
- <image class="address-btn-icon" src="/static/image/icon/address-gray.png"></image>
- <view>收货地址</view>
- </view>
- </app-jump-button>
- </view>
- </view>
- </view>
- <!-- style 3 end -->
- <!-- style 2 start -->
- <view class="style-2 box-grow-1" v-else-if="topStyle == '2'">
- <view class="avatar-container">
- <image :src="avatar" :class="[userInfo.is_vip_card_user && is_icon_super_vip == '1' ? 'avatar is_vip' : 'avatar']"></image>
- <image v-if="userInfo.is_vip_card_user && is_icon_super_vip == '1'" src="/static/image/vip_icon.png" class="vip_icon"></image>
- </view>
- <view class="info-container">
- <template v-if="isLogin">
- <app-form-id @click="goMember" v-if="mall.setting.is_icon_members_grade == 1">
- <view class="member-info inline-flex cross-center dir-left-nowrap">
- <view>
- <image :src="getMemberPicUrl" class="member-icon" mode="aspectFill"></image>
- </view>
- <view class="t-omit">{{userInfo.identity.level_name}}</view>
- </view>
- </app-form-id>
- <view class="dir-left-nowrap cross-center main-center">
- <view class="nickname t-omit"
- :class="[mall.setting.is_icon_members_grade != 1 ? 'no-member-icon' : '',]">
- {{userInfo.nickname}}</view>
- <!--#ifdef MP-WEIXIN-->
- <button class="u-refresh dir-left-nowrap main-between cross-center"
- :class="[mall.setting.is_icon_members_grade != 1 ? 'no-member-icon' : '',]"
- open-type="getUserInfo"
- scope="userInfo"
- @getAuthorize="getUserInfo"
- @getuserinfo="getUserInfo"
- >
- <icon class="u-icon"></icon>
- <text>刷新</text>
- </button>
- <!-- #endif-->
- </view>
- </template>
- <template v-else>
- <app-form-id>
- <view class="login-btn" @click="callLogin">点击登录</view>
- </app-form-id>
- </template>
- </view>
- </view>
- <!-- style 2 end -->
- <!-- style 1 start -->
- <view class="style-1 dir-left-nowrap cross-center box-grow-1" v-else-if="topStyle == '1'">
- <view class="box-grow-0 avatar-container">
- <image :src="avatar" :class="[userInfo.is_vip_card_user && is_icon_super_vip == '1' ? 'avatar is_vip' : 'avatar']"></image>
- <image v-if="userInfo.is_vip_card_user && is_icon_super_vip == '1'" src="/static/image/vip_icon.png" class="vip_icon"></image>
- </view>
- <view class="box-grow-1 info-container">
- <template v-if="isLogin">
- <view class="dir-left-nowrap cross-center">
- <view class="nickname t-omit">{{userInfo.nickname}}</view>
- <!--#ifdef MP-WEIXIN-->
- <button class="u-refresh dir-left-nowrap main-between cross-center member-margin" open-type="getUserInfo"
- scope="userInfo"
- @getAuthorize="getUserInfo"
- @getuserinfo="getUserInfo">
- <icon class="u-icon"></icon>
- <text>刷新</text>
- </button>
- <!-- #endif-->
- </view>
- <app-form-id @click="goMember" v-if="mall.setting.is_icon_members_grade == 1">
- <view class="member-info inline-flex cross-center dir-left-nowrap">
- <view>
- <image :src="getMemberPicUrl" class="member-icon" mode="aspectFill"></image>
- </view>
- <view class="t-omit">{{userInfo.identity.level_name}}</view>
- </view>
- </app-form-id>
- </template>
- <template v-else>
- <app-form-id>
- <view class="login-btn" @click="callLogin">点击登录</view>
- </app-form-id>
- </template>
- </view>
- <view class="box-grow-0 address-container">
- <app-jump-button form url="/pages/address/address">
- <view class="address-btn-1 dir-left-nowrap cross-center" style="background-color:#F84469;">
- <view>
- <image class="address-btn-icon" src="/static/image/icon/address-white.png"></image>
- </view>
- <view>收货地址</view>
- </view>
- </app-jump-button>
- </view>
- </view>
- <!-- style 1 end -->
- </view>
- </template>
- <script>
- import {mapState, mapGetters} from 'vuex';
- export default {
- name: 'app-user-center-top',
- props: {
- topStyle: String,
- topPicUrl: String,
- memberPicUrl: String,
- is_icon_super_vip: {
- type: String,
- default() {
- return '0';
- }
- },
- },
- computed: {
- isLogin() {
- return this.$user.isLogin();
- },
- ...mapState({
- mall: state => state.mallConfig.mall,
- }),
- ...mapGetters({
- userCenter: 'mallConfig/getUserCenter',
- userInfo: 'user/info',
- }),
- avatar() {
- if (this.isLogin && this.userInfo) {
- return this.userInfo.avatar;
- } else {
- return '/static/image/user-default-avatar.png';
- }
- },
- getMemberPicUrl() {
- return this.memberPicUrl;
- // todo 此处选哪个图标待确认
- if (this.memberPicUrl) {
- return this.memberPicUrl;
- } else {
- return this.userInfo.identity.member_pic_url;
- }
- },
- },
- created() {
- if (this.isLogin) {
- this.$store.dispatch('user/info', {refresh: true});
- } else {
- }
- },
- methods: {
- callLogin() {
- this.$store.dispatch('user/accessToken');
- },
- goMember() {
- uni.navigateTo({
- url: '/pages/member/index/index',
- });
- },
- getUserInfo(userInfoResult) {
- let _this = this;
- uni.login({
- scopes: 'auth_user',
- success(loginResult) {
- const data = {
- encryptedData: userInfoResult.detail.encryptedData,
- iv: userInfoResult.detail.iv,
- rawData: userInfoResult.detail.rawData,
- signature: userInfoResult.detail.signature,
- code: loginResult.code,
- };
- _this.$request({
- url: _this.$api.passport.login,
- method: 'post',
- data: data
- }).then(response => {
- uni.hideLoading();
- if (response.code === 0) {
- uni.showToast({
- title: '资料已更新',
- icon: 'none'
- });
- uni.setStorageSync('_USER_ACCESS_TOKEN', response.data.access_token);
- } else {
- return reject(response.msg);
- }
- });
- }
- });
- }
- },
- }
- </script>
- <style scoped lang="scss">
- .app-user-center-top {
- width: #{750rpx};
- height: #{300rpx};
- background-repeat: no-repeat;
- background-size: cover;
- background-position: center;
- overflow: hidden;
- }
- .avatar {
- width: #{132rpx};
- height: #{132rpx};
- border-radius: #{1000rpx};
- }
- .avatar.is_vip {
- border: #{8rpx} solid #ffe993;
- }
- .login-btn {
- display: inline-block;
- padding: #{12rpx} #{24rpx};
- font-size: $uni-font-size-import-one;
- }
- .avatar-container {
- padding: #{24rpx};
- position: relative;
- }
- .style-2 .vip_icon {
- left: 50%;
- margin-left: 29rpx;
- }
- .vip_icon {
- position: absolute;
- right: 0;
- top: 0;
- width: 58rpx;
- height: 57rpx;
- }
- .info-container {
- padding: #{0rpx};
- position: relative;
- z-index: 1000;
- }
- .address-container {
- padding: #{24rpx};
- }
- .member-info {
- background: #3c3642;
- color: #fff;
- font-size: $uni-font-size-weak-two;
- padding: #{6rpx} #{12rpx};
- border-radius: #{1000rpx};
- height: #{36rpx};
- line-height: #{36rpx};
- .member-icon {
- display: block;
- width: #{44rpx};
- height: #{44rpx};
- margin-top: -#{6rpx};
- margin-bottom: -#{6rpx};
- margin-left: -#{12rpx};
- margin-right: #{6rpx};
- border-radius: #{1000rpx};
- overflow: hidden;
- }
- }
- .address-btn-3 {
- text-align: center;
- font-size: $uni-font-size-general-two;
- color: $uni-general-color-two;
- .address-btn-icon {
- width: #{56rpx};
- height: #{56rpx};
- }
- }
- .address-btn-1 {
- padding: #{16rpx} #{18rpx};
- border-radius: #{1000rpx} 0 0 #{1000rpx};
- margin-right: -#{48rpx};
- background: #ff4544;
- color: #ffffff;
- .address-btn-icon {
- width: #{44rpx};
- height: #{44rpx};
- margin-right: #{12rpx};
- display: block;
- }
- }
- .style-3 {
- .style-3-container {
- background-color: #fff;
- border-radius: #{12rpx};
- width: #{656rpx};
- height: #{220rpx};
- background-size: 100% 100%;
- .nickname {
- margin-bottom: #{12rpx};
- color: $uni-important-color-black;
- }
- }
- .u-refresh.member-margin {
- margin-bottom: 12upx;
- }
- }
- .style-2 {
- text-align: center;
- .info-container {
- margin-top: -#{50rpx};
- }
- .nickname {
- color: #fff;
- }
- .nickname.no-member-icon {
- margin-top: #{30rpx};
- }
- .u-refresh.no-member-icon {
- margin-top: #{30rpx};
- }
- .login-btn {
- color: #fff;
- margin-top: #{40rpx};
- }
- }
- .style-1 {
- padding: 0 #{24rpx};
- .nickname {
- color: #fff;
- margin-bottom: #{12rpx};
- }
- .u-refresh.member-margin {
- margin-bottom: 12upx;
- }
- }
- .u-refresh {
- border-radius: 18upx;
- border: 1upx solid #ffffff;
- min-width: 69upx;
- margin:0 0 0 10upx;
- box-sizing: content-box;
- height: 37upx;
- padding: 0 13upx;
- background-color: transparent;
- transform: rotateZ(360deg);
- .u-icon {
- width: 21upx;
- height: 21upx;
- background-image: url('../../../static/image/icon/refresh.png');
- background-size: 100% 100%;
- background-repeat: no-repeat;
- margin-right: 5upx;
- }
- text {
- line-height: 1;
- color: #ffffff;
- font-size: 21upx;
- }
- }
- </style>
|