index.vue 8.9 KB

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