index.vue 9.4 KB

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