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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. background: white;
  153. }
  154. .wrapper {
  155. display: flex;
  156. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  157. flex-direction: column;
  158. height: 100%;
  159. }
  160. .search-box {
  161. margin: 50rpx 40rpx;
  162. height: 72rpx;
  163. border-radius: 36rpx;
  164. background: #f7f7f7;
  165. display: flex;
  166. justify-content: center;
  167. align-items: center;
  168. }
  169. .search-box .icon {
  170. width: 48rpx;
  171. height: 48rpx;
  172. margin: 0 20rpx;
  173. }
  174. .search-box .search {
  175. flex: 1;
  176. margin-right: 20rpx;
  177. height: 100%;
  178. padding: 0 10rpx;
  179. font-size: 28rpx;
  180. color: black;
  181. background: transparent;
  182. }
  183. .content {
  184. display: flex;
  185. flex: 1;
  186. flex-grow: 1;
  187. background: #fff;
  188. border-radius: 30rpx 30rpx 0 0;
  189. padding-top: 40rpx;
  190. }
  191. .left {
  192. width: 180rpx;
  193. border-right: 1px solid #dcdcdc;
  194. margin-right: 29rpx;
  195. }
  196. .left .menu-text {
  197. font-size: 26rpx;
  198. color: #666666;
  199. width: 120rpx;
  200. }
  201. .left .menu {
  202. padding-left: 15rpx;
  203. display: flex;
  204. align-items: center;
  205. margin: 20rpx 0 60rpx 0;
  206. }
  207. .left .active .menu-text {
  208. font-weight: bold;
  209. color: #00b38b;
  210. font-size: 28rpx;
  211. line-height: 32rpx;
  212. }
  213. .left .border {
  214. width: 9rpx;
  215. height: 26rpx;
  216. border-radius: 4rpx;
  217. margin-right: 20rpx;
  218. }
  219. .left .on {
  220. background: linear-gradient(0deg, #43a1e0 0%, #13e7c1 100%);
  221. font-size: 28rpx;
  222. }
  223. .right {
  224. flex: 1;
  225. }
  226. .right-content {
  227. display: flex;
  228. flex-wrap: wrap;
  229. }
  230. // #ifdef MP-ALIPAY
  231. .item {
  232. width: 95rpx;
  233. height: 95rpx;
  234. display: flex;
  235. justify-content: center;
  236. align-items: center;
  237. border-radius: 20rpx;
  238. }
  239. .right .item-box {
  240. display: flex;
  241. flex-direction: column;
  242. justify-content: center;
  243. align-items: center;
  244. margin-right: 26rpx;
  245. margin-bottom: 39rpx;
  246. }
  247. // #endif
  248. // #ifdef MP-WEIXIN
  249. .item {
  250. width: 105rpx;
  251. height: 105rpx;
  252. display: flex;
  253. justify-content: center;
  254. align-items: center;
  255. border-radius: 20rpx;
  256. }
  257. .right .item-box {
  258. display: flex;
  259. flex-direction: column;
  260. justify-content: center;
  261. align-items: center;
  262. margin-right: 30rpx;
  263. margin-bottom: 39rpx;
  264. }
  265. // #endif
  266. .item image {
  267. width: 64rpx;
  268. height: 64rpx;
  269. }
  270. .right .text {
  271. width: 105rpx;
  272. font-size: 22rpx;
  273. text-align: center;
  274. height: 60rpx;
  275. display: flex;
  276. justify-content: center;
  277. align-items: center;
  278. margin-top: 19rpx;
  279. color: #666666;
  280. }
  281. .bg-blue {
  282. background: var(--background);
  283. }
  284. .bg-orange {
  285. background: var(--background);
  286. }
  287. .right .text-orange {
  288. color: #fd8362;
  289. }
  290. </style>