AppSidebar.vue 16 KB

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