index.vue 8.1 KB

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