cm-goods-temp.vue 8.9 KB

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