index.vue 8.9 KB

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