detail.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <NavBar title="门店详情" :showBack="true" />
  5. <view class="detail-card" v-if="shop">
  6. <!-- 门店状态 -->
  7. <view class="status-section">
  8. <view class="status-header">
  9. <text class="shop-name">{{ shop.name }}</text>
  10. <view class="shop-status" :class="getStatusClass(shop.status)">
  11. <view class="status-dot"></view>
  12. <text>{{ getStatusText(shop.status) }}</text>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- 基本信息 -->
  17. <view class="info-section">
  18. <text class="section-title">基本信息</text>
  19. <view class="info-item">
  20. <text class="label">门店地址</text>
  21. <text class="value">{{ shop.address }}</text>
  22. </view>
  23. <view class="info-item">
  24. <text class="label">联系电话</text>
  25. <text class="value">{{ shop.contactPhone }}</text>
  26. </view>
  27. <view class="info-item">
  28. <text class="label">负责人</text>
  29. <text class="value">{{ shop.contactName }}</text>
  30. </view>
  31. <view class="info-item">
  32. <text class="label">营业时间</text>
  33. <text class="value">{{ shop.businessHours }}</text>
  34. </view>
  35. </view>
  36. <!-- 销售数据 -->
  37. <view class="info-section">
  38. <text class="section-title">销售数据</text>
  39. <view class="sales-grid">
  40. <view class="sales-item">
  41. <text class="sales-value accent">¥{{ formatMoney(shop.todaySales) }}</text>
  42. <text class="sales-label">今日销售额</text>
  43. </view>
  44. <view class="sales-item">
  45. <text class="sales-value">{{ shop.todayOrders }}</text>
  46. <text class="sales-label">今日订单</text>
  47. </view>
  48. <view class="sales-item">
  49. <text class="sales-value primary">¥{{ formatMoney(shop.monthSales) }}</text>
  50. <text class="sales-label">本月销售额</text>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 门店设备 -->
  55. <view class="info-section" v-if="shop.devices && shop.devices.length > 0">
  56. <text class="section-title">门店设备</text>
  57. <view class="device-list">
  58. <view class="device-item" v-for="device in shop.devices" :key="device.id">
  59. <view class="device-info">
  60. <text class="device-name">{{ device.name }}</text>
  61. <text class="device-no">{{ device.deviceNo }}</text>
  62. </view>
  63. <view class="device-status" :class="getDeviceStatusClass(device.status)">
  64. <view class="status-dot"></view>
  65. <text>{{ getDeviceStatusText(device.status) }}</text>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script setup lang="ts">
  74. import { ref, onMounted } from 'vue';
  75. import NavBar from '@/components/NavBar.vue';
  76. import { getShopDetail } from '@/api/shop';
  77. import { ShopStatusText, ShopStatusColor } from '@/mock/shop';
  78. import { DeviceStatusText, DeviceStatusColor } from '@/mock/device';
  79. import { formatMoney as formatMoneyUtil, showToast, navigateBack } from '@/utils/common';
  80. const shop = ref<any>(null);
  81. const formatMoney = formatMoneyUtil;
  82. const getStatusText = (status: number) => ShopStatusText[status] || '未知';
  83. const getStatusColor = (status: number) => ShopStatusColor[status] || '#94a3b8';
  84. const getDeviceStatusText = (status: number) => DeviceStatusText[status] || '未知';
  85. const getDeviceStatusColor = (status: number) => DeviceStatusColor[status] || '#94a3b8';
  86. const getStatusClass = (status: number) => {
  87. if (status === 1) return 'active';
  88. return 'inactive';
  89. };
  90. const getDeviceStatusClass = (status: number) => {
  91. if (status === 1) return 'online';
  92. if (status === 0) return 'offline';
  93. return 'maintenance';
  94. };
  95. const loadDetail = async () => {
  96. const pages = getCurrentPages();
  97. const currentPage = pages[pages.length - 1];
  98. const id = (currentPage as any).options?.id;
  99. if (!id) {
  100. showToast('门店ID不存在');
  101. navigateBack();
  102. return;
  103. }
  104. try {
  105. shop.value = await getShopDetail(Number(id));
  106. } catch (error) {
  107. showToast('加载门店详情失败');
  108. navigateBack();
  109. }
  110. };
  111. onMounted(() => {
  112. loadDetail();
  113. });
  114. </script>
  115. <style lang="scss" scoped>
  116. .page {
  117. min-height: 100vh;
  118. background: #f8fafc;
  119. }
  120. .status-section {
  121. background: #ffffff;
  122. padding: 30rpx 32rpx;
  123. margin-bottom: 16rpx;
  124. .status-header {
  125. display: flex;
  126. justify-content: space-between;
  127. align-items: center;
  128. .shop-name {
  129. font-size: 36rpx;
  130. font-weight: 700;
  131. color: #1e293b;
  132. }
  133. .shop-status {
  134. display: flex;
  135. align-items: center;
  136. justify-content: center;
  137. gap: 8rpx;
  138. padding: 10rpx 20rpx;
  139. font-size: 24rpx;
  140. font-weight: 500;
  141. border-radius: 20rpx;
  142. .status-dot {
  143. width: 8rpx;
  144. height: 8rpx;
  145. border-radius: 50%;
  146. }
  147. &.active {
  148. background: #ecfdf5;
  149. color: #10b981;
  150. .status-dot { background: #10b981; }
  151. }
  152. &.inactive {
  153. background: #fff7ed;
  154. color: #f97316;
  155. .status-dot { background: #f97316; }
  156. }
  157. }
  158. }
  159. }
  160. .info-section {
  161. background: #ffffff;
  162. margin-bottom: 16rpx;
  163. padding: 24rpx 32rpx;
  164. .section-title {
  165. display: block;
  166. font-size: 28rpx;
  167. font-weight: 600;
  168. color: #1e293b;
  169. margin-bottom: 20rpx;
  170. padding-bottom: 16rpx;
  171. border-bottom: 1rpx solid #f1f5f9;
  172. }
  173. .info-item {
  174. display: flex;
  175. justify-content: space-between;
  176. padding: 14rpx 0;
  177. .label {
  178. font-size: 28rpx;
  179. color: #64748b;
  180. }
  181. .value {
  182. font-size: 28rpx;
  183. color: #1e293b;
  184. }
  185. }
  186. .sales-grid {
  187. display: flex;
  188. background: #f8fafc;
  189. border-radius: 12rpx;
  190. padding: 20rpx 0;
  191. .sales-item {
  192. flex: 1;
  193. display: flex;
  194. flex-direction: column;
  195. align-items: center;
  196. justify-content: center;
  197. .sales-value {
  198. display: flex;
  199. align-items: center;
  200. justify-content: center;
  201. font-size: 30rpx;
  202. font-weight: 700;
  203. color: #1e293b;
  204. margin-bottom: 8rpx;
  205. &.accent {
  206. color: #f97316;
  207. }
  208. &.primary {
  209. color: #10b981;
  210. }
  211. }
  212. .sales-label {
  213. display: flex;
  214. align-items: center;
  215. justify-content: center;
  216. font-size: 22rpx;
  217. color: #64748b;
  218. }
  219. }
  220. }
  221. .device-list {
  222. .device-item {
  223. display: flex;
  224. justify-content: space-between;
  225. align-items: center;
  226. padding: 20rpx 0;
  227. border-bottom: 1rpx solid #f1f5f9;
  228. &:last-child {
  229. border-bottom: none;
  230. }
  231. .device-info {
  232. .device-name {
  233. display: block;
  234. font-size: 28rpx;
  235. color: #1e293b;
  236. font-weight: 500;
  237. margin-bottom: 4rpx;
  238. }
  239. .device-no {
  240. font-size: 24rpx;
  241. color: #94a3b8;
  242. font-family: monospace;
  243. }
  244. }
  245. .device-status {
  246. display: flex;
  247. align-items: center;
  248. gap: 6rpx;
  249. padding: 8rpx 16rpx;
  250. border-radius: 8rpx;
  251. font-size: 22rpx;
  252. font-weight: 500;
  253. .status-dot {
  254. width: 8rpx;
  255. height: 8rpx;
  256. border-radius: 50%;
  257. }
  258. &.online {
  259. background: #ecfdf5;
  260. color: #10b981;
  261. .status-dot { background: #10b981; }
  262. }
  263. &.offline {
  264. background: #fff7ed;
  265. color: #f97316;
  266. .status-dot { background: #f97316; }
  267. }
  268. &.maintenance {
  269. background: #faf5ff;
  270. color: #a855f7;
  271. .status-dot { background: #a855f7; }
  272. }
  273. }
  274. }
  275. }
  276. }
  277. </style>