nav.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view class="navBox">
  3. <view class="flex nav background-linear-gradient">
  4. <view class="navLeft flex">
  5. <image class="navLeftImg" src="../../static/img/nav01.png" mode="scaleToFill"></image>
  6. <view>BCMM</view>
  7. </view>
  8. <view class="navRight flex">
  9. <view class="tabLange">
  10. <picker :range="langList" range-key='label' @change="selectLang">
  11. <view class="langType">{{label}}</view>
  12. </picker>
  13. </view>
  14. <view class="userInfo flex border-linear-gradient" @click="copyAddress">
  15. <image class="rightImg" src="../../static/img/nav02.png" mode="scaleToFill"></image>
  16. <view class="userInfoName">
  17. {{userInfo.address|hideCenter}}
  18. </view>
  19. </view>
  20. <view class="level text-linear-gradient margin-l-10" v-if="userInfo.level>0">
  21. {{userInfo.level_info.name}}
  22. </view>
  23. </view>
  24. </view>
  25. <navigator :url="url" open-type='redirect' v-if="showTitle">
  26. <view class="flex titleBox position-relative">
  27. <view class="leftBackIcon">
  28. <image class="icon" src="../../static/img/mininext.png" mode="scaleToFill"></image>
  29. </view>
  30. <view class="pageTitle flex-center">
  31. <view>
  32. {{title}}
  33. </view>
  34. </view>
  35. </view>
  36. </navigator>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. mapState,
  42. mapActions,
  43. mapMutations
  44. } from "vuex";
  45. export default {
  46. data() {
  47. return {}
  48. },
  49. filters: {
  50. hideCenter: function(value) {
  51. const st = value.slice(7, value.length - 7);
  52. const sr = value.replace(st, '...')
  53. return sr;
  54. },
  55. },
  56. props: {
  57. title: {
  58. type: String,
  59. default: ""
  60. },
  61. showTitle:{
  62. type:Boolean,
  63. default: false
  64. },
  65. url:{
  66. type: String,
  67. default: "/pages/index/index"
  68. },
  69. },
  70. computed: {
  71. ...mapState({
  72. langList: "langList",
  73. lang: "lang",
  74. }),
  75. ...mapState("user", ['userInfo']),
  76. label() {
  77. let label = ''
  78. try {
  79. label = this.langList.find((item) => {
  80. return item.value == this.lang
  81. }).value;
  82. } catch (e) {
  83. label = 'TW'
  84. }
  85. return label
  86. },
  87. },
  88. methods: {
  89. ...mapActions({
  90. setLang: "setLang",
  91. }),
  92. // 复制地址
  93. copyAddress() {
  94. const that = this;
  95. uni.setClipboardData({
  96. data: this.userInfo.address,
  97. showToast: false,
  98. success: function() {
  99. uni.showToast({
  100. title: that.$t('home.成功')
  101. })
  102. //调用方法成功
  103. console.log("success");
  104. },
  105. });
  106. },
  107. //切换语言
  108. selectLang(value) {
  109. this.setLang(this.langList[value.detail.value].value);
  110. },
  111. },
  112. }
  113. </script>
  114. <style lang="scss">
  115. .titleBox {
  116. padding: 30rpx;
  117. color: #FFF;
  118. .leftBackIcon {
  119. transform: rotate(0.5turn);
  120. .icon {
  121. width: 21rpx;
  122. height: 36rpx;
  123. }
  124. }
  125. .pageTitle {
  126. position: absolute;
  127. top: 0;
  128. bottom: 0;
  129. left: 0;
  130. right: 0;
  131. text-align: center;
  132. flex-grow: 1;
  133. font-weight: 500;
  134. font-size: 34rpx;
  135. }
  136. }
  137. .nav {
  138. padding: 25rpx;
  139. .navLeft {
  140. font-weight: 500;
  141. font-size: 30rpx;
  142. color: #FFFFFF;
  143. .navLeftImg {
  144. width: 58rpx;
  145. height: 58rpx;
  146. margin-right: 10rpx;
  147. }
  148. }
  149. .navRight {
  150. color: #FFF;
  151. .level{
  152. font-weight: bold;
  153. }
  154. .tabLange {
  155. border: 1px solid #FFF;
  156. padding: 6rpx 10rpx;
  157. border-radius: 10rpx;
  158. margin-right: 20rpx;
  159. font-size: 20rpx;
  160. font-weight: bold;
  161. line-height: 28rpx;
  162. }
  163. .userInfo {
  164. border-radius: 15rpx;
  165. padding: 6rpx 10rpx;
  166. line-height: 1;
  167. .rightImg {
  168. width: 36rpx;
  169. height: 36rpx;
  170. margin-right: 10rpx;
  171. }
  172. .userInfoName {
  173. font-size: 25rpx;
  174. }
  175. }
  176. }
  177. }
  178. </style>