index.vue 8.1 KB

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