new-specs-info.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view class="flex-common-css iPhone-bottom box-border-box bgc-f">
  3. <newNav :leftShow="false" :textType='false' class="z-4" @navHeight='navHeight'>
  4. <view slot="leftContent" class="align-items-center nav-left-box pl-32 box-border-box">
  5. <view class="nav-left box-border-box b-rad-32 align-items-center flex-justify-space">
  6. <uni-icons type="left" size="25" :color="leftIconColor" @click="goBack"></uni-icons>
  7. <view class="align-items-center">
  8. <view class="hr mr-16"></view>
  9. <image class="fx-icon" src="/static/img/order-food/fx.png" mode=""></image>
  10. </view>
  11. </view>
  12. </view>
  13. </newNav>
  14. <image class="goods-img" src="/pages-buy/static/fl-bg.png" mode="aspectFill"></image>
  15. <view class="image-box" :style="{height: `calc(41vh - ${newNavHeight}rpx)`}"></view>
  16. <view class="goods-name-box">
  17. <view class="goods-name b-rad-24-24-0-0 p-32-32-0 box-border-box bgc-f">
  18. <view class="fs-36 fw-600 fc-3">
  19. 红烧牛肉面红烧牛111面11牛肉面牛肉面牛肉 红烧牛肉面红烧牛111面11牛肉面牛
  20. </view>
  21. <view class="pt-20 fs-28 fc-6">
  22. 商品描述商品描述商品描述
  23. </view>
  24. </view>
  25. </view>
  26. <view class="scroll-view-css plr-32 box-border-box">
  27. <view class="b-t-eee ptb-30">
  28. <view class="mb-16" v-for="(item,i) in specsData" :key="i">
  29. <view class="fs-28 fc-7 mb-16">
  30. {{item.sku_name}}
  31. </view>
  32. <view class="align-items-center flex-wrap-wrap w-add-16">
  33. <view
  34. class="specs-item b-rad-12 align-items-center flex-justify-center mr-16 mb-16 plr-12 box-border-box"
  35. :class="postData.goods_spec_id.indexOf(info.spec_id)>=0?'s-item fc-FF3333 bgc-FAE9E9 b-FF3333':'n-item bgc-F5F5F5 fc-0'"
  36. v-for="(info,index_two) in item.spec_list" :key="index_two" @click="selectSpec(info,i)">
  37. <view class="align-items-center">
  38. <view class="count-box b-rad-50 bgc-FE6B2C fs-22 fc-f text-align-center"
  39. v-if="item.affect_quantity === 1">
  40. 0
  41. </view>
  42. <view class="align-items-center">
  43. <view class="">
  44. {{info.spec_name}}
  45. </view>
  46. <view class="" v-if="info.spec_price">
  47. ¥{{info.spec_price}}
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="bot-box box-border-box">
  57. <view class="align-items-center flex-justify-space mb-20">
  58. <view class="">
  59. <view class="align-items-baseline">
  60. <view class="fs-32 fc-3 fw-600 mr-4">
  61. ¥
  62. </view>
  63. <view class="fs-48 fc-3 fw-600">
  64. 80.9
  65. </view>
  66. </view>
  67. <view class="fs-24 fc-9">
  68. 不辣、煎蛋
  69. </view>
  70. </view>
  71. <view class="align-items-center">
  72. <image class="cz-img" src="@/static/img/order-food/reduce-img.png" mode=""></image>
  73. <view class="plr-16 fs-32 fc-3 fw-400">
  74. {{postData.number}}
  75. </view>
  76. <image class="cz-img" src="@/static/img/order-food/add-img.png" mode=""></image>
  77. </view>
  78. </view>
  79. <view class="but-box text-align-center fs-32 fc-f fw-600 b-rad-200">
  80. 加入购物车
  81. </view>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. import {
  87. getGoodsGoodsSpec
  88. } from "@/api/goods.js"
  89. export default {
  90. components: {},
  91. data() {
  92. return {
  93. infoData: {},
  94. newNavHeight: '',
  95. specsData: [{
  96. sku_name: '口味',
  97. sku_id: 8,
  98. sku_type: 1, //1:单选, 2:多选
  99. affect_quantity: 0, //是否影响购物车数量: 0-不影响, 1-影响
  100. spec_list: [{
  101. spec_name: '不辣',
  102. spec_id: 0
  103. }, {
  104. spec_name: '微辣',
  105. spec_id: 1
  106. }, {
  107. spec_name: '微辣',
  108. spec_id: 2
  109. }, {
  110. spec_name: '微辣',
  111. spec_id: 3
  112. }]
  113. }, {
  114. sku_name: '小料',
  115. sku_type: 2,
  116. sku_id: 9,
  117. affect_quantity: 1, //是否影响购物车数量: 0-不影响, 1-影响
  118. spec_list: [{
  119. spec_name: '煎蛋',
  120. spec_price: '3',
  121. spec_id: 4
  122. }, {
  123. spec_name: '牛肉',
  124. spec_price: '8',
  125. spec_id: 5
  126. }, {
  127. spec_name: '卤蛋',
  128. spec_price: '2',
  129. spec_id: 6
  130. }, {
  131. spec_name: '卤蛋',
  132. spec_price: '2',
  133. spec_id: 7
  134. }]
  135. }],
  136. spec_key: [],
  137. postData: {
  138. shop_id: '',
  139. goods_id: '',
  140. category_id: '',
  141. goods_spec_id: '',
  142. number: 1
  143. }
  144. }
  145. },
  146. onLoad(data) {},
  147. mounted() {
  148. this.addSpecNum()
  149. },
  150. methods: {
  151. addSpecNum() {
  152. this.specsData.forEach((v, k) => {
  153. if (v.affect_quantity === 1) {
  154. v.spec_list.forEach(spec => {
  155. // 添加数量字段,默认为0
  156. spec.spec_num = 0;
  157. // 或者如果你想要存储选中状态:
  158. // spec.quantity = 0;
  159. // spec.selected = false; // 对于多选规格
  160. });
  161. }
  162. })
  163. setTimeout(() => {
  164. console.log(this.specsData, '111111');
  165. }, 1000)
  166. },
  167. getGoodsGoodsSpec() {
  168. getGoodsGoodsSpec({
  169. goods_id: '5354'
  170. }).then((res) => {
  171. if (res.code * 1 === 1) {
  172. console.log(res);
  173. }
  174. })
  175. },
  176. navHeight(e) {
  177. this.newNavHeight = e
  178. },
  179. goBack() {
  180. uni.navigateBack({
  181. delta: 1
  182. })
  183. },
  184. selectSpec(info, groupKey) {
  185. },
  186. }
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. .nav-left-box {
  191. width: 100%;
  192. height: 100%;
  193. }
  194. .nav-left {
  195. width: 174rpx;
  196. height: 100%;
  197. background: rgba(255, 255, 255, 0.45);
  198. border: 1rpx solid #E3E6EB;
  199. padding: 0 20rpx 0 14rpx;
  200. }
  201. .goods-img {
  202. width: 100%;
  203. height: 41vh;
  204. position: absolute;
  205. top: 0;
  206. left: 0;
  207. }
  208. .fx-icon {
  209. width: 48rpx;
  210. height: 48rpx;
  211. }
  212. .hr {
  213. width: 1rpx;
  214. height: 36rpx;
  215. background: #e7e7e7;
  216. }
  217. .goods-name-box {
  218. position: relative;
  219. }
  220. .goods-name {
  221. width: 100%;
  222. position: relative;
  223. top: -32rpx;
  224. left: 0;
  225. }
  226. .bot-box {
  227. padding: 20rpx 32rpx 12rpx;
  228. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(51, 51, 51, 0.1);
  229. }
  230. .cz-img {
  231. width: 44rpx;
  232. height: 44rpx;
  233. }
  234. .but-box {
  235. width: 100%;
  236. height: 96rpx;
  237. line-height: 96rpx;
  238. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  239. }
  240. .specs-item {
  241. position: relative;
  242. min-width: 218rpx;
  243. height: 72rpx;
  244. }
  245. .w-add-16 {
  246. width: calc(100% + 22rpx);
  247. }
  248. .item-box {
  249. position: relative;
  250. }
  251. .count-box {
  252. width: 28rpx;
  253. height: 28rpx;
  254. line-height: 28rpx;
  255. position: absolute;
  256. right: -8rpx;
  257. top: -8rpx;
  258. }
  259. </style>