index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <script setup lang="ts">
  2. import router from "@/router";
  3. import hxs from "@/subPack/static/hxs.png";
  4. import hx from "@/static/index/hx.png";
  5. import bk from "@/static/index/bk.png";
  6. import pj from "@/static/index/pj.png";
  7. import ye from "@/static/index/ye.png";
  8. import yg from "@/static/index/yg.png";
  9. import pz from "@/static/index/pz.png";
  10. import ls from "@/static/index/ls.png";
  11. import nz from "@/static/index/nz.png";
  12. import sm from "@/static/index/sm.png";
  13. const { statusBarHeight } = uni.getSystemInfoSync();
  14. const { token, userInfo, orgCode, title, isShowLoging, topMenu, StoreMenu } =
  15. storeToRefs(useUserStore());
  16. const { data: dept, send: getDeptList } = useRequest(
  17. () => Apis.sys.getCurrentUserDeparts({}),
  18. {
  19. initialData: [],
  20. immediate: false,
  21. },
  22. ).onSuccess(() => {
  23. title.value = String(dept.value.list[0].departName);
  24. });
  25. const { data: sysMsg, send: getmsgData } = useRequest(
  26. () => Apis.app.getMsg({}),
  27. { immediate: false },
  28. );
  29. function handleCommenPath(url: string) {
  30. if (url == "/subPack/writeOff/index") {
  31. uni.scanCode({
  32. success: function (res) {
  33. console.log(res, "扫码信息");
  34. if (res.result) {
  35. handleCommenPath(`/subPack/writeOff/index?id=${res.result}`);
  36. } else {
  37. uni.showToast({
  38. title: "请检查二维码是否正确",
  39. icon: "none",
  40. });
  41. }
  42. },
  43. });
  44. } else {
  45. router.push(url);
  46. }
  47. }
  48. onMounted(() => {
  49. if (token.value) {
  50. getDeptList();
  51. }
  52. });
  53. onShow(() => {
  54. if (token.value) {
  55. getmsgData();
  56. useUserStore().getMenuList();
  57. }
  58. });
  59. watch(
  60. () => isShowLoging.value,
  61. () => {
  62. if (isShowLoging.value) {
  63. uni.showToast({
  64. image: hxs,
  65. title: "核销成功",
  66. });
  67. }
  68. },
  69. );
  70. function getIcon(path: string) {
  71. const iconMap: Record<string, string> = {
  72. "/subPack/classInspection/index?type=0": pz,
  73. "/subPack/classInspection/index?type=1": ls,
  74. "/subPack/classInspection/index?type=2": nz,
  75. "/subPack/writeOffDetaile/index": hx,
  76. "/subPack/classInspection/index?type=3": bk,
  77. "/subPack/Evaluation/index": pj,
  78. "/subPack/Storebalance/index": ye,
  79. "/subPack/EmployeeList/index": yg,
  80. "/subPack/writeOff/index": sm,
  81. };
  82. return iconMap[path] || "";
  83. }
  84. function getItemClass(path: string) {
  85. const classMap: Record<string, string> = {
  86. "/subPack/classInspection/index?type=0": "header",
  87. "/subPack/classInspection/index?type=1": "ls",
  88. "/subPack/writeOff/index": "sm",
  89. "/subPack/classInspection/index?type=2": "kc",
  90. };
  91. return classMap[path] || "";
  92. }
  93. </script>
  94. <template>
  95. <view
  96. class="h-screen box-border header"
  97. :style="{ paddingTop: `${statusBarHeight}px` }"
  98. >
  99. <view class="h-58rpx"></view>
  100. <view class="px-32rpx mt-48rpx" v-if="!token">
  101. <view
  102. class="bg-white rounded-16rpx flex items-center justify-between py-20rpx px-24rpx"
  103. >
  104. <view>您还未登录,快去登录吧!</view>
  105. <commonbtn
  106. bg-color="#0074FF"
  107. @click="handleCommenPath('/pages/login/index')"
  108. >去登录</commonbtn
  109. >
  110. </view>
  111. </view>
  112. <view class="relative">
  113. <wd-drop-menu>
  114. <wd-drop-menu-item
  115. :options="dept.list"
  116. v-model:model-value="orgCode"
  117. value-key="orgCode"
  118. label-key="departName"
  119. :title="title"
  120. @change="useUserStore().setTitile"
  121. />
  122. </wd-drop-menu>
  123. <view class="absolute top-50% -translate-y-50% right-50rpx" v-if="token">
  124. <view class="flex items-center">
  125. <image src="@/static/index/user.png" class="w-40rpx h-40rpx"></image>
  126. <view class="text-32rpx font-semibold ml-3">{{
  127. userInfo.realname
  128. }}</view>
  129. </view>
  130. </view>
  131. </view>
  132. <view class="px-32rpx">
  133. <view class="grid grid-cols-2 gap-3">
  134. <view
  135. class="flex items-center px-40rpx header rounded-2xl h-162rpx"
  136. @click="handleCommenPath(item.route)"
  137. v-for="item in topMenu"
  138. :class="getItemClass(item.route)"
  139. :key="item.id"
  140. >
  141. <image :src="getIcon(item.route)" class="w-100rpx h-100rpx"></image>
  142. <view class="text-32rpx font-semibold">{{ item.name }}</view>
  143. </view>
  144. </view>
  145. <view class="mt-3" v-if="sysMsg">
  146. <wd-notice-bar
  147. :text="sysMsg.map((it) => it.titile)"
  148. color="#000000"
  149. background-color="#fff"
  150. :delay="3"
  151. direction="vertical"
  152. @click="handleCommenPath('/subPack/notification/index')"
  153. >
  154. <template #prefix>
  155. <image
  156. src="@/static/index/msg.png"
  157. class="w-30rpx h-30rpx mr2"
  158. ></image>
  159. </template>
  160. </wd-notice-bar>
  161. </view>
  162. <view class="mt-3 rounded-2xl bg-white p-28rpx" v-if="StoreMenu">
  163. <view class="font-semibold text-32rpx">门店经营</view>
  164. <view class="grid grid-cols-4 gap-3 mt-3">
  165. <view
  166. class="flex items-center justify-center flex-col"
  167. @click="handleCommenPath(item.route)"
  168. v-for="item in StoreMenu"
  169. :key="item.id"
  170. >
  171. <image :src="getIcon(item.route)" class="w-52rpx h-52rpx"></image>
  172. <view class="text-24rpx text-[rgb(0,0,0,0.6)] mt-3">{{
  173. item.name
  174. }}</view>
  175. </view>
  176. <view class="flex items-center justify-center flex-col">
  177. <image src="@/static/index/kf.png" class="w-52rpx h-52rpx"></image>
  178. <view class="text-24rpx text-[rgb(0,0,0,0.6)] mt-3">平台客服</view>
  179. </view>
  180. </view>
  181. </view>
  182. </view>
  183. </view>
  184. </template>
  185. <route lang="json">
  186. {
  187. "name": "home",
  188. "style": {
  189. "navigationBarTitleText": "首页",
  190. "navigationStyle": "custom",
  191. "disableScroll": true
  192. }
  193. }
  194. </route>
  195. <style scoped lang="scss">
  196. :deep(.wd-drop-menu__list) {
  197. background-color: transparent !important;
  198. .wd-drop-menu__item {
  199. text-align: left !important;
  200. .wd-drop-menu__item-title {
  201. max-width: 300rpx !important;
  202. }
  203. }
  204. }
  205. .ls {
  206. background: linear-gradient(180deg, #ffecec 0%, #ffffff 100%);
  207. }
  208. .kc {
  209. background: linear-gradient(180deg, #fff9e5 0%, #ffffff 100%);
  210. }
  211. .sm {
  212. background: linear-gradient(180deg, #efffff 0%, #ffffff 100%);
  213. }
  214. </style>