index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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 menuHeight = ref(0); //左边菜单的高度
  81. const menuItemHeight = ref(0); // 左边菜单item的高度
  82. const itemId = ref(''); // 栏目右边scroll-view用于滚动的id
  83. const tabbar = ref(classifyData);
  84. const scrollRightTop = ref(0); // 右边栏目scroll-view的滚动条高度
  85. const brandInfo = ref({}); // 车牌信息
  86. const cityInfo = ref({}); // 城市信息
  87. const searchList = ref([]); // 城市信息
  88. onLoad(async (options) => {
  89. id.value = options && options.id
  90. await searchOther();
  91. await searchConfig();
  92. await search();
  93. })
  94. onShow(async () => {
  95. uni.$on('toRoute', function (data) {
  96. brandInfo.value = data
  97. tabbar.value = tabbar.value.map((item, index) => {
  98. if (item.type == '1' && item.value == '0') item.text = data.title
  99. return item
  100. })
  101. })
  102. uni.$on('toCity', function (data) {
  103. cityInfo.value = data
  104. tabbar.value = tabbar.value.map((item, index) => {
  105. if (item.type == '1' && item.value == '1') item.text = data.name
  106. return item
  107. })
  108. })
  109. })
  110. // 查询其他信息
  111. const searchOther = async () => {
  112. let res;
  113. };
  114. // config信息
  115. const searchConfig = async () => {
  116. config.value = uni.getStorageSync('config');
  117. };
  118. // 查询
  119. const search = async () => { };
  120. // 点击左边的栏目切换
  121. const swichMenu = (index) => {
  122. if (index == current.value) return;
  123. current.value = index;
  124. itemId.value = `item${index}`
  125. };
  126. // 右侧滚动
  127. const rightScroll = async (e) => {
  128. scrollTop.value = e.scrollTop
  129. };
  130. // 品牌/城市
  131. const toCommon = (type) => {
  132. if (type == '0') {
  133. uni.navigateTo({
  134. url: `/pagesHome/brand/index`
  135. })
  136. } else {
  137. uni.navigateTo({
  138. url: `/pagesHome/city/index`
  139. })
  140. }
  141. };
  142. // 刻度选择
  143. const changeSliderValue = (e, data) => {
  144. tabbar.value = tabbar.value.map((item, index) => {
  145. if (item.name == data.name) {
  146. if (e.firstValue == 0) item.content = `${e.secondValue}${item.unit}以下`
  147. else item.content = `${e.firstValue}-${e.secondValue}${item.unit}`
  148. item.value = e.values
  149. }
  150. return item
  151. })
  152. };
  153. // 选择
  154. const toSelect = async (value, data) => {
  155. searchList.value.push(data)
  156. tabbar.value = tabbar.value.map((item, index) => {
  157. if (item.name == value.name) {
  158. item.foods = item.foods.map((item1, index1) => {
  159. if (item1.title == data.title) item1.is_open = !item1.is_open
  160. return item1
  161. })
  162. }
  163. return item
  164. })
  165. };
  166. </script>
  167. <style lang="scss" scoped>
  168. .content {
  169. display: flex;
  170. flex-direction: column;
  171. width: 100vw;
  172. height: 100vh;
  173. .info {
  174. position: relative;
  175. flex-grow: 1;
  176. .u-menu-wrap {
  177. flex: 1;
  178. display: flex;
  179. overflow: hidden;
  180. }
  181. .u-tab-view {
  182. width: 200rpx;
  183. background: var(--f6Color);
  184. }
  185. .u-tab-item {
  186. height: 110rpx;
  187. background: var(--f6Color);
  188. box-sizing: border-box;
  189. display: flex;
  190. align-items: center;
  191. justify-content: center;
  192. font-size: var(--font14Size);
  193. color: #444;
  194. line-height: 1;
  195. }
  196. .u-tab-item-active {
  197. position: relative;
  198. color: var(--f00Color);
  199. font-size: var(--font15Size);
  200. font-weight: 600;
  201. background-color: var(--mainColor);
  202. border-left: 4px solid var(--fFFColor);
  203. }
  204. .right-box {
  205. height: 705px;
  206. background-color: rgb(250, 250, 250);
  207. }
  208. .page-view {
  209. padding: 8px;
  210. }
  211. .class-item {
  212. margin-bottom: 30rpx;
  213. background-color: var(--mainColor);
  214. padding: 8px;
  215. border-radius: 4px;
  216. }
  217. .item-title {
  218. font-size: var(--font14Size);
  219. margin: 0 0 2vw 0;
  220. .title {
  221. display: flex;
  222. align-items: center;
  223. justify-content: space-between;
  224. .left {
  225. font-weight: bold;
  226. .span {
  227. font-size: var(--font12Size);
  228. color: var(--f85Color);
  229. }
  230. }
  231. }
  232. }
  233. .item-menu-name {
  234. font-size: var(--font12Size);
  235. }
  236. .item-container {
  237. display: flex;
  238. flex-wrap: wrap;
  239. .thumb-box1 {
  240. font-size: var(--font12Size);
  241. width: 23vw;
  242. text-align: center;
  243. .title_1 {
  244. padding: 2vw;
  245. margin: 1vw;
  246. background-color: var(--f5Color);
  247. }
  248. .title_2 {
  249. padding: 2vw;
  250. margin: 1vw;
  251. background: rgba(255, 222, 173, 0.35);
  252. border: 1px solid var(--fFFColor);
  253. }
  254. }
  255. .thumb-box2 {
  256. width: 100%;
  257. }
  258. .thumb-box3 {
  259. width: 100%;
  260. }
  261. }
  262. }
  263. .foot {
  264. display: flex;
  265. justify-content: space-around;
  266. align-items: center;
  267. padding: 2vw;
  268. .right {
  269. .button {
  270. text-align: center;
  271. width: 65vw;
  272. padding: 4vw 6vw;
  273. font-size: var(--font16Size);
  274. background-color: var(--fFFColor);
  275. }
  276. }
  277. }
  278. }
  279. .scroll-view {
  280. position: absolute;
  281. top: 0;
  282. left: 0;
  283. right: 0;
  284. bottom: 0;
  285. .list-scroll-view {
  286. display: flex;
  287. flex-direction: column;
  288. }
  289. }
  290. </style>