index.vue 9.5 KB

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