AppSidebar.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <template>
  2. <div class="index-nav" :class="{ 'index-nav-top': isActive }">
  3. <nav class="side-navigator-wrap">
  4. <div v-for="(item, index) in sideBarList" :key="index" class="nav-item-wrap">
  5. <div @click="removeTab" class="nav-item-content" :class="{ active: item.checked }">
  6. <router-link :to="item.path" class="nav-item">
  7. <i :class="item.icon"></i>
  8. <span class="nav-item-text">{{ item.name }}</span>
  9. </router-link>
  10. </div>
  11. </div>
  12. </nav>
  13. <div class="hot-list-container">
  14. <div class="hot-list-item">
  15. <!-- <div class="hot-item-header">
  16. <div class="hot-title">
  17. <img src="../assets/image/hot.png"
  18. type="icon" alt="icon" class="hot-icon">
  19. <span title="热门商品" class="title-text">热门商品</span>
  20. </div>
  21. </div>
  22. <div class="divider" style="margin-bottom: 4px;">
  23. <div class="content"></div>
  24. </div> -->
  25. <el-radio-group v-model="tabType" size="small" @change="tabChange">
  26. <el-radio-button label="hot">热门商品</el-radio-button>
  27. <el-radio-button label="new">商城新品</el-radio-button>
  28. </el-radio-group>
  29. <ul class="hot-item-body">
  30. <div class="skeleton">
  31. <li v-for="(item,index) in goodsList" :key="index" class="hot-item" style="cursor: pointer;" @click="handleClickExchange(item.skuId)">
  32. <!-- <a href="/home/pointsMall"> -->
  33. <img style="width: 150px;height: 150px;" :src="item.imgUrl" alt="">
  34. <!-- </a> -->
  35. <div class="hot-item-text" :class="tabType=='new'?'justifyCenter':'justifyBetween'">
  36. <div class="body-index" v-if="tabType=='hot'">
  37. {{ index + 1 }}
  38. </div>
  39. <div class="title-articles">
  40. <!-- <svg t="1681785345732" class="icon" viewBox="0 0 1024 1024" version="1.1"
  41. xmlns="http://www.w3.org/2000/svg" p-id="1220" width="200" height="200">
  42. <path d="M0 0h1024v1024H0V0z" fill="#202425" opacity=".01" p-id="1221">
  43. </path>
  44. <path
  45. d="M989.866667 512c0 263.918933-213.947733 477.866667-477.866667 477.866667S34.133333 775.918933 34.133333 512 248.081067 34.133333 512 34.133333s477.866667 213.947733 477.866667 477.866667z"
  46. fill="#FF7744" p-id="1222"></path>
  47. <path
  48. d="M512 34.133333c176.878933 0 331.298133 96.085333 413.934933 238.933334-82.6368 142.848-237.056 238.933333-413.934933 238.933333S180.701867 415.914667 98.065067 273.066667C180.667733 130.2528 335.121067 34.133333 512 34.133333z"
  49. fill="#FFAA44" p-id="1223"></path>
  50. <path
  51. d="M496.605867 305.3568a17.066667 17.066667 0 0 1 30.788266 0L576.853333 408.917333a17.066667 17.066667 0 0 0 13.175467 9.557334l113.800533 15.018666a17.066667 17.066667 0 0 1 9.5232 29.2864l-83.2512 79.018667a17.066667 17.066667 0 0 0-5.051733 15.496533l20.923733 112.8448a17.066667 17.066667 0 0 1-24.917333 18.090667l-100.864-54.715733a17.066667 17.066667 0 0 0-16.315733 0l-100.864 54.715733a17.066667 17.066667 0 0 1-24.917334-18.090667l20.8896-112.8448a17.066667 17.066667 0 0 0-5.0176-15.496533l-83.217066-79.018667a17.066667 17.066667 0 0 1 9.489066-29.2864l113.800534-15.018666a17.066667 17.066667 0 0 0 13.175466-9.557334l49.425067-103.560533z"
  52. fill="#FFFFFF" p-id="1224"></path>
  53. </svg> -->
  54. <!-- ¥ -->
  55. {{ item.price }}
  56. </div>
  57. </div>
  58. </li>
  59. </div>
  60. </ul>
  61. </div>
  62. </div>
  63. <div class="hot-list-container sticky-block">
  64. <div class="hot-list-item">
  65. <!-- <div class="hot-item-header">
  66. <div class="hot-title">
  67. <img src="../assets/image/hot.png"
  68. type="icon" alt="icon" class="hot-icon">
  69. <span title="热门商品" class="title-text">热门商品</span>
  70. </div>
  71. </div>
  72. <div class="divider" style="margin-bottom: 4px;">
  73. <div class="content"></div>
  74. </div> -->
  75. <el-radio-group v-model="tabType" size="small" @change="tabChange">
  76. <el-radio-button label="hot">热门商品</el-radio-button>
  77. <el-radio-button label="new">商城新品</el-radio-button>
  78. </el-radio-group>
  79. <ul class="hot-item-body">
  80. <div class="skeleton">
  81. <li v-for="(item,index) in goodsList" :key="index" class="hot-item" style="cursor: pointer;" @click="handleClickExchange(item.skuId)">
  82. <!-- <a href="/home/pointsMall"> -->
  83. <img style="width: 150px;height: 150px;" :src="item.imgUrl" alt="">
  84. <!-- </a> -->
  85. <div class="hot-item-text" :class="tabType=='new'?'justifyCenter':'justifyBetween'">
  86. <div class="body-index" v-if="tabType=='hot'">
  87. {{ index + 1 }}
  88. </div>
  89. <div class="title-articles">
  90. ¥{{ item.price }}
  91. </div>
  92. </div>
  93. </li>
  94. </div>
  95. </ul>
  96. </div>
  97. </div>
  98. </div>
  99. </template>
  100. <script>
  101. import { removeTab } from '@/utils/auth'
  102. import { hotSkuList,newSkuList } from "@/api/allApi";
  103. export default {
  104. name: 'AppSidebar',
  105. data() {
  106. return {
  107. tabType:'hot',
  108. goodsList:[],
  109. sideBarList: [
  110. {
  111. value: 'index',
  112. name: '首页',
  113. path: '/home/index',
  114. icon: 'icon-mall-tongzhi',
  115. checked: false,
  116. },
  117. {
  118. value: 'pointsMall',
  119. name: '积分商城',
  120. path: '/home/pointsMall',
  121. icon: 'icon-mall-jifenshangcheng',
  122. checked: false,
  123. },
  124. {
  125. value: 'signIn',
  126. name: '每日签到',
  127. path: '/home/signIn',
  128. icon: 'icon-mall-qiandao',
  129. checked: false,
  130. },
  131. {
  132. value: 'festiveEvents',
  133. name: '活动列表',
  134. path: '/home/festiveEvents',
  135. icon: 'icon-mall-huodong',
  136. checked: false,
  137. },
  138. // {
  139. // value:'myMedal',
  140. // name:'我的勋章',
  141. // path:'/home/myMedal',
  142. // icon:'icon-mall-xunzhang',
  143. // checked:false,
  144. // },
  145. {
  146. value: 'commend',
  147. name: '员工表彰',
  148. path: '/home/commend',
  149. icon: 'icon-mall-rongyubiaozhang',
  150. checked: false,
  151. },
  152. {
  153. value: 'welfareList',
  154. name: '福利领取',
  155. path: '/home/welfareList',
  156. icon: 'icon-mall-hongbao',
  157. checked: false,
  158. },
  159. {
  160. value: 'earnPoints',
  161. name: '积分获取',
  162. path: '/home/earnPoints',
  163. icon: 'icon-mall-zuorenwuzhuanjifen',
  164. checked: false,
  165. },
  166. {
  167. value: 'postInteract',
  168. name: '投票调研',
  169. path: '/home/postInteract',
  170. icon: 'icon-mall-neibuzhengyiguanli',
  171. checked: false,
  172. },
  173. // {
  174. // value:'myCenter',
  175. // name:'个人中心',
  176. // path:'/home/myCenter',
  177. // icon:'icon-mall-gerenzhongxin',
  178. // checked:false,
  179. // },
  180. ],
  181. employeeDynamics: false,
  182. pointsMall: false,
  183. welfareList: false,
  184. festiveEvents: false,
  185. isActive: false,
  186. };
  187. },
  188. methods: {
  189. handleClickExchange(id) {
  190. this.$router.push({
  191. path: '/home/pointsMall/redeem',
  192. query: {
  193. id: id,
  194. name: 'goodsNotice',
  195. type:36,
  196. }
  197. });
  198. },
  199. tabChange(val){
  200. this.getGoodsInfo(val);
  201. },
  202. getGoodsInfo(val){
  203. if(val=='hot'){
  204. hotSkuList().then(response=>{
  205. this.goodsList = response.data.data.list;
  206. });
  207. }else{
  208. newSkuList().then(response=>{
  209. this.goodsList = response.data.data.list;
  210. });
  211. }
  212. },
  213. removeTab() {
  214. removeTab();
  215. },
  216. getRoute() {
  217. var path = this.$route.path;
  218. this.sideBarList.forEach(item => {
  219. if (path.indexOf(item.value) != -1) {
  220. item.checked = true;
  221. } else {
  222. item.checked = false;
  223. }
  224. });
  225. },
  226. // 保存滚动值,这是兼容的写法
  227. handleScroll() {
  228. var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
  229. if (scrollTop >= 1200) {
  230. this.isActive = true
  231. } else {
  232. this.isActive = false
  233. }
  234. },
  235. },
  236. watch: {
  237. $route: 'getRoute'
  238. },
  239. created() {
  240. this.getRoute();
  241. this.getGoodsInfo('hot');
  242. },
  243. mounted() {
  244. window.addEventListener('scroll', this.handleScroll)
  245. },
  246. destroyed() {
  247. // 离开该页面需要移除这个监听的事件,不然会报错
  248. window.removeEventListener('scroll', this.handleScroll)
  249. }
  250. }
  251. </script>
  252. <style scoped>
  253. .index-nav {
  254. width: 180px;
  255. /* position: -webkit-sticky;
  256. position: sticky;
  257. top: 80px; */
  258. margin-right: 20px;
  259. height: -webkit-fit-content;
  260. height: -moz-fit-content;
  261. height: fit-content;
  262. /* max-height: calc(100vh - 101px); */
  263. /* overflow-x: hidden; */
  264. }
  265. .index-nav-top {
  266. /* top: 20px; */
  267. /* max-height: calc(100vh - 40px); */
  268. }
  269. li a {
  270. /* font-weight: bold; */
  271. color: #515767;
  272. }
  273. li a.router-link-active {
  274. color: #1e80ff;
  275. }
  276. .side-navigator-wrap {
  277. border-radius: 4px;
  278. background-color: #fff;
  279. min-width: 180px;
  280. box-sizing: border-box;
  281. padding: 8px;
  282. font-size: 16px;
  283. color: #515767;
  284. margin-bottom: 1.66rem;
  285. }
  286. .nav-item-wrap {
  287. display: flex;
  288. flex-direction: column;
  289. }
  290. .nav-item-content {
  291. line-height: 24px;
  292. border-radius: 4px;
  293. cursor: pointer;
  294. display: flex;
  295. flex-direction: row;
  296. align-items: center;
  297. justify-content: space-between;
  298. }
  299. .active {
  300. background-color: #eaf2ff;
  301. color: #1e80ff;
  302. font-weight: 500
  303. }
  304. .nav-item {
  305. display: inline-block;
  306. width: 100%;
  307. box-sizing: border-box;
  308. position: relative;
  309. padding: 10px 17px;
  310. }
  311. .nav-item i {
  312. vertical-align: middle;
  313. margin-right: 12px;
  314. }
  315. .nav-item-text {
  316. vertical-align: middle;
  317. position: relative;
  318. }
  319. /* .hot-list-container{
  320. margin-top: 20px
  321. } */
  322. .hot-list-item{
  323. border-radius: 4px;
  324. background-color: #fff;
  325. margin-bottom: 1.66rem;
  326. display: flex;
  327. flex-direction: column;
  328. flex: 1;
  329. padding: 12px 8px;
  330. overflow: hidden;
  331. }
  332. .hot-list-item .hot-item-header{
  333. display: flex;
  334. flex-direction: row;
  335. align-content: center;
  336. justify-content: space-between;
  337. margin-bottom: 0.5rem;
  338. align-items: center;
  339. padding: 0 8px;
  340. }
  341. .hot-list-item .hot-item-header .hot-title{
  342. font-weight: 500;
  343. font-size: 1rem;
  344. line-height: 2rem;
  345. display: flex;
  346. flex-direction: row;
  347. align-items: center;
  348. color: #252933;
  349. }
  350. .hot-list-item .hot-item-header .hot-icon{
  351. width: 1.33rem;
  352. height: 1.33rem;
  353. line-height: 0;
  354. margin-right: .66rem;
  355. }
  356. img {
  357. border-style: none;
  358. }
  359. .hot-list-item .divider {
  360. width: 100%;
  361. height: 1px;
  362. box-sizing: border-box;
  363. }
  364. .hot-list-item .divider .content {
  365. margin: 0 8px;
  366. height: 100%;
  367. background: rgba(228, 230, 235, 0.5);
  368. }
  369. .hot-list-item .hot-item-body {
  370. min-height: 7rem;
  371. }
  372. ul {
  373. padding: 0;
  374. margin: 0;
  375. }
  376. .hot-list-item .hot-item-body .hot-item-authors {
  377. height: 40px;
  378. }
  379. .hot-list-item .hot-item-body .hot-item {
  380. display: flex;
  381. flex-direction: column;
  382. align-items: center;
  383. padding: 8px;
  384. /* border-radius: 4px; */
  385. border-bottom: 1.5px solid #dcdfe6;
  386. font-size: 1.16rem;
  387. line-height: 1.83rem;
  388. }
  389. .hot-item-body .hot-item:last-child { border-bottom:none; }
  390. li {
  391. list-style: none;
  392. }
  393. .hot-list-item .hot-item-body .hot-item .body-index{
  394. width: 18px;
  395. height: 18px;
  396. font-size: 16px;
  397. border-radius: 50%;
  398. background-color: #f64242;
  399. display: flex;
  400. justify-content: center;
  401. align-items: center;
  402. color: #fff;
  403. }
  404. .hot-list-item .hot-item-body .hot-item .first-index{
  405. background: linear-gradient(180deg, #f64242 20%, rgba(246, 66, 66, .4) 80%);
  406. -webkit-background-clip: text;
  407. background-clip: text;
  408. color: transparent;
  409. }
  410. .hot-list-item .hot-item-body .hot-item .second-index{
  411. background: linear-gradient(180deg, #ff7426 20%, rgba(255, 116, 38, .4) 80%);
  412. -webkit-background-clip: text;
  413. background-clip: text;
  414. color: transparent;
  415. }
  416. .hot-list-item .hot-item-body .hot-item .third-index{
  417. background: linear-gradient(180deg, #ffac0c 20%, rgba(255, 172, 12, .4) 80%);
  418. -webkit-background-clip: text;
  419. background-clip: text;
  420. color: transparent;
  421. }
  422. .justifyCenter{
  423. justify-content: center;
  424. }
  425. .justifyBetween{
  426. justify-content: space-between;
  427. }
  428. .hot-list-item .hot-item-body .hot-item .hot-item-text{
  429. width: 160px;
  430. display: flex;
  431. align-items: center;
  432. }
  433. .hot-list-item .hot-item-body .hot-item .title-articles{
  434. font-size: 16px;
  435. color: red;
  436. font-weight: bold;
  437. }
  438. ::v-deep .el-radio-button__orig-radio:checked+.el-radio-button__inner {
  439. background-color: red;
  440. border-color: red;
  441. box-shadow: -1px 0 0 0 red;
  442. }
  443. ::v-deep .el-radio-button__inner:hover {
  444. color: #606266;
  445. }
  446. .sticky-block {
  447. width: 180px;
  448. background-color: transparent;
  449. box-sizing: border-box;
  450. position: fixed;
  451. box-shadow: none;
  452. opacity: 0;
  453. transition: all .2s;
  454. z-index: -1;
  455. top: 67px;
  456. pointer-events: none;
  457. }
  458. .index-nav.index-nav-top .sticky-block {
  459. opacity: 1;
  460. top: 20px;
  461. z-index: 5;
  462. pointer-events: all;
  463. }
  464. </style>