templateH.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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 clearfix" v-for="(item, idx) in product" v-if="idx < 4" :key="idx" @click.stop="navToDetailPage(item.id)">
  7. <image class="item-img tui-skeleton-fillet" :src="item.image" mode="aspectFill"></image>
  8. <view class="floor-item_tag" v-if="floorData.listType == 2">
  9. <text>{{ item.tags }}</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="floorData.listType == 1">
  16. <view class="floor-item-act">
  17. <template v-if="userIdentity === 3">
  18. <template v-if="item.actStatus===1">
  19. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  20. {{item.promotions.name}}
  21. <text v-if="hasLogin && item.priceFlag != 1 && item.supplierId == shopId">:¥{{item.price | NumFormat}}</text>
  22. </view>
  23. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  24. </template>
  25. <template v-if="item.actStatus ===0 && item.ladderPriceFlag===1">
  26. <view class="floor-tags">阶梯价格</view>
  27. </template>
  28. </template>
  29. <template v-else>
  30. <template v-if="item.actStatus===1">
  31. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  32. {{item.promotions.name}}
  33. <text v-if="hasLogin && item.priceFlag != 1">:¥{{item.price | NumFormat}}</text>
  34. </view>
  35. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  36. </template>
  37. <template v-if="item.actStatus ===0 && item.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.supplierId == shopId">
  45. <view class="title-none" v-if="item.priceFlag === '1'">
  46. <text class="p big">¥未公开价格</text>
  47. </view>
  48. <view class="price tui-skeleton-rect" v-else :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  49. <text class="p sm">¥</text>
  50. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | 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.priceGrade)" :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.priceFlag === '1'">
  64. <text class="p big">¥未公开价格</text>
  65. </view>
  66. <view class="title-none" v-if="item.priceFlag === '2'">
  67. <text class="p big">¥价格仅会员可见</text>
  68. </view>
  69. <view class="price tui-skeleton-rect" v-if="item.priceFlag === '0'" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  70. <text class="p sm">¥</text>
  71. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | NumFormat}}</text>
  72. </view>
  73. </template>
  74. <template v-else>
  75. <view class="title-none" v-if="item.priceFlag === '1'">
  76. <text class="p big">¥未公开价格</text>
  77. </view>
  78. <view class="price tui-skeleton-rect" v-else :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  79. <text class="p sm">¥</text>
  80. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | NumFormat}}</text>
  81. </view>
  82. </template>
  83. </view>
  84. <view v-else class="no-price">
  85. <view class="p-stars">
  86. <text class="p-no">¥</text>
  87. <uni-grader :grade="Number(item.priceGrade)" :margin="14"></uni-grader>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </swiper-item>
  94. </swiper>
  95. <view class="swiper__recommenddots-box" v-if="productList.length > 1">
  96. <view v-for="(item,idx) in productList"
  97. :key="idx"
  98. :class="[idx===swiperCurrent?'swiper__dots-long':'none']"
  99. :data-index="swiperCurrent" class="swiper__dots-item">
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. </template>
  105. <script>
  106. import { mapState,mapMutations} from 'vuex';
  107. export default{
  108. name:"templateA",
  109. props:{
  110. pageData:{
  111. type:Object
  112. },
  113. userIdentity:{
  114. type:Number
  115. }
  116. },
  117. data() {
  118. return{
  119. shopId:0,
  120. floorData:{},
  121. productList:[],
  122. current:100,
  123. swiperCurrent:0,
  124. pageSize:4,
  125. }
  126. },
  127. filters: {
  128. NumFormat:function(text) {//处理金额
  129. return Number(text).toFixed(2);
  130. },
  131. },
  132. created(){
  133. this.initData(this.pageData)
  134. },
  135. computed: {
  136. ...mapState(['hasLogin','userInfo','isActivity'])
  137. },
  138. watch: {
  139. pageData: {
  140. handler: function (el) {//监听对象的变换使用 function,箭头函数容易出现this指向不正确
  141. this.pageData = el
  142. this.initData(this.pageData)
  143. },
  144. deep: true
  145. }
  146. },
  147. methods:{
  148. initData(data){
  149. this.$api.getStorage().then((resolve) =>{
  150. this.shopId = resolve.shopID
  151. })
  152. if(data.productList.length>0){
  153. this.productList.splice(0,this.productList.length);
  154. for (var i = 0, j = data.productList.length; i < j; i += this.pageSize) {
  155. this.productList.push(data.productList.slice(i, i + this.pageSize));
  156. }
  157. }
  158. this.floorData = data
  159. console.log(this.floorData)
  160. },
  161. PromotionsFormat(promo){//促销活动类型数据处理
  162. if(promo!=null){
  163. if(promo.type == 1 && promo.mode == 1){
  164. return true
  165. }else{
  166. return false
  167. }
  168. }
  169. return false
  170. },
  171. tabClick(index) {//轮播图切换
  172. this.current = index;
  173. },
  174. swiperChange(e) {//轮播切换
  175. const index = e.detail.current;
  176. this.swiperCurrent = index;
  177. },
  178. navToDetailPage(id) {//跳转商品详情页
  179. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  180. }
  181. }
  182. }
  183. </script>
  184. <style lang="scss">
  185. .section_page_main{
  186. width: 100%;
  187. height: auto;
  188. box-sizing: border-box;
  189. .recommend-list{
  190. width: 100%;
  191. height: 1100rpx;
  192. position: relative;
  193. padding-bottom: 20rpx;
  194. .tui-banner-swiper {
  195. width: 100%;
  196. margin: 0 auto;
  197. background: #F7F7F7;
  198. height: 1100rpx;
  199. overflow: hidden;
  200. transform: translateY(0);
  201. .floor-item{
  202. width: 339rpx;
  203. height: 516rpx;
  204. margin-right: 20rpx;
  205. font-size: $font-size-24;
  206. color: $text-color;
  207. background: #FFFFFF;
  208. line-height: 36rpx;
  209. border-radius: 16rpx;
  210. margin-bottom: 20rpx;
  211. float: left;
  212. box-sizing: border-box;
  213. position: relative;
  214. &:nth-child(2n){
  215. margin-right: 0;
  216. }
  217. .item-img{
  218. width: 339rpx;
  219. height: 339rpx;
  220. border-radius: 16rpx 16rpx 0 0;
  221. display: block;
  222. margin-bottom: 8rpx;
  223. }
  224. .floor-item_tag{
  225. width: 100%;
  226. height: 32rpx;
  227. float: left;
  228. margin: 20rpx 0;
  229. padding: 0 20rpx;
  230. box-sizing: border-box;
  231. text{
  232. display: inline-block;
  233. padding: 0 8rpx;
  234. border: 1px solid #e3ebf7;
  235. border-radius: 8rpx ;
  236. color: #9aa5b5;
  237. font-size: $font-size-22;
  238. line-height: 32rpx;
  239. text-align: center;
  240. float: left;
  241. }
  242. }
  243. .floor-item-content{
  244. width: 100%;
  245. padding: 0 20rpx;
  246. box-sizing: border-box;
  247. }
  248. .floor-item-act{
  249. display: block;
  250. width: 100%;
  251. height: 32rpx;
  252. text-align: center;
  253. box-sizing: border-box;
  254. }
  255. .floor-tags{
  256. height: 28rpx;
  257. border-radius: 6rpx;
  258. background-color: #FFFFFF;
  259. line-height: 28rpx;
  260. color: $color-system;
  261. text-align: center;
  262. display: inline-block;
  263. padding:0 16rpx;
  264. font-size: $font-size-20;
  265. border: 1px solid #E15616;
  266. float: left;
  267. }
  268. .title-none{
  269. font-size: $font-size-26;
  270. color: #FF2A2A;
  271. line-height: 54rpx;
  272. }
  273. .title{
  274. width: 100%;
  275. height: 70rpx;
  276. display: flex;
  277. line-height: 35rpx;
  278. flex-direction: column;
  279. margin: 8rpx 0;
  280. padding: 0;
  281. .mclap{
  282. width: 100%;
  283. line-height:35rpx;
  284. text-overflow:ellipsis;
  285. display: -webkit-box;
  286. word-break: break-all;
  287. -webkit-box-orient: vertical;
  288. -webkit-line-clamp: 2;
  289. overflow: hidden;
  290. font-size: 26rpx;
  291. }
  292. }
  293. .no-price{
  294. height: 70rpx;
  295. line-height: 70rpx;
  296. display: flex;
  297. box-sizing: border-box;
  298. .p-no{
  299. font-size: $font-size-30;
  300. color: $text-color;
  301. display: block;
  302. float: left;
  303. }
  304. .p-stars{
  305. float: left;
  306. }
  307. }
  308. .price{
  309. color: #FF2A2A;
  310. line-height:54rpx;
  311. &.none{
  312. text-decoration: line-through;
  313. color: #999999;
  314. }
  315. .sm{
  316. font-size: $font-size-24;
  317. }
  318. .big{
  319. font-size: $font-size-28;
  320. }
  321. }
  322. }
  323. }
  324. }
  325. .swiper__recommenddots-box{
  326. position: absolute;
  327. bottom: 0;
  328. left: 0;
  329. right: 0;
  330. /* #ifndef APP-NVUE */
  331. display: flex;
  332. /* #endif */
  333. flex: 1;
  334. flex-direction: row;
  335. justify-content: center;
  336. align-items: center;
  337. height: 60rpx;
  338. .swiper__dots-item{
  339. width: 8rpx;
  340. height: 8rpx;
  341. border-radius: 100%;
  342. margin-left: 6px;
  343. background-color:rgba(225,86,22,.3);
  344. }
  345. .swiper__dots-long{
  346. width: 32rpx;
  347. height: 8rpx;
  348. border-radius: 4rpx;
  349. background-color: #e15616;
  350. transition: all 0.4s;
  351. }
  352. }
  353. }
  354. </style>