RecommendPcb.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <template>
  2. <div class="wrap">
  3. <div class="reco-title">产品展示</div>
  4. <div class="recommend-fragment clearfix">
  5. <div v-if="!commodities || commodities.length === 0" class="empty-show">
  6. <div class="empty">
  7. <div class="empty-img">
  8. <img src="/images/brandList/empty-cart.jpg">
  9. </div>
  10. <div class="empty-info">
  11. <p class="grey f16"> 暂无展示产品</p>
  12. <i class="iconfont" v-if="emptyShow === false">&#xe610;</i>&nbsp;<a v-if="emptyShow === false" href="/">返回首页</a>
  13. <img v-if="emptyShow === true" src="/images/brandList/upload.png">&nbsp;<a v-if="emptyShow === true" href="/vendor#/store/maintain" target="_blank">马上去上传</a>
  14. </div>
  15. </div>
  16. </div>
  17. <div v-if="commodities.length>0">
  18. <div v-if="commodities.length<=4">
  19. <ul class="recommend-list clearfix">
  20. <li v-for="commodity in commodities.slice(0,3)" class="big">
  21. <a :href="commodity.batchCode ? '/store/productDetail/'+ commodity.batchCode : '#'" class="href">
  22. <div class="img">
  23. <img :src="commodity.comImg.startsWith('static')?'/'+commodity.comImg:commodity.comImg"/>
  24. </div>
  25. <div class="content">
  26. <p>{{commodity.comCode | comCodeFilter}}</p>
  27. <!-- <p class="color666" v-text="commodity.brandNameCn">PANFAEFQ</p>-->
  28. <p class="price" v-if="commodity.minPriceRMB">¥ {{commodity.minPriceRMB | currency}}</p>
  29. <!-- <p class="price" v-if="!commodity.minPriceRMB">$ {{commodity.minPriceUSD || 0}}</p>-->
  30. </div>
  31. </a>
  32. </li>
  33. </ul>
  34. </div>
  35. </div>
  36. <div v-swiper:mySwiper="swiperOption" v-if="commodities && commodities.length>3">
  37. <div class="swiper-wrapper">
  38. <div class="swiper-slide" v-if="commodities.length>0">
  39. <ul class="recommend-list clearfix">
  40. <li v-for="commodity in commodities.slice(0,4)" class="big">
  41. <a :href="commodity.batchCode ? '/store/productDetail/'+ commodity.batchCode : '#'" class="href">
  42. <div class="img">
  43. <img :src="commodity.comImg.startsWith('static')?'/'+commodity.comImg:commodity.comImg"/>
  44. </div>
  45. <div class="content">
  46. <p>{{commodity.comCode | comCodeFilter}}</p>
  47. <!-- <p class="color666" v-text="commodity.brandNameCn">PANFAEFQ</p>-->
  48. <p class="price" v-if="commodity.minPriceRMB">¥ {{commodity.minPriceRMB | currency}}</p>
  49. <!-- <p class="price" v-if="!commodity.minPriceRMB">$ {{commodity.minPriceUSD || 0}}</p>-->
  50. </div>
  51. </a>
  52. </li>
  53. </ul>
  54. </div>
  55. <div class="swiper-slide" v-if="commodities.length>4">
  56. <ul class="recommend-list clearfix">
  57. <li v-for="commodity in commodities.slice(4,8)" class="big">
  58. <a :href="commodity.batchCode ? '/store/productDetail/'+ commodity.batchCode : '#'" class="href">
  59. <div class="img">
  60. <img :src="commodity.comImg.startsWith('static')?'/'+commodity.comImg:commodity.comImg"/>
  61. </div>
  62. <div class="content">
  63. <p>{{commodity.comCode | comCodeFilter}}</p>
  64. <!-- <p class="color666" v-text="commodity.brandNameCn">PANFAEFQ</p>-->
  65. <p class="price" v-if="commodity.minPriceRMB">¥ {{commodity.minPriceRMB | currency}}</p>
  66. <!-- <p class="price" v-if="!commodity.minPriceRMB">$ {{commodity.minPriceUSD || 0}}</p>-->
  67. </div>
  68. </a>
  69. </li>
  70. </ul>
  71. </div>
  72. <div class="swiper-slide" v-if="commodities.length>8">
  73. <ul class="recommend-list clearfix">
  74. <li v-for="commodity in commodities.slice(8,12)" class="big">
  75. <a :href="commodity.batchCode ? '/store/productDetail/'+ commodity.batchCode : '#'" class="href">
  76. <div class="img">
  77. <img :src="commodity.comImg.startsWith('static')?'/'+commodity.comImg:commodity.comImg"/>
  78. </div>
  79. <div class="content">
  80. <p>{{commodity.comCode | comCodeFilter}}</p>
  81. <!-- <p class="color666" v-text="commodity.brandNameCn">PANFAEFQ</p>-->
  82. <p class="price" v-if="commodity.minPriceRMB">¥ {{commodity.minPriceRMB | currency}}</p>
  83. <!-- <p class="price" v-if="!commodity.minPriceRMB">$ {{commodity.minPriceUSD || 0}}</p>-->
  84. </div>
  85. </a>
  86. </li>
  87. </ul>
  88. </div>
  89. <div class="swiper-slide" v-if="commodities.length>12">
  90. <ul class="recommend-list clearfix">
  91. <li v-for="commodity in commodities.slice(12,16)" class="big">
  92. <a :href="commodity.batchCode ? '/store/productDetail/'+ commodity.batchCode : '#'" class="href">
  93. <div class="img">
  94. <img :src="commodity.comImg.startsWith('static')?'/'+commodity.comImg:commodity.comImg"/>
  95. </div>
  96. <div class="content">
  97. <p>{{commodity.comCode | comCodeFilter}}</p>
  98. <!-- <p class="color666" v-text="commodity.brandNameCn">PANFAEFQ</p>-->
  99. <p class="price" v-if="commodity.minPriceRMB">¥ {{commodity.minPriceRMB | currency}}</p>
  100. <!-- <p class="price" v-if="!commodity.minPriceRMB">$ {{commodity.minPriceUSD || 0}}</p>-->
  101. </div>
  102. </a>
  103. </li>
  104. </ul>
  105. </div>
  106. </div>
  107. <div class="swiper-pagination swiper-pagination-bullets"></div>
  108. </div>
  109. </div>
  110. </div>
  111. </template>
  112. <script>
  113. import Buy from '~components/common/buyOrCar/buyComponent.vue'
  114. import NuxtLink from '../../../.nuxt/components/nuxt-link'
  115. export default {
  116. name: 'recommend-product',
  117. components: {
  118. NuxtLink,
  119. Buy
  120. },
  121. computed: {
  122. commodities () {
  123. return this.$store.state.shop.recommend.products.data
  124. },
  125. storeInfo () {
  126. return this.$store.state.shop.storeInfo.store.data
  127. },
  128. isConsignment () {
  129. return this.storeInfo.type === 'CONSIGNMENT'
  130. },
  131. user() {
  132. return this.$store.state.option.user
  133. },
  134. storeStatus () {
  135. return this.$store.state.option.storeStatus.data
  136. },
  137. emptyShow () {
  138. let loggedStatus = false
  139. if (this.user.logged && this.user.data.enterprise.uu) {
  140. if (this.storeStatus.uuid === this.storeInfo.uuid) {
  141. loggedStatus = true
  142. } else {
  143. loggedStatus = false
  144. }
  145. } else {
  146. loggedStatus = false
  147. }
  148. return loggedStatus
  149. },
  150. // 产品推荐轮播
  151. swiperOption () {
  152. return {
  153. autoplay: 5000,
  154. initialSlide: 0,
  155. loop: true,
  156. effect: this.effect,
  157. lazyLoading: true,
  158. // 解决点击分页器后图片就不能轮播的问题
  159. autoplayDisableOnInteraction: false,
  160. pagination: '.swiper-pagination',
  161. paginationClickable: true,
  162. paginationElement: 'li'
  163. }
  164. }
  165. },
  166. filters: {
  167. comCodeFilter: function (title) {
  168. if (title === '') {
  169. return title
  170. }
  171. let len = 0
  172. let index = 0
  173. for (let i = 0; i < title.length; i++) {
  174. if (index === 0 && title.charAt(i).charCodeAt(0) > 255) {
  175. len = len + 2
  176. } else {
  177. len++
  178. }
  179. if (len > 18) {
  180. index = i
  181. break
  182. }
  183. }
  184. if (index > 0) {
  185. return title.substring(0, index) + '...'
  186. } else {
  187. return title
  188. }
  189. },
  190. currency: function (num) {
  191. if (typeof num === 'number') {
  192. if (num <= 0.000001) {
  193. num = 0.000001
  194. } else {
  195. if (num.toString().indexOf('.') === -1) {
  196. num += '.00'
  197. } else {
  198. let inputStr = num.toString()
  199. let arr = inputStr.split('.')
  200. let floatNum = arr[1]
  201. if (floatNum.length > 6) {
  202. num = inputStr.substring(0, arr[0].length + 7)
  203. if (Number(floatNum.charAt(6)) > 4) {
  204. num = (Number(num) * 1000000 + 1) / 1000000
  205. }
  206. } else if (floatNum.length === 1) {
  207. num = num + '0'
  208. }
  209. }
  210. }
  211. }
  212. return num
  213. }
  214. },
  215. methods: {
  216. enidfilter: function (str) {
  217. if (str) {
  218. let encryptStr = '' // 最终返回的加密后的字符串
  219. // 产生三位随机数
  220. let num = ''
  221. for (let i = 0; i < 3; i++) {
  222. num += Math.floor(Math.random() * 10)
  223. }
  224. encryptStr += num // 产生3位随机数
  225. // 16位加密
  226. let tempspit = ''
  227. let strspit = str.toString().toLowerCase()
  228. if (strspit.match(/^[-+]?\d*$/) === null) { // 非整数字符,对每一个字符都转换成16进制,然后拼接
  229. /**
  230. * Unicode汉字、英文字母、数字的unicode范围
  231. *汉字:[0x4e00,0x9fa5](或十进制[19968,40869])
  232. *数字:[0x30,0x39](或十进制[48, 57])
  233. *小写字母:[0x61,0x7a](或十进制[97, 122])
  234. *大写字母:[0x41,0x5a](或十进制[65, 90]
  235. * 'a'的Unicode编码:'&#97;',charCodeAt()的值是97
  236. * '码'的Unicode编码:'\u7801', new String('码').charCodeAt()的值是30721,30721的16进制表示是7801
  237. */
  238. let s = strspit.split('')
  239. for (let i = 0; i < s.length; i++) {
  240. s[i] = s[i].charCodeAt() // 先转换成Unicode编码
  241. s[i] = s[i].toString(16)
  242. // 因为在服务器是每两位当做一个字符进行解析的,所以这里每个字符的Unicode编码范围必须在0——255之间。数字和大小写满足该要求,特殊字符则不一定,如果后续有特殊字符的要求,需要重写编码器和解码器
  243. if (s[i].length === 1) {
  244. s[i] = '0' + s[i]
  245. }
  246. tempspit = tempspit + s[i]
  247. }
  248. tempspit = tempspit + '{' + 1 // 1代表字符
  249. } else { // 数字直接转换成16进制
  250. strspit = parseInt(strspit)
  251. .toString(16)
  252. tempspit = strspit + '{' + 0 // 0代表纯数字
  253. }
  254. let temp = tempspit.split('{') // 对要加密的字符转换成16进制
  255. let numLength = temp[0].length // 转换后的字符长度
  256. numLength = numLength.toString(16) // 字符长度换算成16进制
  257. if (numLength.length === 1) { // 如果是1,补一个0
  258. numLength = '0' + numLength
  259. } else if (numLength.length > 3) { // 转换后的16进制字符长度如果大于2位数,则返回,不支持
  260. return ''
  261. }
  262. encryptStr += numLength
  263. if (temp[1] === '0') {
  264. encryptStr += 0
  265. } else if (temp[1] === '1') {
  266. encryptStr += 1
  267. }
  268. encryptStr += temp[0]
  269. if (encryptStr.length < 20) { // 如果小于20位,补上随机数
  270. // 产生三位随机数
  271. let numtwo = ''
  272. for (let i = 0; i < 20 - encryptStr.length; i++) {
  273. numtwo += Math.floor(Math.random() * 10)
  274. }
  275. let ran = numtwo // 产生3位随机数
  276. encryptStr += ran
  277. }
  278. return encryptStr
  279. }
  280. }
  281. }
  282. }
  283. </script>
  284. <style lang="scss" scoped>
  285. .wrap {
  286. background: #ece9ec;
  287. padding-top: 7px;
  288. width: 100%;
  289. .reco-title {
  290. border-bottom: 1px solid #2496f1;
  291. width: 218px;
  292. height: 34px;
  293. line-height: 34px;
  294. color: #fff;
  295. background: #2496f1;
  296. font-size: 18px;
  297. text-align: center;
  298. border-top-left-radius: 3px;
  299. border-top-right-radius: 3px;
  300. margin: 0;
  301. }
  302. }
  303. .recommend-fragment {
  304. background: #fff;
  305. .empty-show{
  306. height: 530px;
  307. padding-top: 140px;
  308. &:hover{
  309. box-shadow: 0px 0px 0px transparent;
  310. }
  311. .empty{
  312. margin: 0 auto;
  313. width: 181px;
  314. .empty-img{
  315. float: left;
  316. }
  317. .empty-info{
  318. float: left;
  319. margin: 5px 0px 0px 20px;
  320. .grey{
  321. color: #999;
  322. font-size: 14px;
  323. }
  324. i{
  325. color: #5078cb;
  326. }
  327. a{
  328. font-size: 14px;
  329. color: #5078cb;
  330. }
  331. }
  332. }
  333. }
  334. }
  335. .recommend-fragment ul{
  336. width: 100%;
  337. background: #fff;
  338. /* display: inline-block;*/
  339. -webkit-padding-start: 0;
  340. border-radius: 5px;
  341. /*padding-left: 2px;*/
  342. margin: 10px 0;
  343. padding: 0 15px;
  344. }
  345. .recommend-fragment ul li
  346. .img{
  347. height: 42px;
  348. text-align: center;
  349. line-height: 42px;
  350. img{
  351. max-width: 63px;
  352. max-height: 42px;
  353. }
  354. }
  355. .recommend-fragment ul li .content{
  356. width: 100%;
  357. margin: 0 auto;
  358. font-size: 12px;
  359. p{
  360. width: 100%;
  361. text-align: center;
  362. display: inline-block;
  363. line-height: 22px;
  364. overflow: hidden;
  365. text-overflow: ellipsis;
  366. white-space: nowrap;
  367. margin: 5px 0;
  368. padding-left: 10px;
  369. color: #666;
  370. &.price{
  371. color: #ff002e;
  372. margin-top: -3px;
  373. }
  374. }
  375. }
  376. .recommend-fragment ul li .enter-store {
  377. position: absolute;
  378. top: 178px;
  379. width: 100%;
  380. height: 30px;
  381. line-height: 30px;
  382. text-align: left;
  383. }
  384. .recommend-fragment ul li.big .enter-store a {
  385. width: 74px;
  386. height: 24px;
  387. display: inline-block;
  388. line-height: 24px;
  389. text-align: center;
  390. font-size: 13px;
  391. margin-left: 14px;
  392. border-radius: 3px;
  393. &:first-child {
  394. background-color: #fff;
  395. border: 1px solid #3b7cf4;
  396. color: #3b7cf4;
  397. }
  398. &:last-child {
  399. background-color: #ffa422;
  400. border: 1px solid #ffa422;
  401. color: #fff;
  402. }
  403. /*&:visited{
  404. .enter-store {
  405. top: 140px;
  406. left: 0px;
  407. }
  408. }*/
  409. }
  410. .recommend-fragment ul li.big {
  411. float: left;
  412. width: 190px;
  413. height: 125px;
  414. position: relative;
  415. overflow: hidden;
  416. margin: 2px 3px 0px 0px;
  417. &:nth-child(5n){
  418. margin: 2px 0px 0px 0px;
  419. }
  420. &:hover{
  421. /*box-shadow: 2px 0px 1px #d9d9d9, -2px 0px 1px #d9d9d9, 0px 2px 1px #d9d9d9, 0px -2px 1px #d9d9d9;*/
  422. .enter-store {
  423. top: 132px;
  424. left: 0px;
  425. transition: all .3s linear;
  426. }
  427. .img, .content{
  428. transform:translate(0px,-10px);
  429. -ms-transform:translate(0px,-10px); /* IE 9 */
  430. -webkit-transform:translate(0px,-10px); /* Safari and Chrome */
  431. }
  432. }
  433. }
  434. /*.recommend-fragment ul li.small .enter-store a {
  435. width: 74px;
  436. height: 24px;
  437. display: inline-block;
  438. line-height: 22px;
  439. text-align: center;
  440. font-size: 12px;
  441. margin-left: 11px;
  442. border-radius: 3px;
  443. &:first-child {
  444. background-color: #fff;
  445. border: solid 1px #3b7cf4;
  446. color: #3c7df5;
  447. }
  448. &:last-child {
  449. background-color: #ffa422;
  450. border: 1px solid #ffa422;
  451. color: #fff;
  452. }
  453. }
  454. .recommend-fragment ul li.small {
  455. float: left;
  456. width: 180px;
  457. height: 174px;
  458. position: relative;
  459. overflow: hidden;
  460. margin: 2px 8px 0px 0px;
  461. &:nth-child(5n){
  462. margin: 2px 0px 0px 0px;
  463. }
  464. &:hover, &:focus, &:active &:visited{
  465. box-shadow: 2px 0px 1px #d9d9d9, -2px 0px 1px #d9d9d9, 0px 2px 1px #d9d9d9, 0px -2px 1px #d9d9d9;
  466. .enter-store {
  467. top: 140px;
  468. left: 0px;
  469. transition: all .5s;
  470. }
  471. .img, .content{
  472. transform:translate(0px,-10px);
  473. -ms-transform:translate(0px,-10px); !* IE 9 *!
  474. -webkit-transform:translate(0px,-10px); !* Safari and Chrome *!
  475. }
  476. }
  477. }*/
  478. .recommend-fragment ul li.empty-show {
  479. width: 100%;
  480. height: 356px;
  481. padding-top: 150px;
  482. &:hover{
  483. box-shadow: 0px 0px 0px transparent;
  484. }
  485. .empty{
  486. margin: 0 auto;
  487. width: 181px;
  488. .empty-img{
  489. float: left;
  490. }
  491. .empty-info{
  492. float: left;
  493. margin: 5px 0px 0px 20px;
  494. .grey{
  495. color: #999;
  496. font-size: 14px;
  497. }
  498. i{
  499. color: #5078cb;
  500. }
  501. a{
  502. font-size: 14px;
  503. color: #5078cb;
  504. }
  505. }
  506. }
  507. }
  508. .shadow {
  509. width: 1190px;
  510. margin: 0 auto;
  511. position: relative;
  512. img {
  513. position: absolute;
  514. top: -12px;
  515. }
  516. }
  517. </style>