You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

service.vue 6.1KB

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