index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <view class="page-container">
  3. <view class="page-title">
  4. 首页
  5. </view>
  6. <view class="header-section">
  7. <view class="greeting-text">{{ userInfo.role }} {{ userInfo.name }}</view>
  8. <view class="title-text">提供的服务</view>
  9. </view>
  10. <view class="content-grid">
  11. <view class="card large-card" style="background: none;background-color: #54CFAB" @click="build">
  12. <view class="large-card-text">
  13. <view class="card-title" style="font-size: 40rpx">销售查询</view>
  14. <view class="card-subtitle">销售数据一览</view>
  15. <view class="scan-button" style="color:#54CFAB">去查看</view>
  16. </view>
  17. <view class="large-card-icon">
  18. <image :src="imgurl+'/cjx/hexiao/xiaoshouchaxun.png'" mode="aspectFit"></image>
  19. </view>
  20. </view>
  21. <view class="card" @click="navigateTo('ywyList')">
  22. <view class="icon-wrapper" style="background-color: #e4f7ed;">
  23. <image :src="imgurl+'/cjx/hexiao/yewuyuan.png'" mode="aspectFit"></image>
  24. </view>
  25. <view class="card-title">业务员管理</view>
  26. </view>
  27. <view class="card" @click="navigateTo('patrolRecords')">
  28. <view class="icon-wrapper" style="background-color: #f2e7ff;">
  29. <image :src="imgurl+'/cjx/hexiao/hexiaojilu_jxs.png'" mode="aspectFit"></image>
  30. </view>
  31. <view class="card-title">核销记录</view>
  32. </view>
  33. <view class="card stat-card mendian-card" @click="navigateTo('storeStats')">
  34. <view class="stat-content">
  35. <view class="stat-title">门店统计</view>
  36. <view class="stat-value">{{ stats.storeCount }}</view>
  37. <view class="stat-label">总数</view>
  38. </view>
  39. </view>
  40. <view class="card stat-card jifen-card" @click="navigateTo('pointsStats')">
  41. <view class="stat-content">
  42. <view class="stat-title">积分统计</view>
  43. <view class="stat-value">{{ formatNumber(stats.pointsCount) }}</view>
  44. <view class="stat-label">总数</view>
  45. </view>
  46. </view>
  47. </view>
  48. <select-store-drawer
  49. :show="showDrawer"
  50. :selected-id="selectedStore ? selectedStore.id : null"
  51. @close="showDrawer = false"
  52. @select="onStoreSelect"
  53. ></select-store-drawer>
  54. <CustomTabbar :current="0"/>
  55. </view>
  56. </template>
  57. <script>
  58. import CustomTabbar from '@/components/cjx/tabbar_hexiao_jxs.vue';
  59. import {getAdminInfo} from "../../../../utils/auth";
  60. import {getAdminUserInfo} from "../../../../api/hexiao";
  61. import SelectStoreDrawer from '@/components/cjx/select-store-drawer.vue';
  62. export default {
  63. components: {
  64. CustomTabbar,
  65. SelectStoreDrawer
  66. },
  67. data() {
  68. return {
  69. selectedStore: 0,
  70. showDrawer:false,
  71. imgurl:"https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu",
  72. userInfo: {
  73. name: '',
  74. role: '超吉炫'
  75. },
  76. stats: {
  77. storeCount: 0,
  78. pointsCount: 0
  79. }
  80. };
  81. },
  82. onLoad(){
  83. let info = getAdminInfo();
  84. this.userInfo.role = this.userInfo.role+""+info.roleName;
  85. this.userInfo.name = info.userName;
  86. },
  87. onShow(){
  88. getAdminUserInfo().then(res=>{
  89. this.stats.storeCount = res.data.storeCount;
  90. this.stats.pointsCount = res.data.pointTotal;
  91. })
  92. },
  93. methods: {
  94. // 监听从抽屉组件传来的 select 事件
  95. onStoreSelect(store) {
  96. console.log('在首页接收到选中的门店:', store);
  97. this.selectedStore = store;
  98. uni.navigateTo({ url: '/pages/cjx/hexiao/scan_code?storeId='+store.id });
  99. },
  100. // 格式化数字,添加千位分隔符
  101. formatNumber(num) {
  102. return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  103. },
  104. // 扫码事件
  105. scanCode(type) {
  106. // uni.navigateTo({ url: `/pages/cjx/hexiao/scan_code` });
  107. if("stock" === type){
  108. this.showDrawer = true;
  109. }else{
  110. this.build();
  111. }
  112. },
  113. build(){
  114. uni.showToast({
  115. title: '功能建设中',
  116. icon: 'none'
  117. });
  118. },
  119. // 页面跳转
  120. navigateTo(page) {
  121. console.log('准备跳转到:', page);
  122. // uni.navigateTo({ url: `/pages/${page}/${page}` });
  123. if("ywyList" === page){
  124. uni.navigateTo({ url: `/pages/cjx/hexiao/jxs/ywy_list` });
  125. return;
  126. }
  127. if("patrolRecords" === page){
  128. uni.navigateTo({ url: `/pages/cjx/hexiao/jxs/hexiao_record` });
  129. return;
  130. }
  131. if("stockRecords" === page){
  132. uni.navigateTo({ url: `/pages/cjx/hexiao/ywy/add_goods_record` });
  133. }else{
  134. this.build();
  135. }
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss">
  141. .page-container {
  142. background-image: url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/hexiao/hexiao_bg.png");
  143. background-size: 100% 100%;
  144. background-position: center;
  145. background-repeat: no-repeat;
  146. }
  147. .page-title {
  148. padding-top: 5%;
  149. color: #ffffff;
  150. text-align: center;
  151. font-size: 19px;
  152. height: 160rpx;
  153. line-height: 160rpx;
  154. }
  155. .header-section {
  156. padding: 40rpx 40rpx 80rpx;
  157. padding-top: 0rpx;
  158. color: #ffffff;
  159. .greeting-text {
  160. font-size: 32rpx;
  161. opacity: 0.9;
  162. }
  163. .title-text {
  164. font-size: 42rpx;
  165. font-weight: bold;
  166. margin-top: 66rpx;
  167. }
  168. }
  169. .content-grid {
  170. padding: 0 30rpx;
  171. margin-top: -40rpx;
  172. position: relative;
  173. z-index: 10;
  174. // 使用CSS Grid布局
  175. display: grid;
  176. grid-template-columns: 1fr 1fr; // 两列等宽
  177. gap: 20rpx; // 卡片间距
  178. }
  179. .card {
  180. background-image: url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/hexiao/mini_bg.png");
  181. background-position: center;
  182. background-repeat: no-repeat;
  183. background-color: #ffffff;
  184. border-radius: 20rpx;
  185. padding: 25rpx;
  186. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  187. display: flex;
  188. align-items: center;
  189. .card-title {
  190. font-size: 38rpx;
  191. font-weight: 600;
  192. color: #333;
  193. }
  194. .icon-wrapper {
  195. width: 80rpx;
  196. height: 80rpx;
  197. border-radius: 50%;
  198. display: flex;
  199. align-items: center;
  200. justify-content: center;
  201. margin-right: 20rpx;
  202. }
  203. }
  204. .large-card {
  205. // 关键:让这个卡片跨越两行
  206. grid-row: span 2;
  207. height: 83%; // 确保高度自适应
  208. position: relative;
  209. flex-direction: column;
  210. justify-content: space-between;
  211. color: #ffffff;
  212. background-color: #4cd964;
  213. .large-card-text {
  214. position: relative;
  215. left: -18%;
  216. top: 16px;
  217. .card-title { color: #ffffff; }
  218. .card-subtitle { font-size: 24rpx; opacity: 0.8; margin: 10rpx 0; }
  219. }
  220. .scan-button {
  221. background-color: #ffffff;
  222. color: #5E87FF;
  223. font-size: 24rpx;
  224. padding: 8rpx 20rpx;
  225. border-radius: 30rpx;
  226. display: inline-block;
  227. margin-top: 20rpx;
  228. }
  229. .large-card-icon {
  230. align-self: flex-end;
  231. width: 140rpx;
  232. height: 140rpx;
  233. image { width: 100%; height: 100%; }
  234. }
  235. }
  236. .small-card {
  237. flex: 1;
  238. }
  239. .stat-card {
  240. // 关键:让统计卡片默认只占一列,但如果需要跨列可以单独设置
  241. // grid-column: span 2; // 如果需要单张卡片占满一行,则打开此行
  242. flex-direction: row;
  243. justify-content: space-between;
  244. align-items: flex-end;
  245. position: relative;
  246. padding-left: 40rpx;
  247. &::before {
  248. content: '';
  249. position: absolute;
  250. left: 20rpx;
  251. top: 35rpx;
  252. width: 8rpx;
  253. height: 25rpx;
  254. background-color: #6a8dff;
  255. border-radius: 4rpx;
  256. }
  257. .stat-content {
  258. .stat-title { font-size: 28rpx; color: #666; }
  259. .stat-value { font-size: 44rpx; font-weight: bold; color: #333; margin: 10rpx 0; }
  260. .stat-label { font-size: 24rpx; color: #999; }
  261. }
  262. .stat-image {
  263. width: 120rpx;
  264. position: absolute;
  265. right: 20rpx;
  266. bottom: 20rpx;
  267. }
  268. }
  269. .mendian-card{
  270. background-image: url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/hexiao/mendian.png");
  271. background-position: center;
  272. background-repeat: no-repeat;
  273. background-size: 100% 100%;
  274. background-color: inherit;
  275. }
  276. .jifen-card{
  277. background-size: 100% 100%;
  278. background-image: url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/hexiao/jifen.png");
  279. background-position: center;
  280. background-repeat: no-repeat;
  281. background-color: inherit;
  282. }
  283. </style>