index.vue 8.9 KB

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