templateD.vue 8.1 KB

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