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

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