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 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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} 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. console.log("1")
  65. if (!hasLogin()) {
  66. console.log("2")
  67. confirm('您需要登录过后才能使用此功能', () => {
  68. uni.navigateTo({
  69. url: '/login/login',
  70. });
  71. }, '温馨提示', true, '去登录');
  72. } else {
  73. console.log("请求")
  74. console.log(tableSelectIndex.value,'111')
  75. queryMenuConfigAction().then((val : any) => {
  76. console.log("列表",val)
  77. menu.list = val.menuList ? val.menuList : [],
  78. menu.list = deepClone(menu.list)
  79. state.newArr = deepClone(menu.list);
  80. menuShow.list = val.menuList ? val.menuList : [],
  81. activeTab.value = val.menuList[0]['name']
  82. })
  83. }
  84. });
  85. // 深拷贝
  86. const deepClone = (obj) => {
  87. if (typeof obj !== 'object' || obj === null) {
  88. return obj;
  89. }
  90. let clone = Array.isArray(obj) ? [] : {};
  91. for (let key in obj) {
  92. if (obj.hasOwnProperty(key)) {
  93. clone[key] = deepClone(obj[key]);
  94. }
  95. }
  96. return clone;
  97. }
  98. const search = () => {
  99. for (var i = 0; i < menu.list.length; i++) {
  100. state.newArr[i]['children'] = [];
  101. for (var j = 0; j < menu.list[i]['children'].length; j++) {
  102. const name = menu.list[i]['children'][j].name;
  103. if (name.indexOf(state.searchVal) >= 0) {
  104. state.newArr[i]['children'].push(menu.list[i]['children'][j])
  105. }
  106. }
  107. }
  108. // 清除没有孩子的父亲
  109. const lastArr = []
  110. for (var k = 0; k < state.newArr.length; k++) {
  111. if (state.newArr[k]['children'].length != 0) {
  112. lastArr.push(state.newArr[k])
  113. }
  114. }
  115. console.log("lastArr", lastArr)
  116. if (state.searchVal) {
  117. tableSelectIndex.value = 0
  118. }
  119. menuShow.list = lastArr
  120. console.log("menuShow.list", menuShow.list, tableSelectIndex.value)
  121. }
  122. const queryMenuConfigAction = () => {
  123. var data = {
  124. openId: getItem(StorageKeys.OpenId),
  125. systemType: source == "WECHAT" ? '6' : "9",
  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 requestNew(queryMenuConfig, options);
  136. const data = res;
  137. console.log("dataqueryMenuConfigAction", 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: #01243A;
  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. line-height: 32rpx;
  210. font-family: NotoSansHans, NotoSansHans;
  211. font-size: 28rpx;
  212. color: #01243A;
  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. /* background: linear-gradient(0deg, #fff 0%, #C2A75F 50%, #C2A75F 100%); */
  223. border-radius: 4rpx;
  224. font-size: 28rpx;
  225. background: var(--background);
  226. background-size: 100% 100%;
  227. }
  228. .right {
  229. flex: 1;
  230. }
  231. /* .right-content {
  232. display: flex;
  233. flex-wrap: wrap;
  234. }
  235. // #ifdef MP-ALIPAY
  236. .item {
  237. width: 95rpx;
  238. height: 95rpx;
  239. display: flex;
  240. justify-content: center;
  241. align-items: center;
  242. border-radius: 20rpx;
  243. }
  244. .right .item-box {
  245. display: flex;
  246. flex-direction: column;
  247. justify-content: center;
  248. align-items: center;
  249. margin-right: 26rpx;
  250. margin-bottom: 39rpx;
  251. }
  252. // #endif
  253. // #ifdef MP-WEIXIN
  254. .item {
  255. width: 105rpx;
  256. height: 105rpx;
  257. display: flex;
  258. justify-content: center;
  259. align-items: center;
  260. border-radius: 20rpx;
  261. }
  262. .right .item-box {
  263. display: flex;
  264. flex-direction: column;
  265. justify-content: center;
  266. align-items: center;
  267. margin-right: 30rpx;
  268. margin-bottom: 39rpx;
  269. }
  270. // #endif
  271. .item image {
  272. width: 64rpx;
  273. height: 64rpx;
  274. }
  275. .right .text {
  276. width: 105rpx;
  277. font-size: 22rpx;
  278. text-align: center;
  279. height: 60rpx;
  280. display: flex;
  281. justify-content: center;
  282. align-items: center;
  283. margin-top: 19rpx;
  284. color: #666666;
  285. } */
  286. .bg-blue {
  287. background: var(--background);
  288. }
  289. .bg-orange {
  290. background: var(--background);
  291. }
  292. .right .text-orange {
  293. color: #fd8362;
  294. }
  295. .rightListVue {
  296. height: 100%;
  297. }
  298. </style>