index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <view class="content">
  3. <view class="info">
  4. <scroll-view scroll-y="true" class="scroll-view">
  5. <view class="list-scroll-view">
  6. <view class="u-menu-wrap">
  7. <scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view"
  8. :scroll-top="scrollTop">
  9. <view v-for="(item,index) in tabbar" :key="index" :id="'item' + index" class="u-tab-item"
  10. :class="[current == index ? 'u-tab-item-active' : '']" @tap="swichMenu(index)">
  11. <text class="u-line-1">{{item.name}}</text>
  12. </view>
  13. </scroll-view>
  14. <scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box"
  15. :scroll-into-view="itemId" @scroll="rightScroll">
  16. <view class="page-view">
  17. <view class="class-item" :id="'item' + index" v-for="(item,index) in tabbar"
  18. :key="index">
  19. <view class="item-title">
  20. <view v-if="item.type!='2'">{{item.name}}</view>
  21. <view v-else class="title">
  22. <view class="left">{{item.name}} <span class="span">({{item.unit}})</span>
  23. </view>
  24. <view class="right">{{item.content||'不限'}}</view>
  25. </view>
  26. </view>
  27. <view class="item-container">
  28. <view v-if="item.type=='0'" class="thumb-box1"
  29. v-for="(item1, index1) in item.foods" :key="index1"
  30. @tap="toSelect(item,item1)">
  31. <view :class="[item1.is_open==false?'title_1':'title_2']">{{item1.title}}
  32. </view>
  33. </view>
  34. <view v-else-if="item.type=='1'" class="thumb-box2">
  35. <u-button :text="item.text" size="normal" type="info"
  36. @click="toCommon(item.value)"></u-button>
  37. </view>
  38. <view v-else-if="item.type=='2'" class="thumb-box3">
  39. <slider-range :value="item.value" :min="item.min" :max="item.max"
  40. :step="item.step" :scale="{ show: true}"
  41. @change="event=>changeSliderValue(event,item)">
  42. </slider-range>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </scroll-view>
  48. </view>
  49. </view>
  50. </scroll-view>
  51. </view>
  52. <view class="foot">
  53. <view class="left">重置</view>
  54. <view class="right">
  55. <view class="button">共{{total}}辆车符合条件</view>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script setup lang="ts">
  61. import Vue from 'vue';
  62. import classifyData from '@/pagesHome/condition/common/classify.js';
  63. import SliderRange from '@/components/slider-range/index.vue'
  64. import { getCurrentInstance, computed, ref } from 'vue';
  65. //该依赖已内置不需要单独安装
  66. import { onLoad, onShow } from "@dcloudio/uni-app";
  67. // 请求接口
  68. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  69. // openid
  70. const openid = computed(() => {
  71. return uni.getStorageSync('openid');
  72. })
  73. // 基本信息
  74. const config = ref({});
  75. const id = ref('');
  76. const total = ref(0);
  77. // 滑动菜单的值
  78. const scrollTop = ref(0); //tab标题的滚动条位置
  79. const current = ref(0); // 预设当前项的值
  80. const itemId = ref(''); // 栏目右边scroll-view用于滚动的id
  81. const tabbar = ref(classifyData);
  82. const scrollRightTop = ref(0); // 右边栏目scroll-view的滚动条高度
  83. const brandInfo = ref({}); // 车牌信息
  84. const cityInfo = ref({}); // 城市信息
  85. const searchList = ref([]); // 选中的搜索信息
  86. onLoad(async (options) => {
  87. id.value = options && options.id
  88. await searchOther();
  89. await searchConfig();
  90. await search();
  91. })
  92. onShow(async () => {
  93. uni.$on('toRoute', function (data) {
  94. brandInfo.value = data
  95. tabbar.value = tabbar.value.map((item, index) => {
  96. if (item.type == '1' && item.value == '0') item.text = data.title
  97. return item
  98. })
  99. })
  100. uni.$on('toCity', function (data) {
  101. cityInfo.value = data
  102. tabbar.value = tabbar.value.map((item, index) => {
  103. if (item.type == '1' && item.value == '1') item.text = data.name
  104. return item
  105. })
  106. })
  107. })
  108. // 查询其他信息
  109. const searchOther = async () => {
  110. let res;
  111. };
  112. // config信息
  113. const searchConfig = async () => {
  114. config.value = uni.getStorageSync('config');
  115. };
  116. // 查询
  117. const search = async () => { };
  118. // 点击左边的栏目切换
  119. const swichMenu = (index) => {
  120. if (index == current.value) return;
  121. current.value = index;
  122. itemId.value = `item${index}`
  123. };
  124. // 右侧滚动
  125. const rightScroll = async (e) => {
  126. scrollTop.value = e.scrollTop
  127. };
  128. // 品牌/城市
  129. const toCommon = (type) => {
  130. if (type == '0') {
  131. uni.navigateTo({
  132. url: `/pagesHome/brand/index`
  133. })
  134. } else {
  135. uni.navigateTo({
  136. url: `/pagesHome/city/index`
  137. })
  138. }
  139. };
  140. // 刻度选择
  141. const changeSliderValue = (e, data) => {
  142. tabbar.value = tabbar.value.map((item, index) => {
  143. if (item.name == data.name) {
  144. if (e.firstValue == 0) item.content = `${e.secondValue}${item.unit}以下`
  145. else item.content = `${e.firstValue}-${e.secondValue}${item.unit}`
  146. item.value = e.values
  147. }
  148. return item
  149. })
  150. };
  151. // 选择
  152. const toSelect = async (value, data) => {
  153. searchList.value.push(data)
  154. tabbar.value = tabbar.value.map((item, index) => {
  155. if (item.name == value.name) {
  156. item.foods = item.foods.map((item1, index1) => {
  157. if (item1.title == data.title) item1.is_open = !item1.is_open
  158. return item1
  159. })
  160. }
  161. return item
  162. })
  163. };
  164. </script>
  165. <style lang="scss" scoped>
  166. .content {
  167. display: flex;
  168. flex-direction: column;
  169. width: 100vw;
  170. height: 100vh;
  171. .info {
  172. position: relative;
  173. flex-grow: 1;
  174. .u-menu-wrap {
  175. flex: 1;
  176. display: flex;
  177. overflow: hidden;
  178. }
  179. .u-tab-view {
  180. width: 100px;
  181. background: var(--f6Color);
  182. }
  183. .u-tab-item {
  184. height: 55px;
  185. background: var(--f6Color);
  186. box-sizing: border-box;
  187. display: flex;
  188. align-items: center;
  189. justify-content: center;
  190. font-size: var(--font14Size);
  191. color: #444;
  192. line-height: 1;
  193. }
  194. .u-tab-item-active {
  195. position: relative;
  196. color: var(--f00Color);
  197. font-size: var(--font15Size);
  198. font-weight: 600;
  199. background-color: var(--mainColor);
  200. border-left: 4px solid var(--fFFColor);
  201. }
  202. .right-box {
  203. height: 705px;
  204. background-color: rgb(250, 250, 250);
  205. }
  206. .page-view {
  207. padding: 8px;
  208. }
  209. .class-item {
  210. margin-bottom: 15px;
  211. background-color: var(--mainColor);
  212. padding: 8px;
  213. border-radius: 4px;
  214. }
  215. .item-title {
  216. font-size: var(--font14Size);
  217. margin: 0 0 2vw 0;
  218. .title {
  219. display: flex;
  220. align-items: center;
  221. justify-content: space-between;
  222. .left {
  223. font-weight: bold;
  224. .span {
  225. font-size: var(--font12Size);
  226. color: var(--f85Color);
  227. }
  228. }
  229. }
  230. }
  231. .item-menu-name {
  232. font-size: var(--font12Size);
  233. }
  234. .item-container {
  235. display: flex;
  236. flex-wrap: wrap;
  237. .thumb-box1 {
  238. font-size: var(--font12Size);
  239. width: 23vw;
  240. text-align: center;
  241. .title_1 {
  242. padding: 2vw;
  243. margin: 1vw;
  244. background-color: var(--f5Color);
  245. }
  246. .title_2 {
  247. padding: 2vw;
  248. margin: 1vw;
  249. background: rgba(255, 222, 173, 0.35);
  250. border: 1px solid var(--fFFColor);
  251. }
  252. }
  253. .thumb-box2 {
  254. width: 100%;
  255. }
  256. .thumb-box3 {
  257. width: 100%;
  258. }
  259. }
  260. }
  261. .foot {
  262. display: flex;
  263. justify-content: space-around;
  264. align-items: center;
  265. padding: 2vw;
  266. .right {
  267. .button {
  268. text-align: center;
  269. width: 65vw;
  270. padding: 4vw 6vw;
  271. font-size: var(--font16Size);
  272. background-color: var(--fFFColor);
  273. }
  274. }
  275. }
  276. }
  277. .scroll-view {
  278. position: absolute;
  279. top: 0;
  280. left: 0;
  281. right: 0;
  282. bottom: 0;
  283. .list-scroll-view {
  284. display: flex;
  285. flex-direction: column;
  286. }
  287. }
  288. </style>