cm-goods-temp.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template name="goods">
  2. <view class="goods-template">
  3. <!-- 商品列表 -->
  4. <view class="goods-list">
  5. <view v-for="(supplier, index) in goodsData" :key="index" class="goods-item">
  6. <view class="shoptitle">
  7. <view v-if="supplier.promotions" class="floor-item-act">
  8. <view class="floor-tags">{{ supplier.promotions.name }}</view>
  9. </view>
  10. <view class="title-text">{{ supplier.shopName }}</view>
  11. </view>
  12. <view class="productlist" v-for="(pros, idx) in supplier.cartList" :key="idx">
  13. <view class="goods-pros-t">
  14. <view class="pros-img">
  15. <image :src="pros.image" alt="" />
  16. <text class="tips" v-if="pros.giftType == 2 || pros.giftType == 1">赠品</text>
  17. </view>
  18. <view class="pros-product">
  19. <view class="producttitle">{{ pros.name }}</view>
  20. <view class="productspec" v-if="pros.productCategory != 2">规格:{{ pros.unit }}</view>
  21. <view class="productspec" v-if="pros.productCode != '' && pros.productCode != null">
  22. <view>商品编码:{{ pros.productCode }}</view>
  23. </view>
  24. <view class="productprice">
  25. <view class="price"
  26. ><text>¥{{ pros.price | NumFormat }}</text></view
  27. >
  28. <view class="count"><text class="small">x</text>{{ pros.number }}</view>
  29. </view>
  30. <view class="floor-item-act">
  31. <template v-if="pros.actStatus == 1 && pros.promotions">
  32. <view v-if="PromotionsFormat(pros.promotions)" class="floor-tags">
  33. {{ pros.promotions.name }}
  34. <text v-if="pros.promotions">
  35. :¥{{
  36. pros.promotions == null
  37. ? '0.00'
  38. : pros.promotions.touchPrice | NumFormat
  39. }}
  40. </text>
  41. </view>
  42. <view v-else-if="pros.promotions.type != 3" class="floor-tags">{{
  43. pros.promotions.name
  44. }}</view>
  45. </template>
  46. <template v-if="pros.svipProductFlag == 1 && vipFlag == 1">
  47. <view class="svip-tags">
  48. <view class="tags">SVIP</view>
  49. <view class="price">{{ pros.svipPriceTag }}</view>
  50. </view>
  51. </template>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="goods-pros-m">
  57. <view class="m-text">留言:</view>
  58. <view class="m-input">
  59. <input
  60. type="text"
  61. v-model="remark[index]"
  62. @change="changeHandle(index)"
  63. placeholder-class="placeholder"
  64. maxlength="50"
  65. placeholder="选填,最多不超过50个汉字"
  66. />
  67. </view>
  68. </view>
  69. <!-- 运费 -->
  70. <cm-freight-popup
  71. ref="freight"
  72. v-if="isFreight"
  73. :index.sync="index"
  74. :supplier.sync="supplier"
  75. @changePostage="changePostageFlag"
  76. @changeColdChina="hanldChangeColdChina"
  77. />
  78. <view class="goods-pros-b">
  79. <view class="sum-none" v-if="supplier.originalPrice - supplier.totalPrice > 0">
  80. <text class="money-sign">¥</text>
  81. <text class="money">{{ supplier.originalPrice | NumFormat }}</text>
  82. <text class="money-reduced"
  83. >减<text>¥{{ (supplier.originalPrice - supplier.totalPrice) | NumFormat }}</text></text
  84. >
  85. </view>
  86. <view class="sum" v-if="secondflag"
  87. >合计:<text class="money">¥{{ supplier.totalPrice | NumFormat }}</text></view
  88. >
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </template>
  94. <script>
  95. import cmFreightPopup from './cm-freight-popup'
  96. export default {
  97. name: 'goods',
  98. components: {
  99. cmFreightPopup
  100. },
  101. props: {
  102. goodsData: {
  103. type: Array
  104. },
  105. secondflag: {
  106. type: Boolean,
  107. default: true
  108. }
  109. },
  110. data() {
  111. return {
  112. isFreight:false,
  113. remark: [],
  114. vipFlag: 0
  115. }
  116. },
  117. created() {
  118. this.initGetStotage()
  119. },
  120. filters: {
  121. NumFormat(value) {
  122. //处理金额
  123. return Number(value).toFixed(2)
  124. }
  125. },
  126. watch: {
  127. goodsData: {
  128. handler: function(el) {
  129. //监听对象的变换使用 function,箭头函数容易出现this指向不正确
  130. this.goodsData = el
  131. },
  132. deep: true
  133. }
  134. },
  135. computed: {},
  136. methods: {
  137. async initGetStotage() {
  138. const userInfo = await this.$api.getStorage()
  139. this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
  140. this.isFreight = true
  141. },
  142. // 勾选冷链费操作
  143. hanldChangeColdChina(supplier,index){
  144. this.goodsData[index] = supplier
  145. this.$emit('handleGoodList', this.goodsData)
  146. this.$emit('changeChina', supplier)
  147. },
  148. // 更换运费类型 1 不包邮 2 到付
  149. changePostageFlag(supplier,index){
  150. this.goodsData[index] = supplier
  151. this.$emit('handleGoodList', this.goodsData)
  152. this.$emit('changePostage', supplier)
  153. },
  154. PromotionsFormat(promo) {
  155. //促销活动类型数据处理
  156. if (promo != null) {
  157. if (promo.type == 1 && promo.mode == 1) {
  158. return true
  159. } else {
  160. return false
  161. }
  162. }
  163. return false
  164. },
  165. changeHandle(index) {
  166. //输入框的值被改变后
  167. this.goodsData[index].note = this.remark[index]
  168. this.$emit('handleGoodList', this.goodsData)
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss">
  174. .goods-template {
  175. width: 100%;
  176. height: auto;
  177. background: #ffffff;
  178. float: left;
  179. margin-top: 24rpx;
  180. .goods-list {
  181. width: 100%;
  182. height: auto;
  183. background: #f7f7f7;
  184. .goods-item {
  185. width: 702rpx;
  186. padding: 0 24rpx;
  187. background: #ffffff;
  188. margin-bottom: 24rpx;
  189. &:last-child {
  190. margin-bottom: 0;
  191. }
  192. }
  193. .shoptitle {
  194. display: flex;
  195. align-items: center;
  196. height: 80rpx;
  197. line-height: 80rpx;
  198. .title-text {
  199. width: 400rpx;
  200. overflow: hidden;
  201. text-overflow: ellipsis;
  202. white-space: nowrap;
  203. float: left;
  204. font-size: $font-size-28;
  205. color: $text-color;
  206. text-align: left;
  207. line-height: 56rpx;
  208. font-weight: bold;
  209. }
  210. .floor-item-act {
  211. height: 56rpx;
  212. text-align: center;
  213. box-sizing: border-box;
  214. float: left;
  215. padding: 12rpx 0;
  216. margin-right: 12rpx;
  217. }
  218. }
  219. .productlist {
  220. width: 100%;
  221. height: auto;
  222. }
  223. .goods-pros-t {
  224. display: flex;
  225. align-items: center;
  226. width: 100%;
  227. height: auto;
  228. padding: 12rpx 0;
  229. .pros-img {
  230. width: 210rpx;
  231. height: 100%;
  232. border-radius: 10rpx;
  233. margin: 0 26rpx 0 0;
  234. position: relative;
  235. .tips {
  236. display: inline-block;
  237. width: 80rpx;
  238. height: 40rpx;
  239. background-image: linear-gradient(214deg, #ff4500 0%, #ff5800 53%, #ff4367 100%);
  240. line-height: 40rpx;
  241. text-align: center;
  242. font-size: $font-size-24;
  243. color: #ffffff;
  244. border-radius: 10rpx 0 10rpx 0;
  245. position: absolute;
  246. top: 0;
  247. left: 0;
  248. }
  249. image {
  250. width: 210rpx;
  251. height: 210rpx;
  252. border-radius: 10rpx;
  253. border: 1px solid #f3f3f3;
  254. }
  255. }
  256. }
  257. .pros-product {
  258. width: 468rpx;
  259. height: 100%;
  260. line-height: 40rpx;
  261. font-size: $font-size-26;
  262. position: relative;
  263. .producttitle {
  264. width: 100%;
  265. display: inline-block;
  266. height: auto;
  267. text-overflow: ellipsis;
  268. display: -webkit-box;
  269. word-break: break-all;
  270. -webkit-box-orient: vertical;
  271. -webkit-line-clamp: 2;
  272. overflow: hidden;
  273. margin-bottom: 8rpx;
  274. }
  275. .productspec {
  276. height: 40rpx;
  277. line-height: 40rpx;
  278. color: #999999;
  279. text-overflow: ellipsis;
  280. display: -webkit-box;
  281. word-break: break-all;
  282. -webkit-box-orient: vertical;
  283. -webkit-line-clamp: 1;
  284. overflow: hidden;
  285. }
  286. .productprice {
  287. height: 54rpx;
  288. width: 100%;
  289. float: left;
  290. .price {
  291. line-height: 54rpx;
  292. font-size: $font-size-28;
  293. width: 48%;
  294. color: #ff2a2a;
  295. float: left;
  296. }
  297. .count {
  298. height: 100%;
  299. float: right;
  300. position: relative;
  301. .small {
  302. color: #666666;
  303. }
  304. }
  305. }
  306. .floor-item-act {
  307. width: 100%;
  308. height: 56rpx;
  309. text-align: center;
  310. box-sizing: border-box;
  311. float: left;
  312. padding: 0 0 10rpx 0;
  313. }
  314. }
  315. .goods-pros-b {
  316. width: 100%;
  317. height: auto;
  318. padding: 10rpx 0;
  319. .sum-none {
  320. width: 100%;
  321. height: 48rpx;
  322. line-height: 48rpx;
  323. color: $text-color;
  324. float: left;
  325. text-align: right;
  326. .money {
  327. font-size: $font-size-26;
  328. color: #999999;
  329. text-decoration: line-through;
  330. }
  331. .money-sign {
  332. font-size: $font-size-26;
  333. color: #999999;
  334. text-decoration: line-through;
  335. }
  336. .money-reduced {
  337. margin-left: 10rpx;
  338. font-size: $font-size-26;
  339. color: $color-system;
  340. .iconfont {
  341. font-size: $font-size-34;
  342. }
  343. }
  344. }
  345. .sum {
  346. width: 100%;
  347. height: 48rpx;
  348. font-size: $font-size-28;
  349. line-height: 48rpx;
  350. color: $text-color;
  351. display: flex;
  352. justify-content: flex-end;
  353. .money {
  354. color: #ff2a2a;
  355. font-size: $font-size-28;
  356. }
  357. }
  358. }
  359. }
  360. }
  361. .goods-pros-m {
  362. height: 76rpx;
  363. line-height: 76rpx;
  364. font-size: $font-size-26;
  365. color: $text-color;
  366. margin-top: 12rpx;
  367. .m-text {
  368. width: 62rpx;
  369. float: left;
  370. padding-right: 20rpx;
  371. font-weight: bold;
  372. }
  373. .m-input {
  374. display: -webkit-box;
  375. display: -webkit-flex;
  376. display: flex;
  377. -webkit-box-align: center;
  378. -webkit-align-items: center;
  379. align-items: center;
  380. position: relative;
  381. width: 580rpx;
  382. height: 36rpx;
  383. padding: 20rpx;
  384. background: #f7f7f7;
  385. border-radius: 10rpx;
  386. input {
  387. width: 100%;
  388. height: 100%;
  389. background: #f7f7f7;
  390. font-size: $font-size-26;
  391. line-height: 36rpx;
  392. color: #333333;
  393. min-height: 36rpx;
  394. }
  395. }
  396. }
  397. </style>