Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 10 mēnešiem
pirms 10 mēnešiem
pirms 10 mēnešiem
pirms 10 mēnešiem
pirms 10 mēnešiem
pirms 10 mēnešiem
pirms 10 mēnešiem
pirms 10 mēnešiem
pirms 10 mēnešiem
pirms 10 mēnešiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <view class="wrapper">
  3. <view class="search-box">
  4. <image :src="`${$imgUrl}service/icon-search.png`" class="icon" mode="aspectFill" @click="search()"></image>
  5. <input class="search" placeholder="请输入业务名称" v-model="state.searchVal" @confirm="search()" />
  6. </view>
  7. <view class="content">
  8. <view class="left">
  9. <view v-for="(item,index) in menuShow.list" :key="index"
  10. :class="activeTab === item.name ? 'menu active' : 'menu'" @click="tabHandle(item.name,index)">
  11. <view :class="activeTab === item.name ? 'border on' : 'border'" :style="{ '--background': bgOn }"></view>
  12. <view class="menu-text">{{item.name}}</view>
  13. </view>
  14. </view>
  15. <view class="right">
  16. <rightListVue class="rightListVue" :menuList='menuShow.list[tableSelectIndex].children'
  17. v-if="menuShow.list.length > 0" />
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script lang="ts" setup>
  23. import { source } from "@/utils/network/difference";
  24. import rightListVue from "./components/rightList.vue";
  25. import {
  26. ref,
  27. reactive,
  28. } from "vue";
  29. import {
  30. onLoad
  31. } from "@dcloudio/uni-app";
  32. import {
  33. fileURL, fileURLList
  34. } from "@/datas/fileURL.js";
  35. import {
  36. queryMenuConfig
  37. } from "@/utils/network/api.js";
  38. import {requestNew} from "@/utils/network/request.js";
  39. import {
  40. getItem,
  41. StorageKeys,
  42. } from "@/utils/storage";
  43. const bgOn = `url(${fileURL}image/newHome/bg-on.png) center center no-repeat`;
  44. import {hasLogin,confirm,navTo} from "@/utils/utils";
  45. const activeTab = ref("");
  46. const tableSelectIndex = ref(0);
  47. // 切换
  48. function tabHandle(val, index) {
  49. activeTab.value = val;
  50. tableSelectIndex.value = index
  51. console.log(tableSelectIndex.value)
  52. }
  53. const menu = reactive({
  54. list: [] //请求的真正的不会变得
  55. });
  56. const menuShow = reactive({
  57. list: [],//展示的
  58. });
  59. const state = reactive({
  60. searchVal: '', //input输入值
  61. newArr: []
  62. });
  63. onLoad(() => {
  64. load()
  65. });
  66. function load(){
  67. console.log("1")
  68. if (!hasLogin()) {
  69. console.log("2")
  70. confirm('您需要登录过后才能使用此功能', () => {
  71. uni.navigateTo({
  72. url: '/login/login',
  73. });
  74. }, '温馨提示', true, '去登录');
  75. } else {
  76. console.log("请求")
  77. console.log(tableSelectIndex.value,'111')
  78. queryMenuConfigAction().then((val : any) => {
  79. console.log("列表",val)
  80. menu.list = val.menuList ? val.menuList : [],
  81. menu.list = deepClone(menu.list)
  82. state.newArr = deepClone(menu.list);
  83. menuShow.list = val.menuList ? val.menuList : [],
  84. activeTab.value = val.menuList[0]['name']
  85. })
  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. if (state.searchVal) {
  120. tableSelectIndex.value = 0
  121. }
  122. menuShow.list = lastArr
  123. console.log("menuShow.list", menuShow.list, tableSelectIndex.value)
  124. }
  125. const queryMenuConfigAction = () => {
  126. var data = {
  127. openId: getItem(StorageKeys.OpenId),
  128. systemType: source == "WECHAT" ? '6' : "9",
  129. loginSource: getItem("loginSource")
  130. };
  131. const options = {
  132. type: 2,
  133. data: data,
  134. method: "POST",
  135. showLoading: true,
  136. };
  137. return new Promise(async (resolve, reject) => {
  138. const res = await requestNew(queryMenuConfig, options,false, ()=>{
  139. console.log('---------------------我执行了!')
  140. load()
  141. });
  142. const data = res;
  143. console.log("dataqueryMenuConfigAction", data.menuList)
  144. resolve(data);
  145. }).catch((error) => {
  146. reject(error);
  147. });
  148. }
  149. function toNext(url) {
  150. navTo(url);
  151. }
  152. </script>
  153. <style>
  154. page {
  155. height: 100%;
  156. background: white;
  157. }
  158. .wrapper {
  159. display: flex;
  160. background: #01243A;
  161. flex-direction: column;
  162. height: 100%;
  163. }
  164. .search-box {
  165. margin: 50rpx 40rpx;
  166. height: 72rpx;
  167. border-radius: 36rpx;
  168. background: #f7f7f7;
  169. display: flex;
  170. justify-content: center;
  171. align-items: center;
  172. }
  173. .search-box .icon {
  174. width: 48rpx;
  175. height: 48rpx;
  176. margin: 0 20rpx;
  177. }
  178. .search-box .search {
  179. flex: 1;
  180. margin-right: 20rpx;
  181. height: 100%;
  182. padding: 0 10rpx;
  183. font-size: 28rpx;
  184. color: black;
  185. background: transparent;
  186. }
  187. .content {
  188. display: flex;
  189. flex: 1;
  190. flex-grow: 1;
  191. background: #fff;
  192. border-radius: 30rpx 30rpx 0 0;
  193. padding-top: 40rpx;
  194. }
  195. .left {
  196. width: 180rpx;
  197. border-right: 1px solid #dcdcdc;
  198. margin-right: 29rpx;
  199. }
  200. .left .menu-text {
  201. font-size: 26rpx;
  202. color: #666666;
  203. width: 120rpx;
  204. }
  205. .left .menu {
  206. padding-left: 15rpx;
  207. display: flex;
  208. align-items: center;
  209. margin: 20rpx 0 60rpx 0;
  210. }
  211. .left .active .menu-text {
  212. font-weight: bold;
  213. line-height: 32rpx;
  214. font-family: NotoSansHans, NotoSansHans;
  215. font-size: 28rpx;
  216. color: #01243A;
  217. }
  218. .left .border {
  219. width: 9rpx;
  220. height: 26rpx;
  221. border-radius: 4rpx;
  222. margin-right: 20rpx;
  223. }
  224. .left .on {
  225. border-radius: 4rpx;
  226. font-size: 28rpx;
  227. background: var(--background);
  228. background-size: 100% 100%;
  229. }
  230. .right {
  231. flex: 1;
  232. }
  233. .bg-blue {
  234. background: var(--background);
  235. }
  236. .bg-orange {
  237. background: var(--background);
  238. }
  239. .right .text-orange {
  240. color: #fd8362;
  241. }
  242. .rightListVue {
  243. height: 100%;
  244. }
  245. </style>