index.vue 9.3 KB

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