RecommendList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  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<=3">
  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,3)" 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>3">
  56. <ul class="recommend-list clearfix">
  57. <li v-for="commodity in commodities.slice(3,6)" 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>6">
  73. <ul class="recommend-list clearfix">
  74. <li v-for="commodity in commodities.slice(6,9)" 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>9">
  90. <ul class="recommend-list clearfix">
  91. <li v-for="commodity in commodities.slice(9,12)" 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. height: 409px;
  290. .reco-title {
  291. border-bottom: 1px solid #2496f1;
  292. width: 218px;
  293. height: 34px;
  294. line-height: 34px;
  295. color: #fff;
  296. background: #2496f1;
  297. font-size: 18px;
  298. text-align: center;
  299. border-top-left-radius: 3px;
  300. border-top-right-radius: 3px;
  301. margin: 0;
  302. }
  303. }
  304. .recommend-fragment {
  305. background: #fff;
  306. .empty-show{
  307. height: 381px;
  308. padding-top: 140px;
  309. &:hover{
  310. box-shadow: 0px 0px 0px transparent;
  311. }
  312. .empty{
  313. margin: 0 auto;
  314. width: 181px;
  315. .empty-img{
  316. float: left;
  317. }
  318. .empty-info{
  319. float: left;
  320. margin: 5px 0px 0px 20px;
  321. .grey{
  322. color: #999;
  323. font-size: 14px;
  324. }
  325. i{
  326. color: #5078cb;
  327. }
  328. a{
  329. font-size: 14px;
  330. color: #5078cb;
  331. }
  332. }
  333. }
  334. }
  335. }
  336. .recommend-fragment ul{
  337. width: 100%;
  338. height: 360px;
  339. background: #fff;
  340. /* display: inline-block;*/
  341. -webkit-padding-start: 0;
  342. border-radius: 5px;
  343. /*padding-left: 2px;*/
  344. margin: 10px 0;
  345. padding: 0 15px;
  346. }
  347. .recommend-fragment ul li
  348. .img{
  349. height: 42px;
  350. text-align: center;
  351. line-height: 42px;
  352. img{
  353. max-width: 63px;
  354. max-height: 42px;
  355. }
  356. }
  357. .recommend-fragment ul li .content{
  358. width: 100%;
  359. margin: 0 auto;
  360. font-size: 12px;
  361. p{
  362. width: 100%;
  363. text-align: center;
  364. display: inline-block;
  365. line-height: 22px;
  366. overflow: hidden;
  367. text-overflow: ellipsis;
  368. white-space: nowrap;
  369. margin: 5px 0;
  370. padding-left: 10px;
  371. color: #666;
  372. &.price{
  373. color: #ff002e;
  374. margin-top: -3px;
  375. }
  376. }
  377. }
  378. .recommend-fragment ul li .enter-store {
  379. position: absolute;
  380. top: 178px;
  381. width: 100%;
  382. height: 30px;
  383. line-height: 30px;
  384. text-align: left;
  385. }
  386. .recommend-fragment ul li.big .enter-store a {
  387. width: 74px;
  388. height: 24px;
  389. display: inline-block;
  390. line-height: 24px;
  391. text-align: center;
  392. font-size: 13px;
  393. margin-left: 14px;
  394. border-radius: 3px;
  395. &:first-child {
  396. background-color: #fff;
  397. border: 1px solid #3b7cf4;
  398. color: #3b7cf4;
  399. }
  400. &:last-child {
  401. background-color: #ffa422;
  402. border: 1px solid #ffa422;
  403. color: #fff;
  404. }
  405. /*&:visited{
  406. .enter-store {
  407. top: 140px;
  408. left: 0px;
  409. }
  410. }*/
  411. }
  412. .recommend-fragment ul li.big {
  413. float: left;
  414. width: 190px;
  415. height: 115px;
  416. position: relative;
  417. overflow: hidden;
  418. margin: 2px 3px 0px 0px;
  419. &:nth-child(5n){
  420. margin: 2px 0px 0px 0px;
  421. }
  422. &:hover{
  423. /*box-shadow: 2px 0px 1px #d9d9d9, -2px 0px 1px #d9d9d9, 0px 2px 1px #d9d9d9, 0px -2px 1px #d9d9d9;*/
  424. .enter-store {
  425. top: 132px;
  426. left: 0px;
  427. transition: all .3s linear;
  428. }
  429. .img, .content{
  430. transform:translate(0px,-10px);
  431. -ms-transform:translate(0px,-10px); /* IE 9 */
  432. -webkit-transform:translate(0px,-10px); /* Safari and Chrome */
  433. }
  434. }
  435. }
  436. /*.recommend-fragment ul li.small .enter-store a {
  437. width: 74px;
  438. height: 24px;
  439. display: inline-block;
  440. line-height: 22px;
  441. text-align: center;
  442. font-size: 12px;
  443. margin-left: 11px;
  444. border-radius: 3px;
  445. &:first-child {
  446. background-color: #fff;
  447. border: solid 1px #3b7cf4;
  448. color: #3c7df5;
  449. }
  450. &:last-child {
  451. background-color: #ffa422;
  452. border: 1px solid #ffa422;
  453. color: #fff;
  454. }
  455. }
  456. .recommend-fragment ul li.small {
  457. float: left;
  458. width: 180px;
  459. height: 174px;
  460. position: relative;
  461. overflow: hidden;
  462. margin: 2px 8px 0px 0px;
  463. &:nth-child(5n){
  464. margin: 2px 0px 0px 0px;
  465. }
  466. &:hover, &:focus, &:active &:visited{
  467. box-shadow: 2px 0px 1px #d9d9d9, -2px 0px 1px #d9d9d9, 0px 2px 1px #d9d9d9, 0px -2px 1px #d9d9d9;
  468. .enter-store {
  469. top: 140px;
  470. left: 0px;
  471. transition: all .5s;
  472. }
  473. .img, .content{
  474. transform:translate(0px,-10px);
  475. -ms-transform:translate(0px,-10px); !* IE 9 *!
  476. -webkit-transform:translate(0px,-10px); !* Safari and Chrome *!
  477. }
  478. }
  479. }*/
  480. .recommend-fragment ul li.empty-show {
  481. width: 100%;
  482. height: 356px;
  483. padding-top: 150px;
  484. &:hover{
  485. box-shadow: 0px 0px 0px transparent;
  486. }
  487. .empty{
  488. margin: 0 auto;
  489. width: 181px;
  490. .empty-img{
  491. float: left;
  492. }
  493. .empty-info{
  494. float: left;
  495. margin: 5px 0px 0px 20px;
  496. .grey{
  497. color: #999;
  498. font-size: 14px;
  499. }
  500. i{
  501. color: #5078cb;
  502. }
  503. a{
  504. font-size: 14px;
  505. color: #5078cb;
  506. }
  507. }
  508. }
  509. }
  510. .shadow {
  511. width: 1190px;
  512. margin: 0 auto;
  513. position: relative;
  514. img {
  515. position: absolute;
  516. top: -12px;
  517. }
  518. }
  519. </style>