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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. </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 { source } from "@/utils/network/difference";
  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. activeTab.value = val.menuList[0]['name']
  88. })
  89. });
  90. // 深拷贝
  91. const deepClone = (obj) => {
  92. if (typeof obj !== 'object' || obj === null) {
  93. return obj;
  94. }
  95. let clone = Array.isArray(obj) ? [] : {};
  96. for (let key in obj) {
  97. if (obj.hasOwnProperty(key)) {
  98. clone[key] = deepClone(obj[key]);
  99. }
  100. }
  101. return clone;
  102. }
  103. const search = () => {
  104. for (var i = 0; i < menu.list.length; i++) {
  105. state.newArr[i]['children'] = [];
  106. for (var j = 0; j < menu.list[i]['children'].length; j++) {
  107. const name = menu.list[i]['children'][j].name;
  108. if (name.indexOf(state.searchVal) >= 0) {
  109. state.newArr[i]['children'].push(menu.list[i]['children'][j])
  110. }
  111. }
  112. }
  113. // 清除没有孩子的父亲
  114. const lastArr = []
  115. for (var k = 0; k < state.newArr.length; k++) {
  116. if (state.newArr[k]['children'].length != 0) {
  117. lastArr.push(state.newArr[k])
  118. }
  119. }
  120. console.log("lastArr", lastArr)
  121. menuShow.list = lastArr
  122. }
  123. const queryMenuConfigAction = () => {
  124. var data = {
  125. openId: getItem(StorageKeys.OpenId),
  126. systemType: source == "WECHAT" ? '6' : "9",
  127. loginSource: getItem("loginSource")
  128. };
  129. const options = {
  130. type: 2,
  131. data: data,
  132. method: "POST",
  133. showLoading: true,
  134. };
  135. return new Promise(async (resolve, reject) => {
  136. const res = await request(queryMenuConfig, options);
  137. const data = stringToJson(res.bizContent);
  138. console.log("data", data.menuList)
  139. resolve(data);
  140. }).catch((error) => {
  141. reject(error);
  142. });
  143. }
  144. function toNext(url) {
  145. uni.navigateTo({
  146. url: url,
  147. });
  148. }
  149. </script>
  150. <style>
  151. page {
  152. height: 100%;
  153. background: white;
  154. }
  155. .wrapper {
  156. display: flex;
  157. background: linear-gradient(to left, #43a1e0 0%, #13e7c1 100%);
  158. flex-direction: column;
  159. height: 100%;
  160. }
  161. .search-box {
  162. margin: 50rpx 40rpx;
  163. height: 72rpx;
  164. border-radius: 36rpx;
  165. background: #f7f7f7;
  166. display: flex;
  167. justify-content: center;
  168. align-items: center;
  169. }
  170. .search-box .icon {
  171. width: 48rpx;
  172. height: 48rpx;
  173. margin: 0 20rpx;
  174. }
  175. .search-box .search {
  176. flex: 1;
  177. margin-right: 20rpx;
  178. height: 100%;
  179. padding: 0 10rpx;
  180. font-size: 28rpx;
  181. color: black;
  182. background: transparent;
  183. }
  184. .content {
  185. display: flex;
  186. flex: 1;
  187. flex-grow: 1;
  188. background: #fff;
  189. border-radius: 30rpx 30rpx 0 0;
  190. padding-top: 40rpx;
  191. }
  192. .left {
  193. width: 180rpx;
  194. border-right: 1px solid #dcdcdc;
  195. margin-right: 29rpx;
  196. }
  197. .left .menu-text {
  198. font-size: 26rpx;
  199. color: #666666;
  200. width: 120rpx;
  201. }
  202. .left .menu {
  203. padding-left: 15rpx;
  204. display: flex;
  205. align-items: center;
  206. margin: 20rpx 0 60rpx 0;
  207. }
  208. .left .active .menu-text {
  209. font-weight: bold;
  210. color: #00b38b;
  211. font-size: 28rpx;
  212. line-height: 32rpx;
  213. }
  214. .left .border {
  215. width: 9rpx;
  216. height: 26rpx;
  217. border-radius: 4rpx;
  218. margin-right: 20rpx;
  219. }
  220. .left .on {
  221. background: linear-gradient(0deg, #43a1e0 0%, #13e7c1 100%);
  222. font-size: 28rpx;
  223. }
  224. .right {
  225. flex: 1;
  226. }
  227. .right-content {
  228. display: flex;
  229. flex-wrap: wrap;
  230. }
  231. // #ifdef MP-ALIPAY
  232. .item {
  233. width: 95rpx;
  234. height: 95rpx;
  235. display: flex;
  236. justify-content: center;
  237. align-items: center;
  238. border-radius: 20rpx;
  239. }
  240. .right .item-box {
  241. display: flex;
  242. flex-direction: column;
  243. justify-content: center;
  244. align-items: center;
  245. margin-right: 26rpx;
  246. margin-bottom: 39rpx;
  247. }
  248. // #endif
  249. // #ifdef MP-WEIXIN
  250. .item {
  251. width: 105rpx;
  252. height: 105rpx;
  253. display: flex;
  254. justify-content: center;
  255. align-items: center;
  256. border-radius: 20rpx;
  257. }
  258. .right .item-box {
  259. display: flex;
  260. flex-direction: column;
  261. justify-content: center;
  262. align-items: center;
  263. margin-right: 30rpx;
  264. margin-bottom: 39rpx;
  265. }
  266. // #endif
  267. .item image {
  268. width: 64rpx;
  269. height: 64rpx;
  270. }
  271. .right .text {
  272. width: 105rpx;
  273. font-size: 22rpx;
  274. text-align: center;
  275. height: 60rpx;
  276. display: flex;
  277. justify-content: center;
  278. align-items: center;
  279. margin-top: 19rpx;
  280. color: #666666;
  281. }
  282. .bg-blue {
  283. background: var(--background);
  284. }
  285. .bg-orange {
  286. background: var(--background);
  287. }
  288. .right .text-orange {
  289. color: #fd8362;
  290. }
  291. </style>