goodsList.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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.shopName}}</view>
  8. </view>
  9. <view class="productlist" v-for="(pros,idx) in item.cartList" :key="idx">
  10. <view class="goods-pros-t">
  11. <view class="pros-img">
  12. <image :src="pros.image" alt="" />
  13. </view>
  14. <view class="pros-product">
  15. <view class="producttitle">{{pros.name}}</view>
  16. <view class="productspec" v-if="pros.productCategory!=2">规格:{{pros.unit}}</view>
  17. <view class="productspec" v-if="pros.productCode!=''&&pros.productCode!=null">
  18. <view >商品编码:{{pros.productCode}}</view>
  19. </view>
  20. <view class="productprice">
  21. <view class="price"><text>¥{{pros.price | NumFormat}}</text></view>
  22. <view class="count"><text class="small">x</text>{{pros.number}}</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 | NumFormat }}</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. vipFlag:0,
  57. }
  58. },
  59. created(){
  60. this.initGetStotage()
  61. },
  62. filters:{
  63. NumFormat(value) {//处理金额
  64. return Number(value).toFixed(2)
  65. },
  66. },
  67. watch: {
  68. goodsData: {
  69. handler: function (el) {//监听对象的变换使用 function,箭头函数容易出现this指向不正确
  70. this.goodsData = el
  71. },
  72. deep: true
  73. }
  74. },
  75. computed: {
  76. },
  77. methods:{
  78. async initGetStotage() {
  79. const userInfo = await this.$api.getStorage()
  80. this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
  81. },
  82. PromotionsFormat(promo){//促销活动类型数据处理
  83. if(promo!=null){
  84. if(promo.type == 1 && promo.mode == 1){
  85. return true
  86. }else{
  87. return false
  88. }
  89. }
  90. return false
  91. },
  92. changeHandle (index) {//输入框的值被改变后
  93. this.goodsData[index].note = this.remark[index]
  94. this.$emit('handleGoodList',this.goodsData)
  95. }
  96. },
  97. }
  98. </script>
  99. <style lang="scss">
  100. .goods-template{
  101. width: 100%;
  102. height: auto;
  103. background: #FFFFFF;
  104. float: left;
  105. margin-top: 24rpx;
  106. .goods-list{
  107. width: 100%;
  108. height: auto;
  109. background:#F7F7F7;
  110. .goods-item{
  111. width: 702rpx;
  112. padding: 0 24rpx;
  113. background: #FFFFFF;
  114. margin-bottom: 24rpx;
  115. &:last-child{
  116. margin-bottom: 0;
  117. }
  118. }
  119. .shoptitle{
  120. display: flex;
  121. align-items: center;
  122. height: 80rpx;
  123. line-height: 80rpx;
  124. .title-text{
  125. width: 400rpx;
  126. overflow: hidden;
  127. text-overflow:ellipsis;
  128. white-space: nowrap;
  129. float: left;
  130. font-size: $font-size-28;
  131. color: $text-color;
  132. text-align: left;
  133. line-height: 56rpx;
  134. font-weight: bold;
  135. }
  136. }
  137. .productlist{
  138. width: 100%;
  139. height: auto;
  140. }
  141. .goods-pros-t{
  142. display: flex;
  143. align-items: center;
  144. width: 100%;
  145. height: auto;
  146. padding:12rpx 0;
  147. .pros-img{
  148. width: 210rpx;
  149. height: 100%;
  150. border-radius: 10rpx;
  151. margin:0 26rpx 0 0;
  152. position: relative;
  153. image{
  154. width: 210rpx;
  155. height: 210rpx;
  156. border-radius: 10rpx;
  157. border:1px solid #f3f3f3;
  158. }
  159. }
  160. }
  161. .pros-product{
  162. width: 468rpx;
  163. height: 100%;
  164. line-height: 40rpx;
  165. font-size: $font-size-26;
  166. position: relative;
  167. .producttitle{
  168. width: 100%;
  169. display: inline-block;
  170. height: auto;
  171. text-overflow:ellipsis;
  172. display: -webkit-box;
  173. word-break: break-all;
  174. -webkit-box-orient: vertical;
  175. -webkit-line-clamp: 2;
  176. overflow: hidden;
  177. margin-bottom: 8rpx;
  178. }
  179. .productspec{
  180. height: 40rpx;
  181. line-height: 40rpx;
  182. color: #999999;
  183. text-overflow:ellipsis;
  184. display: -webkit-box;
  185. word-break: break-all;
  186. -webkit-box-orient: vertical;
  187. -webkit-line-clamp: 1;
  188. overflow: hidden;
  189. }
  190. .productprice{
  191. height: 54rpx;
  192. width: 100%;
  193. float: left;
  194. .price{
  195. line-height: 54rpx;
  196. font-size: $font-size-28;
  197. width: 48%;
  198. color: #FF2A2A;
  199. float: left;
  200. }
  201. .count{
  202. height: 100%;
  203. float: right;
  204. position: relative;
  205. .small{
  206. color: #666666;
  207. }
  208. }
  209. }
  210. }
  211. .goods-pros-m{
  212. height: 76rpx;
  213. line-height: 76rpx;
  214. font-size: $font-size-26;
  215. color: $text-color;
  216. margin-top: 12rpx;
  217. .m-text{
  218. width: 62rpx;
  219. float: left;
  220. padding-right: 20rpx;
  221. font-weight:bold;
  222. }
  223. .m-input{
  224. display: -webkit-box;
  225. display: -webkit-flex;
  226. display: flex;
  227. -webkit-box-align: center;
  228. -webkit-align-items: center;
  229. align-items: center;
  230. position: relative;
  231. width: 580rpx;
  232. height: 36rpx;
  233. padding: 20rpx;
  234. background: #F7F7F7;
  235. border-radius: 10rpx;
  236. input{
  237. width: 100%;
  238. height: 100%;
  239. background: #F7F7F7;
  240. font-size: $font-size-26;
  241. line-height: 36rpx;
  242. color: #333333;
  243. min-height: 36rpx;
  244. }
  245. }
  246. }
  247. .goods-pros-b{
  248. width:100%;
  249. height: auto;
  250. padding: 10rpx 0;
  251. .sum-none{
  252. width: 100%;
  253. height: 48rpx;
  254. line-height: 48rpx;
  255. color: $text-color;
  256. float: left;
  257. text-align: right;
  258. .money{
  259. font-size: $font-size-26;
  260. color: #999999;
  261. text-decoration: line-through;
  262. }
  263. .money-sign{
  264. font-size: $font-size-26;
  265. color: #999999;
  266. text-decoration: line-through;
  267. }
  268. .money-reduced{
  269. margin-left: 10rpx;
  270. font-size: $font-size-26;
  271. color: $color-system;
  272. .iconfont{
  273. font-size: $font-size-34;
  274. }
  275. }
  276. }
  277. .sum{
  278. width: 100%;
  279. height: 48rpx;
  280. font-size: $font-size-28;
  281. line-height: 48rpx;
  282. color: $text-color;
  283. display: flex;
  284. justify-content: flex-end;
  285. .money{
  286. color: #FF2A2A;
  287. font-size: $font-size-28;
  288. }
  289. }
  290. }
  291. }
  292. }
  293. </style>