cm-goods-temp.vue 7.1 KB

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