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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <navBar title="服务" :scrollTop="scrollTop" :isBack="isBack" navbgClass="nav-bgXin" fontColor='#fff'></navBar>
  3. <view class="wrapper">
  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" v-if="menuShow.list && menuShow.list.length > 0">
  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'" :style="{ '--background': bgOn }"></view>
  13. <view class="menu-text">{{item.name}}</view>
  14. </view>
  15. </view>
  16. <view class="right">
  17. <rightListVue class="rightListVue" :menuList='menuShow.list[tableSelectIndex].children'
  18. v-if="menuShow.list.length > 0" />
  19. </view>
  20. </view>
  21. <view class="content" v-else-if="!state.load">
  22. <view class="left">
  23. <view class="menu active">
  24. <view class="border on"></view>
  25. <view class="menu-text">其他服务</view>
  26. </view>
  27. </view>
  28. <view class="right">
  29. <view class="login-content" @click="goToLogin">
  30. <view class="tips" >登录查看更多模块</view>
  31. <view class="custom-btn">登录</view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="content" v-else></view>
  36. </view>
  37. </template>
  38. <script lang="ts" setup>
  39. import { source } from "@/utils/network/difference";
  40. import rightListVue from "./components/rightList.vue";
  41. import { ref, reactive, } from "vue";
  42. import { onLoad, onShow, onPageScroll } from "@dcloudio/uni-app";
  43. import navBar from "../../components/nav-bar/nav-bar2.vue";
  44. import { fileURL, fileURLList } from "@/datas/fileURL.js";
  45. import { queryMenuConfig } from "@/utils/network/api.js";
  46. import {requestNew } from "@/utils/network/request.js";
  47. import { getItem, StorageKeys } from "@/utils/storage";
  48. import { hasLogin, confirm, navTo} from "@/utils/utils";
  49. const bgOn = `url(${fileURL}image/newHome/bg-on.png) center center no-repeat`;
  50. const activeTab = ref("");
  51. const tableSelectIndex = ref(0);
  52. const scrollTop = ref(0);
  53. const isBack = ref(false);
  54. // 切换
  55. function tabHandle(val, index) {
  56. activeTab.value = val;
  57. tableSelectIndex.value = index
  58. console.log(tableSelectIndex.value)
  59. }
  60. const menu = reactive({
  61. list: [] //请求的真正的不会变得
  62. });
  63. const menuShow = reactive({
  64. list: [],//展示的
  65. });
  66. const emptyList = reactive({
  67. list: [] //请求的真正的不会变得
  68. });
  69. const state = reactive({
  70. searchVal: '', //input输入值
  71. newArr: [],
  72. load: true
  73. });
  74. onLoad(() => {
  75. // load()
  76. });
  77. onShow(() => {
  78. state.load = false
  79. if (menu && menu.list.length <= 0) {
  80. load()
  81. }
  82. })
  83. onPageScroll((e) => {
  84. scrollTop.value = e.scrollTop;
  85. });
  86. function load(){
  87. console.log("1")
  88. if (!hasLogin()) {
  89. console.log("2")
  90. state.load = false
  91. // confirm('您需要登录过后才能使用此功能', () => {
  92. // uni.navigateTo({
  93. // url: '/login/login',
  94. // });
  95. // }, '温馨提示', true, '去登录');
  96. } else {
  97. console.log("请求")
  98. console.log(tableSelectIndex.value,'111')
  99. state.load = true
  100. queryMenuConfigAction().then((val : any) => {
  101. console.log("列表",val)
  102. state.load = false
  103. menu.list = val.menuList ? val.menuList : [],
  104. menu.list = deepClone(menu.list)
  105. state.newArr = deepClone(menu.list);
  106. menuShow.list = val.menuList ? val.menuList : [],
  107. activeTab.value = val.menuList[0]['name']
  108. }).catch(() => {
  109. state.load = true
  110. })
  111. }
  112. }
  113. // 深拷贝
  114. const deepClone = (obj) => {
  115. if (typeof obj !== 'object' || obj === null) {
  116. return obj;
  117. }
  118. let clone = Array.isArray(obj) ? [] : {};
  119. for (let key in obj) {
  120. if (obj.hasOwnProperty(key)) {
  121. clone[key] = deepClone(obj[key]);
  122. }
  123. }
  124. return clone;
  125. }
  126. const search = () => {
  127. for (var i = 0; i < menu.list.length; i++) {
  128. state.newArr[i]['children'] = [];
  129. for (var j = 0; j < menu.list[i]['children'].length; j++) {
  130. const name = menu.list[i]['children'][j].name;
  131. if (name.indexOf(state.searchVal) >= 0) {
  132. state.newArr[i]['children'].push(menu.list[i]['children'][j])
  133. }
  134. }
  135. }
  136. // 清除没有孩子的父亲
  137. const lastArr = []
  138. for (var k = 0; k < state.newArr.length; k++) {
  139. if (state.newArr[k]['children'].length != 0) {
  140. lastArr.push(state.newArr[k])
  141. }
  142. }
  143. console.log("lastArr", lastArr)
  144. if (state.searchVal) {
  145. tableSelectIndex.value = 0
  146. }
  147. menuShow.list = lastArr
  148. console.log("menuShow.list", menuShow.list, tableSelectIndex.value)
  149. }
  150. const queryMenuConfigAction = () => {
  151. var data = {
  152. openId: getItem(StorageKeys.OpenId),
  153. systemType: source == "WECHAT" ? '6' : "9",
  154. loginSource: getItem("loginSource")
  155. };
  156. const options = {
  157. type: 2,
  158. data: data,
  159. method: "POST",
  160. showLoading: true,
  161. };
  162. return new Promise(async (resolve, reject) => {
  163. const res = await requestNew(queryMenuConfig, options,false, ()=>{
  164. console.log('---------------------我执行了!')
  165. load()
  166. });
  167. const data = res;
  168. console.log("dataqueryMenuConfigAction", data.menuList)
  169. resolve(data);
  170. }).catch((error) => {
  171. reject(error);
  172. });
  173. }
  174. const goToLogin = () => {
  175. uni.navigateTo({
  176. url: '/login/login',
  177. });
  178. }
  179. function toNext(url) {
  180. navTo(url);
  181. }
  182. </script>
  183. <style>
  184. page {
  185. height: 100%;
  186. background: white;
  187. }
  188. .wrapper {
  189. padding-top: 150rpx;
  190. display: flex;
  191. background: #01243A;
  192. flex-direction: column;
  193. height: calc(100% - 150rpx);
  194. }
  195. .search-box {
  196. margin: 50rpx 40rpx;
  197. height: 72rpx;
  198. border-radius: 36rpx;
  199. background: #f7f7f7;
  200. display: flex;
  201. justify-content: center;
  202. align-items: center;
  203. }
  204. .search-box .icon {
  205. width: 48rpx;
  206. height: 48rpx;
  207. margin: 0 20rpx;
  208. }
  209. .search-box .search {
  210. flex: 1;
  211. margin-right: 20rpx;
  212. height: 100%;
  213. padding: 0 10rpx;
  214. font-size: 28rpx;
  215. color: black;
  216. background: transparent;
  217. }
  218. .content {
  219. display: flex;
  220. flex: 1;
  221. flex-grow: 1;
  222. background: #fff;
  223. border-radius: 30rpx 30rpx 0 0;
  224. padding-top: 40rpx;
  225. }
  226. .left {
  227. width: 180rpx;
  228. border-right: 1px solid #dcdcdc;
  229. margin-right: 29rpx;
  230. }
  231. .left .menu-text {
  232. font-size: 26rpx;
  233. color: #666666;
  234. width: 120rpx;
  235. }
  236. .left .menu {
  237. padding-left: 15rpx;
  238. display: flex;
  239. align-items: center;
  240. margin: 20rpx 0 60rpx 0;
  241. }
  242. .left .active .menu-text {
  243. font-weight: bold;
  244. line-height: 32rpx;
  245. font-family: NotoSansHans, NotoSansHans;
  246. font-size: 28rpx;
  247. color: #01243A;
  248. }
  249. .left .border {
  250. width: 9rpx;
  251. height: 26rpx;
  252. border-radius: 4rpx;
  253. margin-right: 20rpx;
  254. }
  255. .left .on {
  256. border-radius: 4rpx;
  257. font-size: 28rpx;
  258. background: var(--background);
  259. background-size: 100% 100%;
  260. }
  261. .right {
  262. flex: 1;
  263. }
  264. .bg-blue {
  265. background: var(--background);
  266. }
  267. .bg-orange {
  268. background: var(--background);
  269. }
  270. .right .text-orange {
  271. color: #fd8362;
  272. }
  273. .rightListVue {
  274. height: 100%;
  275. }
  276. .login-content{
  277. display: flex;
  278. display: flex;
  279. flex-direction: column;
  280. align-items: center;
  281. justify-content: center;
  282. margin-top: 232rpx;
  283. }
  284. .tips{
  285. color: #999999;
  286. font-size: 30rpx;
  287. text-align: center;
  288. }
  289. .custom-btn{
  290. width: 120rpx;
  291. height: 68rpx;
  292. background: radial-gradient(at 0% 0%, #01243A 0%, #004576 100%);
  293. border-radius: 68rpx;
  294. font-size: 26rpx;
  295. color: #FFFFFF;
  296. line-height: 68rpx;
  297. margin: 32rpx auto;
  298. text-align: center;
  299. }
  300. </style>