index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. <template>
  2. <view :style="colorStyle">
  3. <view
  4. class="product-window"
  5. :class="
  6. (attr.cartAttr === true ? 'on' : '') +
  7. ' ' +
  8. (iSbnt ? 'join' : '') +
  9. ' ' +
  10. (iScart ? 'joinCart' : '') +
  11. ' ' +
  12. (type == '2' ? 'joinCart2' : '')
  13. "
  14. :style="{ bottom: bottomVal }"
  15. @touchmove.stop
  16. >
  17. <view
  18. class="textpic acea-row row-between-wrapper"
  19. @touchmove.stop.prevent="moveHandle"
  20. >
  21. <view class="pictrue" @click="showImg()">
  22. <image :src="attr.productSelect.image"></image>
  23. </view>
  24. <view class="text">
  25. <view class="line2 store-name">
  26. {{ attr.productSelect.store_name }}
  27. </view>
  28. <view class="money font-color">
  29. <view class="acea-row row-middle">
  30. {{ $t(`到手价`) }}
  31. <baseMoney
  32. class="mr-12"
  33. :money="attr.productSelect.price"
  34. symbolSize="24"
  35. integerSize="40"
  36. decimalSize="24"
  37. weight
  38. color="var(--view-theme)"
  39. ></baseMoney>
  40. <!-- <text class='vip-money'
  41. v-if="is_vip == 0 && attr.productSelect.vip_price">{{$t(`¥`)}}{{attr.productSelect.vip_price}}</text>
  42. <view class="vipImg" v-if="is_vip == 0 && attr.productSelect.vip_price">
  43. <image src="../../static/images/svip.gif"></image>
  44. </view> -->
  45. </view>
  46. <text class="stock" v-if="isShow && !type"
  47. >{{ $t(`库存`) }}
  48. {{ attr.productSelect.stock || 0 + unitName }}</text
  49. >
  50. <text class="stock" v-if="limitNum && type"
  51. >{{ $t(`库存`) }}
  52. {{ attr.productSelect.quota || 0 + unitName }}</text
  53. >
  54. <text class="stock" v-if="minQty > 1 && is_virtual"
  55. >{{ $t(`起购`) }} {{ minQty + unitName }}</text
  56. >
  57. </view>
  58. </view>
  59. <view class="iconfont icon-guanbi" @click="closeAttr"></view>
  60. </view>
  61. <scroll-view class="rollTop" scroll-y @touchmove.stop.prevent="moveHandle">
  62. <view class="productWinList">
  63. <view
  64. class="item"
  65. v-for="(item, indexw) in attr.productAttr"
  66. :key="indexw"
  67. >
  68. <view class="title">{{ $t(item.attr_name) }}</view>
  69. <view class="listn acea-row row-middle">
  70. <view
  71. class="itemn"
  72. :class="item.index === itemn.attr ? 'on' : ''"
  73. v-for="(itemn, indexn) in item.attr_value"
  74. @click="tapAttr(indexw, indexn)"
  75. :key="indexn"
  76. >
  77. <img
  78. v-if="itemn.pic"
  79. class="attr-img"
  80. :src="itemn.pic"
  81. alt=""
  82. srcset=""
  83. />
  84. {{ $t(itemn.attr) }}
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="cart acea-row row-between-wrapper" v-if="!is_virtual">
  90. <view class="title">{{ $t(`数量`) }}</view>
  91. <view class="carnum acea-row row-left">
  92. <text class="stock" v-if="limitNum && !type"
  93. >{{ $t(`限购`) }}{{ limitNum + unitName }}</text
  94. >
  95. <text class="stock line" v-if="limitNum && !type && minQty > 1">
  96. |
  97. </text>
  98. <text class="stock" v-if="minQty > 1"
  99. >{{ $t(`起购`) }}{{ minQty + unitName }}</text
  100. >
  101. <view
  102. class="item reduce acea-row row-center-wrapper"
  103. :class="attr.productSelect.cart_num <= minQty ? 'on' : ''"
  104. v-if="attr.productSelect.cart_num <= minQty"
  105. >
  106. <text class="iconfont icon-shangpinshuliang-jian"></text>
  107. </view>
  108. <view
  109. class="item reduce acea-row row-center-wrapper"
  110. :class="attr.productSelect.cart_num <= minQty ? 'on' : ''"
  111. @click="CartNumDes"
  112. v-else
  113. >
  114. <text class="iconfont icon-shangpinshuliang-jian"></text>
  115. </view>
  116. <view class="item num acea-row row-middle">
  117. <input
  118. type="number"
  119. v-model="attr.productSelect.cart_num"
  120. data-name="productSelect.cart_num"
  121. @input="bindCode(attr.productSelect.cart_num)"
  122. @focus="inputBindFocus"
  123. @blur="inputBindBlur"
  124. />
  125. </view>
  126. <view
  127. v-if="iSplus"
  128. class="item plus acea-row row-center-wrapper"
  129. :class="
  130. attr.productSelect.cart_num >= attr.productSelect.stock ||
  131. (limitNum && attr.productSelect.cart_num >= limitNum)
  132. ? 'on'
  133. : ''
  134. "
  135. @click="CartNumAdd"
  136. >
  137. <text class="iconfont icon-shangpinshuliang-jia"></text>
  138. </view>
  139. <view
  140. v-else
  141. class="item plus"
  142. :class="
  143. attr.productSelect.cart_num >= attr.productSelect.quota ||
  144. attr.productSelect.cart_num >=
  145. attr.productSelect.product_stock ||
  146. attr.productSelect.cart_num >= attr.productSelect.num ||
  147. (type == 'seckill' &&
  148. attr.productSelect.cart_num >= attr.productSelect.once_num)
  149. ? 'on'
  150. : ''
  151. "
  152. @click="CartNumAdd"
  153. >+</view
  154. >
  155. </view>
  156. </view>
  157. </scroll-view>
  158. <view
  159. class="joinBnt bg-color"
  160. v-if="
  161. iSbnt &&
  162. attr.productSelect.product_stock > 0 &&
  163. attr.productSelect.quota > 0
  164. "
  165. @click="goCat"
  166. >
  167. {{ $t(`我要参团`) }}
  168. </view>
  169. <view
  170. class="joinBnt on"
  171. v-else-if="
  172. (iSbnt && attr.productSelect.quota <= 0) ||
  173. (iSbnt && attr.productSelect.product_stock <= 0)
  174. "
  175. >
  176. {{ $t(`已售罄`) }}
  177. </view>
  178. <view
  179. class="joinBnt bg-color"
  180. v-if="iScart && attr.productSelect.stock"
  181. @click="goCat"
  182. >{{ $t(`确定`) }}</view
  183. >
  184. <view
  185. class="joinBnt on"
  186. v-else-if="iScart && !attr.productSelect.stock"
  187. >{{ $t(`已售罄`) }}</view
  188. >
  189. </view>
  190. <view
  191. class="mask"
  192. @touchmove.stop.prevent="moveHandle"
  193. :hidden="attr.cartAttr === false"
  194. @click="closeAttr"
  195. >
  196. </view>
  197. </view>
  198. </template>
  199. <script>
  200. import colors from "@/mixins/color";
  201. export default {
  202. mixins: [colors],
  203. props: {
  204. attr: {
  205. type: Object,
  206. default: () => {},
  207. },
  208. limitNum: {
  209. type: Number,
  210. value: 0,
  211. },
  212. minQty: {
  213. type: Number,
  214. value: 0,
  215. },
  216. isShow: {
  217. type: Number,
  218. value: 0,
  219. },
  220. iSbnt: {
  221. type: Number,
  222. value: 0,
  223. },
  224. iSplus: {
  225. type: Number,
  226. value: 0,
  227. },
  228. iScart: {
  229. type: Number,
  230. value: 0,
  231. },
  232. is_vip: {
  233. type: Number,
  234. value: 0,
  235. },
  236. is_virtual: {
  237. type: Number,
  238. value: 0,
  239. },
  240. type: {
  241. type: String,
  242. default: "",
  243. },
  244. unitName: {
  245. type: String,
  246. default: "",
  247. },
  248. },
  249. data() {
  250. return {
  251. bottomVal: "",
  252. };
  253. },
  254. mounted() {},
  255. methods: {
  256. inputBindFocus(e) {
  257. // this.bottomVal = 40 + 'rpx'
  258. },
  259. inputBindBlur() {
  260. this.bottomVal = "0px";
  261. },
  262. moveHandle() {
  263. return false;
  264. },
  265. getpreviewImage: function () {
  266. uni.previewImage({
  267. urls: this.attr.productSelect.image.split(","),
  268. current: this.attr.productSelect.image,
  269. });
  270. },
  271. goCat: function () {
  272. this.$emit("goCat");
  273. },
  274. /**
  275. * 购物车手动输入数量
  276. *
  277. */
  278. bindCode: function (e) {
  279. this.$emit("iptCartNum", e);
  280. },
  281. closeAttr: function () {
  282. this.$emit("myevent");
  283. },
  284. CartNumDes: function () {
  285. this.$emit("ChangeCartNum", false);
  286. },
  287. CartNumAdd: function () {
  288. this.$emit("ChangeCartNum", true);
  289. },
  290. tapAttr: function (indexw, indexn) {
  291. let that = this;
  292. that.$emit("attrVal", {
  293. indexw: indexw,
  294. indexn: indexn,
  295. });
  296. this.$set(
  297. this.attr.productAttr[indexw],
  298. "index",
  299. this.attr.productAttr[indexw].attr_values[indexn]
  300. );
  301. let value = that.getCheckedValue().join(",");
  302. that.$emit("ChangeAttr", value);
  303. if (this.limitNum == 1) {
  304. if (this.attr.productSelect.quota > 0) {
  305. this.attr.productSelect.cart_num = 1;
  306. } else {
  307. this.attr.productSelect.cart_num = 0;
  308. }
  309. }
  310. },
  311. //获取被选中属性;
  312. getCheckedValue: function () {
  313. let productAttr = this.attr.productAttr;
  314. let value = [];
  315. for (let i = 0; i < productAttr.length; i++) {
  316. for (let j = 0; j < productAttr[i].attr_values.length; j++) {
  317. if (productAttr[i].index === productAttr[i].attr_values[j]) {
  318. value.push(productAttr[i].attr_values[j]);
  319. }
  320. }
  321. }
  322. return value;
  323. },
  324. showImg() {
  325. this.$emit("getImg");
  326. },
  327. },
  328. };
  329. </script>
  330. <style scoped lang="scss">
  331. .vip-money {
  332. color: #282828;
  333. font-size: 28rpx;
  334. font-weight: 700;
  335. margin-left: 6rpx;
  336. }
  337. .vipImg {
  338. width: 68rpx;
  339. height: 27rpx;
  340. image {
  341. width: 100%;
  342. height: 100%;
  343. }
  344. }
  345. .product-window {
  346. position: fixed;
  347. bottom: 0;
  348. width: 100%;
  349. left: 0;
  350. background-color: #fff;
  351. z-index: 100;
  352. border-radius: 16rpx 16rpx 0 0;
  353. transform: translate3d(0, 100%, 0);
  354. transition: all 0.3s cubic-bezier(0.25, 0.5, 0.5, 0.9);
  355. padding-bottom: 140rpx;
  356. padding-bottom: calc(
  357. 140rpx + constant(safe-area-inset-bottom)
  358. ); ///兼容 IOS<11.2/
  359. padding-bottom: calc(140rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  360. }
  361. .product-window.on {
  362. transform: translate3d(0, 0, 0);
  363. }
  364. .product-window.join {
  365. padding-bottom: 30rpx;
  366. }
  367. .product-window.joinCart {
  368. padding-bottom: 30rpx;
  369. z-index: 999;
  370. }
  371. .product-window.joinCart2 {
  372. padding-bottom: 130rpx;
  373. z-index: 999;
  374. }
  375. .product-window .textpic {
  376. padding: 0 80rpx 0 30rpx;
  377. margin-top: 29rpx;
  378. position: relative;
  379. }
  380. .product-window .textpic .pictrue {
  381. width: 150rpx;
  382. height: 150rpx;
  383. }
  384. .product-window .textpic .pictrue image {
  385. width: 100%;
  386. height: 100%;
  387. border-radius: 10rpx;
  388. }
  389. .product-window .textpic .text {
  390. width: 470rpx;
  391. font-size: 28rpx;
  392. color: #202020;
  393. }
  394. .product-window .textpic .text .money {
  395. font-size: 24rpx;
  396. margin-top: 10rpx;
  397. }
  398. .product-window .textpic .text .money .num {
  399. font-size: 36rpx;
  400. }
  401. .product-window .textpic .text .money .stock {
  402. color: #999;
  403. margin-left: 6rpx;
  404. margin-right: 20rpx;
  405. }
  406. .product-window .textpic .iconfont {
  407. position: absolute;
  408. right: 30rpx;
  409. top: -5rpx;
  410. font-size: 35rpx;
  411. color: #8a8a8a;
  412. }
  413. .product-window .rollTop {
  414. max-height: 500rpx;
  415. margin-top: 36rpx;
  416. }
  417. .product-window .productWinList .item ~ .item {
  418. margin-top: 36rpx;
  419. }
  420. .product-window .productWinList .item .title {
  421. font-size: 30rpx;
  422. color: #999;
  423. padding: 0 30rpx;
  424. }
  425. .product-window .productWinList .item .listn {
  426. padding: 0 30rpx 0 16rpx;
  427. }
  428. .product-window .productWinList .item .listn .itemn {
  429. border: 1px solid #f2f2f2;
  430. font-size: 26rpx;
  431. color: #282828;
  432. padding: 7rpx 33rpx;
  433. border-radius: 25rpx;
  434. margin: 20rpx 0 0 14rpx;
  435. background-color: #f2f2f2;
  436. display: flex;
  437. align-items: center;
  438. .attr-img {
  439. width: 37rpx;
  440. height: 37rpx;
  441. margin-right: 8rpx;
  442. }
  443. }
  444. .product-window .productWinList .item .listn .itemn.on {
  445. color: var(--view-theme);
  446. background: var(--view-minorColorT);
  447. border-color: var(--view-theme);
  448. }
  449. .product-window .productWinList .item .listn .itemn.limit {
  450. color: #999;
  451. text-decoration: line-through;
  452. }
  453. .product-window .cart {
  454. margin-top: 36rpx;
  455. padding: 0 30rpx;
  456. align-items: center;
  457. }
  458. .product-window .cart .title {
  459. font-size: 30rpx;
  460. color: #999;
  461. }
  462. .product-window .cart .carnum {
  463. height: 54rpx;
  464. .stock {
  465. font-size: 20rpx;
  466. line-height: 54rpx;
  467. color: #aaa;
  468. }
  469. .line {
  470. padding: 0 6rpx;
  471. }
  472. }
  473. .product-window .cart .carnum .iconfont {
  474. font-size: 25rpx;
  475. }
  476. .product-window .cart .carnum view {
  477. // border: 1px solid #a4a4a4;
  478. width: 84rpx;
  479. text-align: center;
  480. height: 100%;
  481. line-height: 54rpx;
  482. color: #282828;
  483. font-size: 45rpx;
  484. }
  485. .product-window .cart .carnum .reduce {
  486. border-right: 0;
  487. border-radius: 6rpx 0 0 6rpx;
  488. line-height: 48rpx;
  489. font-size: 60rpx;
  490. }
  491. .product-window .cart .carnum .reduce.on {
  492. // border-color: #e3e3e3;
  493. color: #dedede;
  494. }
  495. .product-window .cart .carnum .plus {
  496. border-left: 0;
  497. border-radius: 0 6rpx 6rpx 0;
  498. line-height: 46rpx;
  499. }
  500. .product-window .cart .carnum .plus.on {
  501. // border-color: #e3e3e3;
  502. color: #dedede;
  503. }
  504. .product-window .cart .carnum .num {
  505. background: rgba(242, 242, 242, 1);
  506. color: #282828;
  507. font-size: 28rpx;
  508. }
  509. .product-window .joinBnt {
  510. font-size: 30rpx;
  511. width: 620rpx;
  512. height: 86rpx;
  513. border-radius: 50rpx;
  514. text-align: center;
  515. line-height: 86rpx;
  516. color: #fff;
  517. margin: 21rpx auto 0 auto;
  518. }
  519. .product-window .joinBnt.on {
  520. background-color: #bbb;
  521. color: #fff;
  522. }
  523. </style>