templateD.vue 8.2 KB

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