You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

390 lines
9.0 KiB

3 months ago
  1. <template>
  2. <view>
  3. <view class="product-window"
  4. :class="(attr.cartAttr === true ? 'on' : '') + ' ' + (iSbnt?'join':'') + ' ' + (iScart?'joinCart':'')">
  5. <view class="textpic acea-row row-between-wrapper">
  6. <view class="pictrue" @click="showImg()">
  7. <image :src="attr.productSelect.image"></image>
  8. </view>
  9. <view class="text">
  10. <view class="line1">
  11. {{ attr.productSelect.storeName }}
  12. </view>
  13. <view class="money">
  14. <view class="flex align-baseline">
  15. <text class="num">{{ attr.productSelect.price }}</text>
  16. <view class="flex pl-2"
  17. v-if="attr.productSelect.vipPrice && attr.productSelect.vipPrice > 0">
  18. <image :src="urlDomain+'crmebimage/perset/staticImg/vip_badge.png'" class="vip_icon"></image>
  19. <text class='vip_money skeleton-rect'>{{attr.productSelect.vipPrice}}</text>
  20. </view>
  21. </view>
  22. <view>
  23. <text class="stock" v-if='isShow'>库存: {{ attr.productSelect.stock }}</text>
  24. <text class='stock' v-if="limitNum">限量: {{attr.productSelect.quota}}</text>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="iconfont icon-guanbi" @click="closeAttr"></view>
  29. </view>
  30. <view class="rollTop">
  31. <view class="productWinList">
  32. <view class="item" v-for="(item, indexw) in attr.productAttr" :key="indexw">
  33. <view class="title">{{ item.attrName }}</view>
  34. <view class="listn acea-row row-middle">
  35. <view class="itemn" :class="item.index === itemn ? 'on' : ''"
  36. v-for="(itemn, indexn) in item.attrValues" @click="tapAttr(indexw, indexn)"
  37. :key="indexn">
  38. {{ itemn }}
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="cart acea-row row-between-wrapper">
  44. <view class="title">数量</view>
  45. <view class="carnum acea-row row-left">
  46. <view class="item reduce" :class="attr.productSelect.cart_num <= 1 ? 'on' : ''"
  47. @click="CartNumDes">
  48. -
  49. </view>
  50. <view class='item num'>
  51. <input type="number" v-model="attr.productSelect.cart_num"
  52. data-name="productSelect.cart_num" @input="bindCode(attr.productSelect.cart_num)"
  53. maxlength="3"></input>
  54. </view>
  55. <view v-if="iSplus" class="item plus" :class="attr.productSelect.cart_num >= attr.productSelect.stock? 'on': ''" @click="CartNumAdd">
  56. +
  57. </view>
  58. <view v-else class='item plus'
  59. :class='(attr.productSelect.cart_num === onceNum) || (attr.productSelect.cart_num >= attr.productSelect.quota) || (attr.productSelect.cart_num >= attr.productSelect.stock) || (attr.productSelect.cart_num >= attr.productSelect.num)? "on":""'
  60. @click='CartNumAdd'>+</view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="joinBnt bg_color" v-if="iSbnt && attr.productSelect.stock>0 &&attr.productSelect.quota>0"
  65. @click="goCat">我要参团</view>
  66. <view class="joinBnt on"
  67. v-else-if="(iSbnt && attr.productSelect.quota<=0)||(iSbnt &&attr.productSelect.stock<=0)">已售罄</view>
  68. <view class="joinBnt bg_color" v-if="iScart && attr.productSelect.stock" @click="goCat">确定</view>
  69. <!-- <view class="joinBnt bg-color" v-if="iSbnt && attr.productSelect.stock && attr.productSelect.quota" @click="goCat">确定</view> -->
  70. <view class="joinBnt on" v-else-if="(iScart && !attr.productSelect.stock)">已售罄</view>
  71. </view>
  72. <view class="mask" @touchmove.prevent :hidden="attr.cartAttr === false" @click="closeAttr"></view>
  73. </view>
  74. </template>
  75. <script>
  76. export default {
  77. props: {
  78. attr: {
  79. type: Object,
  80. default: () => {}
  81. },
  82. //一次最多可买几个,活动商品中使用
  83. onceNum: {
  84. type: Number,
  85. value: 1
  86. },
  87. limitNum: {
  88. type: Number,
  89. value: 0
  90. },
  91. isShow: {
  92. type: Number,
  93. value: 0
  94. },
  95. iSbnt: {
  96. type: Number,
  97. value: 0
  98. },
  99. iSplus: {
  100. type: Number,
  101. value: 0
  102. },
  103. iScart: {
  104. type: Number,
  105. value: 0
  106. }
  107. },
  108. data() {
  109. return {
  110. urlDomain: this.$Cache.get("imgHost"),
  111. };
  112. },
  113. created() {},
  114. methods: {
  115. goCat: function() {
  116. this.$emit('goCat');
  117. },
  118. /**
  119. * 购物车手动输入数量
  120. *
  121. */
  122. bindCode: function(e) {
  123. this.$emit('iptCartNum', this.attr.productSelect.cart_num);
  124. },
  125. closeAttr: function() {
  126. this.$emit('myevent');
  127. },
  128. CartNumDes: function() {
  129. this.$emit('ChangeCartNum', false);
  130. },
  131. CartNumAdd: function() {
  132. this.$emit('ChangeCartNum', true);
  133. },
  134. tapAttr: function(indexw, indexn) {
  135. let that = this;
  136. that.$emit("attrVal", {
  137. indexw: indexw,
  138. indexn: indexn
  139. });
  140. this.$set(this.attr.productAttr[indexw], 'index', this.attr.productAttr[indexw].attrValues[indexn]);
  141. let value = that.getCheckedValue().join(",");
  142. that.$emit("ChangeAttr", value);
  143. },
  144. //获取被选中属性;
  145. getCheckedValue: function() {
  146. let productAttr = this.attr.productAttr;
  147. let value = [];
  148. for (let i = 0; i < productAttr.length; i++) {
  149. for (let j = 0; j < productAttr[i].attrValues.length; j++) {
  150. if (productAttr[i].index === productAttr[i].attrValues[j]) {
  151. value.push(productAttr[i].attrValues[j]);
  152. }
  153. }
  154. }
  155. return value;
  156. },
  157. showImg() {
  158. this.$emit('getImg');
  159. },
  160. }
  161. }
  162. </script>
  163. <style scoped lang="scss">
  164. .product-window {
  165. position: fixed;
  166. bottom: 0;
  167. width: 100%;
  168. left: 0;
  169. background-color: #fff;
  170. z-index: 77;
  171. border-radius: 16rpx 16rpx 0 0;
  172. padding-bottom: 100rpx;
  173. padding-bottom: calc(env(safe-area-inset-bottom) + 100rpx);
  174. transform: translate3d(0, 100%, 0);
  175. transition: all .2s cubic-bezier(0, 0, .25, 1);
  176. }
  177. .product-window.on {
  178. transform: translate3d(0, 0, 0);
  179. }
  180. .product-window.join {
  181. padding-bottom: 30rpx;
  182. }
  183. .product-window.joinCart {
  184. padding-bottom: 30rpx;
  185. z-index: 999;
  186. }
  187. .product-window .textpic {
  188. padding: 0 130rpx 0 30rpx;
  189. margin-top: 29rpx;
  190. position: relative;
  191. }
  192. .product-window .textpic .pictrue {
  193. width: 150rpx;
  194. height: 150rpx;
  195. }
  196. .product-window .textpic .pictrue image {
  197. width: 100%;
  198. height: 100%;
  199. border-radius: 10rpx;
  200. }
  201. .product-window .textpic .text {
  202. width: 410rpx;
  203. font-size: 32rpx;
  204. color: #333333;
  205. }
  206. .product-window .textpic .text .money {
  207. font-size: 24rpx;
  208. margin-top: 23rpx;
  209. @include price_color(theme);
  210. }
  211. .product-window .textpic .text .money .num {
  212. font-family: PingFang SC;
  213. font-size: 36rpx;
  214. font-weight: 600;
  215. }
  216. .product-window .textpic .text .money .stock {
  217. color: #999;
  218. }
  219. .product-window .textpic .iconfont {
  220. position: absolute;
  221. right: 30rpx;
  222. top: -5rpx;
  223. font-size: 35rpx;
  224. color: #8a8a8a;
  225. }
  226. .product-window .rollTop {
  227. max-height: 62vh;
  228. overflow: auto;
  229. margin-top: 36rpx;
  230. }
  231. .product-window .productWinList .item~.item {
  232. margin-top: 36rpx;
  233. }
  234. .product-window .productWinList .item .title {
  235. font-size: 30rpx;
  236. color: #999;
  237. padding: 0 30rpx;
  238. }
  239. .product-window .productWinList .item .listn {
  240. padding: 0 30rpx 0 16rpx;
  241. }
  242. .product-window .productWinList .item .listn .itemn {
  243. border: 1px solid #F2F2F2;
  244. font-size: 26rpx;
  245. color: #282828;
  246. padding: 7rpx 33rpx;
  247. border-radius: 40rpx;
  248. margin: 20rpx 0 0 14rpx;
  249. background-color: #F2F2F2;
  250. }
  251. .product-window .productWinList .item .listn .itemn.on {
  252. @include main_color(theme);
  253. @include coupons_border_color(theme);
  254. @include cate-two-btn(theme);
  255. }
  256. .product-window .productWinList .item .listn .itemn.limit {
  257. color: #999;
  258. text-decoration: line-through;
  259. }
  260. .product-window .cart {
  261. margin-top: 50rpx;
  262. margin-bottom: 30rpx;
  263. padding: 0 30rpx;
  264. }
  265. .product-window .cart .title {
  266. font-size: 30rpx;
  267. color: #999;
  268. }
  269. .product-window .cart .carnum {
  270. height: 54rpx;
  271. }
  272. .product-window .cart .carnum view {
  273. // border: 1px solid #a4a4a4;
  274. width: 84rpx;
  275. text-align: center;
  276. height: 100%;
  277. line-height: 54rpx;
  278. color: #282828;
  279. font-size: 45rpx;
  280. }
  281. .product-window .cart .carnum .reduce {
  282. border-right: 0;
  283. border-radius: 6rpx 0 0 6rpx;
  284. line-height: 48rpx;
  285. }
  286. .product-window .cart .carnum .reduce.on {
  287. // border-color: #e3e3e3;
  288. color: #DEDEDE;
  289. font-size: 44rpx;
  290. }
  291. .product-window .cart .carnum .plus {
  292. border-left: 0;
  293. border-radius: 0 6rpx 6rpx 0;
  294. line-height: 46rpx;
  295. }
  296. .product-window .cart .carnum .plus.on {
  297. border-color: #e3e3e3;
  298. color: #dedede;
  299. }
  300. .product-window .cart .carnum .num {
  301. background: rgba(242, 242, 242, 1);
  302. color: #282828;
  303. font-size: 28rpx;
  304. border-radius: 12rpx;
  305. line-height: 29px;
  306. height: 54rpx;
  307. input {
  308. display: -webkit-inline-box;
  309. }
  310. }
  311. .product-window .joinBnt {
  312. font-size: 30rpx;
  313. width: 620rpx;
  314. height: 86rpx;
  315. border-radius: 50rpx;
  316. text-align: center;
  317. line-height: 86rpx;
  318. color: #fff;
  319. margin: 21rpx auto 0 auto;
  320. }
  321. .align-baseline {
  322. align-items: baseline;
  323. }
  324. .bg_color {
  325. @include main-bg_color(theme);
  326. }
  327. .product-window .joinBnt.on {
  328. background-color: #bbb;
  329. color: #fff;
  330. }
  331. .align-center {
  332. align-items: center;
  333. }
  334. .vip_icon {
  335. width: 44rpx;
  336. height: 28rpx;
  337. }
  338. .vip_money {
  339. background: #FFE7B9;
  340. border-radius: 4px;
  341. font-size: 22rpx;
  342. color: #333;
  343. line-height: 28rpx;
  344. text-align: center;
  345. padding: 0 6rpx;
  346. box-sizing: border-box;
  347. margin-left: -4rpx;
  348. }
  349. .pl-2 {
  350. padding-left: 20rpx;
  351. }
  352. </style>