RecommendList.vue 16 KB

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