index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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.name }}
  12. </view>
  13. <view class="money">
  14. <!-- 积分商品价格 -->
  15. <PointsPrice v-if="productType===ProductTypeEnum.Integral" :pointsPrice="attr.productSelect"
  16. :pointsGoodsStyle="hotPointsStyle"></PointsPrice>
  17. <!-- 其他商品价格 -->
  18. <svip-price v-else :svipIconStyle="svipIconStyle" :productPrice="attr.productSelect"
  19. :svipPriceStyle="svipPriceStyle"></svip-price>
  20. <view class="mt-12">
  21. <!-- <text class="stock" v-if='isShow'>
  22. 库存:{{ attr.productSelect.groupPrice&&attr.productSelect.stock>0?attr.productSelect.groupStock:attr.productSelect.stock }}</text> -->
  23. <text class='stock' v-if="limitNum">限量: {{attr.productSelect.quota}}</text>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="iconfont icon-guanbi" @click="closeAttr"></view>
  28. </view>
  29. <view class="rollTop">
  30. <view class="productWinList">
  31. <view class="item" v-for="(item, indexw) in attr.productAttr" :key="indexw">
  32. <view class="title">{{ item.attrName }}</view>
  33. <view class="listn acea-row row-middle">
  34. <view class="itemn flex"
  35. :class="item.index === itemn.optionName&&(marketingType === ProductMarketingTypeEnum.Groupbuying||productType===ProductTypeEnum.Integral)?'groupOn':item.index === itemn.optionName?'on':''"
  36. v-for="(itemn, indexn) in item.optionList" @click="tapAttr(indexw, indexn,item)"
  37. :key="indexn">
  38. <image v-if="itemn.image" class="attr-img" :src="itemn.image" alt="" srcset="" />
  39. <text class="option-name">{{ itemn.optionName }}</text>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="cart acea-row row-between-wrapper">
  45. <view class="title">数量</view>
  46. <view class="limit-buy"
  47. v-if="marketingType === ProductMarketingTypeEnum.Groupbuying&&!isProductType&&buyLimitNum>0">
  48. {{`最多可购买(${buyLimitNum})件`}}
  49. </view>
  50. <view class="carnum acea-row row-left">
  51. <view v-if="!isProductType" class="item reduce"
  52. :class="attr.productSelect.cart_num <= 1 ? 'on' : ''" @click="CartNumDes">
  53. -
  54. </view>
  55. <view class='item num'>
  56. <input type="number" :always-embed="true" :adjust-position="true" cursor-spacing="50"
  57. :disabled="isProductType" v-model="attr.productSelect.cart_num"
  58. data-name="productSelect.cart_num" min="1" @input="bindCode" maxlength="3"></input>
  59. </view>
  60. <!-- 除拼团+++ -->
  61. <view v-if="iSplus && !isProductType&&marketingType !== ProductMarketingTypeEnum.Groupbuying"
  62. class="item plus" :class="attr.productSelect.cart_num >= attr.productSelect.stock? 'on': ''"
  63. @click="CartNumAdd(1)">
  64. +
  65. </view>
  66. <!-- 拼团商品+++ -->
  67. <view v-if="iSplus&&!isProductType&&marketingType === ProductMarketingTypeEnum.Groupbuying"
  68. class="item plus" :class="attr.productSelect.cart_num >= buyLimitNum? 'on': ''"
  69. @click="CartNumAdd(2)">
  70. +
  71. </view>
  72. <!-- <view v-if="!iSplus && !isProductType" class='item plus'
  73. :class='(attr.productSelect.cart_num >= attr.productSelect.quota) || (attr.productSelect.cart_num >= attr.productSelect.stock) || (attr.productSelect.cart_num >= attr.productSelect.num)? "on":""'
  74. @click='CartNumAdd'>+</view> -->
  75. </view>
  76. </view>
  77. </view>
  78. <view class="joinBnt bg_color" v-if="iSbnt && attr.productSelect.stock>0 &&attr.productSelect.quota>0"
  79. @click="goCat">我要参团</view>
  80. <view class="joinBnt on"
  81. v-else-if="(iSbnt && attr.productSelect.quota<=0)||(iSbnt &&attr.productSelect.stock<=0)">已售罄</view>
  82. <view class="joinBnt bg_color" v-if="iScart && attr.productSelect.stock" @click="goCat">确定</view>
  83. <!-- <view class="joinBnt bg-color" v-if="iSbnt && attr.productSelect.stock && attr.productSelect.quota" @click="goCat">确定</view> -->
  84. <view class="joinBnt on" v-else-if="(iScart && !attr.productSelect.stock)">已售罄</view>
  85. </view>
  86. <view class="mask" @touchmove.prevent :hidden="attr.cartAttr === false" @click="closeAttr"></view>
  87. </view>
  88. </template>
  89. <script>
  90. // +----------------------------------------------------------------------
  91. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  92. // +----------------------------------------------------------------------
  93. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  94. // +----------------------------------------------------------------------
  95. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  96. // +----------------------------------------------------------------------
  97. // | Author: CRMEB Team <admin@crmeb.com>
  98. // +----------------------------------------------------------------------
  99. import svipPrice from '@/components/svipPrice.vue';
  100. import PointsPrice from '@/components/PointsPrice.vue';
  101. import {
  102. ProductTypeEnum,
  103. ProductMarketingTypeEnum
  104. } from "@/enums/productEnums";
  105. /**
  106. * 积分商品推荐样式
  107. */
  108. export const hotPointsStyle = {
  109. iconStyle: {
  110. width: '32rpx',
  111. height: '32rpx'
  112. },
  113. priceStyle: {
  114. fontSize: '32rpx',
  115. },
  116. unitStyle: {
  117. fontSize: '28rpx',
  118. },
  119. }
  120. export default {
  121. components: {
  122. svipPrice,
  123. PointsPrice
  124. },
  125. props: {
  126. attr: {
  127. type: Object,
  128. default: () => {}
  129. },
  130. limitNum: {
  131. type: Number,
  132. value: 0
  133. },
  134. isShow: {
  135. type: Number,
  136. value: 0
  137. },
  138. iSbnt: {
  139. type: Number,
  140. value: 0
  141. },
  142. iSplus: {
  143. type: Number,
  144. value: 0
  145. },
  146. iScart: {
  147. type: Number,
  148. value: 0
  149. },
  150. // 商品类型 0=普通商品,1-积分商品,2-虚拟商品,4=视频号,5-云盘商品,6-卡密商品
  151. productType: {
  152. type: Number,
  153. value: 0
  154. },
  155. //0=基础商品,1=秒杀,2=拼团
  156. marketingType: {
  157. type: Number,
  158. value: 0
  159. },
  160. groupBuyActivityResponse: {
  161. default: () => {}
  162. }
  163. },
  164. data() {
  165. return {
  166. ProductTypeEnum: ProductTypeEnum,
  167. ProductMarketingTypeEnum: ProductMarketingTypeEnum,
  168. hotPointsStyle: hotPointsStyle, //积分金额样式
  169. //普通价格
  170. svipPriceStyle: {
  171. svipBox: {
  172. height: '34rpx',
  173. borderRadius: '60rpx 56rpx 56rpx 20rpx',
  174. },
  175. icon: {
  176. fontSize: '23rpx',
  177. height: '34rpx',
  178. borderRadius: '16rpx 0 16rpx 2rpx'
  179. },
  180. price: {
  181. fontSize: '44rpx'
  182. },
  183. svipPrice: {
  184. fontSize: '27rpx'
  185. }
  186. },
  187. //svip价格
  188. svipIconStyle: {
  189. svipBox: {
  190. height: '34rpx',
  191. borderRadius: '36rpx 40rpx 40rpx 0.4rpx',
  192. },
  193. price: {
  194. fontSize: '44rpx'
  195. },
  196. svipPrice: {
  197. fontSize: '22rpx'
  198. }
  199. },
  200. urlDomain: this.$Cache.get("imgHost")
  201. };
  202. },
  203. mounted() {},
  204. computed: {
  205. //是否是虚拟商品,云盘5
  206. isProductType() {
  207. return this.productType === 5;
  208. },
  209. buyLimitNum() {
  210. let buyLimitCount = this.groupBuyActivityResponse.buyLimitCount
  211. let groupStock = this.attr.productSelect.groupStock
  212. let stock = this.attr.productSelect.stock
  213. let oncQuota = this.groupBuyActivityResponse.oncQuota
  214. let allQuota = this.groupBuyActivityResponse.allQuota
  215. // 极端情况判断
  216. if (oncQuota == 0 && allQuota != 0) {
  217. oncQuota = allQuota
  218. }
  219. if (oncQuota == 0 && allQuota == 0) {
  220. oncQuota = groupStock
  221. allQuota = groupStock
  222. }
  223. if (buyLimitCount == -1) {
  224. buyLimitCount = groupStock
  225. }
  226. let min = Math.min(buyLimitCount, groupStock, oncQuota, stock)
  227. this.$emit('buyLimit', min);
  228. return min
  229. }
  230. },
  231. methods: {
  232. goCat: function() {
  233. this.$emit('goCat');
  234. },
  235. /**
  236. * 购物车手动输入数量
  237. *
  238. */
  239. bindCode: function(e) {
  240. this.$emit('iptCartNum', this.attr.productSelect.cart_num);
  241. },
  242. closeAttr: function() {
  243. this.$emit('myevent');
  244. },
  245. CartNumDes: function() {
  246. this.$emit('ChangeCartNum', false);
  247. },
  248. CartNumAdd: function(type) {
  249. this.$emit('ChangeCartNum', true, this.buyLimitNum, type);
  250. },
  251. tapAttr: function(indexw, indexn, item) {
  252. let that = this;
  253. that.$emit("attrVal", {
  254. indexw: indexw,
  255. indexn: indexn
  256. });
  257. this.$set(this.attr.productAttr[indexw], 'index', this.attr.productAttr[indexw].attrValues[indexn]);
  258. let value = that.getCheckedValue().join(",");
  259. //let value = that.getCheckedValue().join(",");
  260. that.$emit("ChangeAttr", value);
  261. },
  262. //获取被选中属性;
  263. getCheckedValue: function() {
  264. let productAttr = this.attr.productAttr;
  265. let value = [];
  266. for (let i = 0; i < productAttr.length; i++) {
  267. for (let j = 0; j < productAttr[i].attrValues.length; j++) {
  268. if (productAttr[i].index === productAttr[i].attrValues[j]) {
  269. value.push(productAttr[i].attrValues[j]);
  270. }
  271. }
  272. }
  273. return value;
  274. },
  275. showImg() {
  276. this.$emit('getImg');
  277. },
  278. }
  279. }
  280. </script>
  281. <style scoped lang="scss">
  282. .attr-img {
  283. width: 37rpx;
  284. height: 37rpx;
  285. margin-right: 12rpx;
  286. border-radius: 8rpx;
  287. }
  288. .product-window {
  289. position: fixed;
  290. bottom: 0;
  291. width: 100%;
  292. left: 0;
  293. background-color: #fff;
  294. z-index: 77;
  295. border-radius: 16rpx 16rpx 0 0;
  296. padding-bottom: 100rpx;
  297. padding-bottom: calc(env(safe-area-inset-bottom) + 100rpx);
  298. transform: translate3d(0, 100%, 0);
  299. transition: all .2s cubic-bezier(0, 0, .25, 1);
  300. }
  301. .product-window.on {
  302. transform: translate3d(0, 0, 0);
  303. }
  304. .product-window.join {
  305. padding-bottom: 30rpx;
  306. }
  307. .product-window.joinCart {
  308. padding-bottom: 30rpx;
  309. z-index: 999;
  310. }
  311. .product-window .textpic {
  312. padding: 0 130rpx 0 24rpx;
  313. margin-top: 29rpx;
  314. position: relative;
  315. }
  316. .product-window .textpic .pictrue {
  317. width: 150rpx;
  318. height: 150rpx;
  319. }
  320. .product-window .textpic .pictrue image {
  321. width: 100%;
  322. height: 100%;
  323. border-radius: 10rpx;
  324. }
  325. .product-window .textpic .text {
  326. width: 424rpx;
  327. font-size: 28rpx;
  328. color: #333333;
  329. }
  330. .product-window .textpic .text .money {
  331. font-size: 28rpx;
  332. margin-top: 12rpx;
  333. @include price_color(theme);
  334. }
  335. .product-window .textpic .text .money .num {
  336. font-family: PingFang SC;
  337. font-size: 36rpx;
  338. font-weight: 600;
  339. }
  340. .product-window .textpic .text .money .stock {
  341. color: #999;
  342. }
  343. .product-window .textpic .iconfont {
  344. position: absolute;
  345. right: 30rpx;
  346. top: -5rpx;
  347. font-size: 35rpx;
  348. color: #8a8a8a;
  349. }
  350. .product-window .rollTop {
  351. max-height: 760rpx; //规格较多时候弹框高度为高为800rpx
  352. overflow: auto;
  353. margin-top: 36rpx;
  354. }
  355. .product-window .productWinList .item~.item {
  356. margin-top: 36rpx;
  357. }
  358. .product-window .productWinList .item .title {
  359. font-size: 28rpx;
  360. color: #999;
  361. padding: 0 30rpx;
  362. }
  363. .product-window .productWinList .item .listn {
  364. padding: 0 30rpx 0 16rpx;
  365. }
  366. .product-window .productWinList .item .listn .itemn {
  367. border: 1px solid #F2F2F2;
  368. font-size: 26rpx;
  369. color: #282828;
  370. padding: 4rpx 0;
  371. border-radius: 8rpx;
  372. margin: 20rpx 0 0 14rpx;
  373. background-color: #F2F2F2;
  374. .attr-img{
  375. margin: 0 -8rpx 0 4rpx;
  376. }
  377. .option-name{
  378. margin: 0 20rpx 0;
  379. }
  380. }
  381. .product-window .productWinList .item .listn .itemn.on {
  382. @include main_color(theme);
  383. @include coupons_border_color(theme);
  384. @include cate-two-btn(theme);
  385. }
  386. .product-window .productWinList .item .listn .itemn.limit {
  387. color: #999;
  388. text-decoration: line-through;
  389. }
  390. .product-window .cart {
  391. margin-top: 50rpx;
  392. margin-bottom: 30rpx;
  393. padding: 0 24rpx;
  394. }
  395. .product-window .cart .title {
  396. font-size: 30rpx;
  397. color: #999;
  398. }
  399. .product-window .cart .carnum {
  400. height: 54rpx;
  401. }
  402. .product-window .cart .carnum view {
  403. // border: 1px solid #a4a4a4;
  404. width: 84rpx;
  405. text-align: center;
  406. height: 100%;
  407. line-height: 54rpx;
  408. color: #282828;
  409. font-size: 45rpx;
  410. }
  411. .product-window .cart .carnum .reduce {
  412. border-right: 0;
  413. border-radius: 6rpx 0 0 6rpx;
  414. line-height: 48rpx;
  415. }
  416. .product-window .cart .carnum .reduce.on {
  417. // border-color: #e3e3e3;
  418. color: #DEDEDE;
  419. font-size: 44rpx;
  420. }
  421. .product-window .cart .carnum .plus {
  422. border-left: 0;
  423. border-radius: 0 6rpx 6rpx 0;
  424. line-height: 46rpx;
  425. }
  426. .product-window .cart .carnum .plus.on {
  427. border-color: #e3e3e3;
  428. color: #dedede;
  429. }
  430. .product-window .cart .carnum .num {
  431. background: rgba(242, 242, 242, 1);
  432. color: #282828;
  433. font-size: 28rpx;
  434. border-radius: 12rpx;
  435. line-height: 54rpx;
  436. height: 54rpx;
  437. input {
  438. display: -webkit-inline-box;
  439. line-height: 54rpx;
  440. height: 54rpx;
  441. }
  442. }
  443. .product-window .joinBnt {
  444. font-size: 30rpx;
  445. width: 620rpx;
  446. height: 86rpx;
  447. border-radius: 50rpx;
  448. text-align: center;
  449. line-height: 86rpx;
  450. color: #fff;
  451. margin: 21rpx auto 0 auto;
  452. }
  453. .align-baseline {
  454. align-items: baseline;
  455. }
  456. .bg_color {
  457. @include main-bg_color(theme);
  458. }
  459. .product-window .joinBnt.on {
  460. background-color: #bbb;
  461. color: #fff;
  462. }
  463. .align-center {
  464. align-items: center;
  465. }
  466. .vip_icon {
  467. width: 44rpx;
  468. height: 28rpx;
  469. }
  470. .vip_money {
  471. background: #FFE7B9;
  472. border-radius: 4px;
  473. font-size: 22rpx;
  474. color: #333;
  475. line-height: 28rpx;
  476. text-align: center;
  477. padding: 0 6rpx;
  478. box-sizing: border-box;
  479. margin-left: -4rpx;
  480. }
  481. .pl-2 {
  482. padding-left: 20rpx;
  483. }
  484. .limit-buy {
  485. font-weight: 400;
  486. font-size: 22rpx;
  487. color: #E93323;
  488. margin-left: 25%;
  489. }
  490. .groupOn {
  491. background: #FCEAE9 !important;
  492. border: 1px solid #E93323 !important;
  493. color: #E93323 !important;
  494. }
  495. </style>