AppSidebar.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  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. {{ item.redeemPoints }} 积分
  57. <span v-if="item.wxPay!='0'"> + {{ item.wxPay }} 元</span>
  58. </div>
  59. </div>
  60. </li>
  61. </div>
  62. </ul>
  63. </div>
  64. </div>
  65. <div class="hot-list-container sticky-block">
  66. <div class="hot-list-item">
  67. <!-- <div class="hot-item-header">
  68. <div class="hot-title">
  69. <img src="../assets/image/hot.png"
  70. type="icon" alt="icon" class="hot-icon">
  71. <span title="热门商品" class="title-text">热门商品</span>
  72. </div>
  73. </div>
  74. <div class="divider" style="margin-bottom: 4px;">
  75. <div class="content"></div>
  76. </div> -->
  77. <el-radio-group v-model="tabType" size="small" @change="tabChange">
  78. <el-radio-button label="hot">热门商品</el-radio-button>
  79. <el-radio-button label="new">商城新品</el-radio-button>
  80. </el-radio-group>
  81. <ul class="hot-item-body">
  82. <div class="skeleton">
  83. <li v-for="(item,index) in goodsList" :key="index" class="hot-item" style="cursor: pointer;" @click="handleClickExchange(item.skuId)">
  84. <!-- <a href="/home/pointsMall"> -->
  85. <img style="width: 150px;height: 150px;" :src="item.imgUrl" alt="">
  86. <!-- </a> -->
  87. <div class="hot-item-text" :class="tabType=='new'?'justifyCenter':'justifyBetween'">
  88. <div class="body-index" v-if="tabType=='hot'">
  89. {{ index + 1 }}
  90. </div>
  91. <div class="title-articles">
  92. <!-- ¥{{ item.price }} -->
  93. {{ item.redeemPoints }} 积分
  94. <span v-if="item.wxPay!='0'"> + {{ item.wxPay }} 元</span>
  95. </div>
  96. </div>
  97. </li>
  98. </div>
  99. </ul>
  100. </div>
  101. </div>
  102. </div>
  103. </template>
  104. <script>
  105. import { removeTab } from '@/utils/auth'
  106. import { hotSkuList,newSkuList } from "@/api/allApi";
  107. import { mapGetters } from 'vuex'
  108. export default {
  109. name: 'AppSidebar',
  110. computed: {
  111. // 将 getter 映射到当前组件的计算属性
  112. ...mapGetters(['userInfo'])
  113. },
  114. data() {
  115. return {
  116. tabType:'hot',
  117. goodsList:[],
  118. sideBarList: [
  119. {
  120. value: 'index',
  121. name: '首页',
  122. path: '/home/index',
  123. icon: 'icon-mall-tongzhi',
  124. checked: false,
  125. },
  126. {
  127. value: 'douYinYeZhanZan',
  128. name: '抖音叶盏点赞',
  129. path: '/home/douYinYeZhanZan',
  130. icon: 'icon-mall-xunzhang',
  131. checked: false,
  132. },
  133. {
  134. value: 'pointsMall',
  135. name: '积分商城',
  136. path: '/home/pointsMall',
  137. icon: 'icon-mall-jifenshangcheng',
  138. checked: false,
  139. },
  140. {
  141. value: 'signIn',
  142. name: '每日签到',
  143. path: '/home/signIn',
  144. icon: 'icon-mall-qiandao',
  145. checked: false,
  146. },
  147. {
  148. value: 'festiveEvents',
  149. name: '活动列表',
  150. path: '/home/festiveEvents',
  151. icon: 'icon-mall-huodong',
  152. checked: false,
  153. },
  154. // {
  155. // value:'myMedal',
  156. // name:'我的勋章',
  157. // path:'/home/myMedal',
  158. // icon:'icon-mall-xunzhang',
  159. // checked:false,
  160. // },
  161. {
  162. value: 'commend',
  163. name: '员工表彰',
  164. path: '/home/commend',
  165. icon: 'icon-mall-rongyubiaozhang',
  166. checked: false,
  167. },
  168. {
  169. value: 'welfareList',
  170. name: '福利领取',
  171. path: '/home/welfareList',
  172. icon: 'icon-mall-hongbao',
  173. checked: false,
  174. },
  175. {
  176. value: 'earnPoints',
  177. name: '积分获取',
  178. path: '/home/earnPoints',
  179. icon: 'icon-mall-zuorenwuzhuanjifen',
  180. checked: false,
  181. },
  182. {
  183. value: 'postInteract',
  184. name: '投票调研',
  185. path: '/home/postInteract',
  186. icon: 'icon-mall-neibuzhengyiguanli',
  187. checked: false,
  188. },
  189. // {
  190. // value:'myCenter',
  191. // name:'个人中心',
  192. // path:'/home/myCenter',
  193. // icon:'icon-mall-gerenzhongxin',
  194. // checked:false,
  195. // },
  196. ],
  197. sideBarList1: [
  198. {
  199. value: 'index',
  200. name: '首页',
  201. path: '/home/index',
  202. icon: 'icon-mall-tongzhi',
  203. checked: false,
  204. },
  205. {
  206. value: 'pointsMall',
  207. name: '积分商城',
  208. path: '/home/pointsMall',
  209. icon: 'icon-mall-jifenshangcheng',
  210. checked: false,
  211. },
  212. {
  213. value: 'welfareList',
  214. name: '福利领取',
  215. path: '/home/welfareList',
  216. icon: 'icon-mall-hongbao',
  217. checked: false,
  218. },
  219. ],
  220. employeeDynamics: false,
  221. pointsMall: false,
  222. welfareList: false,
  223. festiveEvents: false,
  224. isActive: false,
  225. };
  226. },
  227. methods: {
  228. handleClickExchange(id) {
  229. this.$router.push({
  230. path: '/home/pointsMall/redeem',
  231. query: {
  232. id: id,
  233. name: 'goodsNotice',
  234. type:36,
  235. }
  236. });
  237. },
  238. tabChange(val){
  239. this.getGoodsInfo(val);
  240. },
  241. getGoodsInfo(val){
  242. if(val=='hot'){
  243. hotSkuList().then(response=>{
  244. this.goodsList = response.data.data.list;
  245. });
  246. }else{
  247. newSkuList().then(response=>{
  248. this.goodsList = response.data.data.list;
  249. });
  250. }
  251. },
  252. removeTab() {
  253. removeTab();
  254. },
  255. getRoute() {
  256. var path = this.$route.path;
  257. this.sideBarList.forEach(item => {
  258. if (path.indexOf(item.value) != -1) {
  259. item.checked = true;
  260. } else {
  261. item.checked = false;
  262. }
  263. });
  264. },
  265. // 保存滚动值,这是兼容的写法
  266. handleScroll() {
  267. var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
  268. if (scrollTop >= 1200) {
  269. this.isActive = true
  270. } else {
  271. this.isActive = false
  272. }
  273. },
  274. },
  275. watch: {
  276. $route: 'getRoute'
  277. },
  278. created() {
  279. this.getRoute();
  280. this.getGoodsInfo('hot');
  281. },
  282. mounted() {
  283. window.addEventListener('scroll', this.handleScroll)
  284. },
  285. destroyed() {
  286. // 离开该页面需要移除这个监听的事件,不然会报错
  287. window.removeEventListener('scroll', this.handleScroll)
  288. }
  289. }
  290. </script>
  291. <style scoped>
  292. .index-nav {
  293. width: 180px;
  294. /* position: -webkit-sticky;
  295. position: sticky;
  296. top: 80px; */
  297. margin-right: 20px;
  298. height: -webkit-fit-content;
  299. height: -moz-fit-content;
  300. height: fit-content;
  301. /* max-height: calc(100vh - 101px); */
  302. /* overflow-x: hidden; */
  303. }
  304. .index-nav-top {
  305. /* top: 20px; */
  306. /* max-height: calc(100vh - 40px); */
  307. }
  308. li a {
  309. /* font-weight: bold; */
  310. color: #515767;
  311. }
  312. li a.router-link-active {
  313. color: #1e80ff;
  314. }
  315. .side-navigator-wrap {
  316. border-radius: 4px;
  317. background-color: #fff;
  318. min-width: 180px;
  319. box-sizing: border-box;
  320. padding: 8px;
  321. font-size: 16px;
  322. color: #515767;
  323. margin-bottom: 1.66rem;
  324. }
  325. .nav-item-wrap {
  326. display: flex;
  327. flex-direction: column;
  328. }
  329. .nav-item-content {
  330. line-height: 24px;
  331. border-radius: 4px;
  332. cursor: pointer;
  333. display: flex;
  334. flex-direction: row;
  335. align-items: center;
  336. justify-content: space-between;
  337. }
  338. .active {
  339. background-color: #eaf2ff;
  340. color: #1e80ff;
  341. font-weight: 500
  342. }
  343. .nav-item {
  344. display: inline-block;
  345. width: 100%;
  346. box-sizing: border-box;
  347. position: relative;
  348. padding: 10px 17px;
  349. }
  350. .nav-item i {
  351. vertical-align: middle;
  352. margin-right: 12px;
  353. }
  354. .nav-item-text {
  355. vertical-align: middle;
  356. position: relative;
  357. }
  358. /* .hot-list-container{
  359. margin-top: 20px
  360. } */
  361. .hot-list-item{
  362. border-radius: 4px;
  363. background-color: #fff;
  364. margin-bottom: 1.66rem;
  365. display: flex;
  366. flex-direction: column;
  367. flex: 1;
  368. padding: 12px 8px;
  369. overflow: hidden;
  370. }
  371. .hot-list-item .hot-item-header{
  372. display: flex;
  373. flex-direction: row;
  374. align-content: center;
  375. justify-content: space-between;
  376. margin-bottom: 0.5rem;
  377. align-items: center;
  378. padding: 0 8px;
  379. }
  380. .hot-list-item .hot-item-header .hot-title{
  381. font-weight: 500;
  382. font-size: 1rem;
  383. line-height: 2rem;
  384. display: flex;
  385. flex-direction: row;
  386. align-items: center;
  387. color: #252933;
  388. }
  389. .hot-list-item .hot-item-header .hot-icon{
  390. width: 1.33rem;
  391. height: 1.33rem;
  392. line-height: 0;
  393. margin-right: .66rem;
  394. }
  395. img {
  396. border-style: none;
  397. }
  398. .hot-list-item .divider {
  399. width: 100%;
  400. height: 1px;
  401. box-sizing: border-box;
  402. }
  403. .hot-list-item .divider .content {
  404. margin: 0 8px;
  405. height: 100%;
  406. background: rgba(228, 230, 235, 0.5);
  407. }
  408. .hot-list-item .hot-item-body {
  409. min-height: 7rem;
  410. }
  411. ul {
  412. padding: 0;
  413. margin: 0;
  414. }
  415. .hot-list-item .hot-item-body .hot-item-authors {
  416. height: 40px;
  417. }
  418. .hot-list-item .hot-item-body .hot-item {
  419. display: flex;
  420. flex-direction: column;
  421. align-items: center;
  422. padding: 8px;
  423. /* border-radius: 4px; */
  424. border-bottom: 1.5px solid #dcdfe6;
  425. font-size: 1.16rem;
  426. line-height: 1.83rem;
  427. }
  428. .hot-item-body .hot-item:last-child { border-bottom:none; }
  429. li {
  430. list-style: none;
  431. }
  432. .hot-list-item .hot-item-body .hot-item .body-index{
  433. width: 16px;
  434. height: 16px;
  435. font-size: 12px;
  436. border-radius: 50%;
  437. background-color: #f64242;
  438. display: flex;
  439. justify-content: center;
  440. align-items: center;
  441. color: #fff;
  442. }
  443. .hot-list-item .hot-item-body .hot-item .first-index{
  444. background: linear-gradient(180deg, #f64242 20%, rgba(246, 66, 66, .4) 80%);
  445. -webkit-background-clip: text;
  446. background-clip: text;
  447. color: transparent;
  448. }
  449. .hot-list-item .hot-item-body .hot-item .second-index{
  450. background: linear-gradient(180deg, #ff7426 20%, rgba(255, 116, 38, .4) 80%);
  451. -webkit-background-clip: text;
  452. background-clip: text;
  453. color: transparent;
  454. }
  455. .hot-list-item .hot-item-body .hot-item .third-index{
  456. background: linear-gradient(180deg, #ffac0c 20%, rgba(255, 172, 12, .4) 80%);
  457. -webkit-background-clip: text;
  458. background-clip: text;
  459. color: transparent;
  460. }
  461. .justifyCenter{
  462. justify-content: center;
  463. }
  464. .justifyBetween{
  465. justify-content: space-between;
  466. }
  467. .hot-list-item .hot-item-body .hot-item .hot-item-text{
  468. width: 160px;
  469. display: flex;
  470. align-items: center;
  471. }
  472. .hot-list-item .hot-item-body .hot-item .title-articles{
  473. font-size: 12px;
  474. color: red;
  475. font-weight: bold;
  476. }
  477. ::v-deep .el-radio-button__orig-radio:checked+.el-radio-button__inner {
  478. background-color: red;
  479. border-color: red;
  480. box-shadow: -1px 0 0 0 red;
  481. }
  482. ::v-deep .el-radio-button__inner:hover {
  483. color: #606266;
  484. }
  485. .sticky-block {
  486. width: 180px;
  487. background-color: transparent;
  488. box-sizing: border-box;
  489. position: fixed;
  490. box-shadow: none;
  491. opacity: 0;
  492. transition: all .2s;
  493. z-index: -1;
  494. top: 67px;
  495. pointer-events: none;
  496. }
  497. .index-nav.index-nav-top .sticky-block {
  498. opacity: 1;
  499. top: 20px;
  500. z-index: 5;
  501. pointer-events: all;
  502. }
  503. </style>