info.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="main">
  3. <!-- 一级循环 -->
  4. <view class="one" v-for="(item,index) in menuList" :key="index" :class="item.oneStare?'oneshow':'onehide'">
  5. <view class="one-label" @tap="oneList(index,item)">
  6. <view class="left">
  7. <uni-icons v-if="item.icon" :type="item.icon" size="20" color="#07C4A8"></uni-icons>
  8. <text>{{item.name}}</text>
  9. </view>
  10. <view class="right">
  11. <uni-icons v-if="item.children&&item.children.length>0" :type="item.oneStare?'bottom':'forward'"
  12. size="20" color="#07C4A8"></uni-icons>
  13. </view>
  14. </view>
  15. <!-- 二级循环 -->
  16. <view class="two" v-for="(item2,index2) in item.children" :key="index2"
  17. :class="item2.twoStare?'twoshow':'twohide'">
  18. <view class="two-label" @tap="twoList(index,index2,item2)">
  19. <view class="left">
  20. <uni-icons v-if="item2.icon" :type="item2.icon" size="20"></uni-icons>
  21. <text>{{item2.name}}</text>
  22. </view>
  23. <view class="right">
  24. <uni-icons v-if="item2.children&&item2.children.length>0"
  25. :type="item2.twoStare?'bottom':'forward'" size="20"></uni-icons>
  26. </view>
  27. </view>
  28. <view class="three">
  29. <!-- 三级循环 -->
  30. <view class="three-label" v-for="(item3,index3) in item2.children" :key="index3"
  31. @tap="thrList(item3)">
  32. <view class="left">
  33. <uni-icons v-if="item3.icon" :type="item3.icon" size="20" color="#858585"></uni-icons>
  34. <text>{{item3.name}}</text>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. menu
  45. } from '@/common/site.js';
  46. export default {
  47. data() {
  48. return {
  49. id: '',
  50. user: {},
  51. menuList: menu
  52. }
  53. },
  54. onLoad: async function(e) {
  55. const that = this;
  56. that.$set(that, `id`, e && e.id || '');
  57. that.searchToken();
  58. },
  59. methods: {
  60. searchToken() {
  61. const that = this;
  62. try {
  63. const res = uni.getStorageSync('token');
  64. if (res) {
  65. const user = that.$jwt(res);
  66. that.$set(that, `user`, user);
  67. } else {
  68. uni.navigateTo({
  69. url: `/pages/login/index`
  70. })
  71. }
  72. } catch (e) {
  73. uni.showToast({
  74. title: err.errmsg,
  75. icon: 'error',
  76. duration: 2000
  77. });
  78. }
  79. },
  80. // 一级菜单展开
  81. oneList(index, item) {
  82. const that = this;
  83. let menuList = that.menuList;
  84. menuList[index]['oneStare'] = !menuList[index]['oneStare'];
  85. if (item && item.route) {
  86. uni.navigateTo({
  87. url: `/${item.route}?id=${that.id}`
  88. })
  89. }
  90. },
  91. // 二级菜单展开
  92. twoList(index, index2, item2) {
  93. const that = this;
  94. let menuList = that.menuList;
  95. menuList[index].children[index2]['twoStare'] = !menuList[index].children[index2]['twoStare'];
  96. if (item2 && item2.route) {
  97. uni.navigateTo({
  98. url: `/${item2.route}?id=${that.id}`
  99. })
  100. }
  101. },
  102. // 三级菜单
  103. thrList(item3) {
  104. const that = this;
  105. if (item3 && item3.route) {
  106. uni.navigateTo({
  107. url: `/${item3.route}?id=${that.id}`
  108. })
  109. }
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss" scoped>
  115. .main {
  116. /* 一级 */
  117. .one {
  118. transition: all 0.5s;
  119. .one-label {
  120. display: flex;
  121. justify-content: space-between;
  122. align-items: center;
  123. padding: 4vw;
  124. border-bottom: 1px var(--feColor) solid;
  125. .left {
  126. display: flex;
  127. align-items: center;
  128. font-size: var(--font16Size);
  129. font-weight: bold;
  130. color: var(--f07CColor);
  131. text {
  132. margin: 0 0 0 1vw;
  133. }
  134. }
  135. }
  136. }
  137. /* 二级 */
  138. .two {
  139. transition: all 0.5s;
  140. .two-label {
  141. display: flex;
  142. justify-content: space-between;
  143. align-items: center;
  144. padding: 4vw;
  145. border-bottom: 1px var(--feColor) solid;
  146. .left {
  147. display: flex;
  148. align-items: center;
  149. font-size: var(--font15Size);
  150. text {
  151. margin: 0 0 0 1vw;
  152. }
  153. }
  154. }
  155. }
  156. /* 三级 */
  157. .three {
  158. .three-label {
  159. display: flex;
  160. justify-content: space-between;
  161. align-items: center;
  162. padding: 4vw;
  163. border-bottom: 1px var(--feColor) solid;
  164. .left {
  165. display: flex;
  166. align-items: center;
  167. font-size: var(--font14Size);
  168. color: var(--f85Color);
  169. text {
  170. margin: 0 0 0 1vw;
  171. }
  172. }
  173. }
  174. }
  175. /* 展开收起效果 start */
  176. .oneshow {}
  177. .oneshow .two {
  178. display: block;
  179. }
  180. .onehide {}
  181. .onehide .two {
  182. display: none;
  183. }
  184. /* 展开收起效果 end */
  185. .twoshow {}
  186. .twoshow .three {
  187. display: block;
  188. }
  189. .twohide {}
  190. .twohide .three {
  191. display: none;
  192. }
  193. }
  194. </style>