index.vue 10 KB

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