app-user-center-top.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <view class="app-user-center-top cross-center" :style="{'background-image': 'url('+topPicUrl+')'}">
  3. <!-- style 3 start -->
  4. <view class="style-3 box-grow-1 main-center" v-if="topStyle == '3'">
  5. <view class="style-3-container dir-left-nowrap cross-center"
  6. :style="userCenter.style_bg_pic_url?`background-image: url(${userCenter.style_bg_pic_url})`:``">
  7. <view class="box-grow-0 avatar-container">
  8. <image :src="avatar" :class="[userInfo.is_vip_card_user && is_icon_super_vip == '1' ? 'avatar is_vip' : 'avatar']"></image>
  9. <image v-if="userInfo.is_vip_card_user && is_icon_super_vip == '1'" src="/static/image/vip_icon.png" class="vip_icon"></image>
  10. </view>
  11. <view class="box-grow-1 info-container">
  12. <template v-if="isLogin">
  13. <view class="nickname">{{userInfo.nickname}}</view>
  14. <app-form-id @click="goMember" v-if="mall.setting.is_icon_members_grade == 1">
  15. <view class="member-info inline-flex cross-center dir-left-nowrap">
  16. <view>
  17. <image :src="getMemberPicUrl" class="member-icon" mode="aspectFill"></image>
  18. </view>
  19. <view>{{userInfo.identity.level_name}}</view>
  20. </view>
  21. </app-form-id>
  22. </template>
  23. <template v-else>
  24. <app-form-id>
  25. <view class="login-btn" @click="callLogin">点击登录</view>
  26. </app-form-id>
  27. </template>
  28. </view>
  29. <view class="box-grow-0 address-container">
  30. <app-jump-button form url="/pages/address/address">
  31. <view class="address-btn-3">
  32. <image class="address-btn-icon" src="/static/image/icon/address-gray.png"></image>
  33. <view>收货地址</view>
  34. </view>
  35. </app-jump-button>
  36. </view>
  37. </view>
  38. </view>
  39. <!-- style 3 end -->
  40. <!-- style 2 start -->
  41. <view class="style-2 box-grow-1" v-else-if="topStyle == '2'">
  42. <view class="avatar-container">
  43. <image :src="avatar" :class="[userInfo.is_vip_card_user && is_icon_super_vip == '1' ? 'avatar is_vip' : 'avatar']"></image>
  44. <image v-if="userInfo.is_vip_card_user && is_icon_super_vip == '1'" src="/static/image/vip_icon.png" class="vip_icon"></image>
  45. </view>
  46. <view class="info-container">
  47. <template v-if="isLogin">
  48. <app-form-id @click="goMember" v-if="mall.setting.is_icon_members_grade == 1">
  49. <view class="member-info inline-flex cross-center dir-left-nowrap">
  50. <view>
  51. <image :src="getMemberPicUrl" class="member-icon" mode="aspectFill"></image>
  52. </view>
  53. <view>{{userInfo.identity.level_name}}</view>
  54. </view>
  55. </app-form-id>
  56. <view class="nickname"
  57. :class="[mall.setting.is_icon_members_grade != 1 ? 'no-member-icon' : '',]">
  58. {{userInfo.nickname}}
  59. </view>
  60. </template>
  61. <template v-else>
  62. <app-form-id>
  63. <view class="login-btn" @click="callLogin">点击登录</view>
  64. </app-form-id>
  65. </template>
  66. </view>
  67. </view>
  68. <!-- style 2 end -->
  69. <!-- style 1 start -->
  70. <view class="style-1 dir-left-nowrap cross-center box-grow-1" v-else-if="topStyle == '1'">
  71. <view class="box-grow-0 avatar-container">
  72. <image :src="avatar" :class="[userInfo.is_vip_card_user && is_icon_super_vip == '1' ? 'avatar is_vip' : 'avatar']"></image>
  73. <image v-if="userInfo.is_vip_card_user && is_icon_super_vip == '1'" src="/static/image/vip_icon.png" class="vip_icon"></image>
  74. </view>
  75. <view class="box-grow-1 info-container">
  76. <template v-if="isLogin">
  77. <view class="nickname">{{userInfo.nickname}}</view>
  78. <app-form-id @click="goMember" v-if="mall.setting.is_icon_members_grade == 1">
  79. <view class="member-info inline-flex cross-center dir-left-nowrap">
  80. <view>
  81. <image :src="getMemberPicUrl" class="member-icon" mode="aspectFill"></image>
  82. </view>
  83. <view>{{userInfo.identity.level_name}}</view>
  84. </view>
  85. </app-form-id>
  86. </template>
  87. <template v-else>
  88. <app-form-id>
  89. <view class="login-btn" @click="callLogin">点击登录</view>
  90. </app-form-id>
  91. </template>
  92. </view>
  93. <view class="box-grow-0 address-container">
  94. <app-jump-button form url="/pages/address/address">
  95. <view class="address-btn-1 dir-left-nowrap cross-center" :class="[`${theme}-background`]">
  96. <view>
  97. <image class="address-btn-icon" src="/static/image/icon/address-white.png"></image>
  98. </view>
  99. <view>收货地址</view>
  100. </view>
  101. </app-jump-button>
  102. </view>
  103. </view>
  104. <!-- style 1 end -->
  105. </view>
  106. </template>
  107. <script>
  108. import {mapState, mapGetters} from 'vuex';
  109. export default {
  110. name: 'app-user-center-top',
  111. props: {
  112. topStyle: String,
  113. topPicUrl: String,
  114. memberPicUrl: String,
  115. is_icon_super_vip: {
  116. type: String,
  117. default() {
  118. return '0';
  119. }
  120. },
  121. },
  122. computed: {
  123. isLogin() {
  124. return this.$user.isLogin();
  125. },
  126. ...mapState({
  127. theme: state => state.mallConfig.theme,
  128. mall: state => state.mallConfig.mall,
  129. }),
  130. ...mapGetters({
  131. userCenter: 'mallConfig/getUserCenter',
  132. userInfo: 'user/info',
  133. }),
  134. avatar() {
  135. if (this.isLogin && this.userInfo) {
  136. return this.userInfo.avatar;
  137. } else {
  138. return '/static/image/user-default-avatar.png';
  139. }
  140. },
  141. getMemberPicUrl() {
  142. return this.memberPicUrl;
  143. // todo 此处选哪个图标待确认
  144. if (this.memberPicUrl) {
  145. return this.memberPicUrl;
  146. } else {
  147. return this.userInfo.identity.member_pic_url;
  148. }
  149. },
  150. },
  151. created() {
  152. if (this.isLogin) {
  153. this.$store.dispatch('user/info');
  154. } else {
  155. }
  156. },
  157. methods: {
  158. callLogin() {
  159. this.$store.dispatch('user/accessToken');
  160. },
  161. goMember() {
  162. uni.navigateTo({
  163. url: '/pages/member/index/index',
  164. });
  165. }
  166. },
  167. }
  168. </script>
  169. <style scoped lang="scss">
  170. .app-user-center-top {
  171. width: #{750rpx};
  172. height: #{300rpx};
  173. background-repeat: no-repeat;
  174. background-size: cover;
  175. background-position: center;
  176. overflow: hidden;
  177. }
  178. .avatar {
  179. width: #{132rpx};
  180. height: #{132rpx};
  181. border-radius: #{1000rpx};
  182. }
  183. .avatar.is_vip {
  184. border: #{8rpx} solid #ffe993;
  185. }
  186. .login-btn {
  187. display: inline-block;
  188. padding: #{12rpx} #{24rpx};
  189. font-size: $uni-font-size-import-one;
  190. }
  191. .avatar-container {
  192. padding: #{24rpx};
  193. position: relative;
  194. }
  195. .style-2 .vip_icon {
  196. left: 50%;
  197. margin-left: 29rpx;
  198. }
  199. .vip_icon {
  200. position: absolute;
  201. right: 0;
  202. top: 0;
  203. width: 58rpx;
  204. height: 57rpx;
  205. }
  206. .info-container {
  207. padding: #{0rpx};
  208. }
  209. .address-container {
  210. padding: #{24rpx};
  211. }
  212. .member-info {
  213. background: #3c3642;
  214. color: #fff;
  215. font-size: $uni-font-size-weak-two;
  216. padding: #{6rpx} #{12rpx};
  217. border-radius: #{1000rpx};
  218. height: #{36rpx};
  219. line-height: #{36rpx};
  220. .member-icon {
  221. display: block;
  222. width: #{44rpx};
  223. height: #{44rpx};
  224. margin-top: -#{6rpx};
  225. margin-bottom: -#{6rpx};
  226. margin-left: -#{12rpx};
  227. margin-right: #{6rpx};
  228. border-radius: #{1000rpx};
  229. overflow: hidden;
  230. }
  231. }
  232. .address-btn-3 {
  233. text-align: center;
  234. font-size: $uni-font-size-general-two;
  235. color: $uni-general-color-two;
  236. .address-btn-icon {
  237. width: #{56rpx};
  238. height: #{56rpx};
  239. }
  240. }
  241. .address-btn-1 {
  242. padding: #{16rpx} #{18rpx};
  243. border-radius: #{1000rpx} 0 0 #{1000rpx};
  244. margin-right: -#{48rpx};
  245. .address-btn-icon {
  246. width: #{44rpx};
  247. height: #{44rpx};
  248. margin-right: #{12rpx};
  249. display: block;
  250. }
  251. }
  252. .style-3 {
  253. .style-3-container {
  254. background-color: #fff;
  255. border-radius: #{12rpx};
  256. width: #{656rpx};
  257. height: #{220rpx};
  258. background-size: 100% 100%;
  259. .nickname {
  260. margin-bottom: #{12rpx};
  261. color: $uni-important-color-black;
  262. }
  263. }
  264. }
  265. .style-2 {
  266. text-align: center;
  267. .info-container {
  268. margin-top: -#{50rpx};
  269. }
  270. .nickname {
  271. color: #fff;
  272. }
  273. .nickname.no-member-icon {
  274. margin-top: #{30rpx};
  275. }
  276. .login-btn {
  277. color: #fff;
  278. margin-top: #{40rpx};
  279. }
  280. }
  281. .style-1 {
  282. padding: 0 #{24rpx};
  283. .nickname {
  284. color: #fff;
  285. margin-bottom: #{12rpx};
  286. }
  287. }
  288. </style>