detail-attr.vue 7.0 KB

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