goodsList.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template name="goods">
  2. <view class="goods-template">
  3. <!-- 商品列表 -->
  4. <view class="goods-list">
  5. <view v-for="(item, index) in goodsData" :key="index" class="goods-item">
  6. <view class="shoptitle">
  7. <view class="title-text">{{item.name}}</view>
  8. </view>
  9. <view class="productlist" v-for="(pros,idx) in item.productList" :key="idx">
  10. <view class="goods-pros-t">
  11. <view class="pros-img">
  12. <image :src="pros.mainImage" alt="" />
  13. <text class="tips" v-if="pros.productType == 2">赠品</text>
  14. </view>
  15. <view class="pros-product">
  16. <view class="producttitle">{{ pros.productName }}</view>
  17. <view class="floor-item-act" v-if="pros.promotion!=null">
  18. <view v-if="PromotionsFormat(pros.promotion)" class="floor-tags">
  19. {{pros.promotion.name}}
  20. <text v-if ="pros.promotion!=null">
  21. :¥{{ pros.promotion == null ? '0.00' : pros.promotion.touchPrice | NumFormat}}
  22. </text>
  23. </view>
  24. <view v-else-if="pros.promotion.type !=3" class="floor-tags">{{pros.promotion.name}}</view>
  25. </view>
  26. <view class="productspec">规格:{{ pros.unit }}</view>
  27. <view class="productprice">
  28. <view class="price" :class="PromotionsFormat(pros.promotion) ? 'disabled' : ''">
  29. <text>¥{{(PromotionsFormat(pros.promotion) ? pros.price : pros.retailPrice) | NumFormat}}</text>
  30. </view>
  31. <view class="count"><text class="small">x</text>{{ pros.productCount }}</view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="goods-pros-m">
  37. <view class="m-text">留言:</view>
  38. <view class="m-input">
  39. <input type="text"
  40. v-model="remark[index]"
  41. @change="changeHandle(index)"
  42. placeholder-class="placeholder"
  43. maxlength="50"
  44. placeholder="选填,最多不超过50个汉字"/>
  45. </view>
  46. </view>
  47. <view class="goods-pros-b">
  48. <view class="sum-none" v-if="(item.fullReduction)>0">
  49. <text class="money-sign">¥</text>
  50. <text class="money">{{ ( item.shopTotalPrice +item.fullReduction ) | NumFormat }}</text>
  51. <text class="money-reduced">减<text>¥{{ item.fullReduction | NumFormat}}</text></text>
  52. </view>
  53. <view class="sum">合计:<text class="money">¥{{ item.shopTotalPrice | NumFormat }}</text></view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. export default{
  61. name:"goods",
  62. props:{
  63. goodsData:{
  64. type:Array
  65. }
  66. },
  67. data() {
  68. return{
  69. remark:[]
  70. }
  71. },
  72. created(){
  73. },
  74. filters:{
  75. NumFormat(value) {//处理金额
  76. return Number(value).toFixed(2);
  77. },
  78. },
  79. watch: {
  80. goodsData: {
  81. handler: function (el) {//监听对象的变换使用 function,箭头函数容易出现this指向不正确
  82. this.goodsData = el
  83. },
  84. deep: true
  85. }
  86. },
  87. computed: {
  88. },
  89. methods:{
  90. PromotionsFormat(promo){//促销活动类型数据处理
  91. if(promo!=null){
  92. if(promo.type == 1 && promo.mode == 1){
  93. return true
  94. }else{
  95. return false
  96. }
  97. }
  98. return false
  99. },
  100. changeHandle (index) {//输入框的值被改变后
  101. this.goodsData[index].note = this.remark[index]
  102. this.$emit('handleGoodList',this.goodsData)
  103. }
  104. },
  105. }
  106. </script>
  107. <style lang="scss">
  108. .goods-template{
  109. width: 100%;
  110. height: auto;
  111. background: #FFFFFF;
  112. float: left;
  113. margin-top: 24rpx;
  114. .goods-list{
  115. width: 100%;
  116. height: auto;
  117. background:#F7F7F7;
  118. .goods-item{
  119. width: 702rpx;
  120. padding: 0 24rpx;
  121. background: #FFFFFF;
  122. margin-bottom: 24rpx;
  123. &:last-child{
  124. margin-bottom: 0;
  125. }
  126. }
  127. .shoptitle{
  128. display: flex;
  129. align-items: center;
  130. height: 80rpx;
  131. line-height: 80rpx;
  132. .title-text{
  133. width: 400rpx;
  134. overflow: hidden;
  135. text-overflow:ellipsis;
  136. white-space: nowrap;
  137. float: left;
  138. font-size: $font-size-28;
  139. color: $text-color;
  140. text-align: left;
  141. line-height: 56rpx;
  142. font-weight: bold;
  143. }
  144. }
  145. .productlist{
  146. width: 100%;
  147. height: auto;
  148. }
  149. .goods-pros-t{
  150. display: flex;
  151. align-items: center;
  152. width: 100%;
  153. height: auto;
  154. padding:12rpx 0;
  155. .pros-img{
  156. width: 210rpx;
  157. height: 100%;
  158. border-radius: 10rpx;
  159. margin:0 26rpx 0 0;
  160. position: relative;
  161. .tips{
  162. display: inline-block;
  163. width: 80rpx;
  164. height: 40rpx;
  165. background-image: linear-gradient(214deg, #ff4500 0%, #ff5800 53%, #ff4367 100%);
  166. line-height: 40rpx;
  167. text-align: center;
  168. font-size: $font-size-24;
  169. color: #FFFFFF;
  170. border-radius:10rpx 0 10rpx 0 ;
  171. position: absolute;
  172. top:0;
  173. left: 0;
  174. }
  175. image{
  176. width: 210rpx;
  177. height: 210rpx;
  178. border-radius: 10rpx;
  179. border:1px solid #f3f3f3;
  180. }
  181. }
  182. }
  183. .pros-product{
  184. width: 468rpx;
  185. height: 100%;
  186. line-height: 40rpx;
  187. font-size: $font-size-26;
  188. position: relative;
  189. .producttitle{
  190. width: 100%;
  191. display: inline-block;
  192. height: auto;
  193. text-overflow:ellipsis;
  194. display: -webkit-box;
  195. word-break: break-all;
  196. -webkit-box-orient: vertical;
  197. -webkit-line-clamp: 2;
  198. overflow: hidden;
  199. margin-bottom: 8rpx;
  200. }
  201. .productspec{
  202. width: 100%;
  203. float: left;
  204. height: 40rpx;
  205. color: #999999;
  206. line-height: 40rpx;
  207. text-overflow:ellipsis;
  208. display: -webkit-box;
  209. word-break: break-all;
  210. -webkit-box-orient: vertical;
  211. -webkit-line-clamp: 2;
  212. overflow: hidden;
  213. }
  214. .productprice{
  215. width: 100%;
  216. height: 54rpx;
  217. line-height: 54rpx;
  218. width: 100%;
  219. float: left;
  220. margin-top: 30rpx;
  221. .price{
  222. line-height: 54rpx;
  223. font-size: $font-size-28;
  224. width: 48%;
  225. color: #FF2A2A;
  226. float: left;
  227. &.disabled{
  228. color: #999999;
  229. text-decoration: line-through;
  230. }
  231. }
  232. .count{
  233. height: 100%;
  234. float: right;
  235. position: relative;
  236. .small{
  237. color: #666666;
  238. }
  239. }
  240. }
  241. .floor-item-act{
  242. width: 100%;
  243. height: auto;
  244. text-align: center;
  245. box-sizing: border-box;
  246. float: left;
  247. padding:0 0 10rpx 0;
  248. .floor-tags{
  249. height: 28rpx;
  250. border-radius: 6rpx;
  251. background-color: #FFFFFF;
  252. line-height: 28rpx;
  253. color: #ff2a2a;
  254. text-align: center;
  255. display: inline-block;
  256. padding:0 5rpx;
  257. font-size: $font-size-20;
  258. border: 1px solid #ff2a2a;
  259. float: left;
  260. }
  261. }
  262. }
  263. .goods-pros-m{
  264. height: 76rpx;
  265. line-height: 76rpx;
  266. font-size: $font-size-26;
  267. color: $text-color;
  268. margin-top: 12rpx;
  269. .m-text{
  270. width: 62rpx;
  271. float: left;
  272. padding-right: 20rpx;
  273. font-weight:bold;
  274. }
  275. .m-input{
  276. display: -webkit-box;
  277. display: -webkit-flex;
  278. display: flex;
  279. -webkit-box-align: center;
  280. -webkit-align-items: center;
  281. align-items: center;
  282. position: relative;
  283. width: 576rpx;
  284. height: 36rpx;
  285. padding: 20rpx;
  286. background: #F9F9F9;
  287. border-radius: 10rpx;
  288. input{
  289. width: 100%;
  290. height: 100%;
  291. font-size: $font-size-26;
  292. line-height: 36rpx;
  293. color: #333333;
  294. min-height: 36rpx;
  295. }
  296. }
  297. }
  298. .goods-pros-b{
  299. width:100%;
  300. height: auto;
  301. padding: 10rpx 0;
  302. .sum-none{
  303. width: 100%;
  304. height: 48rpx;
  305. line-height: 48rpx;
  306. color: $text-color;
  307. float: left;
  308. text-align: right;
  309. .money{
  310. font-size: $font-size-26;
  311. color: #999999;
  312. text-decoration: line-through;
  313. }
  314. .money-sign{
  315. font-size: $font-size-26;
  316. color: #999999;
  317. text-decoration: line-through;
  318. }
  319. .money-reduced{
  320. margin-left: 10rpx;
  321. font-size: $font-size-26;
  322. color: $color-system;
  323. .iconfont{
  324. font-size: $font-size-34;
  325. }
  326. }
  327. }
  328. .sum{
  329. width: 100%;
  330. height: 48rpx;
  331. font-size: $font-size-28;
  332. line-height: 48rpx;
  333. color: $text-color;
  334. display: flex;
  335. justify-content: flex-end;
  336. .money{
  337. color: #FF2A2A;
  338. font-size: $font-size-28;
  339. }
  340. }
  341. }
  342. }
  343. }
  344. </style>