index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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">
  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. openXS(){
  96. uni.navigateTo({ url: '/pages/hexiao/xiaoshou/index?type=3' });
  97. },
  98. onStoreSelect(store) {
  99. console.log('在首页接收到选中的门店:', store);
  100. this.selectedStore = store;
  101. uni.navigateTo({ url: '/pages/hexiao/scan_code?storeId='+store.id });
  102. },
  103. // 格式化数字,添加千位分隔符
  104. formatNumber(num) {
  105. return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  106. },
  107. // 扫码事件
  108. scanCode(type) {
  109. // uni.navigateTo({ url: `/pages/cjx/hexiao/scan_code` });
  110. if("stock" === type){
  111. this.showDrawer = true;
  112. }else{
  113. this.build();
  114. }
  115. },
  116. build(){
  117. uni.showToast({
  118. title: '功能建设中',
  119. icon: 'none'
  120. });
  121. },
  122. // 页面跳转
  123. navigateTo(page) {
  124. console.log('准备跳转到:', page);
  125. // uni.navigateTo({ url: `/pages/${page}/${page}` });
  126. if("ywyList" === page){
  127. uni.navigateTo({ url: `/pages/hexiao/jxs/ywy_list` });
  128. return;
  129. }
  130. if("patrolRecords" === page){
  131. uni.navigateTo({ url: `/pages/hexiao/jxs/hexiao_record` });
  132. return;
  133. }
  134. if("stockRecords" === page){
  135. uni.navigateTo({ url: `/pages/hexiao/ywy/add_goods_record` });
  136. }else if("pointsStats" === page){
  137. uni.navigateTo({ url: `/pages/cjx/shop/score_list?score=`+this.stats.pointsCount });
  138. }else{
  139. this.build();
  140. }
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss">
  146. .page-container {
  147. background-image: url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/hexiao/hexiao_bg.png");
  148. background-size: 100% 100%;
  149. background-position: center;
  150. background-repeat: no-repeat;
  151. }
  152. .page-title {
  153. padding-top: 5%;
  154. color: #ffffff;
  155. text-align: center;
  156. font-size: 19px;
  157. height: 160rpx;
  158. line-height: 160rpx;
  159. }
  160. .header-section {
  161. padding: 40rpx 40rpx 80rpx;
  162. padding-top: 0rpx;
  163. color: #ffffff;
  164. .greeting-text {
  165. font-size: 32rpx;
  166. opacity: 0.9;
  167. }
  168. .title-text {
  169. font-size: 42rpx;
  170. font-weight: bold;
  171. margin-top: 66rpx;
  172. }
  173. }
  174. .content-grid {
  175. padding: 0 30rpx;
  176. margin-top: -40rpx;
  177. position: relative;
  178. z-index: 10;
  179. // 使用CSS Grid布局
  180. display: grid;
  181. grid-template-columns: 1fr 1fr; // 两列等宽
  182. gap: 20rpx; // 卡片间距
  183. }
  184. .card {
  185. background-image: url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/hexiao/mini_bg.png");
  186. background-position: center;
  187. background-repeat: no-repeat;
  188. background-color: #ffffff;
  189. border-radius: 20rpx;
  190. padding: 25rpx;
  191. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  192. display: flex;
  193. align-items: center;
  194. .card-title {
  195. font-size: 38rpx;
  196. font-weight: 600;
  197. color: #333;
  198. }
  199. .icon-wrapper {
  200. width: 80rpx;
  201. height: 80rpx;
  202. border-radius: 50%;
  203. display: flex;
  204. align-items: center;
  205. justify-content: center;
  206. margin-right: 20rpx;
  207. }
  208. }
  209. .large-card {
  210. // 关键:让这个卡片跨越两行
  211. grid-row: span 2;
  212. height: 83%; // 确保高度自适应
  213. position: relative;
  214. flex-direction: column;
  215. justify-content: space-between;
  216. color: #ffffff;
  217. background-color: #4cd964;
  218. .large-card-text {
  219. position: relative;
  220. left: -18%;
  221. top: 16px;
  222. .card-title { color: #ffffff; }
  223. .card-subtitle { font-size: 24rpx; opacity: 0.8; margin: 10rpx 0; }
  224. }
  225. .scan-button {
  226. background-color: #ffffff;
  227. color: #5E87FF;
  228. font-size: 24rpx;
  229. padding: 8rpx 20rpx;
  230. border-radius: 30rpx;
  231. display: inline-block;
  232. margin-top: 20rpx;
  233. }
  234. .large-card-icon {
  235. align-self: flex-end;
  236. width: 140rpx;
  237. height: 140rpx;
  238. image { width: 100%; height: 100%; }
  239. }
  240. }
  241. .small-card {
  242. flex: 1;
  243. }
  244. .stat-card {
  245. // 关键:让统计卡片默认只占一列,但如果需要跨列可以单独设置
  246. // grid-column: span 2; // 如果需要单张卡片占满一行,则打开此行
  247. flex-direction: row;
  248. justify-content: space-between;
  249. align-items: flex-end;
  250. position: relative;
  251. padding-left: 40rpx;
  252. &::before {
  253. content: '';
  254. position: absolute;
  255. left: 20rpx;
  256. top: 35rpx;
  257. width: 8rpx;
  258. height: 25rpx;
  259. background-color: #6a8dff;
  260. border-radius: 4rpx;
  261. }
  262. .stat-content {
  263. .stat-title { font-size: 28rpx; color: #666; }
  264. .stat-value { font-size: 44rpx; font-weight: bold; color: #333; margin: 10rpx 0; }
  265. .stat-label { font-size: 24rpx; color: #999; }
  266. }
  267. .stat-image {
  268. width: 120rpx;
  269. position: absolute;
  270. right: 20rpx;
  271. bottom: 20rpx;
  272. }
  273. }
  274. .mendian-card{
  275. background-image: url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/hexiao/mendian.png");
  276. background-position: center;
  277. background-repeat: no-repeat;
  278. background-size: 100% 100%;
  279. background-color: inherit;
  280. }
  281. .jifen-card{
  282. background-size: 100% 100%;
  283. background-image: url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/hexiao/jifen.png");
  284. background-position: center;
  285. background-repeat: no-repeat;
  286. background-color: inherit;
  287. }
  288. </style>