index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <template>
  2. <!-- 商品属性规格弹窗 -->
  3. <view>
  4. <view class="product-window">
  5. <view class="textpic">
  6. <image class="pictrue" :src="attr.productSelect.image"></image>
  7. <view class="text">
  8. <text class="name line1" v-if="attr.productSelect.store_name && attr.productSelect.store_name.length>=15">{{ type == 'setMeal'?title : attr.productSelect.store_name.slice(0,15)}}...</text>
  9. <text class="name line1" v-else>{{type == 'setMeal'?title : attr.productSelect.store_name?attr.productSelect.store_name.slice(0,15):''}}</text>
  10. <view class="money font-color">
  11. <view class="top">
  12. <text class="lable" v-if="type != 'points'">¥</text>
  13. <text class="num">{{ attr.productSelect.price }}</text>
  14. <text v-if="type == 'points'" class="num">积分</text>
  15. <text class='vip-money' v-if="is_vip>0 && attr.productSelect.vip_price && storeInfo && storeInfo.price_type == 'member'">¥{{attr.productSelect.vip_price}}</text>
  16. <image class="vipImg" v-if="is_vip>0 && attr.productSelect.vip_price && storeInfo && storeInfo.price_type == 'member'" src="@/static/images/vip.png" mode=""></image>
  17. <view class="icon" v-if="is_vip>0 && attr.productSelect.vip_price && storeInfo && storeInfo.price_type == 'level'">
  18. <image class="level" :src="imgHost + '/statics/images/level.png'"></image>
  19. <text class="levelName">{{storeInfo.level_name}}</text>
  20. </view>
  21. </view>
  22. <text class="stock" v-if='isShow'>库存: {{ attr.productSelect.stock }}</text>
  23. <text class='stock' v-if="limitNum">{{type == 'seckill' ? '限量' : type == 'points'?'剩余':'库存'}}: {{attr.productSelect.quota}}</text>
  24. <slot name="bottom" :attr="attr"></slot>
  25. </view>
  26. </view>
  27. <image class="close" @click="closeAttr" :src="imgHost + '/statics/images/close.png'"></image>
  28. </view>
  29. <view class="rollTop">
  30. <scroll-view :style="'width:100%; max-height: 600rpx; display: flex; flex-direction: column;'" :scroll-y="true">
  31. <view class="productWinList">
  32. <view class="item" v-for="(item, indexw) in attr.productAttr" :key="indexw">
  33. <text class="title">{{ item.attr_name }}</text>
  34. <view class="listn">
  35. <text class="itemn" :class="item.index === itemn.attr ? 'on' : ''"
  36. v-for="(itemn, indexn) in item.attr_value" @click="tapAttr(indexw, indexn)"
  37. :key="indexn">
  38. {{ itemn.attr }}
  39. </text>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="cart" v-if="type != 'setMeal'">
  44. <text class="title">数量</text>
  45. <view class="carnum">
  46. <text class="item reduce"
  47. :class="attr.productSelect.cart_num <= 1 ? 'on' : ''" v-if="attr.productSelect.cart_num <= 1">
  48. -
  49. </text>
  50. <text class="item reduce"
  51. :class="attr.productSelect.cart_num <= 1 ? 'on' : ''" @click="CartNumDes" v-else>
  52. -
  53. </text>
  54. <view class='item'>
  55. <input class="num" 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. <text v-if="iSplus" class="item plus" :class="
  60. attr.productSelect.cart_num >= attr.productSelect.stock
  61. ? 'on'
  62. : ''
  63. " @click="CartNumAdd">
  64. +
  65. </text>
  66. <text 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'>+</text>
  69. </view>
  70. </view>
  71. </scroll-view>
  72. </view>
  73. <view class="bntCon">
  74. <text class="joinBnt bg-color" v-if="iScart && attr.productSelect.stock>0" @click="goCat">确定</text>
  75. <text class="joinBnt on" v-else-if="iScart && !attr.productSelect.stock">已售罄</text>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. import { HTTP_REQUEST_URL } from '@/config/app';
  82. export default {
  83. props: {
  84. cusPreviewImg: {
  85. type: Number,
  86. value: 0
  87. },
  88. title: {
  89. type: String,
  90. default: ''
  91. },
  92. attr: {
  93. type: Object,
  94. default: () => {}
  95. },
  96. storeInfo: {
  97. type: Object,
  98. default: () => {}
  99. },
  100. limitNum: {
  101. type: Number,
  102. value: 0
  103. },
  104. isShow: {
  105. type: Number,
  106. value: 0
  107. },
  108. iSbnt: {
  109. type: Number,
  110. value: 0
  111. },
  112. iSplus: {
  113. type: Number,
  114. value: 0
  115. },
  116. iScart: {
  117. type: Number,
  118. value: 0
  119. },
  120. is_vip: {
  121. type: Number,
  122. value: 0
  123. },
  124. type: {
  125. type: String,
  126. default: ''
  127. },
  128. },
  129. data() {
  130. return {
  131. imgHost: HTTP_REQUEST_URL,
  132. };
  133. },
  134. mounted() {},
  135. methods: {
  136. goCat: function() {
  137. this.$emit('goCat');
  138. },
  139. /**
  140. * 购物车手动输入数量
  141. *
  142. */
  143. bindCode: function(e) {
  144. this.$emit('iptCartNum', this.attr.productSelect.cart_num);
  145. },
  146. closeAttr: function() {
  147. this.$emit('closeScrollview');
  148. },
  149. CartNumDes: function() {
  150. this.$emit('ChangeCartNum', false);
  151. },
  152. CartNumAdd: function() {
  153. this.$emit('ChangeCartNum', true);
  154. },
  155. tapAttr: function(indexw, indexn) {
  156. let that = this;
  157. that.$emit("attrVal", {
  158. indexw: indexw,
  159. indexn: indexn
  160. });
  161. this.$set(this.attr.productAttr[indexw], 'index', this.attr.productAttr[indexw].attr_values[indexn]);
  162. let value = that
  163. .getCheckedValue()
  164. .join(",");
  165. that.$emit("ChangeAttr", value);
  166. },
  167. //获取被选中属性;
  168. getCheckedValue: function() {
  169. let productAttr = this.attr.productAttr;
  170. let value = [];
  171. for (let i = 0; i < productAttr.length; i++) {
  172. for (let j = 0; j < productAttr[i].attr_values.length; j++) {
  173. if (productAttr[i].index === productAttr[i].attr_values[j]) {
  174. value.push(productAttr[i].attr_values[j]);
  175. }
  176. }
  177. }
  178. return value;
  179. }
  180. }
  181. }
  182. </script>
  183. <style scoped lang="scss">
  184. .bg-color{
  185. background-color: #e93323 !important;
  186. }
  187. .vip-money {
  188. color: #282828;
  189. font-size: 28rpx;
  190. font-weight: 700;
  191. margin-left: 6rpx;
  192. }
  193. .vipImg {
  194. width: 56rpx;
  195. height: 20rpx;
  196. margin-left: 6rpx;
  197. }
  198. .bntCon{
  199. flex-direction: row;
  200. justify-content: center;
  201. margin-bottom: 20rpx;
  202. }
  203. .rollTop{
  204. margin-top: 30rpx;
  205. }
  206. .product-window.join {
  207. padding-bottom: 30rpx;
  208. }
  209. .product-window.joinCart {
  210. padding-bottom: 30rpx;
  211. z-index: 10000;
  212. }
  213. .product-window .textpic {
  214. padding: 0 130rpx 0 30rpx;
  215. margin-top: 29rpx;
  216. position: relative;
  217. display: flex;
  218. flex-direction: row;
  219. justify-content: space-between;
  220. }
  221. .product-window .textpic .pictrue {
  222. width: 150rpx;
  223. height: 150rpx;
  224. border-radius: 10rpx;
  225. }
  226. .product-window .textpic .text {
  227. width: 410rpx;
  228. }
  229. .product-window .textpic .text .name{
  230. font-size: 32rpx;
  231. color: #202020;
  232. }
  233. .product-window .textpic .text .money {
  234. margin-top: 34rpx;
  235. .top{
  236. display: flex;
  237. flex-direction: row;
  238. align-items: center;
  239. .lable{
  240. color: #e93323;
  241. font-size: 24rpx;
  242. }
  243. }
  244. .icon{
  245. display: flex;
  246. background: #FF9500;
  247. border-radius: 18rpx;
  248. flex-direction: row;
  249. justify-content: center;
  250. align-items: center;
  251. margin-left: 10rpx;
  252. padding: 2rpx 5rpx;
  253. .levelName{
  254. font-size: 16rpx;
  255. font-weight: normal;
  256. color: #fff;
  257. }
  258. .level{
  259. width: 25rpx;
  260. height: 25rpx;
  261. margin-left: 4rpx;
  262. }
  263. }
  264. }
  265. .product-window .textpic .text .money .num {
  266. font-size: 36rpx;
  267. color: #e93323;
  268. }
  269. .product-window .textpic .text .money .stock {
  270. color: #999;
  271. margin-left: 6rpx;
  272. font-size: 28rpx;
  273. }
  274. .product-window .textpic .close{
  275. position: absolute;
  276. right: 30rpx;
  277. width: 30rpx;
  278. height: 30rpx;
  279. }
  280. .item{
  281. background-color: transparent;
  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. flex-direction: row;
  294. align-items: center;
  295. flex-wrap: wrap;
  296. }
  297. .product-window .productWinList .item .listn .itemn {
  298. border: 1px solid #F2F2F2;
  299. font-size: 26rpx;
  300. color: #282828;
  301. padding: 7rpx 33rpx;
  302. border-radius: 25rpx;
  303. margin: 20rpx 0 0 14rpx;
  304. background-color: #F2F2F2;
  305. }
  306. .product-window .productWinList .item .listn .itemn.on {
  307. color: #e93323;
  308. background: rgba(233, 51, 35, 0.1);
  309. border-color: #e93323;
  310. }
  311. .product-window .productWinList .item .listn .itemn.limit {
  312. color: #999;
  313. text-decoration: line-through;
  314. }
  315. .product-window .cart {
  316. margin-top: 36rpx;
  317. padding: 0 30rpx;
  318. flex-direction: row;
  319. justify-content: space-between;
  320. align-items: center;
  321. }
  322. .product-window .cart .title {
  323. font-size: 30rpx;
  324. color: #999;
  325. }
  326. .product-window .cart .carnum {
  327. height: 54rpx;
  328. margin-top: 24rpx;
  329. flex-direction: row;
  330. justify-content: flex-start;
  331. }
  332. .product-window .cart .carnum .iconfont {
  333. font-size: 25rpx;
  334. }
  335. .product-window .cart .carnum .item {
  336. width: 84rpx;
  337. text-align: center;
  338. height: 100%;
  339. line-height: 54rpx;
  340. color: #282828;
  341. font-size: 45rpx;
  342. }
  343. .product-window .cart .carnum .reduce {
  344. border-right: 0;
  345. border-radius: 6rpx 0 0 6rpx;
  346. line-height: 48rpx;
  347. font-size: 60rpx;
  348. flex-direction: row;
  349. align-items: center;
  350. justify-content: center;
  351. margin-right: 10rpx;
  352. background-color: transparent;
  353. }
  354. .product-window .cart .carnum .reduce.on {
  355. color: #DEDEDE;
  356. }
  357. .product-window .cart .carnum .plus {
  358. border-left: 0;
  359. border-radius: 0 6rpx 6rpx 0;
  360. line-height: 46rpx;
  361. flex-direction: row;
  362. align-items: center;
  363. justify-content: center;
  364. font-size: 50rpx;
  365. margin-left: 10rpx;
  366. background-color: transparent;
  367. }
  368. .product-window .cart .carnum .plus.on {
  369. color: #dedede;
  370. }
  371. .product-window .cart .carnum .num {
  372. background: rgba(242, 242, 242, 1);
  373. color: #282828;
  374. font-size: 28rpx;
  375. flex-direction: row;
  376. align-items: center;
  377. width: 84rpx;
  378. height: 54rpx;
  379. text-align: center;
  380. line-height: 54rpx;
  381. }
  382. .product-window .joinBnt {
  383. font-size: 30rpx;
  384. width: 620rpx;
  385. height: 86rpx;
  386. border-radius: 50rpx;
  387. text-align: center;
  388. line-height: 86rpx;
  389. color: #fff;
  390. margin-top: 21rpx;
  391. }
  392. .product-window .joinBnt.on {
  393. background-color: #bbb;
  394. color: #fff;
  395. }
  396. </style>