index.vue 8.8 KB

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