Browse Source

no message

宇宙无敌M1处理器的MacBook Pro 4 years ago
parent
commit
abb504820f
1 changed files with 65 additions and 171 deletions
  1. 65 171
      components/page-component/app-user-center-top/app-user-center-top.vue

+ 65 - 171
components/page-component/app-user-center-top/app-user-center-top.vue

xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -1,34 +1,25 @@
 <template>
-	<!-- 'background-image': 'url('+topPicUrl+')' -->
     <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="[is_vip_card_user && is_icon_super_vip == '1' ? 'avatar is_vip' : 'avatar']"></image>
-                    <image v-if="is_vip_card_user && is_icon_super_vip == '1'" src="/static/image/vip_icon.png" class="vip_icon"></image>
+                    <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 v-if="userInfo" class="nickname t-omit" :style="{'color':userNameColor}">{{userInfo.nickname}}</view>
-                            <!--#ifdef MP-WEIXIN -->
+                            <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"
-                                    @click="getUserInfo"
+                                    @getAuthorize="getUserInfo"
+                                    @getuserinfo="getUserInfo"
                             >
-                                <icon class="u-icon" type></icon>
-                                <text>刷新</text>
-                            </button>
-                            <!-- #endif-->
-                            <!--#ifdef H5 -->
-                            <button class="u-refresh dir-left-nowrap main-between cross-center member-margin"
-                                    @click="getUserInfo"
-                                    v-if="isWechat"
-                            >
-                                <icon class="u-icon" type></icon>
+                                <icon class="u-icon"></icon>
                                 <text>刷新</text>
                             </button>
                             <!-- #endif-->
@@ -38,7 +29,7 @@
                                 <view>
                                     <image :src="getMemberPicUrl" class="member-icon" mode="aspectFill"></image>
                                 </view>
-                                <view v-if="userInfo" class="t-omit">{{userInfo.identity.level_name}}</view>
+                                <view class="t-omit">{{userInfo.identity.level_name}}</view>
                             </view>
                         </app-form-id>
                     </template>
@@ -49,15 +40,9 @@
                     </template>
                 </view>
                 <view class="box-grow-0 address-container">
-                    <app-jump-button v-if="userInfo && userInfo.is_show_pay_code" form url="/plugins/teller/index/index">
-                        <view class="address-btn-3 pay-code">
-                            <image class="pay-code-icon" src="/static/image/icon/pay-code.png"></image>
-                            <view>付款码</view>
-                        </view>
-                    </app-jump-button>
                     <app-jump-button form url="/pages/address/address">
-                        <view class="address-btn-3">
-                            <image class="address-btn-icon" src="/static/image/icon/address-white.png"></image>
+                        <view class="address-btn-3" >
+                            <image class="address-btn-icon" src="/static/image/icon/address-gray.png"></image>
                             <view>收货地址</view>
                         </view>
                     </app-jump-button>
@@ -68,15 +53,9 @@
 
         <!-- style 2 start -->
         <view class="style-2 box-grow-1" v-else-if="topStyle == '2'">
-            <app-jump-button v-if="userInfo && userInfo.is_show_pay_code" form url="/plugins/teller/index/index">
-                <view class="pay-code-btn">
-                    <image class="pay-code-icon" src="/static/image/icon/pay-code.png"></image>
-                    <view>付款码</view>
-                </view>
-            </app-jump-button>
             <view class="avatar-container">
-                <image :src="avatar" :class="[is_vip_card_user && is_icon_super_vip == '1' ? 'avatar is_vip' : 'avatar']"></image>
-                <image v-if="is_vip_card_user  && is_icon_super_vip == '1'" src="/static/image/vip_icon.png" class="vip_icon"></image>
+                <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">
@@ -85,31 +64,22 @@
                             <view>
                                 <image :src="getMemberPicUrl" class="member-icon" mode="aspectFill"></image>
                             </view>
