index.vue 8.5 KB

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