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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <view class="wrapper">
  3. <!-- <navBar title="九州ETC" bgColor="#01243A" fontColor='#fff' :backImgWhite='true'></navBar> -->
  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. <!-- <view class="right-content">
  18. <block v-if="menuShow.list.length > 0">
  19. <view v-for="(item,index) in menuShow.list[tableSelectIndex].children" :key='index' class="item-box"
  20. @click="toNext(item.link)">
  21. <view class="item bg-blue" :style="{ '--background': bgBlue }">
  22. <image :src="`${fileURLList}${item.iconPath}`" mode="aspectFill" />
  23. </view>
  24. <view class="text">{{item.name}}</view>
  25. </view>
  26. </block>
  27. </view> -->
  28. <rightListVue class="rightListVue" :menuList='menuShow.list[tableSelectIndex].children'
  29. v-if="menuShow.list.length > 0" />
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script lang="ts" setup>
  35. import { source } from "@/utils/network/difference";
  36. import navBar from "@/components/nav-bar/nav-bar.vue";
  37. import rightListVue from "./components/rightList.vue";
  38. import {
  39. ref,
  40. reactive,
  41. } from "vue";
  42. import {
  43. onShow
  44. } from "@dcloudio/uni-app";
  45. import {
  46. fileURL, fileURLList
  47. } from "@/datas/fileURL.js";
  48. import {
  49. queryMenuConfig
  50. } from "@/utils/network/api.js";
  51. import {requestNew} from "@/utils/network/request.js";
  52. import {
  53. getItem,
  54. StorageKeys,
  55. } from "@/utils/storage";
  56. const bgOn = `url(${fileURL}image/newHome/bg-on.png) center center no-repeat`;
  57. import {hasLogin,confirm} from "@/utils/utils";
  58. const activeTab = ref("");
  59. const tableSelectIndex = ref(0);
  60. // 切换
  61. function tabHandle(val, index) {
  62. activeTab.value = val;
  63. tableSelectIndex.value = index
  64. console.log(tableSelectIndex.value)
  65. }
  66. const menu = reactive({
  67. list: [] //请求的真正的不会变得
  68. });
  69. const menuShow = reactive({
  70. list: [],//展示的
  71. });
  72. const state = reactive({
  73. searchVal: '', //input输入值
  74. newArr: []
  75. });
  76. onShow(() => {
  77. console.log("1")
  78. if (!hasLogin()) {
  79. console.log("2")
  80. confirm('您需要登录过后才能使用此功能', () => {
  81. uni.navigateTo({
  82. url: '/login/login',
  83. });
  84. }, '温馨提示', true, '去登录');
  85. } else {
  86. console.log("请求")
  87. queryMenuConfigAction().then((val : any) => {
  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);
  147. const data = res;
  148. console.log("dataqueryMenuConfigAction", data.menuList)
  149. resolve(data);
  150. }).catch((error) => {
  151. reject(error);
  152. });
  153. }
  154. function toNext(url) {
  155. uni.navigateTo({
  156. url: url,
  157. });
  158. }
  159. </script>
  160. <style>
  161. page {
  162. height: 100%;
  163. background: white;
  164. }
  165. .wrapper {
  166. display: flex;
  167. background: #01243A;
  168. flex-direction: column;
  169. height: 100%;
  170. }
  171. .search-box {
  172. margin: 50rpx 40rpx;
  173. height: 72rpx;
  174. border-radius: 36rpx;
  175. background: #f7f7f7;
  176. display: flex;
  177. justify-content: center;
  178. align-items: center;
  179. }
  180. .search-box .icon {
  181. width: 48rpx;
  182. height: 48rpx;
  183. margin: 0 20rpx;
  184. }
  185. .search-box .search {
  186. flex: 1;
  187. margin-right: 20rpx;
  188. height: 100%;
  189. padding: 0 10rpx;
  190. font-size: 28rpx;
  191. color: black;
  192. background: transparent;
  193. }
  194. .content {
  195. display: flex;
  196. flex: 1;
  197. flex-grow: 1;
  198. background: #fff;
  199. border-radius: 30rpx 30rpx 0 0;
  200. padding-top: 40rpx;
  201. }
  202. .left {
  203. width: 180rpx;
  204. border-right: 1px solid #dcdcdc;
  205. margin-right: 29rpx;
  206. }
  207. .left .menu-text {
  208. font-size: 26rpx;
  209. color: #666666;
  210. width: 120rpx;
  211. }
  212. .left .menu {
  213. padding-left: 15rpx;
  214. display: flex;
  215. align-items: center;
  216. margin: 20rpx 0 60rpx 0;
  217. }
  218. .left .active .menu-text {
  219. font-weight: bold;
  220. line-height: 32rpx;
  221. font-family: NotoSansHans, NotoSansHans;
  222. font-size: 28rpx;
  223. color: #01243A;
  224. }
  225. .left .border {
  226. width: 9rpx;
  227. height: 26rpx;
  228. border-radius: 4rpx;
  229. margin-right: 20rpx;
  230. }
  231. .left .on {
  232. /* background: linear-gradient(0deg, #43a1e0 0%, #13e7c1 100%); */
  233. /* background: linear-gradient(0deg, #fff 0%, #C2A75F 50%, #C2A75F 100%); */
  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. /* .right-content {
  243. display: flex;
  244. flex-wrap: wrap;
  245. }
  246. // #ifdef MP-ALIPAY
  247. .item {
  248. width: 95rpx;
  249. height: 95rpx;
  250. display: flex;
  251. justify-content: center;
  252. align-items: center;
  253. border-radius: 20rpx;
  254. }
  255. .right .item-box {
  256. display: flex;
  257. flex-direction: column;
  258. justify-content: center;
  259. align-items: center;
  260. margin-right: 26rpx;
  261. margin-bottom: 39rpx;
  262. }
  263. // #endif
  264. // #ifdef MP-WEIXIN
  265. .item {
  266. width: 105rpx;
  267. height: 105rpx;
  268. display: flex;
  269. justify-content: center;
  270. align-items: center;
  271. border-radius: 20rpx;
  272. }
  273. .right .item-box {
  274. display: flex;
  275. flex-direction: column;
  276. justify-content: center;
  277. align-items: center;
  278. margin-right: 30rpx;
  279. margin-bottom: 39rpx;
  280. }
  281. // #endif
  282. .item image {
  283. width: 64rpx;
  284. height: 64rpx;
  285. }
  286. .right .text {
  287. width: 105rpx;
  288. font-size: 22rpx;
  289. text-align: center;
  290. height: 60rpx;
  291. display: flex;
  292. justify-content: center;
  293. align-items: center;
  294. margin-top: 19rpx;
  295. color: #666666;
  296. } */
  297. .bg-blue {
  298. background: var(--background);
  299. }
  300. .bg-orange {
  301. background: var(--background);
  302. }
  303. .right .text-orange {
  304. color: #fd8362;
  305. }
  306. .rightListVue {
  307. height: 100%;
  308. }
  309. </style>