-                            <view v-if="userInfo" class="t-omit">{{userInfo.identity.level_name}}</view>
+                            <view class="t-omit">{{userInfo.identity.level_name}}</view>
                         </view>
                     </app-form-id>
                     <view class="dir-left-nowrap cross-center main-center">
-                        <view v-if="userInfo" class="nickname t-omit" :style="{'color':userNameColor}"
+                        <view class="nickname t-omit"
                               :class="[mall.setting.is_icon_members_grade != 1 ? 'no-member-icon' : '',]">
                             {{userInfo.nickname}}</view>
-                        <!--#ifdef MP-WEIXIN -->
+                        <!--#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"
-                                @click="getUserInfo"
+                                @getAuthorize="getUserInfo"
+                                @getuserinfo="getUserInfo"
                         >
-                            <icon class="u-icon" type></icon>
-                            <text>刷新</text>
-                        </button>
-                        <!-- #endif-->
-                        <!--#ifdef H5 -->
-                        <button class="u-refresh dir-left-nowrap main-between cross-center"
-                                v-if="isWechat"
-                                :class="[mall.setting.is_icon_members_grade != 1 ? 'no-member-icon' : '',]"
-                                @click="getUserInfo"
-                        >
-                            <icon class="u-icon" type></icon>
+                            <icon class="u-icon"></icon>
                             <text>刷新</text>
                         </button>
                         <!-- #endif-->
@@ -127,25 +97,19 @@
         <!-- 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="[is_vip_card_user && is_icon_super_vip == '1' ? 'avatar is_vip' : 'avatar']"></image>
-                <image v-if="is_vip_card_user && is_icon_super_vip == '1'" src="/static/image/vip_icon.png" class="vip_icon"></image>
+                <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 v-if="userInfo" class="nickname t-omit" :style="{'color':userNameColor}">{{userInfo.nickname}}</view>
-                        <!--#ifdef MP-WEIXIN -->
-                        <button class="u-refresh dir-left-nowrap main-between cross-center member-margin" 
-                                @click="getUserInfo">
-                            <icon class="u-icon" type></icon>
-                            <text>刷新</text>
-                        </button>
-                        <!-- #endif-->
-                        <!--#ifdef  H5 -->
-                        <button class="u-refresh dir-left-nowrap main-between cross-center member-margin"
-                                v-if="isWechat"
-                                @click="getUserInfo">
-                            <icon class="u-icon" type></icon>
+                        <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-->
@@ -155,7 +119,7 @@
                             <view>
                                 <image :src="getMemberPicUrl" class="member-icon" mode="aspectFill"></image>
                             </view>
-                            <view v-if="userInfo" class="t-omit">{{userInfo.identity.level_name}}</view>
+                            <view class="t-omit">{{userInfo.identity.level_name}}</view>
                         </view>
                     </app-form-id>
                 </template>
@@ -166,14 +130,8 @@
                 </template>
             </view>
             <view class="box-grow-0 address-container">
-                <app-jump-button v-if="userInfo && userInfo.is_show_pay_code" form url="/plugins/teller/index/index">
-                    <view class="pay-code">
-                        <image class="pay-code-icon" src="/static/image/icon/pay-code.png"></image>
-                        <view>付款码</view>
-                    </view>
-                </app-jump-button>
                 <app-jump-button form url="/pages/address/address">
-                    <view class="address-btn-1 dir-left-nowrap cross-center" >
+                    <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>
@@ -189,7 +147,6 @@
 
 <script>
     import {mapState, mapGetters} from 'vuex';
