index.vue 9.2 KB

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