nav.vue 3.4 KB

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