index.vue 11 KB

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