index.vue 9.9 KB

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