goodsList.vue 11 KB

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