productWindow.vue 7.8 KB

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