goodsList.vue 8.4 KB

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