Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

service.vue 6.2KB

10 meses atrás
10 meses atrás
10 meses atrás
10 meses atrás
10 meses atrás
10 meses atrás
10 meses atrás
10 meses atrás
10 meses atrás
10 meses atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <navBar title="服务" :scrollTop="scrollTop" :isBack="isBack" navbgClass="nav-bgXin" fontColor='#fff'></navBar>
  3. <view class="wrapper">
  4. <view class="search-box">
  5. <image :src="`${$imgUrl}service/icon-search.png`" class="icon" mode="aspectFill" @click="search()"></image>
  6. <input class="search" placeholder="请输入业务名称" v-model="state.searchVal" @confirm="search()" />
  7. </view>
  8. <view class="content">
  9. <view class="left">
  10. <view v-for="(item,index) in menuShow.list" :key="index"
  11. :class="activeTab === item.name ? 'menu active' : 'menu'" @click="tabHandle(item.name,index)">
  12. <view :class="activeTab === item.name ? 'border on' : 'border'" :style="{ '--background': bgOn }"></view>
  13. <view class="menu-text">{{item.name}}</view>
  14. </view>
  15. </view>
  16. <view class="right">
  17. <rightListVue class="rightListVue" :menuList='menuShow.list[tableSelectIndex].children'
  18. v-if="menuShow.list.length > 0" />
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script lang="ts" setup>
  24. import { source } from "@/utils/network/difference";
  25. import rightListVue from "./components/rightList.vue";
  26. import {
  27. ref,
  28. reactive,
  29. } from "vue";
  30. import {
  31. onLoad,
  32. onShow,
  33. onPageScroll
  34. } from "@dcloudio/uni-app";
  35. import navBar from "../../components/nav-bar/nav-bar2.vue";
  36. import {
  37. fileURL, fileURLList
  38. } from "@/datas/fileURL.js";
  39. import {
  40. queryMenuConfig
  41. } from "@/utils/network/api.js";
  42. import {requestNew} from "@/utils/network/request.js";
  43. import {
  44. getItem,
  45. StorageKeys,
  46. } from "@/utils/storage";
  47. const bgOn = `url(${fileURL}image/newHome/bg-on.png) center center no-repeat`;
  48. import {hasLogin,confirm,navTo} from "@/utils/utils";
  49. const activeTab = ref("");
  50. const tableSelectIndex = ref(0);
  51. const scrollTop = ref(0);
  52. const isBack = ref(false);
  53. // 切换
  54. function tabHandle(val, index) {
  55. activeTab.value = val;
  56. tableSelectIndex.value = index
  57. console.log(tableSelectIndex.value)
  58. }
  59. const menu = reactive({
  60. list: [] //请求的真正的不会变得
  61. });
  62. const menuShow = reactive({
  63. list: [],//展示的
  64. });
  65. const state = reactive({
  66. searchVal: '', //input输入值
  67. newArr: []
  68. });
  69. onLoad(() => {
  70. // load()
  71. });
  72. onShow(() => {
  73. if (menu && menu.list.length <= 0) {
  74. load()
  75. }
  76. })
  77. onPageScroll((e) => {
  78. scrollTop.value = e.scrollTop;
  79. });
  80. function load(){
  81. console.log("1")
  82. if (!hasLogin()) {
  83. console.log("2")
  84. confirm('您需要登录过后才能使用此功能', () => {
  85. uni.navigateTo({
  86. url: '/login/login',
  87. });
  88. }, '温馨提示', true, '去登录');
  89. } else {
  90. console.log("请求")
  91. console.log(tableSelectIndex.value,'111')
  92. queryMenuConfigAction().then((val : any) => {
  93. console.log("列表",val)
  94. menu.list = val.menuList ? val.menuList : [],
  95. menu.list = deepClone(menu.list)
  96. state.newArr = deepClone(menu.list);
  97. menuShow.list = val.menuList ? val.menuList : [],
  98. activeTab.value = val.menuList[0]['name']
  99. })
  100. }
  101. }
  102. // 深拷贝
  103. const deepClone = (obj) => {
  104. if (typeof obj !== 'object' || obj === null) {
  105. return obj;
  106. }
  107. let clone = Array.isArray(obj) ? [] : {};
  108. for (let key in obj) {
  109. if (obj.hasOwnProperty(key)) {
  110. clone[key] = deepClone(obj[key]);
  111. }
  112. }
  113. return clone;
  114. }
  115. const search = () => {
  116. for (var i = 0; i < menu.list.length; i++) {
  117. state.newArr[i]['children'] = [];
  118. for (var j = 0; j < menu.list[i]['children'].length; j++) {
  119. const name = menu.list[i]['children'][j].name;
  120. if (name.indexOf(state.searchVal) >= 0) {
  121. state.newArr[i]['children'].push(menu.list[i]['children'][j])
  122. }
  123. }
  124. }
  125. // 清除没有孩子的父亲
  126. const lastArr = []
  127. for (var k = 0; k < state.newArr.length; k++) {
  128. if (state.newArr[k]['children'].length != 0) {
  129. lastArr.push(state.newArr[k])
  130. }
  131. }
  132. console.log("lastArr", lastArr)
  133. if (state.searchVal) {
  134. tableSelectIndex.value = 0
  135. }
  136. menuShow.list = lastArr
  137. console.log("menuShow.list", menuShow.list, tableSelectIndex.value)
  138. }
  139. const queryMenuConfigAction = () => {
  140. var data = {
  141. openId: getItem(StorageKeys.OpenId),
  142. systemType: source == "WECHAT" ? '6' : "9",
  143. loginSource: getItem("loginSource")
  144. };
  145. const options = {
  146. type: 2,
  147. data: data,
  148. method: "POST",
  149. showLoading: true,
  150. };
  151. return new Promise(async (resolve, reject) => {
  152. const res = await requestNew(queryMenuConfig, options,false, ()=>{
  153. console.log('---------------------我执行了!')
  154. load()
  155. });
  156. const data = res;
  157. console.log("dataqueryMenuConfigAction", data.menuList)
  158. resolve(data);
  159. }).catch((error) => {
  160. reject(error);
  161. });
  162. }
  163. function toNext(url) {
  164. navTo(url);
  165. }
  166. </script>
  167. <style>
  168. page {
  169. height: 100%;
  170. background: white;
  171. }
  172. .wrapper {
  173. padding-top: 150rpx;
  174. display: flex;
  175. background: #01243A;
  176. flex-direction: column;
  177. height: calc(100% - 150rpx);
  178. }
  179. .search-box {
  180. margin: 50rpx 40rpx;
  181. height: 72rpx;
  182. border-radius: 36rpx;
  183. background: #f7f7f7;
  184. display: flex;
  185. justify-content: center;
  186. align-items: center;
  187. }
  188. .search-box .icon {
  189. width: 48rpx;
  190. height: 48rpx;
  191. margin: 0 20rpx;
  192. }
  193. .search-box .search {
  194. flex: 1;
  195. margin-right: 20rpx;
  196. height: 100%;
  197. padding: 0 10rpx;
  198. font-size: 28rpx;
  199. color: black;
  200. background: transparent;
  201. }
  202. .content {
  203. display: flex;
  204. flex: 1;
  205. flex-grow: 1;
  206. background: #fff;
  207. border-radius: 30rpx 30rpx 0 0;
  208. padding-top: 40rpx;
  209. }
  210. .left {
  211. width: 180rpx;
  212. border-right: 1px solid #dcdcdc;
  213. margin-right: 29rpx;
  214. }
  215. .left .menu-text {
  216. font-size: 26rpx;
  217. color: #666666;
  218. width: 120rpx;
  219. }
  220. .left .menu {
  221. padding-left: 15rpx;
  222. display: flex;
  223. align-items: center;
  224. margin: 20rpx 0 60rpx 0;
  225. }
  226. .left .active .menu-text {
  227. font-weight: bold;
  228. line-height: 32rpx;
  229. font-family: NotoSansHans, NotoSansHans;
  230. font-size: 28rpx;
  231. color: #01243A;
  232. }
  233. .left .border {
  234. width: 9rpx;
  235. height: 26rpx;
  236. border-radius: 4rpx;
  237. margin-right: 20rpx;
  238. }
  239. .left .on {
  240. border-radius: 4rpx;
  241. font-size: 28rpx;
  242. background: var(--background);
  243. background-size: 100% 100%;
  244. }
  245. .right {
  246. flex: 1;
  247. }
  248. .bg-blue {
  249. background: var(--background);
  250. }
  251. .bg-orange {
  252. background: var(--background);
  253. }
  254. .right .text-orange {
  255. color: #fd8362;
  256. }
  257. .rightListVue {
  258. height: 100%;
  259. }
  260. </style>