goodsList.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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-logo"><image :src="item.logo" mode=""></image></view>
  8. <view class="title-text">{{item.name}}</view>
  9. </view>
  10. <view class="productlist" v-for="(pros,idx) in item.productsList" :key="idx">
  11. <view class="goods-pros-t">
  12. <view class="pros-img"><image :src="pros.mainImage" alt="" /></view>
  13. <view class="pros-product">
  14. <view class="producttitle">{{pros.name}}</view>
  15. <view class="productspec">规格:{{pros.unit}}</view>
  16. <view class="productprice">
  17. <view class="price">
  18. <text>¥{{pros.retailPrice.toFixed(2)}}</text>
  19. </view>
  20. <view class="count">
  21. <text class="small">x</text>{{pros.productCount}}
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="goods-pros-m">
  28. <view class="m-text">留言:</view>
  29. <view class="m-input">
  30. <input type="text"
  31. v-model="remark[index]"
  32. @change="changeHandle(index)"
  33. placeholder-class="placeholder"
  34. maxlength="50"
  35. placeholder="选填,最多不超过50个汉字"/>
  36. </view>
  37. </view>
  38. <view class="goods-pros-b">
  39. <view class="sum">合计:<text class="money">¥{{item.totalPrice.toFixed(2)}}</text></view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default{
  47. name:"goods",
  48. props:{
  49. goodsData:{
  50. type:Array
  51. }
  52. },
  53. data() {
  54. return{
  55. remark:[]
  56. }
  57. },
  58. created(){
  59. },
  60. watch: {
  61. goodsData: {
  62. handler: function (el) {//监听对象的变换使用 function,箭头函数容易出现this指向不正确
  63. this.goodsData = el
  64. },
  65. deep: true
  66. }
  67. },
  68. computed: {
  69. },
  70. methods:{
  71. changeHandle (index) {//输入框的值被改变后
  72. this.goodsData[index].note = this.remark[index]
  73. this.$emit('handleGoodList',this.goodsData)
  74. }
  75. },
  76. }
  77. </script>
  78. <style lang="scss">
  79. .goods-template{
  80. width: 100%;
  81. height: auto;
  82. background: #FFFFFF;
  83. float: left;
  84. margin-top: 24rpx;
  85. .goods-list{
  86. width: 100%;
  87. height: auto;
  88. background:#F7F7F7;
  89. .goods-item{
  90. width: 702rpx;
  91. padding: 0 24rpx;
  92. background: #FFFFFF;
  93. margin-bottom: 24rpx;
  94. &:last-child{
  95. margin-bottom: 0;
  96. }
  97. }
  98. .shoptitle{
  99. display: flex;
  100. align-items: center;
  101. height: 80rpx;
  102. line-height: 80rpx;
  103. .title-logo{
  104. width: 48rpx;
  105. height: 48rpx;
  106. float: left;
  107. image{
  108. width: 48rpx;
  109. height: 48rpx;
  110. }
  111. }
  112. .title-text{
  113. float: left;
  114. margin-left: 16rpx;
  115. font-size: $font-size-28;
  116. color: $text-color;
  117. text-align: left;
  118. line-height: 56rpx;
  119. font-weight: bold;
  120. }
  121. }
  122. .productlist{
  123. width: 100%;
  124. height: auto;
  125. }
  126. .goods-pros-t{
  127. display: flex;
  128. align-items: center;
  129. width: 100%;
  130. height: 217rpx;
  131. padding:12rpx 0;
  132. .pros-img{
  133. width: 210rpx;
  134. height: 100%;
  135. border-radius: 10rpx;
  136. margin:0 26rpx 0 0;
  137. border:1px solid #f3f3f3;
  138. image{
  139. width: 100%;
  140. height: 100%;
  141. border-radius: 10rpx;
  142. }
  143. }
  144. }
  145. .pros-product{
  146. width: 468rpx;
  147. height: 100%;
  148. line-height: 36rpx;
  149. font-size: $font-size-26;
  150. position: relative;
  151. .producttitle{
  152. width: 100%;
  153. display: inline-block;
  154. height: auto;
  155. text-overflow:ellipsis;
  156. display: -webkit-box;
  157. word-break: break-all;
  158. -webkit-box-orient: vertical;
  159. -webkit-line-clamp: 2;
  160. overflow: hidden;
  161. margin-bottom: 8rpx;
  162. }
  163. .productspec{
  164. height: 36rpx;
  165. color: #999999;
  166. }
  167. .productprice{
  168. height: 48rpx;
  169. position: absolute;
  170. width: 100%;
  171. bottom: 0;
  172. .price{
  173. line-height: 48rpx;
  174. font-size: $font-size-28;
  175. width: 48%;
  176. color: #FF2A2A;
  177. float: left;
  178. }
  179. .count{
  180. height: 100%;
  181. float: right;
  182. position: relative;
  183. .small{
  184. color: #666666;
  185. }
  186. }
  187. }
  188. }
  189. .goods-pros-m{
  190. height: 76rpx;
  191. line-height: 76rpx;
  192. font-size: $font-size-26;
  193. color: $text-color;
  194. margin-top: 12rpx;
  195. .m-text{
  196. width: 62rpx;
  197. float: left;
  198. padding-right: 20rpx;
  199. font-weight:bold;
  200. }
  201. .m-input{
  202. display: -webkit-box;
  203. display: -webkit-flex;
  204. display: flex;
  205. -webkit-box-align: center;
  206. -webkit-align-items: center;
  207. align-items: center;
  208. position: relative;
  209. width: 580rpx;
  210. height: 36rpx;
  211. padding: 20rpx;
  212. background: #F7F7F7;
  213. border-radius: 10rpx;
  214. input{
  215. width: 100%;
  216. height: 100%;
  217. background: #F7F7F7;
  218. font-size: $font-size-26;
  219. line-height: 36rpx;
  220. color: #333333;
  221. min-height: 36rpx;
  222. }
  223. }
  224. }
  225. .goods-pros-b{
  226. width:100%;
  227. height: auto;
  228. .sum{
  229. font-size: $font-size-28;
  230. line-height: 60rpx;
  231. color: $text-color;
  232. display: flex;
  233. justify-content: flex-end;
  234. .money{
  235. color: #FF2A2A;
  236. font-size: $font-size-28;
  237. }
  238. }
  239. }
  240. }
  241. }
  242. </style>