index.vue 6.3 KB

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