templateB.vue 7.9 KB

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