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 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. onLoad
  44. } from "@dcloudio/uni-app";
  45. import {
  46. fileURL, fileURLList
  47. } from "@/datas/fileURL.js";
  48. import {
  49. msg
  50. } from "@/utils/utils";
  51. import {
  52. queryMenuConfig
  53. } from "@/utils/network/api.js";
  54. import {
  55. request
  56. } from "@/utils/network/request.js";
  57. import {
  58. getItem,
  59. StorageKeys,
  60. } from "@/utils/storage";
  61. import {
  62. stringToJson
  63. } from "@/utils/network/encryption";
  64. const bgOn = `url(${fileURL}image/newHome/bg-on.png) center center no-repeat`;
  65. const activeTab = ref("");
  66. const tableSelectIndex = ref(0);
  67. // 切换
  68. function tabHandle(val, index) {
  69. activeTab.value = val;
  70. tableSelectIndex.value = index
  71. console.log(tableSelectIndex.value)
  72. }
  73. const menu = reactive({
  74. list: [] //请求的真正的不会变得
  75. });
  76. const menuShow = reactive({
  77. list: [],//展示的
  78. });
  79. const state = reactive({
  80. searchVal: '', //input输入值
  81. newArr: []
  82. });
  83. onLoad(() => {
  84. queryMenuConfigAction().then((val : any) => {
  85. menu.list = val.menuList ? val.menuList : [],
  86. menu.list = deepClone(menu.list)
  87. state.newArr = deepClone(menu.list);
  88. menuShow.list = val.menuList ? val.menuList : [],
  89. activeTab.value = val.menuList[0]['name']
  90. })
  91. });
  92. // 深拷贝
  93. const deepClone = (obj) => {
  94. if (typeof obj !== 'object' || obj === null) {
  95. return obj;
  96. }
  97. let clone = Array.isArray(obj) ? [] : {};
  98. for (let key in obj) {
  99. if (obj.hasOwnProperty(key)) {
  100. clone[key] = deepClone(obj[key]);
  101. }
  102. }
  103. return clone;
  104. }
  105. const search = () => {
  106. for (var i = 0; i < menu.list.length; i++) {
  107. state.newArr[i]['children'] = [];
  108. for (var j = 0; j < menu.list[i]['children'].length; j++) {
  109. const name = menu.list[i]['children'][j].name;
  110. if (name.indexOf(state.searchVal) >= 0) {
  111. state.newArr[i]['children'].push(menu.list[i]['children'][j])
  112. }
  113. }
  114. }
  115. // 清除没有孩子的父亲
  116. const lastArr = []
  117. for (var k = 0; k < state.newArr.length; k++) {
  118. if (state.newArr[k]['children'].length != 0) {
  119. lastArr.push(state.newArr[k])
  120. }
  121. }
  122. console.log("lastArr", lastArr)
  123. if (state.searchVal) {
  124. tableSelectIndex.value = 0
  125. }
  126. menuShow.list = lastArr
  127. console.log("menuShow.list", menuShow.list, tableSelectIndex.value)
  128. }
  129. const queryMenuConfigAction = () => {
  130. var data = {
  131. openId: getItem(StorageKeys.OpenId),
  132. systemType: source == "WECHAT" ? '6' : "9",
  133. loginSource: getItem("loginSource")
  134. };
  135. const options = {
  136. type: 2,
  137. data: data,
  138. method: "POST",
  139. showLoading: true,
  140. };
  141. return new Promise(async (resolve, reject) => {
  142. const res = await request(queryMenuConfig, options);
  143. const data = stringToJson(res.bizContent);
  144. console.log("dataqueryMenuConfigAction", data.menuList)
  145. resolve(data);
  146. }).catch((error) => {
  147. reject(error);
  148. });
  149. }
  150. function toNext(url) {
  151. uni.navigateTo({
  152. url: url,
  153. });
  154. }
  155. </script>
  156. <style>
  157. page {
  158. height: 100%;
  159. background: white;
  160. }
  161. .wrapper {
  162. display: flex;
  163. background: #01243A;
  164. flex-direction: column;
  165. height: 100%;
  166. }
  167. .search-box {
  168. margin: 50rpx 40rpx;
  169. height: 72rpx;
  170. border-radius: 36rpx;
  171. background: #f7f7f7;
  172. display: flex;
  173. justify-content: center;
  174. align-items: center;
  175. }
  176. .search-box .icon {
  177. width: 48rpx;
  178. height: 48rpx;
  179. margin: 0 20rpx;
  180. }
  181. .search-box .search {
  182. flex: 1;
  183. margin-right: 20rpx;
  184. height: 100%;
  185. padding: 0 10rpx;
  186. font-size: 28rpx;
  187. color: black;
  188. background: transparent;
  189. }
  190. .content {
  191. display: flex;
  192. flex: 1;
  193. flex-grow: 1;
  194. background: #fff;
  195. border-radius: 30rpx 30rpx 0 0;
  196. padding-top: 40rpx;
  197. }
  198. .left {
  199. width: 180rpx;
  200. border-right: 1px solid #dcdcdc;
  201. margin-right: 29rpx;
  202. }
  203. .left .menu-text {
  204. font-size: 26rpx;
  205. color: #666666;
  206. width: 120rpx;
  207. }
  208. .left .menu {
  209. padding-left: 15rpx;
  210. display: flex;
  211. align-items: center;
  212. margin: 20rpx 0 60rpx 0;
  213. }
  214. .left .active .menu-text {
  215. font-weight: bold;
  216. line-height: 32rpx;
  217. font-family: NotoSansHans, NotoSansHans;
  218. font-size: 28rpx;
  219. color: #01243A;
  220. }
  221. .left .border {
  222. width: 9rpx;
  223. height: 26rpx;
  224. border-radius: 4rpx;
  225. margin-right: 20rpx;
  226. }
  227. .left .on {
  228. /* background: linear-gradient(0deg, #43a1e0 0%, #13e7c1 100%); */
  229. /* background: linear-gradient(0deg, #fff 0%, #C2A75F 50%, #C2A75F 100%); */
  230. border-radius: 4rpx;
  231. font-size: 28rpx;
  232. background: var(--background);
  233. background-size: 100% 100%;
  234. }
  235. .right {
  236. flex: 1;
  237. }
  238. /* .right-content {
  239. display: flex;
  240. flex-wrap: wrap;
  241. }
  242. // #ifdef MP-ALIPAY
  243. .item {
  244. width: 95rpx;
  245. height: 95rpx;
  246. display: flex;
  247. justify-content: center;
  248. align-items: center;
  249. border-radius: 20rpx;
  250. }
  251. .right .item-box {
  252. display: flex;
  253. flex-direction: column;
  254. justify-content: center;
  255. align-items: center;
  256. margin-right: 26rpx;
  257. margin-bottom: 39rpx;
  258. }
  259. // #endif
  260. // #ifdef MP-WEIXIN
  261. .item {
  262. width: 105rpx;
  263. height: 105rpx;
  264. display: flex;
  265. justify-content: center;
  266. align-items: center;
  267. border-radius: 20rpx;
  268. }
  269. .right .item-box {
  270. display: flex;
  271. flex-direction: column;
  272. justify-content: center;
  273. align-items: center;
  274. margin-right: 30rpx;
  275. margin-bottom: 39rpx;
  276. }
  277. // #endif
  278. .item image {
  279. width: 64rpx;
  280. height: 64rpx;
  281. }
  282. .right .text {
  283. width: 105rpx;
  284. font-size: 22rpx;
  285. text-align: center;
  286. height: 60rpx;
  287. display: flex;
  288. justify-content: center;
  289. align-items: center;
  290. margin-top: 19rpx;
  291. color: #666666;
  292. } */
  293. .bg-blue {
  294. background: var(--background);
  295. }
  296. .bg-orange {
  297. background: var(--background);
  298. }
  299. .right .text-orange {
  300. color: #fd8362;
  301. }
  302. .rightListVue {
  303. height: 100%;
  304. }
  305. </style>