NsAside.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <aside class="main-sidebar clearfix">
  3. <div class="main-sidebar-body">
  4. <ul>
  5. <li @click="$router.push('/goods/cart')">
  6. <div class="li-item">
  7. <img src="~/assets/images/index/index_card.png" />
  8. <span>购物车</span>
  9. <em v-show="cartCount">{{ cartCount }}</em>
  10. </div>
  11. </li>
  12. <li class="mobile">
  13. <div class="mobile-qrcode-wrap">
  14. <div class="mobile-qrcode" v-if="qrcode">
  15. <img :src="$img(qrcode)" />
  16. </div>
  17. </div>
  18. <div class="li-item">
  19. <img src="~/assets/images/index/index_code.png" />
  20. <span>手机购买</span>
  21. </div>
  22. </li>
  23. <li class="kefuTip" v-if="serviceConfig.type != 'none'">
  24. <div class="li-item" @click="showServiceFn()">
  25. <img src="~/assets/images/index/index_service.png" />
  26. <span>联系客服</span>
  27. </div>
  28. </li>
  29. <li @click="$router.push('/member')">
  30. <div class="li-item">
  31. <img src="~/assets/images/index/index_member.png" />
  32. <span>会员中心</span>
  33. </div>
  34. </li>
  35. </ul>
  36. <div :class="['back-top',{ showBtn: visible }]" @click="toTop">
  37. <img src="~/assets/images/index/index_top.png">
  38. <span>回到顶部</span>
  39. </div>
  40. </div>
  41. <div class="main-sidebar-right">
  42. <div id="mainSidebarHistoryProduct" class="history-product"></div>
  43. </div>
  44. <!--联系客服弹窗-->
  45. <servicerMessage ref="servicer" class="kefu" :shop="{shop_id:0,logo:siteInfo.logo,shop_name:'平台客服'}">
  46. </servicerMessage>
  47. </aside>
  48. </template>
  49. <script>
  50. import servicerMessage from '@/components/message/servicerMessage.vue'
  51. import {
  52. mapGetters
  53. } from "vuex"
  54. import {
  55. shopServiceOpen
  56. } from "@/api/website.js"
  57. export default {
  58. props: {},
  59. data() {
  60. return {
  61. visible: false,
  62. hackReset: false,
  63. serviceConfig: {
  64. type: 'nome'
  65. },
  66. }
  67. },
  68. components: {
  69. servicerMessage
  70. },
  71. computed: {
  72. ...mapGetters(["wapQrcode","cartCount", "siteInfo", 'member']),
  73. qrcode: function() {
  74. return this.wapQrcode === "" ? "" : this.wapQrcode.path.h5.img
  75. },
  76. logined: function() {
  77. return this.member !== undefined && this.member !== "" && this.member !== {}
  78. }
  79. },
  80. created() {
  81. this.$store.dispatch("site/qrCodes");
  82. this.shopServiceOpen();
  83. },
  84. mounted() {
  85. window.addEventListener("scroll", this.handleScroll)
  86. },
  87. beforeDestroy() {
  88. window.removeEventListener("scroll", this.handleScroll)
  89. },
  90. watch: {},
  91. methods: {
  92. handleScroll() {
  93. this.visible = window.pageYOffset > 300
  94. },
  95. shopServiceOpen() {
  96. shopServiceOpen().then((res) => {
  97. if (res.code == 0) {
  98. this.serviceConfig = res.data.pc;
  99. }
  100. })
  101. },
  102. toTop() {
  103. let timer = setInterval(function() {
  104. let osTop = document.documentElement.scrollTop || document.body.scrollTop
  105. let ispeed = Math.floor(-osTop / 5)
  106. document.documentElement.scrollTop = document.body.scrollTop = osTop + ispeed
  107. this.isTop = true
  108. if (osTop === 0) {
  109. clearInterval(timer)
  110. }
  111. }, 20)
  112. },
  113. // 打开客服弹窗
  114. showServiceFn() {
  115. if (this.logined) {
  116. switch (this.serviceConfig.type) {
  117. case 'third':
  118. window.open(this.serviceConfig.third_url, "_blank");
  119. break;
  120. case 'niushop':
  121. this.hackReset = true;
  122. this.$refs.servicer.show()
  123. break;
  124. }
  125. } else {
  126. this.$message({
  127. message: "您还未登录",
  128. type: "warning"
  129. })
  130. }
  131. }
  132. },
  133. }
  134. </script>
  135. <style scoped lang="scss">
  136. // 公共代码部分
  137. %flex-center{
  138. display: flex;
  139. flex-direction: column;
  140. justify-content: center;
  141. align-items: center;
  142. }
  143. %li-temp{
  144. cursor: pointer;
  145. img{
  146. width: 23px;
  147. height: 23px;
  148. }
  149. span {
  150. margin-top: 9px;
  151. color: #000;
  152. line-height: 1;
  153. font-size: 12px;
  154. }
  155. }
  156. %arrows{
  157. &::after {
  158. content: "";
  159. position: absolute;
  160. right: 0px;
  161. top: 50%;
  162. transform: translate(-8px, -50%) rotate(45deg);
  163. height: 10px;
  164. width: 10px;
  165. background-color: #ff4649;
  166. }
  167. }
  168. // 具体代码
  169. .main-sidebar {
  170. position: fixed;
  171. top: 50%;
  172. transform: translateY(-50%);
  173. right: 148px;
  174. z-index: 400;
  175. .main-sidebar-body {
  176. ul {
  177. width: 88px;
  178. background-color: #fff;
  179. box-shadow: 0px 2px 12px 0px rgba(102, 128, 153, 0.16);
  180. border-radius: 8px;
  181. padding: 2px 0;
  182. li {
  183. .li-item {
  184. @extend %flex-center;
  185. position: relative;
  186. height: 85px;
  187. text-align: center;
  188. @extend %li-temp;
  189. em {
  190. position: absolute;
  191. top: 10px;
  192. right: 19px;
  193. min-width: 17px;
  194. height: 15px;
  195. line-height: 15px;
  196. display: inline-block;
  197. padding: 0 2px;
  198. color: #ffffff;
  199. font-size: 10px;
  200. font-style: normal;
  201. text-align: center;
  202. border-radius: 8px;
  203. background-color: $base-color;
  204. }
  205. &::after{
  206. content: "";
  207. position: absolute;
  208. left: 50%;
  209. transform: translateX(-50%);
  210. bottom: 0;
  211. width: 60px;
  212. height: 1px;
  213. background: #ECECEC;
  214. }
  215. }
  216. &:last-of-type > .li-item::after{
  217. background-color: transparent;
  218. }
  219. &.kefuTip{
  220. position: relative;
  221. }
  222. &.mobile{
  223. position: relative;
  224. .mobile-qrcode-wrap{
  225. display: none;
  226. position: absolute;
  227. left: -160px;
  228. top: -28px;
  229. }
  230. .mobile-qrcode{
  231. position: relative;
  232. margin-right: 10px;
  233. width: 150px;
  234. height: 150px;
  235. padding: 10px;
  236. background-color: #fff;
  237. border: 8px;
  238. box-sizing: border-box;
  239. box-shadow: 0px 2px 12px 0px rgba(102, 128, 153, 0.16);
  240. @extend %arrows;
  241. &::after{
  242. right: -13px;
  243. background-color: #fff;
  244. box-shadow: 0px 2px 12px 0px rgba(102, 128, 153, 0.16);
  245. }
  246. }
  247. &:hover .mobile-qrcode-wrap{
  248. display: block;
  249. img{
  250. width: 100%;
  251. height: 100%;
  252. }
  253. }
  254. }
  255. }
  256. }
  257. a,
  258. .cart,
  259. .el-button {
  260. width: 40px;
  261. height: 40px;
  262. line-height: 40px;
  263. display: block;
  264. margin-bottom: 10px;
  265. color: #ffffff;
  266. text-align: center;
  267. -webkit-transition: background-color 0.3s;
  268. transition: background-color 0.3s;
  269. padding: 0;
  270. border: none;
  271. background: transparent;
  272. &:hover {
  273. background-color: $base-color;
  274. }
  275. }
  276. .back-top {
  277. @extend %flex-center;
  278. display: none;
  279. margin-top: 10px;
  280. width: 88px;
  281. height: 88px;
  282. background-color: #fff;
  283. box-shadow: 0px 2px 12px 0px rgba(102, 128, 153, 0.16);
  284. border-radius: 8px;
  285. @extend %li-temp;
  286. }
  287. .showBtn {
  288. display: flex;
  289. opacity: 1;
  290. cursor: pointer;
  291. }
  292. i {
  293. font-size: 16px;
  294. }
  295. }
  296. }
  297. @media screen and (max-width: 1750px) {
  298. .main-sidebar {
  299. right: 100px;
  300. }
  301. }
  302. @media screen and (max-width: 1620px) {
  303. .main-sidebar {
  304. right: 10px;
  305. }
  306. }
  307. .kefuTip .tip {
  308. display: none;
  309. }
  310. .kefuTip:hover .tip {
  311. display: block;
  312. position: absolute;
  313. right: 85px;
  314. top: -20px;
  315. .tip_item {
  316. border-top-left-radius: 118px;
  317. border-top-right-radius: 118px;
  318. margin-right: 13px;
  319. width: 100px;
  320. background: #FF4649;
  321. color: #fff;
  322. padding-bottom: 1px;
  323. @extend %arrows;
  324. }
  325. .kefu_logo {
  326. width: 78px;
  327. margin: 0 auto 10px;
  328. border-radius: 50%;
  329. img {
  330. margin-top: 14px;
  331. background: linear-gradient(to top right, #e4e4e4, #FFF);
  332. border-radius: 50%;
  333. width: 100%;
  334. height: 78px
  335. }
  336. }
  337. .text {
  338. padding: 0 !important;
  339. background: #fff;
  340. margin: 0 10px 10px;
  341. color: #FF4649;
  342. border-radius: 3px;
  343. text-align: center;
  344. line-height: 30px;
  345. }
  346. }
  347. </style>