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.3KB

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