goodsList.vue 4.8 KB

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