topView.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="flex topBox" :style="{background:backg}">
  3. <view class="flex_item">
  4. <image src="/static/img/img01.png" style="width: 56rpx;height: 49rpx;"></image>
  5. <view style="color: #fff;font-size: 36rpx;padding-left: 15rpx;">NICE</view>
  6. </view>
  7. <view class="flex_item topTpl">
  8. <view class="addr" style="margin-right: 15rpx;">L{{userInfo.level}}</view>
  9. <view class="addr" v-if="userInfo.addresss">{{userInfo.addresss}}</view>
  10. <view class="flex_item tplInfo">
  11. <image src="/static/img/img14.png" style="width: 28rpx;height: 28rpx;margin: 0rpx 15rpx;"></image>
  12. <picker :range="langList" range-key='label' @change="selectLang">
  13. <view style="font-size: 22rpx;">{{langLabel}}</view>
  14. </picker>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import { getUserInfo } from '@/api/login.js';
  21. import {mapState,mapActions,mapMutations} from "vuex";
  22. export default {
  23. props:{
  24. backg: {
  25. type: String,
  26. default: '#15130E'
  27. },
  28. },
  29. data() {
  30. return{
  31. };
  32. },
  33. mounted() {
  34. this.getInfo();
  35. },
  36. computed: {
  37. ...mapState({
  38. langList: "langList",
  39. lang: "lang",
  40. }),
  41. ...mapState('user', ['userInfo']),
  42. langLabel () {
  43. const langLabel = this.langList.find((item) => {
  44. return item.value == this.lang
  45. }).label;
  46. return langLabel
  47. }
  48. },
  49. methods: {
  50. ...mapMutations('user', ['setUserInfo']),
  51. ...mapActions({
  52. setLang: "setLang",
  53. }),
  54. getInfo(){
  55. const obj = this
  56. getUserInfo({}).then(({
  57. data
  58. }) => {
  59. data.addresss = data.address.slice(0, 4) + "****" + data.address.slice(data.address.length - 4);
  60. obj.setUserInfo(data);
  61. }).catch(e => {
  62. console.log(e.msg);
  63. });
  64. },
  65. //切换语言
  66. selectLang (value) {
  67. this.setLang(this.langList[value.detail.value].value);
  68. this.$router.go(0)
  69. },
  70. },
  71. };
  72. </script>
  73. <style lang="scss" scoped>
  74. .topBox {
  75. color: #FFE0BD;
  76. padding: 25rpx 25rpx 25rpx 25rpx;
  77. position: fixed;
  78. top: 0;
  79. width: 100%;
  80. z-index: 999;
  81. .topTpl {
  82. .addr {
  83. padding: 4rpx 15rpx;
  84. background: linear-gradient(-74deg, #CE9C6D, #FFECD6);
  85. box-shadow: 3rpx 4rpx 5rpx 0rpx rgba(151, 118, 74, 0.5);
  86. border-radius: 21rpx;
  87. font-size: 24rpx;
  88. font-family: PingFang SC;
  89. font-weight: 500;
  90. color: #986629;
  91. }
  92. }
  93. }
  94. </style>