index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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'
  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.totalSales <= 1 ? 'on' : ''"
  47. v-if="attr.productSelect.totalSales <= 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.totalSales <= 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="attr.productSelect.totalSales"
  56. data-name="productSelect.totalSales" @input="bindCode(attr.productSelect.totalSales)" />
  57. </view>
  58. <view v-if="iSplus" class="item plus acea-row row-center-wrapper" :class="
  59. attr.productSelect.totalSales >= 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.totalSales >= 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. if (e > this.attr.productSelect.totalStock){
  150. this.$util.Tips({
  151. title: this.$t(`数量大于库存,请重新输入`),
  152. success: () => {
  153. },
  154. });
  155. }else{
  156. this.$emit('iptCartNum', e);
  157. }
  158. },
  159. closeAttr: function () {
  160. this.$emit('myevent');
  161. },
  162. CartNumDes: function () {
  163. this.$emit('ChangeCartNum', false);
  164. },
  165. CartNumAdd: function () {
  166. this.$emit('ChangeCartNum', true);
  167. },
  168. tapAttr: function (item, indexn) {
  169. let that = this;
  170. that.$emit("ChangeAttr", item);
  171. },
  172. //获取被选中属性;
  173. getCheckedValue: function () {
  174. let productAttr = this.attr.productAttr;
  175. let value = [];
  176. for (let i = 0; i < productAttr.length; i++) {
  177. for (let j = 0; j < productAttr[i].attr_values.length; j++) {
  178. if (productAttr[i].index === productAttr[i].attr_values[j]) {
  179. value.push(productAttr[i].attr_values[j]);
  180. }
  181. }
  182. }
  183. return value;
  184. },
  185. showImg() {
  186. this.$emit('getImg');
  187. },
  188. }
  189. }
  190. </script>
  191. <style scoped lang="scss">
  192. .vip-money {
  193. color: #282828;
  194. font-size: 28rpx;
  195. font-weight: 700;
  196. margin-left: 6rpx;
  197. }
  198. .vipImg {
  199. width: 68rpx;
  200. height: 27rpx;
  201. image {
  202. width: 100%;
  203. height: 100%;
  204. }
  205. }
  206. .product-window {
  207. position: fixed;
  208. bottom: 0;
  209. width: 100%;
  210. left: 0;
  211. background-color: #fff;
  212. z-index: 100;
  213. border-radius: 16rpx 16rpx 0 0;
  214. transform: translate3d(0, 100%, 0);
  215. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  216. padding-bottom: 140rpx;
  217. padding-bottom: calc(140rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  218. padding-bottom: calc(140rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  219. }
  220. .product-window.on {
  221. transform: translate3d(0, 0, 0);
  222. }
  223. .product-window.join {
  224. padding-bottom: 30rpx;
  225. }
  226. .product-window.joinCart {
  227. padding-bottom: 30rpx;
  228. z-index: 10000;
  229. }
  230. .product-window .textpic {
  231. padding: 0 130rpx 0 30rpx;
  232. margin-top: 29rpx;
  233. position: relative;
  234. }
  235. .product-window .textpic .pictrue {
  236. width: 150rpx;
  237. height: 150rpx;
  238. }
  239. .product-window .textpic .pictrue image {
  240. width: 100%;
  241. height: 100%;
  242. border-radius: 10rpx;
  243. }
  244. .product-window .textpic .text {
  245. width: 410rpx;
  246. font-size: 32rpx;
  247. color: #202020;
  248. }
  249. .product-window .textpic .text .money {
  250. font-size: 24rpx;
  251. margin-top: 40rpx;
  252. }
  253. .product-window .textpic .text .money .num {
  254. font-size: 36rpx;
  255. }
  256. .product-window .textpic .text .money .stock {
  257. color: #999;
  258. margin-left: 6rpx;
  259. }
  260. .product-window .textpic .iconfont {
  261. position: absolute;
  262. right: 30rpx;
  263. top: -5rpx;
  264. font-size: 35rpx;
  265. color: #8a8a8a;
  266. }
  267. .product-window .rollTop {
  268. max-height: 500rpx;
  269. overflow: auto;
  270. margin-top: 36rpx;
  271. }
  272. .product-window .productWinList .item~.item {
  273. margin-top: 36rpx;
  274. }
  275. .product-window .productWinList .item .title {
  276. font-size: 30rpx;
  277. color: #999;
  278. padding: 0 30rpx;
  279. }
  280. .product-window .productWinList .item .listn {
  281. padding: 0 30rpx 0 16rpx;
  282. }
  283. .product-window .productWinList .item .listn .itemn {
  284. border: 1px solid #F2F2F2;
  285. font-size: 26rpx;
  286. color: #282828;
  287. padding: 7rpx 33rpx;
  288. border-radius: 25rpx;
  289. margin: 20rpx 0 0 14rpx;
  290. background-color: #F2F2F2;
  291. }
  292. .product-window .productWinList .item .listn .itemn.on {
  293. color: var(--view-theme);
  294. background: var(--view-minorColorT);
  295. border-color: var(--view-theme);
  296. }
  297. .product-window .productWinList .item .listn .itemn.limit {
  298. color: #999;
  299. text-decoration: line-through;
  300. }
  301. .product-window .cart {
  302. margin-top: 36rpx;
  303. padding: 0 30rpx;
  304. }
  305. .product-window .cart .title {
  306. font-size: 30rpx;
  307. color: #999;
  308. }
  309. .product-window .cart .carnum {
  310. height: 54rpx;
  311. margin-top: 24rpx;
  312. }
  313. .product-window .cart .carnum .iconfont {
  314. font-size: 25rpx;
  315. }
  316. .product-window .cart .carnum view {
  317. // border: 1px solid #a4a4a4;
  318. width: 84rpx;
  319. text-align: center;
  320. height: 100%;
  321. line-height: 54rpx;
  322. color: #282828;
  323. font-size: 45rpx;
  324. }
  325. .product-window .cart .carnum .reduce {
  326. border-right: 0;
  327. border-radius: 6rpx 0 0 6rpx;
  328. line-height: 48rpx;
  329. font-size: 60rpx;
  330. }
  331. .product-window .cart .carnum .reduce.on {
  332. // border-color: #e3e3e3;
  333. color: #DEDEDE;
  334. }
  335. .product-window .cart .carnum .plus {
  336. border-left: 0;
  337. border-radius: 0 6rpx 6rpx 0;
  338. line-height: 46rpx;
  339. }
  340. .product-window .cart .carnum .plus.on {
  341. // border-color: #e3e3e3;
  342. color: #dedede;
  343. }
  344. .product-window .cart .carnum .num {
  345. background: rgba(242, 242, 242, 1);
  346. color: #282828;
  347. font-size: 28rpx;
  348. }
  349. .product-window .joinBnt {
  350. font-size: 30rpx;
  351. width: 620rpx;
  352. height: 86rpx;
  353. border-radius: 50rpx;
  354. text-align: center;
  355. line-height: 86rpx;
  356. color: #fff;
  357. margin: 21rpx auto 0 auto;
  358. }
  359. .product-window .joinBnt.on {
  360. background-color: #bbb;
  361. color: #fff;
  362. }
  363. </style>