index.vue 11 KB

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