templateC.vue 8.5 KB

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