index.vue 11 KB

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