templateG.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <view class="section_page_main clearfix">
  3. <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)">
  4. <image class="item-img tui-skeleton-fillet" :src="item.image" mode="aspectFill"></image>
  5. <view class="floor-item_tag" v-if="floorData.listType == 2">
  6. <text>{{ item.tags }}</text>
  7. </view>
  8. <view class="floor-item-content">
  9. <view class="title tui-skeleton-rect">
  10. <text class="mclap">{{item.name}}</text>
  11. </view>
  12. <view class="floor-item-price" v-if="floorData.listType == 1">
  13. <view class="floor-item-act">
  14. <template v-if="userIdentity === 3">
  15. <template v-if="item.actStatus===1">
  16. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  17. {{item.promotions.name}}
  18. <text v-if="hasLogin && item.priceFlag != 1 && item.supplierId == shopId">:¥{{item.price | NumFormat}}</text>
  19. </view>
  20. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  21. </template>
  22. <template v-if="item.actStatus ===0 && item.ladderPriceFlag===1">
  23. <view class="floor-tags">阶梯价格</view>
  24. </template>
  25. </template>
  26. <template v-else>
  27. <template v-if="item.actStatus===1">
  28. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  29. {{item.promotions.name}}
  30. <text v-if="hasLogin && item.priceFlag != 1">:¥{{item.price | NumFormat}}</text>
  31. </view>
  32. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  33. </template>
  34. <template v-if="item.actStatus ===0 && item.ladderPriceFlag===1">
  35. <view class="floor-tags">阶梯价格</view>
  36. </template>
  37. </template>
  38. </view>
  39. <view v-if="hasLogin">
  40. <template v-if="userIdentity == 3">
  41. <template v-if="item.supplierId == shopId">
  42. <view class="title-none" v-if="item.priceFlag === '1'">
  43. <text class="p big">¥未公开价格</text>
  44. </view>
  45. <view class="price tui-skeleton-rect" v-else :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  46. <text class="p sm">¥</text>
  47. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | NumFormat}}</text>
  48. </view>
  49. </template>
  50. <template v-else>
  51. <view class="no-price">
  52. <view class="p-stars">
  53. <text class="p-no">¥</text>
  54. <uni-grader :grade="Number(item.priceGrade)" :margin="14"></uni-grader>
  55. </view>
  56. </view>
  57. </template>
  58. </template>
  59. <template v-else-if="userIdentity ===4">
  60. <view class="title-none" v-if="item.priceFlag === '1'">
  61. <text class="p big">¥未公开价格</text>
  62. </view>
  63. <view class="title-none" v-if="item.priceFlag === '2'">
  64. <text class="p big">¥价格仅会员可见</text>
  65. </view>
  66. <view class="price tui-skeleton-rect" v-if="item.priceFlag === '0'" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  67. <text class="p sm">¥</text>
  68. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | NumFormat}}</text>
  69. </view>
  70. </template>
  71. <template v-else>
  72. <view class="title-none" v-if="item.priceFlag === '1'">
  73. <text class="p big">¥未公开价格</text>
  74. </view>
  75. <view class="price tui-skeleton-rect" v-else :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  76. <text class="p sm">¥</text>
  77. <text class="p big">{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price ) | NumFormat}}</text>
  78. </view>
  79. </template>
  80. </view>
  81. <view v-else class="no-price">
  82. <view class="p-stars">
  83. <text class="p-no">¥</text>
  84. <uni-grader :grade="Number(item.priceGrade)" :margin="14"></uni-grader>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. import { mapState,mapMutations} from 'vuex';
  94. export default{
  95. name:"templateA",
  96. props:{
  97. pageData:{
  98. type:Object
  99. },
  100. userIdentity:{
  101. type:Number
  102. }
  103. },
  104. data() {
  105. return{
  106. floorData:{}
  107. }
  108. },
  109. filters: {
  110. NumFormat:function(text) {//处理金额
  111. return Number(text).toFixed(2);
  112. },
  113. },
  114. created(){
  115. this.initData(this.pageData)
  116. },
  117. computed: {
  118. ...mapState(['hasLogin','userInfo','isActivity'])
  119. },
  120. watch: {
  121. pageData: {
  122. handler: function (el) {//监听对象的变换使用 function,箭头函数容易出现this指向不正确
  123. this.pageData = el
  124. this.initData(this.pageData)
  125. },
  126. deep: true
  127. }
  128. },
  129. methods:{
  130. initData(data){
  131. this.floorData = data
  132. console.log(this.floorData)
  133. },
  134. PromotionsFormat(promo){//促销活动类型数据处理
  135. if(promo!=null){
  136. if(promo.type == 1 && promo.mode == 1){
  137. return true
  138. }else{
  139. return false
  140. }
  141. }
  142. return false
  143. },
  144. navToDetailPage(id) {//跳转商品详情页
  145. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss">
  151. .section_page_main{
  152. width: 100%;
  153. height: auto;
  154. box-sizing: border-box;
  155. .floor-item{
  156. width: 339rpx;
  157. height: 516rpx;
  158. margin-right: 20rpx;
  159. font-size: $font-size-24;
  160. color: $text-color;
  161. background: #FFFFFF;
  162. line-height: 36rpx;
  163. border-radius: 16rpx;
  164. margin-bottom: 20rpx;
  165. float: left;
  166. box-sizing: border-box;
  167. position: relative;
  168. &:nth-child(2n){
  169. margin-right: 0;
  170. }
  171. .item-img-gg{
  172. width: 339rpx;
  173. height: 516rpx;
  174. display: block;
  175. border-radius: 16rpx;
  176. }
  177. .item-img{
  178. width: 339rpx;
  179. height: 339rpx;
  180. border-radius: 16rpx 16rpx 0 0;
  181. display: block;
  182. margin-bottom: 8rpx;
  183. }
  184. .floor-item_tag{
  185. width: 100%;
  186. height: 32rpx;
  187. float: left;
  188. margin: 20rpx 0;
  189. padding: 0 20rpx;
  190. box-sizing: border-box;
  191. text{
  192. display: inline-block;
  193. padding: 0 8rpx;
  194. border: 1px solid #e3ebf7;
  195. border-radius: 8rpx ;
  196. color: #9aa5b5;
  197. font-size: $font-size-22;
  198. line-height: 32rpx;
  199. text-align: center;
  200. float: left;
  201. }
  202. }
  203. .floor-item-content{
  204. width: 100%;
  205. padding: 0 20rpx;
  206. box-sizing: border-box;
  207. }
  208. .floor-item-act{
  209. display: block;
  210. width: 100%;
  211. height: 32rpx;
  212. text-align: center;
  213. box-sizing: border-box;
  214. }
  215. .floor-tags{
  216. height: 28rpx;
  217. border-radius: 6rpx;
  218. background-color: #FFFFFF;
  219. line-height: 28rpx;
  220. color: $color-system;
  221. text-align: center;
  222. display: inline-block;
  223. padding:0 16rpx;
  224. font-size: $font-size-20;
  225. border: 1px solid #E15616;
  226. float: left;
  227. }
  228. .title-none{
  229. font-size: $font-size-26;
  230. color: #FF2A2A;
  231. line-height: 54rpx;
  232. }
  233. .title{
  234. width: 100%;
  235. height: 70rpx;
  236. display: flex;
  237. line-height: 35rpx;
  238. flex-direction: column;
  239. margin: 8rpx 0;
  240. padding: 0;
  241. .mclap{
  242. width: 100%;
  243. line-height:35rpx;
  244. text-overflow:ellipsis;
  245. display: -webkit-box;
  246. word-break: break-all;
  247. -webkit-box-orient: vertical;
  248. -webkit-line-clamp: 2;
  249. overflow: hidden;
  250. font-size: 26rpx;
  251. }
  252. }
  253. .no-price{
  254. height: 70rpx;
  255. line-height: 70rpx;
  256. display: flex;
  257. box-sizing: border-box;
  258. .p-no{
  259. font-size: $font-size-30;
  260. color: $text-color;
  261. display: block;
  262. float: left;
  263. }
  264. .p-stars{
  265. float: left;
  266. }
  267. }
  268. .price{
  269. color: #FF2A2A;
  270. line-height:54rpx;
  271. &.none{
  272. text-decoration: line-through;
  273. color: #999999;
  274. }
  275. .sm{
  276. font-size: $font-size-24;
  277. }
  278. .big{
  279. font-size: $font-size-28;
  280. }
  281. }
  282. }
  283. }
  284. </style>