index.vue 11 KB

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