templateE.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <view class="section_page_main clearfix">
  3. <view class="floor-item ad_01">
  4. <image class="item-img-gg" :src="floorData.banner" mode="aspectFill"></image>
  5. </view>
  6. <view class="floor-item ad_04 clearfix" v-for="(item, idx) in floorData.productList" 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. </view>
  94. </template>
  95. <script>
  96. import { mapState,mapMutations} from 'vuex';
  97. export default{
  98. name:"templateA",
  99. props:{
  100. pageData:{
  101. type:Object
  102. },
  103. userIdentity:{
  104. type:Number
  105. }
  106. },
  107. data() {
  108. return{
  109. floorData:{}
  110. }
  111. },
  112. filters: {
  113. NumFormat:function(text) {//处理金额
  114. return Number(text).toFixed(2);
  115. },
  116. },
  117. created(){
  118. this.initData(this.pageData)
  119. },
  120. computed: {
  121. ...mapState(['hasLogin','userInfo','isActivity'])
  122. },
  123. watch: {
  124. pageData: {
  125. handler: function (el) {//监听对象的变换使用 function,箭头函数容易出现this指向不正确
  126. this.pageData = el
  127. this.initData(this.pageData)
  128. },
  129. deep: true
  130. }
  131. },
  132. methods:{
  133. initData(data){
  134. this.floorData = data
  135. console.log(this.floorData)
  136. },
  137. PromotionsFormat(promo){//促销活动类型数据处理
  138. if(promo!=null){
  139. if(promo.type == 1 && promo.mode == 1){
  140. return true
  141. }else{
  142. return false
  143. }
  144. }
  145. return false
  146. },
  147. navToDetailPage(id) {//跳转商品详情页
  148. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  149. }
  150. }
  151. }
  152. </script>
  153. <style lang="scss">
  154. .section_page_main{
  155. width: 100%;
  156. height: auto;
  157. box-sizing: border-box;
  158. .floor-item{
  159. width: 339rpx;
  160. height: 516rpx;
  161. margin-right: 20rpx;
  162. font-size: $font-size-24;
  163. color: $text-color;
  164. background: #FFFFFF;
  165. line-height: 36rpx;
  166. border-radius: 16rpx;
  167. margin-bottom: 20rpx;
  168. float: left;
  169. box-sizing: border-box;
  170. position: relative;
  171. &.ad_01{
  172. width: 100%;
  173. height: 240rpx;
  174. .item-img-gg{
  175. width: 100%;
  176. height: 240rpx;
  177. display: block;
  178. border-radius: 16rpx;
  179. }
  180. }
  181. &.ad_02{
  182. margin-right: 20rpx;
  183. }
  184. &:nth-child(odd){
  185. margin-right: 0;
  186. }
  187. .item-img-gg{
  188. width: 339rpx;
  189. height: 516rpx;
  190. display: block;
  191. border-radius: 16rpx;
  192. }
  193. .item-img{
  194. width: 339rpx;
  195. height: 339rpx;
  196. border-radius: 16rpx 16rpx 0 0;
  197. display: block;
  198. margin-bottom: 8rpx;
  199. }
  200. .floor-item_tag{
  201. width: 100%;
  202. height: 32rpx;
  203. float: left;
  204. margin: 20rpx 0;
  205. padding: 0 20rpx;
  206. box-sizing: border-box;
  207. text{
  208. display: inline-block;
  209. padding: 0 8rpx;
  210. border: 1px solid #e3ebf7;
  211. border-radius: 8rpx ;
  212. color: #9aa5b5;
  213. font-size: $font-size-22;
  214. line-height: 32rpx;
  215. text-align: center;
  216. float: left;
  217. }
  218. }
  219. .floor-item-content{
  220. width: 100%;
  221. padding: 0 20rpx;
  222. box-sizing: border-box;
  223. }
  224. .floor-item-act{
  225. display: block;
  226. width: 100%;
  227. height: 32rpx;
  228. text-align: center;
  229. box-sizing: border-box;
  230. }
  231. .floor-tags{
  232. height: 28rpx;
  233. border-radius: 6rpx;
  234. background-color: #FFFFFF;
  235. line-height: 28rpx;
  236. color: $color-system;
  237. text-align: center;
  238. display: inline-block;
  239. padding:0 16rpx;
  240. font-size: $font-size-20;
  241. border: 1px solid #E15616;
  242. float: left;
  243. }
  244. .title-none{
  245. font-size: $font-size-26;
  246. color: #FF2A2A;
  247. line-height: 54rpx;
  248. }
  249. .title{
  250. width: 100%;
  251. height: 70rpx;
  252. display: flex;
  253. line-height: 35rpx;
  254. flex-direction: column;
  255. margin: 8rpx 0;
  256. padding: 0;
  257. .mclap{
  258. width: 100%;
  259. line-height:35rpx;
  260. text-overflow:ellipsis;
  261. display: -webkit-box;
  262. word-break: break-all;
  263. -webkit-box-orient: vertical;
  264. -webkit-line-clamp: 2;
  265. overflow: hidden;
  266. font-size: 26rpx;
  267. }
  268. }
  269. .no-price{
  270. height: 70rpx;
  271. line-height: 70rpx;
  272. display: flex;
  273. box-sizing: border-box;
  274. .p-no{
  275. font-size: $font-size-30;
  276. color: $text-color;
  277. display: block;
  278. float: left;
  279. }
  280. .p-stars{
  281. float: left;
  282. }
  283. }
  284. .price{
  285. color: #FF2A2A;
  286. line-height:54rpx;
  287. &.none{
  288. text-decoration: line-through;
  289. color: #999999;
  290. }
  291. .sm{
  292. font-size: $font-size-24;
  293. }
  294. .big{
  295. font-size: $font-size-28;
  296. }
  297. }
  298. }
  299. }
  300. </style>