index.vue 8.8 KB

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