123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- <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="nickname">{{userInfo.nickname}}</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>{{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>{{userInfo.identity.level_name}}</view>
- </view>
- </app-form-id>
- <view class="nickname"
- :class="[mall.setting.is_icon_members_grade != 1 ? 'no-member-icon' : '',]">
- {{userInfo.nickname}}
- </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="nickname">{{userInfo.nickname}}</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>{{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" :class="[`${theme}-background`]">
- <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({
- theme: state => state.mallConfig.theme,
- 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');
- } else {
- }
- },
- methods: {
- callLogin() {
- this.$store.dispatch('user/accessToken');
- },
- goMember() {
- uni.navigateTo({
- url: '/pages/member/index/index',
- });
- }
- },
- }
- </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};
- }
- .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};
- .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;
- }
- }
- }
- .style-2 {
- text-align: center;
- .info-container {
- margin-top: -#{50rpx};
- }
- .nickname {
- color: #fff;
- }
- .nickname.no-member-icon {
- margin-top: #{30rpx};
- }
- .login-btn {
- color: #fff;
- margin-top: #{40rpx};
- }
- }
- .style-1 {
- padding: 0 #{24rpx};
- .nickname {
- color: #fff;
- margin-bottom: #{12rpx};
- }
- }
- </style>
|