-    import Vue from "@dcloudio/vue-cli-plugin-uni/packages/h5-vue";
 
     export default {
         name: 'app-user-center-top',
@@ -197,7 +154,6 @@
             topStyle: String,
             topPicUrl: String,
             memberPicUrl: String,
-            userNameColor: String,
             is_icon_super_vip: {
                 type: String,
                 default() {
@@ -211,9 +167,6 @@
             },
             ...mapState({
                 mall: state => state.mallConfig.mall,
-                is_vip_card_user: function(state) {
-                    return state.user.info && state.user.info.is_vip_card_user ? 1 : 0;
-                }
             }),
             ...mapGetters({
                 userCenter: 'mallConfig/getUserCenter',
@@ -235,19 +188,13 @@
                     return this.userInfo.identity.member_pic_url;
                 }
             },
-            // #ifdef H5
-            isWechat: function() {
-                return this.$jwx.isWechat();
-            }
-            // #endif
         },
-        // #ifdef MP
         created() {
             if (this.isLogin) {
                 this.$store.dispatch('user/info', {refresh: true});
+            } else {
             }
         },
-        // #endif
         methods: {
             callLogin() {
                 this.$store.dispatch('user/accessToken');
@@ -257,65 +204,45 @@
                     url: '/pages/member/index/index',
                 });
             },
-            getUserInfo() {
-                // #ifdef MP
+            getUserInfo(userInfoResult) {
                 let _this = this;
                 uni.login({
                     scopes: 'auth_user',
-                    success:(loginResult)=> {
-						this.getuserinfodata(loginResult)
-                    }
-                });
-                // #endif
-                // #ifdef H5
-                this.$request({
-                    url: this.$api.registered.url,
-                    method: 'get',
-                    data: {
-                        scope: 'snsapi_userinfo',
-                        response_type: 'code',
-                        url: `${window.location.href}`
-                    }
-                }).then(res => {
-                    if (res.code === 0) {
-                        this.$storage.setStorageSync('_USER_SIGN', true);
-                        window.location.replace(res.data.url);
-                    } else {
-                        uni.navigateTo({
-                            url: '/pages/registered/sign'
+                    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);
+                            }
                         });
                     }
                 });
-                // #endif
-            },
-			getuserinfodata(code){
-				this.$request({
-				    url: this.$api.passport.login,
-				    method: 'post',
-				    data: {
-						code:code.code
-					}
-				}).then(response => {
-				    uni.hideLoading();
-				    if (response.code === 0) {
-				        uni.showToast({
-				            title: '资料已更新',
-				            icon: 'none'
-				        });
-				        this.$storage.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: #{360rpx};
+        height: #{300rpx};
         background-repeat: no-repeat;
         background-size: cover;
         background-position: center;
@@ -359,7 +286,7 @@
     .info-container {
         padding: #{0rpx};
         position: relative;
-        z-index: 997;
+        z-index: 1000;
     }
 
     .address-container {
@@ -388,35 +315,14 @@
         }
     }
 
-    .pay-code-btn {
-        z-index: 998;
-        position: absolute;
-        right: 50rpx;
-        top: 0;
-        color: #fff;
-        text-align: center;
-        font-size: $uni-font-size-weak-two;
-        .pay-code-icon {
-            width: #{44rpx};
-            height: #{44rpx};   
-        }
-    }
-
     .address-btn-3 {
         text-align: center;
         font-size: $uni-font-size-general-two;
-        color: #ffffff;
-        &.pay-code {
-            margin-bottom: #{20rpx};
-            font-size: $uni-font-size-weak-two;
-            .pay-code-icon {
-                width: #{44rpx};
-                height: #{44rpx};   
-            }
-        }
+        color: $uni-general-color-two;
+
         .address-btn-icon {
-            width: #{44rpx};
-            height: #{44rpx};
+            width: #{56rpx};
+            height: #{56rpx};
         }
     }
 
@@ -455,8 +361,7 @@
 
     .style-2 {
         text-align: center;
-        position: relative;
-        
+
         .info-container {
             margin-top: -#{50rpx};
         }
@@ -488,17 +393,6 @@
         .u-refresh.member-margin {
             margin-bottom: 12upx;
         }
-        .pay-code {
-            margin-bottom: #{20rpx};
-            color: #fff;
-            text-align: center;
-            font-size: $uni-font-size-weak-two;
-            margin-left: #{96rpx};
-            .pay-code-icon {
-                width: #{44rpx};
-                height: #{44rpx};   
-            }
-        }
     }