foot_goods_book.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <FootDialog :isTitle="false" :isRadius="true" :visible.sync="dialogShow" :zIndex="300">
  3. <view slot="main" class="book-wrap">
  4. <view class="goods-img-price-wrap">
  5. <view class="goods-img"><image :src="selectSkuItemObj.thumbnail || base.thumbnail"></image></view>
  6. <view class="goods-price-box">
  7. <view class="price">
  8. <text>¥ {{ selectSkuItemObj.price ? selectSkuItemObj.price : base.price }}</text>
  9. </view>
  10. <view class="sku-params" v-if="selectSkuItemObj.specificationValues && selectSkuItemObj.specificationValues.length > 0">
  11. <text>选择:</text>
  12. <text class="sku_str">
  13. <block v-for="(item, index) in selectSkuItemObj.specificationValues" :key="index">{{ space + item.value }}</block>
  14. </text>
  15. </view>
  16. <view class="count-num" v-if="selectSkuItemObj.availableStock">
  17. <text>库存:</text>
  18. <text>{{ space }}{{ selectSkuItemObj.availableStock }}</text>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="goods-sku-list-wrap">
  23. <view class="sku-item" v-for="(item, index) in specifications" :key="index">
  24. <view class="sku-name">{{ item.name }}</view>
  25. <view class="sku-value-box">
  26. <block v-for="(skuItem, idx) in item.entries" :key="idx">
  27. <text
  28. v-if="JSON.stringify(selectSpecificationValueMaps)!=='{}'"
  29. @tap="onSelectSku(index, skuItem)"
  30. :class="[!skuItem.isSelected ? disabled : selectSpecificationValueMaps[index + ''].id == skuItem.id ? 'active' : '']"
  31. :style="skuItem.isSelected && selectSpecificationValueMaps[index + ''].id == skuItem.id ? 'color: #FFFFFF;' : 'color: #666666;'"
  32. >
  33. {{ skuItem.value }}
  34. </text>
  35. <text
  36. v-else
  37. @tap="onSelectSku(index, skuItem)"
  38. style="color: #666666;"
  39. >
  40. {{ skuItem.value }}
  41. </text>
  42. </block>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="goods-num-select-wrap">
  47. <text class="num-text">数量</text>
  48. <view class="number-select">
  49. <view class="number-change-less" @tap.stop="onGoodsNum(-1)">-</view>
  50. <input class="goods-number" type="number" :value="number" @input="onInput" @blur="onGoodsNumBlur" />
  51. <view class="number_change_add" @tap.stop="onGoodsNum(1)">+</view>
  52. </view>
  53. </view>
  54. <view class="comfirm-btn-box"><button @tap="onConfirm">确定</button></view>
  55. <image @tap.stop="hide" class="book-close" src="http://139.9.103.171:1888/img/image/close.png"></image>
  56. </view>
  57. </FootDialog>
  58. </template>
  59. <script>
  60. import FootDialog from './foot_dialog.vue';
  61. export default {
  62. components: {
  63. FootDialog
  64. },
  65. props: {
  66. number: {
  67. type: [Number, String],
  68. default: 0
  69. },
  70. specifications: {
  71. type: Array,
  72. default: () => {
  73. return [];
  74. }
  75. },
  76. selectSpecificationValueMaps: {
  77. type: Object,
  78. default: () => {
  79. return {};
  80. }
  81. },
  82. base: {
  83. type: Object,
  84. default: () => {
  85. return {};
  86. }
  87. },
  88. selectSkuItemObj: {
  89. type: Object,
  90. default: () => {
  91. return {};
  92. }
  93. },
  94. dataList: {
  95. type: Array,
  96. default: () => {
  97. return []; // [{label:'选项',value:1}]
  98. }
  99. },
  100. type: {
  101. type: Number,
  102. default: -1
  103. }
  104. },
  105. data() {
  106. return {
  107. isSelected: false,
  108. space: '\xa0\xa0',
  109. dialogShow: false
  110. };
  111. },
  112. methods: {
  113. show() {
  114. if (!this.isSelected && this.specifications != null && this.specifications.length > 0) {
  115. for (var i = 0; i < this.specifications.length; i++) {
  116. if (this.specifications[i].entries != null && this.specifications[i].entries.length > 0) this.$emit('selectSku', i, this.specifications[i].entries[0]);
  117. }
  118. this.isSelected = true;
  119. }
  120. this.dialogShow = true;
  121. },
  122. hide() {
  123. this.dialogShow = false;
  124. },
  125. onSelectSku(index, skuItem) {
  126. this.$emit('selectsku', index, skuItem);
  127. },
  128. onInput(e) {
  129. this.$emit('update:number', e.detail.value);
  130. },
  131. onGoodsNumBlur(e) {
  132. this.$emit('goodsnumblur', e);
  133. },
  134. // 数量变化
  135. onGoodsNum(delta) {
  136. this.$emit('goodsnum', delta);
  137. },
  138. // 确认
  139. onConfirm(item) {
  140. this.$emit('confirm', item);
  141. }
  142. }
  143. };
  144. </script>
  145. <style lang="scss">
  146. .book-wrap {
  147. background: white;
  148. border-top-left-radius: 20upx;
  149. border-top-right-radius: 20upx;
  150. width: 100%;
  151. .goods-img-price-wrap {
  152. display: flex;
  153. flex-direction: row;
  154. align-items: center;
  155. padding: 30upx 0;
  156. border-bottom: 1 solid #e5e5e5;
  157. .goods-img {
  158. height: 120upx;
  159. width: 120upx;
  160. padding-left: 30upx;
  161. image {
  162. width: 120upx;
  163. height: 120upx;
  164. }
  165. }
  166. .goods-price-box {
  167. display: flex;
  168. flex-direction: column;
  169. justify-content: space-around;
  170. height: 120upx;
  171. padding-left: 28upx;
  172. .price {
  173. display: flex;
  174. flex-direction: row;
  175. align-items: center;
  176. text {
  177. padding-left: 10upx;
  178. padding-top: 7upx;
  179. font-size: 48upx;
  180. color: #2f7ff5;;
  181. }
  182. }
  183. .sku-params {
  184. font-size: 24upx;
  185. color: #999;
  186. }
  187. .count-num {
  188. font-size: 24upx;
  189. color: #999;
  190. }
  191. }
  192. }
  193. .goods-sku-list-wrap {
  194. display: flex;
  195. flex-direction: column;
  196. .sku-item {
  197. padding: 0 30upx;
  198. .sku-name {
  199. font-size: 24upx;
  200. color: #333;
  201. padding: 20upx 0upx;
  202. }
  203. .sku-value-box {
  204. display: flex;
  205. flex-wrap: wrap;
  206. flex-direction: row;
  207. text {
  208. font-size: 26upx;
  209. color: #333;
  210. padding: 10upx 20upx;
  211. margin-right: 15upx;
  212. border: 2upx solid #ebebeb;
  213. opacity: 0.6;
  214. border-radius: 5px;
  215. margin-bottom: 10upx;
  216. }
  217. .active {
  218. background-color:$base;
  219. border: 2upx solid $base;
  220. color: #fff;
  221. opacity: 1;
  222. }
  223. .disabled {
  224. background-color: #e5e5e5;
  225. color: #ccc;
  226. opacity: 1;
  227. }
  228. }
  229. }
  230. }
  231. .goods-num-select-wrap {
  232. display: flex;
  233. flex-direction: row;
  234. justify-content: space-between;
  235. align-items: center;
  236. padding: 20upx 30upx 30upx 30upx;
  237. .num-text {
  238. font-size: 24upx;
  239. color: rgb(51, 51, 51);
  240. }
  241. .number-select {
  242. height: 50upx;
  243. border-radius: 6upx;
  244. border: 2upx solid #e5e5e5;
  245. display: flex;
  246. flex-direction: row;
  247. align-items: center;
  248. justify-content: space-around;
  249. width: 200upx;
  250. .number-change-less {
  251. width: 60upx;
  252. text-align: center;
  253. border-right: 2upx solid #e5e5e5;
  254. height: 100%;
  255. line-height: 50upx;
  256. font-size: 36upx;
  257. }
  258. .number_change_add {
  259. width: 60upx;
  260. text-align: center;
  261. border-left: 2upx solid #e5e5e5;
  262. height: 100%;
  263. line-height: 50upx;
  264. font-size: 36upx;
  265. }
  266. .goods-number {
  267. margin-bottom: 0;
  268. width: 60upx;
  269. padding: 0 10upx;
  270. text-align: center;
  271. font-size: 36upx;
  272. color: #353535;
  273. }
  274. }
  275. }
  276. .comfirm-btn-box {
  277. margin: 40upx;
  278. button {
  279. color: #fff;
  280. border-radius: 6upx;
  281. text-align: center;
  282. background: $base;
  283. }
  284. }
  285. .book-close {
  286. position: absolute;
  287. width: 30upx;
  288. height: 30upx;
  289. right: 10upx;
  290. top: 0upx;
  291. padding: 20upx;
  292. }
  293. }
  294. </style>