templateH.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <view class="section_page_main clearfix">
  3. <view class="recommend-list">
  4. <swiper class="tui-banner-swiper" :autoplay="false" :interval="5000" :duration="500" :circular="true" @change="swiperChange">
  5. <swiper-item v-for="(product,index) in productList" :key="index">
  6. <view class="floor-item ad_04 clearfix" v-for="(item, idx) in floorData.floorImageList" v-if="idx < 4" :key="idx" @click.stop="navToDetailPage(item)">
  7. <image class="item-img tui-skeleton-fillet" :src="item.image" mode="aspectFill"></image>
  8. <view class="floor-item_tag" v-if="item.listType == 2">
  9. <text>{{ item.label }}</text>
  10. </view>
  11. <view class="floor-item-content">
  12. <view class="title tui-skeleton-rect">
  13. <text class="mclap">{{item.name}}</text>
  14. </view>
  15. <view class="floor-item-price" v-if="item.listType == 1">
  16. <view class="floor-item-act">
  17. <template v-if="userIdentity === 3">
  18. <template v-if="item.product.actStatus===1">
  19. <view class="floor-tags" v-if="PromotionsFormat(item.product.promotions)">
  20. {{item.product.promotions.name}}
  21. <text v-if="hasLogin && item.product.price1TextFlag != 1 && item.product.shopID == shopId">:¥{{item.product.retailPrice | NumFormat}}</text>
  22. </view>
  23. <view class="floor-tags" v-else>{{item.product.promotions.name}}</view>
  24. </template>
  25. <template v-if="item.product.actStatus ===0 && item.product.ladderPriceFlag===1">
  26. <view class="floor-tags">阶梯价格</view>
  27. </template>
  28. </template>
  29. <template v-else>
  30. <template v-if="item.product.actStatus===1">
  31. <view class="floor-tags" v-if="PromotionsFormat(item.product.promotions)">
  32. {{item.product.promotions.name}}
  33. <text v-if="hasLogin && item.product.price1TextFlag != 1">:¥{{item.product.retailPrice | NumFormat}}</text>
  34. </view>
  35. <view class="floor-tags" v-else>{{item.product.promotions.name}}</view>
  36. </template>
  37. <template v-if="item.product.actStatus ===0 && item.product.ladderPriceFlag===1">
  38. <view class="floor-tags">阶梯价格</view>
  39. </template>
  40. </template>
  41. </view>
  42. <view v-if="hasLogin">
  43. <template v-if="userIdentity == 3">
  44. <template v-if="item.product.shopID == shopId">
  45. <view class="title-none" v-if="item.product.price1TextFlag === '1'">
  46. <text class="p big">¥未公开价格</text>
  47. </view>
  48. <view class="price tui-skeleton-rect" v-else :class="PromotionsFormat(item.product.promotions) ? 'none' : ''">
  49. <text class="p sm">¥</text>
  50. <text class="p big">{{ (PromotionsFormat(item.product.promotions) ? item.product.price1 : item.product.retailPrice ) | NumFormat}}</text>
  51. </view>
  52. </template>
  53. <template v-else>
  54. <view class="no-price">
  55. <view class="p-stars">
  56. <text class="p-no">¥</text>
  57. <uni-grader :grade="Number(item.product.price1Grade)" :margin="14"></uni-grader>
  58. </view>
  59. </view>
  60. </template>
  61. </template>
  62. <template v-else-if="userIdentity ===4">
  63. <view class="title-none" v-if="item.product.price1TextFlag === '1'">
  64. <text class="p big">¥未公开价格</text>
  65. </view>
  66. <view class="title-none" v-if="item.product.price1TextFlag === '2'">
  67. <text class="p big">¥价格仅会员可见</text>
  68. </view>
  69. <view class="price tui-skeleton-rect" v-if="item.product.price1TextFlag === '0'" :class="PromotionsFormat(item.product.promotions) ? 'none' : ''">
  70. <text class="p sm">¥</text>
  71. <text class="p big">{{ (PromotionsFormat(item.product.promotions) ? item.product.price1 : item.product.retailPrice ) | NumFormat}}</text>
  72. </view>
  73. </template>
  74. <template v-else>
  75. <view class="title-none" v-if="item.product.price1TextFlag === '1'">
  76. <text class="p big">¥未公开价格</text>
  77. </view>
  78. <view class="price tui-skeleton-rect" v-else :class="PromotionsFormat(item.product.promotions) ? 'none' : ''">
  79. <text class="p sm">¥</text>
  80. <text class="p big">{{ (PromotionsFormat(item.product.promotions) ? item.product.price1 : item.product.retailPrice ) | NumFormat}}</text>
  81. </view>
  82. </template>
  83. </view>
  84. <view v-else class="no-price">
  85. <template v-if="item.product.productCategory == 1">
  86. <view class="p-stars">
  87. <text class="p-no">¥</text>
  88. <uni-grader :grade="Number(item.product.price1Grade)" :margin="14"></uni-grader>
  89. </view>
  90. </template>
  91. <template v-else>
  92. <view class="p-stars">
  93. <text class="p-no">¥登录可见</text>
  94. </view>
  95. </template>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </swiper-item>
  101. </swiper>
  102. <view class="swiper__recommenddots-box" v-if="productList.length > 1">
  103. <view v-for="(item,idx) in productList"
  104. :key="idx"
  105. :class="[idx===swiperCurrent?'swiper__dots-long':'none']"
  106. :data-index="swiperCurrent" class="swiper__dots-item">
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </template>
  112. <script>
  113. import { mapState,mapMutations} from 'vuex';
  114. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  115. export default{
  116. name:"templateH",
  117. components:{
  118. uniGrader
  119. },
  120. props:{
  121. pageData:{
  122. type:Object
  123. },
  124. userIdentity:{
  125. type:Number
  126. }
  127. },
  128. data() {
  129. return{
  130. shopId:0,
  131. floorData:{},
  132. productList:[],
  133. current:100,
  134. swiperCurrent:0,
  135. pageSize:4,
  136. }
  137. },
  138. filters: {
  139. NumFormat:function(text) {//处理金额
  140. return Number(text).toFixed(2);
  141. },
  142. },
  143. created(){
  144. this.initData(this.pageData)
  145. },
  146. computed: {
  147. ...mapState(['hasLogin','userInfo','isActivity'])
  148. },
  149. watch: {
  150. pageData: {
  151. handler: function (el) {//监听对象的变换使用 function,箭头函数容易出现this指向不正确
  152. this.pageData = el
  153. this.initData(this.pageData)
  154. },
  155. deep: true
  156. }
  157. },
  158. methods:{
  159. initData(data){
  160. this.$api.getStorage().then((resolve) =>{
  161. this.shopId = resolve.shopID
  162. })
  163. if(data.floorImageList.length>0){
  164. this.productList.splice(0,this.productList.length);
  165. for (var i = 0, j = data.floorImageList.length; i < j; i += this.pageSize) {
  166. this.productList.push(data.floorImageList.slice(i, i + this.pageSize));
  167. }
  168. }
  169. this.floorData = data
  170. // console.log(this.floorData)
  171. },
  172. PromotionsFormat(promo){//促销活动类型数据处理
  173. if(promo!=null){
  174. if(promo.type == 1 && promo.mode == 1){
  175. return true
  176. }else{
  177. return false
  178. }
  179. }
  180. return false
  181. },
  182. tabClick(index) {//轮播图切换
  183. this.current = index;
  184. },
  185. swiperChange(e) {//轮播切换
  186. const index = e.detail.current;
  187. this.swiperCurrent = index;
  188. },
  189. navToDetailPage(pros) {//跳转商品详情页
  190. if(pros.listType == 1){
  191. if(pros.product.productCategory == '1'){
  192. this.$api.navigateTo(`/pages/goods/product?id=${pros.product.productID}`)
  193. }else{
  194. this.$api.navigateTo(`/second/pages/product/product-details?id=${pros.product.productID}`)
  195. }
  196. }else{
  197. /**
  198. * 页面跳转类型
  199. * 1、二级页面,2、搜索项目仪器,3、直播页面,4、自由页面,5、商品详情,6、仪器项目详情,7、供应商主页
  200. * 8、专题活动页,9、二手市场介绍,10、二手商品列表,11、二手商品发布,12、商品搜索,13、信息详情
  201. * 14、品牌招商介绍页,15、维修保养介绍页,16、首页,17、注册页,18、信息中心,19、供应商列表
  202. **/
  203. if(pros.linkType){
  204. const typeMap = {
  205. 1:`/pages/goods/goods-instrument?linkId=${pros.linkParam.id}&title=${pros.name}`,
  206. 2:`/pages/goods/instrument-details?id=${pros.linkParam.id}`,
  207. 4:`/h5/pages/activity/activity?id=${pros.linkParam.id}`,
  208. 5:`/pages/goods/product?id=${pros.linkParam.id}`,
  209. 7:`/supplier/pages/user/my-shop?shopId=${pros.linkParam.id}`,
  210. 8:`/h5/pages/activity/activity-list`,
  211. 9:`/second/pages/form/introduce`,
  212. 10:`/second/pages/product/product-list`,
  213. 11:`/second/pages/form/form`,
  214. 12:`/pages/search/search?keyWord=${pros.name}`,
  215. 13:`/h5/pages/article/page?link=${pros.link}`,
  216. 14:`/h5/pages/article/page?link=${pros.link}`,
  217. 15:`/h5/pages/article/page?link=${pros.link}`,
  218. 17:`/pages/login/register-select`,
  219. 18:`/h5/pages/article/page?link=${pros.link}`,
  220. 19:`/pages/search/search-supplier?keyWord=${pros.name}`
  221. }
  222. const url = typeMap[pros.linkType];
  223. this.$api.navigateTo(url)
  224. }
  225. }
  226. }
  227. }
  228. }
  229. </script>
  230. <style lang="scss">
  231. .section_page_main{
  232. width: 100%;
  233. height: auto;
  234. box-sizing: border-box;
  235. .recommend-list{
  236. width: 100%;
  237. height: 1100rpx;
  238. position: relative;
  239. padding-bottom: 20rpx;
  240. .tui-banner-swiper {
  241. width: 100%;
  242. margin: 0 auto;
  243. background: #F7F7F7;
  244. height: 1100rpx;
  245. overflow: hidden;
  246. transform: translateY(0);
  247. .floor-item{
  248. width: 339rpx;
  249. height: 516rpx;
  250. margin-right: 20rpx;
  251. font-size: $font-size-24;
  252. color: $text-color;
  253. background: #FFFFFF;
  254. line-height: 36rpx;
  255. border-radius: 16rpx;
  256. margin-bottom: 20rpx;
  257. float: left;
  258. box-sizing: border-box;
  259. position: relative;
  260. &:nth-child(2n){
  261. margin-right: 0;
  262. }
  263. .item-img{
  264. width: 339rpx;
  265. height: 339rpx;
  266. border-radius: 16rpx 16rpx 0 0;
  267. display: block;
  268. margin-bottom: 8rpx;
  269. }
  270. .floor-item_tag{
  271. width: 100%;
  272. height: 32rpx;
  273. float: left;
  274. margin: 20rpx 0;
  275. padding: 0 20rpx;
  276. box-sizing: border-box;
  277. text{
  278. display: inline-block;
  279. padding: 0 8rpx;
  280. border: 1px solid #e3ebf7;
  281. border-radius: 8rpx ;
  282. color: #9aa5b5;
  283. font-size: $font-size-22;
  284. line-height: 32rpx;
  285. text-align: center;
  286. float: left;
  287. }
  288. }
  289. .floor-item-content{
  290. width: 100%;
  291. padding: 0 20rpx;
  292. box-sizing: border-box;
  293. }
  294. .floor-item-act{
  295. display: block;
  296. width: 100%;
  297. height: 32rpx;
  298. text-align: center;
  299. box-sizing: border-box;
  300. }
  301. .floor-tags{
  302. height: 28rpx;
  303. border-radius: 6rpx;
  304. background-color: #FFFFFF;
  305. line-height: 28rpx;
  306. color: $color-system;
  307. text-align: center;
  308. display: inline-block;
  309. padding:0 16rpx;
  310. font-size: $font-size-20;
  311. border: 1px solid #E15616;
  312. float: left;
  313. }
  314. .title-none{
  315. font-size: $font-size-26;
  316. color: #FF2A2A;
  317. line-height: 54rpx;
  318. }
  319. .title{
  320. width: 100%;
  321. height: 70rpx;
  322. display: flex;
  323. line-height: 35rpx;
  324. flex-direction: column;
  325. margin: 8rpx 0;
  326. padding: 0;
  327. .mclap{
  328. width: 100%;
  329. line-height:35rpx;
  330. text-overflow:ellipsis;
  331. display: -webkit-box;
  332. word-break: break-all;
  333. -webkit-box-orient: vertical;
  334. -webkit-line-clamp: 2;
  335. overflow: hidden;
  336. font-size: 26rpx;
  337. }
  338. }
  339. .no-price{
  340. height: 54rpx;
  341. line-height: 54rpx;
  342. display: flex;
  343. box-sizing: border-box;
  344. .p-no{
  345. font-size: $font-size-28;
  346. color: $text-color;
  347. display: block;
  348. float: left;
  349. }
  350. .p-stars{
  351. float: left;
  352. }
  353. }
  354. .price{
  355. color: #FF2A2A;
  356. line-height:54rpx;
  357. &.none{
  358. text-decoration: line-through;
  359. color: #999999;
  360. }
  361. .sm{
  362. font-size: $font-size-24;
  363. }
  364. .big{
  365. font-size: $font-size-28;
  366. }
  367. }
  368. }
  369. }
  370. }
  371. .swiper__recommenddots-box{
  372. position: absolute;
  373. bottom: 0;
  374. left: 0;
  375. right: 0;
  376. /* #ifndef APP-NVUE */
  377. display: flex;
  378. /* #endif */
  379. flex: 1;
  380. flex-direction: row;
  381. justify-content: center;
  382. align-items: center;
  383. height: 60rpx;
  384. .swiper__dots-item{
  385. width: 8rpx;
  386. height: 8rpx;
  387. border-radius: 100%;
  388. margin-left: 6px;
  389. background-color:rgba(225,86,22,.3);
  390. }
  391. .swiper__dots-long{
  392. width: 32rpx;
  393. height: 8rpx;
  394. border-radius: 4rpx;
  395. background-color: #e15616;
  396. transition: all 0.4s;
  397. }
  398. }
  399. }
  400. </style>