index.vue 8.3 KB

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