detail-attr.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view class="detail-attr" >
  3. <view class="safe-area-inset-bottom u-bottom-fixed">
  4. <view class="attr-content" @tap.stop="preventD">
  5. <view class="top dir-left-nowrap">
  6. <view class="image-view">
  7. <image :src="attr_pic_url ? attr_pic_url : image_url" @click="clickImage(index)"></image>
  8. </view>
  9. <view class="price dir-top-nowrap">
  10. <text class="des" :style="{'color': theme.color}">定金¥{{attr_deposit}}抵¥{{attr_swell_deposit}}</text>
  11. <text class="swell" :style="{'color': theme.color}" v-if="level_show == 0 || level_show == 2">
  12. ¥{{attr_price}}
  13. <text class="swell-text"> 预售价</text>
  14. </text>
  15. <text class="swell" :style="{'color': theme.color}" v-if="level_show === 1">
  16. ¥{{attr_price_member}}
  17. <text class="swell-text"> 会员价</text>
  18. </text>
  19. <text class="stock">库存{{attr_stock}}</text>
  20. </view>
  21. <image class="close" src="/static/image/icon/icon-close.png" @click="close_attr"></image>
  22. </view>
  23. <scroll-view class="center" :scroll-y="true">
  24. <view class="row" v-for="(item, index) in attr_groups" :key="index">
  25. <text class="attr-group-name">{{item.attr_group_name}}</text>
  26. <view class="attr-row dir-left-wrap">
  27. <view class="attr-item"
  28. :style="{'background-color': attr.active ? theme.background: ''}"
  29. :class=" attr.active ? 'active-attr-item' : 'default-back'"
  30. v-for="(attr, ind) in item.attr_list"
  31. :key="ind"
  32. @click.stop="select_attr(item, attr)"
  33. >{{attr.attr_name}}</view>
  34. </view>
  35. </view>
  36. </scroll-view>
  37. <view class="bottom dir-left-nowrap main-between cross-center">
  38. <text>数量</text>
  39. <view class="num dir-right-nowrap main-between cross-center">
  40. <image class="image" src="/static/image/cart/can-be-added.png" @click.stop="add_num"></image>
  41. <input type="number" class="input" :value="num" @change="change_num">
  42. <image class="image" :src="num === 1 ? '../image/can-be-reduced.png' : '/static/image/cart/can-be-reduced.png'" @click.stop="edd_num"></image>
  43. </view>
  44. </view>
  45. <view :style="{height:`${height}rpx`}" >
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. name: "detail-attr",
  54. data() {
  55. return {
  56. image_url: ''
  57. }
  58. },
  59. props: {
  60. height: Number,
  61. cover_pic: String,
  62. attr: Array,
  63. attr_groups: Array,
  64. goods_stock: Number,
  65. attr_swell_deposit: {
  66. type: [String, Number]
  67. },
  68. attr_deposit: {
  69. type: [String, Number]
  70. },
  71. attr_stock: {
  72. type: [String, Number]
  73. },
  74. price_member: Number,
  75. attr_price: String,
  76. level_show: Number,
  77. attr_price_member: Number,
  78. num: Number,
  79. attr_pic_url: String,
  80. theme: Object,
  81. },
  82. methods: {
  83. close_attr() {
  84. this.$emit('close_attr', true);
  85. },
  86. select_attr(data, item) {
  87. this.$emit('select_attr', {
  88. data: data.attr_group_id, item: item.attr_id
  89. });
  90. },
  91. change_num(data) {
  92. this.$emit('change_num_data', Number(data.detail.value));
  93. },
  94. add_num() {
  95. this.$emit('change_num', 1);
  96. },
  97. edd_num() {
  98. if (this.num === 1) return;
  99. this.$emit('change_num', -1);
  100. },
  101. clickImage() {
  102. let url = [];
  103. if (this.attr_pic_url) {
  104. url.push(this.attr_pic_url);
  105. } else {
  106. url.push(this.image_url);
  107. }
  108. uni.previewImage({
  109. urls: url
  110. });
  111. },
  112. preventD() {}
  113. },
  114. mounted() {
  115. if (this.attr[0] && this.attr[0].pic_url) {
  116. this.image_url = this.attr[0].pic_url;
  117. } else {
  118. this.image_url = this.cover_pic;
  119. }
  120. }
  121. }
  122. </script>
  123. <style scoped lang="scss">
  124. .detail-attr {
  125. width: #{750rpx};
  126. background-color: rgba(153,153,153,0.3);
  127. height: 100%;
  128. position: fixed;
  129. top: 0;
  130. left: 0;
  131. z-index: 1601;
  132. }
  133. .attr-content {
  134. width: #{750rpx};
  135. border-top-left-radius: #{15rpx};
  136. border-top-right-radius: #{15rpx};
  137. padding: 0 #{24rpx};
  138. .top {
  139. height: #{155rpx};
  140. width: #{702rpx};
  141. border-bottom: #{1rpx} solid #e2e2e2;
  142. position: relative;
  143. .image-view {
  144. width: #{200rpx};
  145. height: #{200rpx};
  146. background-color: white;
  147. border-radius: #{9rpx};
  148. text-align: center;
  149. position: absolute;
  150. top: #{-63rpx};
  151. >image {
  152. width: #{192rpx};
  153. height: #{192rpx};
  154. margin-top: #{4rpx};
  155. border-radius: #{9rpx};
  156. }
  157. }
  158. .close {
  159. width: #{35rpx};
  160. height: #{35rpx};
  161. padding: #{5rpx};
  162. position: absolute;
  163. right: 0;
  164. top: #{20rpx};
  165. }
  166. .price {
  167. height: #{141rpx};
  168. margin-left: #{228rpx};
  169. width: #{441rpx};
  170. padding-top: #{28rpx};
  171. .stock {
  172. font-size: #{24rpx};
  173. color: #999999;
  174. }
  175. .des {
  176. font-size: #{22rpx};
  177. margin-bottom: #{5rpx};
  178. }
  179. .swell {
  180. font-size: #{24rpx};
  181. margin-bottom: #{5rpx};
  182. .swell-text {
  183. font-size: #{21rpx};
  184. }
  185. }
  186. }
  187. }
  188. .center {
  189. max-height: #{333rpx};
  190. .row {
  191. width: #{702rpx};
  192. border-bottom: #{1rpx} solid #e2e2e2;
  193. padding: #{32rpx 0 0 0};
  194. font-size: #{25rpx};
  195. .attr-group-name {
  196. color: #666666;
  197. }
  198. .attr-row {
  199. margin-top: #{19rpx};
  200. .attr-item {
  201. height: #{57rpx};
  202. line-height: #{57rpx};
  203. text-align: center;
  204. border-radius: #{9rpx};
  205. color: #1b1b1b;
  206. margin-right: #{20rpx};
  207. padding: 0 #{24rpx};
  208. margin-bottom: #{32rpx};
  209. }
  210. .active-attr-item {
  211. color: #ffffff;
  212. }
  213. }
  214. }
  215. }
  216. .bottom {
  217. height: #{123rpx};
  218. width: #{702rpx};
  219. color: #6a6a6a;
  220. .num {
  221. width: #{216rpx};
  222. height: #{60rpx};
  223. .input {
  224. width: #{90rpx};
  225. height: #{60rpx};
  226. background-color: #f7f7f7;
  227. text-align: center;
  228. color: #353535;
  229. }
  230. .image {
  231. width: #{60rpx};
  232. height: #{60rpx};
  233. margin: #{0 2upx};
  234. }
  235. }
  236. }
  237. }
  238. .default-back {
  239. background-color: #f2f2f2;
  240. }
  241. .u-bottom-fixed {
  242. position: fixed;
  243. bottom: 0;
  244. left: 0;
  245. width: 100%;
  246. z-index: 1601;
  247. background-color: #ffffff;
  248. }
  249. </style>