index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <template>
  2. <view :style="viewColor">
  3. <view class="product-window" :class="(attr.cartAttr === true ? 'on' : '') + ' ' + (iSbnt || destri?'join':'') + ' ' + (isPresell ?'presell-window':'')">
  4. <view class="textpic acea-row row-between-wrapper">
  5. <view class="pictrue">
  6. <image :src="attr.productSelect.image ? attr.productSelect.image : image" @click="loookImg"></image>
  7. </view>
  8. <view class="text">
  9. <view class="line1">
  10. {{ attr.productSelect.store_name }}
  11. </view>
  12. <view v-if="isPresell" class="money presell_price">
  13. <view>
  14. 预售价
  15. <text class="num">{{ attr.productSelect.price }}</text>
  16. <text v-if="presell_type === 2">定金¥<text class="num">{{ attr.productSelect.down_price }}</text></text>
  17. </view>
  18. <text class="stock" v-if='isShow'>库存: {{ attr.productSelect.stock }}</text>
  19. <text class='stock' v-if="limitNum">限量: {{attr.productSelect.quota_show}}</text>
  20. </view>
  21. <view v-else class="money">
  22. <view class="acea-row row-middle">
  23. <view class="acea-row row-middle">
  24. <view v-if="type=='points'" class="points_money">
  25. <image :src="`${domain}/static/images/jf-point.png`" mode=""></image>
  26. <text class="points-num">{{attr.productSelect.ot_price}}</text>积分 <text v-if="attr.productSelect.price > 0">+{{attr.productSelect.price}}元</text>
  27. <text v-if="limitCount > 0" class="points-limit">限购{{limitCount}}件</text>
  28. </view>
  29. <view v-else>
  30. <text></text><text class="num">{{ attr.productSelect.price }}</text>
  31. </view>
  32. <view v-if="svipPrice" class="acea-row row-middle">
  33. <text class='vip-money'>{{attr.productSelect.svip_price}}</text>
  34. <view class="vipImg">
  35. <image :src="`${domain}/static/images/svip.png`"></image>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="stock_count">
  41. <text class="stock" v-if='isShow'>库存: {{ attr.productSelect.stock }}</text>
  42. <text class='stock' v-if="limitNum">限量: {{attr.productSelect.quota_show}}</text>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="iconfont icon-guanbi" @click="closeAttr"></view>
  47. </view>
  48. <view class="productWinList">
  49. <view class="item" v-for="(item, indexw) in attr.productAttr" :key="indexw">
  50. <view class="title">{{ item.attr_name }}</view>
  51. <view class="listn acea-row row-middle">
  52. <view class="itemn" :class="item.index === itemn.attr ? 'on' : ''" v-for="(itemn, indexn) in item.attr_value"
  53. @click="tapAttr(indexw, indexn)" :key="indexn">
  54. {{ itemn.attr }}
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view v-if="type !='points'" class="cart acea-row">
  60. <view class="title">数量</view>
  61. <view class="carnum acea-row row-left">
  62. <view class="buy_limit" v-if="minCount>0 || maxCount>0">
  63. (<text v-if="minCount>0">{{minCount}}件起购<text v-if="minCount>0 && maxCount>0"></text></text><text v-if="maxCount>0">最多{{maxCount}}件</text>)
  64. </view>
  65. <view class="item reduce" :class="(attr.productSelect.cart_num <= 1 || (minCount>0 && attr.productSelect.cart_num<=minCount)) ? 'on' : ''" @click="CartNumDes">
  66. -
  67. </view>
  68. <view class='item num'>
  69. <input type="number" v-model="attr.productSelect.cart_num" data-name="productSelect.cart_num" @input="bindCode(attr.productSelect.cart_num)" @keydown="btKeyDown" @keyup="btKeyUp"></input>
  70. </view>
  71. <view v-if="iSplus" class="item plus" :class="(attr.productSelect.cart_num >= attr.productSelect.stock || destri || (maxCount>0&&attr.productSelect.cart_num>=maxCount)) ? 'on' : ''"
  72. @click="CartNumAdd">+</view>
  73. <view v-else class='item plus' :class='((attr.productSelect.cart_num >= attr.productSelect.quota_show)
  74. || (attr.productSelect.cart_num >= attr.productSelect.product_stock) || (maxCount>0&&attr.productSelect.cart_num>=maxCount)) ? "on":""'
  75. @click='CartNumAdd'>+</view>
  76. </view>
  77. </view>
  78. <view class="joinBnt b-color" v-if="destri && attr.productSelect.stock>0" @click="goCat">立即购买</view>
  79. <view class="joinBnt on" v-else-if="destri && attr.productSelect.stock<=0">已售罄</view>
  80. <view class="joinBnt b-color" v-if="iSbnt && attr.productSelect.stock>0"
  81. @click="goCat">我要参团</view>
  82. <view class="joinBnt on" v-else-if="(iSbnt && attr.productSelect.stock<=0)">已售罄</view>
  83. </view>
  84. <view class="mask" @touchmove.prevent :hidden="attr.cartAttr === false" @click="closeAttr"></view>
  85. </view>
  86. </template>
  87. <script>
  88. // +----------------------------------------------------------------------
  89. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  90. // +----------------------------------------------------------------------
  91. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  92. // +----------------------------------------------------------------------
  93. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  94. // +----------------------------------------------------------------------
  95. // | Author: CRMEB Team <admin@crmeb.com>
  96. // +----------------------------------------------------------------------
  97. import { mapGetters } from "vuex";
  98. export default {
  99. props: {
  100. attr: {
  101. type: Object,
  102. default: () => {}
  103. },
  104. limitNum: {
  105. type: Number,
  106. value: 0
  107. },
  108. limitCount: {
  109. type: Number || String,
  110. value: 0
  111. },
  112. isShow: {
  113. type: Number,
  114. value: 0
  115. },
  116. iSbnt: {
  117. type: Number,
  118. value: 0
  119. },
  120. iSplus: {
  121. type: Number,
  122. value: 0
  123. },
  124. destri: {
  125. type: Number,
  126. value: 0
  127. },
  128. isPresell: {
  129. type: Number,
  130. value: 0
  131. },
  132. presell_type: {
  133. type: Number,
  134. value: 1
  135. },
  136. image: {
  137. type: String,
  138. value: ''
  139. },
  140. maxCount: {
  141. type: Number,
  142. value: 0
  143. },
  144. minCount: {
  145. type: Number,
  146. value: 0
  147. },
  148. payLimit: {
  149. type: Number || String,
  150. value: 1
  151. },
  152. svipPrice: {
  153. type: Boolean,
  154. value: false
  155. },
  156. type: {
  157. type: String,
  158. value: ''
  159. },
  160. domain: {
  161. type: String,
  162. value: ''
  163. }
  164. },
  165. computed: mapGetters(['viewColor']),
  166. data() {
  167. return {
  168. };
  169. },
  170. mounted(){
  171. console.log(this.maxCount)
  172. },
  173. methods: {
  174. // 查看大图
  175. loookImg(){
  176. let self = this
  177. let arr = [self.attr.productSelect.image ? self.attr.productSelect.image : self.image]
  178. uni.previewImage({
  179. urls: arr,
  180. });
  181. },
  182. goCat: function() {
  183. this.$emit('goCat');
  184. },
  185. /**
  186. * 购物车手动输入数量
  187. *
  188. */
  189. bindCode: function(e) {
  190. let num = JSON.parse(JSON.stringify(e))
  191. this.$emit('iptCartNum', num);
  192. },
  193. btKeyDown(e) {
  194. e.target.value = e.target.value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5]/g,"");
  195. },
  196. btKeyUp(e) {
  197. e.target.value = e.target.value.replace(/[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/g,"")
  198. },
  199. closeAttr: function() {
  200. this.$emit('myevent');
  201. },
  202. CartNumDes: function() {
  203. if (!this.destri) {
  204. this.$emit('ChangeCartNum', false);
  205. }
  206. },
  207. CartNumAdd: function() {
  208. if (!this.destri) {
  209. this.$emit('ChangeCartNum', true);
  210. }
  211. },
  212. tapAttr: function(indexw, indexn) {
  213. let that = this;
  214. that.$emit("attrVal", {
  215. indexw: indexw,
  216. indexn: indexn
  217. });
  218. this.$set(this.attr.productAttr[indexw], 'index', this.attr.productAttr[indexw].attr_values[indexn]);
  219. let value = that.getCheckedValue().join(",");
  220. that.$emit("ChangeAttr", value);
  221. },
  222. //获取被选中属性;
  223. getCheckedValue: function() {
  224. let productAttr = this.attr.productAttr;
  225. let value = [];
  226. for (let i = 0; i < productAttr.length; i++) {
  227. for (let j = 0; j < productAttr[i].attr_values.length; j++) {
  228. if (productAttr[i].index === productAttr[i].attr_values[j]) {
  229. value.push(productAttr[i].attr_values[j]);
  230. }
  231. }
  232. }
  233. return value;
  234. }
  235. }
  236. }
  237. </script>
  238. <style scoped lang="scss">
  239. .product-window {
  240. position: fixed;
  241. bottom: 0;
  242. width: 100%;
  243. left: 0;
  244. background-color: #fff;
  245. z-index: 77;
  246. border-radius: 16rpx 16rpx 0 0;
  247. padding-bottom: 140rpx;
  248. padding-bottom: calc(140rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  249. padding-bottom: calc(140rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  250. transform: translate3d(0, 100%, 0);
  251. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  252. &.presell-window {
  253. padding-bottom: 200rpx;
  254. padding-bottom: calc(200rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  255. padding-bottom: calc(200rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  256. }
  257. }
  258. .product-window.on {
  259. transform: translate3d(0, 0, 0);
  260. }
  261. .product-window.join {
  262. padding-bottom: 30rpx;
  263. }
  264. .product-window .textpic {
  265. padding: 0 80rpx 0 30rpx;
  266. margin-top: 29rpx;
  267. position: relative;
  268. }
  269. .product-window .textpic .pictrue {
  270. width: 150rpx;
  271. height: 150rpx;
  272. }
  273. .product-window .textpic .pictrue image {
  274. width: 100%;
  275. height: 100%;
  276. border-radius: 10rpx;
  277. }
  278. .product-window .textpic .text {
  279. width: 460rpx;
  280. font-size: 32rpx;
  281. color: #202020;
  282. }
  283. .product-window .textpic .text .money {
  284. font-size: 24rpx;
  285. margin-top: 26rpx;
  286. font-weight: 700;
  287. color: var(--view-priceColor);
  288. }
  289. .product-window .textpic .text .money .points_money {
  290. font-weight: normal;
  291. display: flex;
  292. align-items: baseline;
  293. }
  294. .product-window .textpic .text .money .points_money image{
  295. width: 26rpx;
  296. height: 26rpx;
  297. }
  298. .product-window .textpic .text .money .points_money .points-num{
  299. font-size: 34rpx;
  300. }
  301. .product-window .textpic .text .money .points_money .points-limit{
  302. display: flex;
  303. padding: 0 10rpx;
  304. align-items: center;
  305. justify-content: center;
  306. color: var(--view-theme);
  307. border: 1px solid var(--view-theme);
  308. height: 30rpx;
  309. border-radius: 13rpx;
  310. background: var(--view-bgColor);
  311. margin-left: 10rpx;
  312. font-size: 18rpx;
  313. }
  314. .product-window .stock_count{
  315. margin-top: 5rpx;
  316. }
  317. .product-window .textpic .text .money .num {
  318. font-size: 36rpx;
  319. }
  320. .product-window .textpic .text .money .stock {
  321. color: #999;
  322. margin-left: 18rpx;
  323. font-weight: normal;
  324. }
  325. .product-window .textpic .text .presell_price {
  326. color: #FF7F00;
  327. .num {
  328. display: inline-block;
  329. margin-right: 20rpx;
  330. }
  331. .stock {
  332. margin-left: 0;
  333. }
  334. }
  335. .vip-money {
  336. color: #282828;
  337. font-size: 22rpx;
  338. margin-left: 6rpx;
  339. }
  340. .vipImg {
  341. width: 65rpx;
  342. height: 28rpx;
  343. margin-left: 4rpx;
  344. image {
  345. width: 100%;
  346. height: 100%;
  347. display: block;
  348. }
  349. }
  350. .product-window .textpic .iconfont {
  351. position: absolute;
  352. right: 30rpx;
  353. top: -5rpx;
  354. font-size: 35rpx;
  355. color: #8a8a8a;
  356. }
  357. .product-window .productWinList {
  358. max-height: 395rpx;
  359. overflow: auto;
  360. margin-top: 36rpx;
  361. }
  362. .product-window .productWinList .item~.item {
  363. margin-top: 36rpx;
  364. }
  365. .product-window .productWinList .item .title {
  366. font-size: 30rpx;
  367. color: #999;
  368. padding: 0 30rpx;
  369. }
  370. .product-window .productWinList .item .listn {
  371. padding: 0 30rpx 0 16rpx;
  372. }
  373. .product-window .productWinList .item .listn .itemn {
  374. border: 1px solid #bbb;
  375. font-size: 26rpx;
  376. color: #282828;
  377. padding: 7rpx 33rpx;
  378. border-radius: 6rpx;
  379. margin: 14rpx 0 0 14rpx;
  380. }
  381. .product-window .productWinList .item .listn .itemn.on {
  382. color: #fff;
  383. background-color: var(--view-theme);
  384. border-color: var(--view-theme);
  385. }
  386. .product-window .cart {
  387. margin-top: 36rpx;
  388. padding: 0 30rpx;
  389. display: -webkit-box;
  390. display: -webkit-flex;
  391. display: -ms-flexbox;
  392. display: flex;
  393. -webkit-box-pack: justify;
  394. -webkit-justify-content: space-between;
  395. -ms-flex-pack: justify;
  396. justify-content: space-between;
  397. }
  398. .product-window .cart .title {
  399. font-size: 30rpx;
  400. color: #999;
  401. line-height: 54rpx;
  402. }
  403. .product-window .cart .carnum {
  404. height: 54rpx;
  405. align-items: center;
  406. }
  407. .product-window .cart .carnum .buy_limit {
  408. font-size: 22rpx;
  409. color: var(--view-theme);
  410. margin-right: 30rpx;
  411. }
  412. .product-window .cart .carnum .item {
  413. border: 1px solid #a4a4a4;
  414. width: 84rpx;
  415. text-align: center;
  416. height: 100%;
  417. line-height: 54rpx;
  418. color: #a4a4a4;
  419. font-size: 45rpx;
  420. }
  421. .product-window .cart .carnum .reduce {
  422. border-right: 0;
  423. border-radius: 6rpx 0 0 6rpx;
  424. line-height: 48rpx;
  425. }
  426. .product-window .cart .carnum .reduce.on {
  427. border-color: #e3e3e3;
  428. color: #dedede;
  429. }
  430. .product-window .cart .carnum .plus {
  431. border-left: 0;
  432. border-radius: 0 6rpx 6rpx 0;
  433. line-height: 46rpx;
  434. }
  435. .product-window .cart .carnum .plus.on {
  436. border-color: #e3e3e3;
  437. color: #dedede;
  438. }
  439. .product-window .cart .carnum .num {
  440. color: #282828;
  441. font-size: 28rpx;
  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. &.b-color{
  453. background-color: var(--view-theme);
  454. }
  455. }
  456. .product-window .joinBnt.on {
  457. background-color: #bbb;
  458. color: #fff;
  459. background-image: none;
  460. }
  461. </style>