productWindow.vue 8.0 KB

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