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