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.

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