OrderHeader.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="order-header-container">
  3. <TuanAppShim bg="#fff"></TuanAppShim>
  4. <view class="top-wrapper">
  5. <view class="switch-btn">
  6. <button class="uni-btn" :class="{ active: currentMode === 'shoppingMall' }" @click="$emit('change-mode', 'shoppingMall')">商城</button>
  7. <button class="uni-btn" :class="{ active: currentMode === 'businessDistrict' }" @click="$emit('change-mode', 'businessDistrict')">
  8. 商圈
  9. </button>
  10. <view
  11. class="active-scroll-bar"
  12. :class="{ 'scroll-right': currentMode === 'businessDistrict', 'scroll-center': currentMode === 'shoppingMall' }"
  13. ></view>
  14. </view>
  15. </view>
  16. <scroll-view
  17. v-if="menus && menus.length" :scroll-into-view="currentActiveId" scroll-with-animation
  18. class="menus-wrapper" scroll-x="true"
  19. >
  20. <view class="menu-list">
  21. <view
  22. v-for="menu in menus" :id="'item_' + menu.value" :key="menu.value" class="menu-item"
  23. :class="{ active: currentStatus * 1 === menu.value }" @click="$emit('change-status', menu)"
  24. >
  25. {{ menu.label }}
  26. </view>
  27. </view>
  28. </scroll-view>
  29. <tui-toast ref="toast"></tui-toast>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. name: 'OrderHeader',
  35. props: {
  36. currentMode: {
  37. type: String,
  38. default: 'shoppingMall'
  39. },
  40. menus: {
  41. type: Array,
  42. required: true
  43. },
  44. currentStatus: {
  45. type: [Number, String],
  46. required: true
  47. }
  48. },
  49. data() {
  50. return {
  51. searchValue: ''
  52. }
  53. },
  54. computed: {
  55. currentActiveId() {
  56. return 'item_' + this.currentStatus
  57. }
  58. },
  59. watch: {
  60. searchValue(newSeachValue) {
  61. if (!newSeachValue) {
  62. this.$emit('search', this.searchValue)
  63. }
  64. }
  65. },
  66. methods: {
  67. handleSearchOrder() {
  68. if (!this.searchValue) {
  69. this.ttoast({
  70. type: 'info',
  71. title: '请输入订单号'
  72. })
  73. return
  74. }
  75. this.$emit('search', this.searchValue)
  76. },
  77. clearSearch() {
  78. this.searchValue = ''
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .order-header-container {
  85. position: fixed;
  86. top: 0;
  87. left: 0;
  88. right: 0;
  89. width: 100%;
  90. padding: 30upx;
  91. box-sizing: border-box;
  92. background-color: #fff;
  93. border-radius: 0 0 50upx 50upx;
  94. z-index: 10;
  95. .top-wrapper {
  96. display: flex;
  97. align-items: center;
  98. justify-content: space-between;
  99. .switch-btn {
  100. width: 405upx;
  101. position: relative;
  102. display: flex;
  103. align-items: center;
  104. height: 62upx;
  105. flex-shrink: 0;
  106. border: 1upx solid #ef5613;
  107. border-radius: 100upx;
  108. overflow: hidden;
  109. .uni-btn {
  110. position: relative;
  111. z-index: 1;
  112. flex: 1;
  113. color: #ef5613;
  114. font-size: 32upx;
  115. display: flex;
  116. align-items: center;
  117. justify-content: center;
  118. flex: 1;
  119. &.active {
  120. color: #fff;
  121. }
  122. }
  123. .active-scroll-bar {
  124. position: absolute;
  125. left: 0;
  126. top: 0;
  127. // width: 150upx;
  128. width: 220upx;
  129. height: 62upx;
  130. border-radius: 50upx 0px 0 50upx;
  131. background: linear-gradient(112deg, #ef5613 6%, #f87f4b 74%);
  132. transition: all 350ms;
  133. &.scroll-center {
  134. left: 0upx;
  135. border-radius: 0 0 0px 0px ;
  136. }
  137. &.scroll-right {
  138. left: 205upx;
  139. border-radius: 0 0 54upx 0px ;
  140. }
  141. }
  142. }
  143. .search-wrapper {
  144. display: flex;
  145. align-items: center;
  146. justify-content: space-between;
  147. border: 1upx solid #888889;
  148. border-radius: 100upx;
  149. height: 62upx;
  150. flex: 1;
  151. margin-left: 28upx;
  152. padding: 15upx 20upx;
  153. box-sizing: border-box;
  154. .search-input {
  155. font-size: 24upx;
  156. flex: 1;
  157. margin-right: 10upx;
  158. }
  159. }
  160. }
  161. .menu-list {
  162. display: flex;
  163. align-items: center;
  164. color: #888889;
  165. font-size: 28upx;
  166. white-space: nowrap;
  167. margin-top: 22upx;
  168. .menu-item {
  169. position: relative;
  170. white-space: nowrap;
  171. line-height: 1.5;
  172. margin-right: 68upx;
  173. &::after {
  174. content: '';
  175. display: block;
  176. width: 0;
  177. height: 6upx;
  178. background-color: #f87f4b;
  179. border-radius: 20px;
  180. transition: all 350ms;
  181. transform-origin: center center;
  182. }
  183. &.active {
  184. color: #222229;
  185. &::after {
  186. width: 100%;
  187. }
  188. }
  189. }
  190. }
  191. }
  192. </style>