cm-goods-temp.vue 8.9 KB

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