menu.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  1. <template>
  2. <view class="menu-box display-flex">
  3. <scroll-view scroll-y="true" class="menu-box-left" :scroll-into-view="idMark" :scroll-with-animation='true'>
  4. <view class="menu-type-list-f">
  5. <view class="menu-type-list fs-26 box-border-box align-items-center flex-justify-center"
  6. v-for="(item,i) in categoryData" :key="i" @click="selectType(item)"
  7. :class="type === item.type?'bgc-f fc-3 fw-600':'fc-6 fw-400'" :id="'scroll'+ item.type">
  8. {{item.name}}
  9. <view class="menu-type-num fc-f" v-show="item.num > 0">{{item.num > 99?'99+':item.num}}</view>
  10. </view>
  11. </view>
  12. </scroll-view>
  13. <scroll-view :scroll-y="true" :scroll-with-animation='true' :scroll-into-view="idMarkTwo" @scroll="menuScroll">
  14. <view class="menu-box-right">
  15. <view class="menu-box-only" v-for="(item,i) in categoryData" :key="i" :id="'scroll'+ item.type">
  16. <view class="mb-32 fs-30">{{item.name}}</view>
  17. <view class="menu-list flex-justify-space" v-for="(info,k) in item.list" :key="k" :id="'goods_id'+ info.goods_id">
  18. <image class="flex-shrink0 goods_img" :src="info.goods_image" mode="scaleToFill"></image>
  19. <view class="menu-list-right flex-direction flex-justify-space">
  20. <view class="mb-8">
  21. <view class="mb-4 goods-name text-overflow-ellipsis fs-32 fw-600">{{info.goods_name}}
  22. </view>
  23. <view class="text-overflow-ellipsis-one fw-400 fc-9 fs-24 mb-2 goods-name"
  24. v-if="info.spec_type == 1">
  25. {{info.goods_desc}}
  26. </view>
  27. <view class="fw-400 fc-9 fs-24">月销{{info.sales}}</view>
  28. </view>
  29. <view class="flex-justify-space align-items-flex-end">
  30. <view class="">
  31. <span class="fs-24 fw-400 fc-FB3D03">¥</span>
  32. <span
  33. class="fs-40 fw-b fc-FB3D03">{{info.seckill_money>0?info.seckill_money:info.price}}</span>
  34. <!-- <view class="">
  35. <span class="fs-24 fc-9 fw-400 text-line-through">¥{{info.line_price}}</span>
  36. </view> -->
  37. </view>
  38. <view class="display-flex align-items-center" v-if="info.spec_type == 1">
  39. <image v-show="info.num > 0" class="wh-44" @click="addred(1,i,k,info)"
  40. src="@/static/img/takeout/j.png" mode=""></image>
  41. <view v-show="info.num > 0"
  42. class="right-only-right-2 text-align-center fs-28 fw-400">{{info.num}}</view>
  43. <image class="wh-44" src="@/static/img/takeout/add.png" @click="addred(2,i,k,info)"
  44. mode=""></image>
  45. </view>
  46. <view v-else class="right-only-right text-align-center" @click="addred(3,i,k,info)">
  47. <view class="fw-600 fs-28 fc-f">
  48. 选规格
  49. </view>
  50. <view class="selectedNum" v-if="info.num>0">
  51. {{info.num}}
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </scroll-view>
  60. <uni-popup ref="popupGG" type="bottom">
  61. <view class="gg-box flex-index-css">
  62. <view class="flex-justify-space box-border-box p-32">
  63. <view class="fs-32 fw-500 fc-0">商品详情规格</view>
  64. <view class="" @click="gbPop">
  65. <uni-icons type="closeempty" size="20"></uni-icons>
  66. </view>
  67. </view>
  68. <view class="goods-info flex-justify-space mb-32 box-border-box plr-32">
  69. <image v-if="popData.goodsItem.goods_image" :src="popData.goodsItem.goods_image" mode="scaleToFill">
  70. </image>
  71. <view class="flex-1">
  72. <view style="width: 446rpx;" class="fw-600 fs-34 text-overflow-ellipsis-one">
  73. {{popData.goodsItem.goods_name}}
  74. </view>
  75. <view class="fw-400 fc-9 fs-24 mb-2 text-overflow-ellipsis-t">
  76. {{popData.goodsItem.goods_desc}}
  77. </view>
  78. <view class="fw-400 fc-9 fs-24">月销{{popData.goodsItem.sales}}</view>
  79. </view>
  80. </view>
  81. <scroll-view scroll-y="true" class="scroll-view-css box-border-box plr-32">
  82. <view class="" v-for="(item,i) in popData.spec_attr" :key="i">
  83. <view class="fs-32 fw-500 fc-0 mb-32">{{item.group_name}}</view>
  84. <view class="flex-wrap-wrap">
  85. <view class="spec-item text-align-center fs-28"
  86. :class="popData.spec_ids.indexOf(info.item_id)>=0?'s-item':'n-item'"
  87. v-for="(info,k) in item.spec_items" :key="k" @click="selectSpec(info,i)">
  88. {{info.spec_value}}
  89. </view>
  90. </view>
  91. </view>
  92. </scroll-view>
  93. <!-- <view class="scroll-view-css box-border-box plr-32">
  94. <view class="" v-for="(item,i) in popData.spec_attr" :key="i">
  95. <view class="fs-32 fw-500 fc-0 mb-32">{{item.group_name}}</view>
  96. <view class="flex-wrap-wrap">
  97. <view class="spec-item text-align-center fs-28"
  98. :class="popData.spec_ids.indexOf(info.item_id)>=0?'s-item':'n-item'"
  99. v-for="(info,k) in item.spec_items" :key="k" @click="selectSpec(info,i)">
  100. {{info.spec_value}}
  101. </view>
  102. </view>
  103. </view>
  104. </view> -->
  105. <view class="pop-buttom box-border-box plr-32">
  106. <view class="flex-justify-space mb-28">
  107. <view class="pop-buttom-left">
  108. <view class="">
  109. <span class="fw-600 fs-32 fc-ED301D">¥</span>
  110. <span class="fw-600 fs-48 fc-ED301D">{{popData.price}}</span>
  111. </view>
  112. <view class="">
  113. <span class="fw-400 fs-24 fc-9">已选规格:</span>
  114. <span class="fw-400 fs-24">{{popData.spec_name.join(';')}}</span>
  115. </view>
  116. </view>
  117. <view class="display-flex align-items-center">
  118. <image class="wh-44" @click.stop="setSpecNum(1)" src="@/static/img/takeout/j.png" mode="">
  119. </image>
  120. <view class="right-only-right-2 text-align-center fs-28 fw-400">{{popData.num}}</view>
  121. <image class="wh-44" src="@/static/img/takeout/add.png" @click.stop="setSpecNum(2)" mode="">
  122. </image>
  123. </view>
  124. </view>
  125. <view class="pop-buttom-2 text-align-center fs-32 fw-600 fc-f" @click="addred(4)">选好了</view>
  126. </view>
  127. </view>
  128. </uni-popup>
  129. </view>
  130. </template>
  131. <script>
  132. import tools from "@/service/tools";
  133. import {
  134. shopCategory,
  135. shopGoods,
  136. shopGoodsSpec
  137. } from "@/api/shop";
  138. import {
  139. getShopIngList,
  140. setShopIngAdd,
  141. setShopIngDel,
  142. setShopIngNumber
  143. } from "@/api/shopping";
  144. export default {
  145. name: 'menu-box',
  146. props: {
  147. 'shop_id': {
  148. default: 0
  149. }
  150. },
  151. data() {
  152. return {
  153. idMark: '', //滚动自适应参数
  154. idMarkTwo: '', //滚动自适应参数
  155. type: 0, //分类标识
  156. typeList: [],
  157. categoryData: [],
  158. menuList: [],
  159. cartData: {
  160. total_price: 0,
  161. total_num: 0,
  162. total_goods_money: 0,
  163. pack_price: 0,
  164. must_category: 0,
  165. is_place_order: 0,
  166. err_msg: 0,
  167. goods_list: [],
  168. },
  169. isAjax: false,
  170. operate_id: '',
  171. popData: {
  172. goodsItem: {},
  173. price: '0.00',
  174. line_price: '',
  175. num: 0,
  176. goods_id: '',
  177. is_quota: 0,
  178. is_infinite: 0,
  179. quota_num: 0,
  180. payNum: 0,
  181. stock: 0,
  182. spec_key: '',
  183. goods_spec_id: '',
  184. spec_name: [],
  185. spec_ids: [],
  186. spec_list: [],
  187. spec_attr: [],
  188. },
  189. selectedNum: 1,
  190. selectedSpecification: []
  191. }
  192. },
  193. watch: {
  194. 'shop_id': function() {
  195. this.getShopGoods();
  196. }
  197. },
  198. mounted() {
  199. this.operate_id = uni.getStorageSync('operate_id')
  200. this.getShopGoods();
  201. this.getShopIngList(true);
  202. },
  203. methods: {
  204. setSpecNum(type) {
  205. if (!this.popData.goods_spec_id) {
  206. console.log('被阻挡');
  207. tools.error('请选择规格')
  208. return;
  209. }
  210. if (type === 1) {
  211. // 减
  212. console.log('减');
  213. if (this.popData.num > 0) {
  214. --this.popData.num;
  215. this.$forceUpdate()
  216. } else {
  217. this.isAjax = false
  218. }
  219. } else {
  220. console.log('加');
  221. if (this.popData.is_infinite === 0 && this.popData.payNum > this.popData.stock) {
  222. console.log('加1');
  223. tools.error('商品库存' + this.popData.stock + '件')
  224. } else if (this.popData.is_quota > 0 && this.popData.payNum > this.popData.quota_num) {
  225. console.log('加2');
  226. tools.error('限购' + this.popData.quota_num + '件')
  227. } else {
  228. // 加
  229. console.log('加3');
  230. ++this.popData.num;
  231. this.$forceUpdate()
  232. }
  233. }
  234. },
  235. getShopGoodsSpec(item) {
  236. shopGoodsSpec({
  237. 'goods_id': item.goods_id
  238. }).then(res => {
  239. this.popData.goodsItem = item
  240. if (this.popData.goods_id !== item.goods_id) {
  241. this.popData.goods_id = item.goods_id
  242. this.popData.spec_name = []
  243. this.popData.price = '0.00'
  244. this.popData.line_price = ''
  245. this.popData.spec_key = ''
  246. this.popData.num = 1
  247. this.popData.spec_ids = []
  248. } else {
  249. this.popData.num = 1;
  250. if (this.cartData.goods_list.length > 0) {
  251. this.cartData.goods_list.forEach(item => {
  252. if (item.spec_sku_id === this.popData.spec_key) {
  253. this.popData.num = item.goods_number
  254. }
  255. })
  256. }
  257. }
  258. this.popData.spec_list = res.data.spec_list
  259. this.popData.spec_attr = res.data.spec_attr
  260. console.log(this.selectedSpecification, '+++++++++++++++++');
  261. this.selectedSpecification.forEach((v, k) => {
  262. if (v.goods_id === item.goods_id) {
  263. v.goodsItem = item
  264. v.spec_list = res.data.spec_list
  265. v.spec_attr = res.data.spec_attr
  266. let data = JSON.parse(JSON.stringify(v))
  267. this.popData = data
  268. }
  269. })
  270. console.log(this.popData, '********************');
  271. this.$refs.popupGG.open();
  272. this.setGoodsSpecPrice()
  273. this.isAjax = false
  274. }).catch(() => {
  275. tools.error('规格信息异常')
  276. this.isAjax = false
  277. })
  278. },
  279. setGoodsSpecPrice() {
  280. console.log(this.popData.spec_ids)
  281. if (this.popData.spec_ids.length > 0) {
  282. let spec_ids = JSON.parse(JSON.stringify(this.popData.spec_ids))
  283. spec_ids.sort((a, b) => a - b);
  284. let spec_key = spec_ids.join('_')
  285. this.popData.spec_key = spec_key
  286. console.log('this.popData.spec_list[spec_key]', this.popData.spec_list[spec_key])
  287. if (this.popData.spec_list[spec_key] !== undefined) {
  288. this.popData.price = this.popData.spec_list[spec_key].seckill_money > 0 ? this.popData.spec_list[
  289. spec_key].seckill_money : this.popData.spec_list[spec_key].price
  290. this.popData.line_price = this.popData.spec_list[spec_key].line_price
  291. if (this.popData.goods_spec_id !== this.popData.spec_list[spec_key].goods_spec_id + '') {
  292. this.popData.num = 1
  293. }
  294. this.popData.goods_spec_id = this.popData.spec_list[spec_key].goods_spec_id + ''
  295. let cartKey = this.cartData.goods_list.findIndex(row => this.popData.goods_spec_id * 1 === row
  296. .goods_spec_id * 1)
  297. if (cartKey >= 0) {
  298. this.popData.num = this.cartData.goods_list[cartKey].goods_number
  299. }
  300. } else {
  301. this.popData.line_price = '0.00'
  302. this.popData.price = '0.00'
  303. this.popData.num = 0
  304. this.popData.goods_spec_id = ''
  305. }
  306. } else {
  307. this.popData.price = '0.00'
  308. this.popData.line_price = '0.00'
  309. this.popData.num = 0
  310. this.popData.goods_spec_id = ''
  311. }
  312. },
  313. setShopIngList(cartData) {
  314. this.cartData = cartData
  315. this.selectedSpecification = []
  316. this.setGoodsNum()
  317. },
  318. getShopIngList(isStart) {
  319. getShopIngList({
  320. 'shop_id': this.shop_id,
  321. }).then(res => {
  322. if (res.code === 1) {
  323. this.cartData = res.data
  324. let data = res.data
  325. data.goods_list.forEach((v, k) => {
  326. let ge = JSON.parse(JSON.stringify(v))
  327. ge.spec_ids = ge.spec_sku_id.split('_').map(item => Number(item.trim()))
  328. ge.spec_name = ge.goods_attr.split(',').map(item => item.trim())
  329. this.selectedSpecification.push(ge)
  330. })
  331. console.log(this.selectedSpecification, '初始回显已选数据');
  332. this.$emit('setCartData', this.cartData)
  333. this.setGoodsNum()
  334. }
  335. })
  336. },
  337. setGoodsNum() {
  338. if (this.cartData.goods_list.length > 0) {
  339. let goodsIds = []
  340. this.categoryData.forEach(categoryItem => {
  341. categoryItem.list.forEach(goodsItem => {
  342. goodsItem.num = 0
  343. this.cartData.goods_list.forEach(item => {
  344. if (item.goods_id === goodsItem.goods_id) {
  345. if (goodsIds.indexOf(item.goods_id) < 0) {
  346. goodsIds.push(item.goods_id)
  347. goodsItem.num = item.goods_number * 1
  348. } else {
  349. goodsItem.num += item.goods_number * 1
  350. }
  351. }
  352. })
  353. })
  354. })
  355. } else {
  356. //购物车数据清除
  357. this.categoryData.forEach(categoryItem => {
  358. categoryItem.list.forEach(goodsItem => {
  359. goodsItem.num = 0
  360. })
  361. })
  362. }
  363. },
  364. getShopGoods() {
  365. if (this.shop_id < 0 || !this.operate_id) {
  366. return;
  367. }
  368. shopGoods({
  369. 'shop_id': this.shop_id,
  370. operate_id: this.operate_id,
  371. }).then(res => {
  372. if (res.code === 1) {
  373. this.categoryData = res.data
  374. const category_id = uni.getStorageSync('category_id')
  375. const goods_id = uni.getStorageSync('goods_id')
  376. if (category_id.type && category_id.type != 'undefined') {
  377. this.selectType(category_id, goods_id)
  378. } else {
  379. this.selectType(this.categoryData[0])
  380. }
  381. // if (this.categoryData.length > 0) {
  382. // this.selectType(this.categoryData[0])
  383. // }
  384. this.categoryData.forEach(categoryItem => {
  385. categoryItem.list.forEach(goodsItem => {
  386. goodsItem.payNum = 0
  387. goodsItem.spec = []
  388. })
  389. })
  390. setTimeout(() => {
  391. this.setGoodsNum()
  392. }, 1000)
  393. }
  394. })
  395. },
  396. selectType(item, itemTwo) {
  397. if (this.type != item.type) {
  398. this.type = item.type;
  399. this.idMark = 'scroll' + item.type
  400. if (itemTwo) {
  401. this.idMarkTwo = 'goods_id' + itemTwo.goodsId
  402. } else {
  403. this.idMarkTwo = this.idMark
  404. }
  405. if (this.idMark === this.idMarkTwo) {
  406. console.log("id跳转");
  407. }
  408. this.$forceUpdate()
  409. }
  410. },
  411. menuScroll(e) {
  412. let _this = this;
  413. let query = uni.createSelectorQuery().in(this);
  414. const goods_id = uni.getStorageSync('goods_id')
  415. if (goods_id.goodsId && goods_id.goodsId != 'undefined') {
  416. query.selectAll(".menu-list").boundingClientRect(data => {
  417. data.forEach((v) => {
  418. if (data[this.categoryData.length - 1].top <= 392) {
  419. return
  420. }
  421. if (v.top < 332 && v.top > 0) {
  422. // _this.idMark = v.id;
  423. let arr = v.id.split('scroll');
  424. }
  425. })
  426. uni.setStorageSync('category_id', '')
  427. uni.setStorageSync('goods_id', '')
  428. }).exec();
  429. } else {
  430. query.selectAll(".menu-box-only").boundingClientRect(data => {
  431. data.forEach((v) => {
  432. if (data[this.categoryData.length - 1].top <= 392) {
  433. return
  434. }
  435. if (v.top < 332 && v.top > 0) {
  436. // _this.idMark = v.id;
  437. let arr = v.id.split('scroll');
  438. _this.type = Number(arr[1]);
  439. }
  440. this.$forceUpdate()
  441. })
  442. }).exec();
  443. }
  444. },
  445. addred(type, i, k, item) {
  446. if (this.isAjax) {
  447. return
  448. }
  449. this.isAjax = true
  450. if (type === 1) {
  451. // 减
  452. if (item.num > 0) {
  453. // --item.num;
  454. this.setSub(item, type);
  455. } else {
  456. this.isAjax = false
  457. }
  458. } else if (type === 2) {
  459. // 加
  460. if (item.is_infinite === 0 && item.num >= item.stock) {
  461. tools.error('商品库存' + item.stock + '件')
  462. this.isAjax = false
  463. } else if (item.is_quota > 0 && item.num >= item.quota_num) {
  464. tools.error('限购' + item.quota_num + '件')
  465. this.isAjax = false
  466. } else {
  467. this.setSub(item, type);
  468. }
  469. } else if (type === 3) {
  470. // 选规格
  471. console.log(item)
  472. this.selectedSpecification.forEach((v, k) => {
  473. if (v.goods_id === item.goods_id) {
  474. v.quota_num = item.quota_num
  475. v.payNum = item.num
  476. v.stock = item.stock
  477. }
  478. })
  479. this.popData.is_quota = item.is_quota
  480. this.popData.quota_num = item.quota_num
  481. this.popData.is_infinite = item.is_infinite
  482. this.popData.payNum = item.num
  483. this.popData.stock = item.stock
  484. this.getShopGoodsSpec(item)
  485. } else {
  486. let data = JSON.parse(JSON.stringify(this.popData))
  487. this.selectedSpecification.push(data)
  488. this.$refs.popupGG.close();
  489. console.log('this.popData.goods_spec_id')
  490. console.log(this.popData)
  491. console.log(this.selectedSpecification, 'this.___________________________');
  492. if (this.popData.goods_spec_id) {
  493. if (this.popData.is_infinite === 0 && this.popData.payNum > this.popData.stock) {
  494. tools.error('商品库存' + this.popData.stock + '件')
  495. this.popData.num = this.popData.stock
  496. } else if (this.popData.is_quota > 0 && this.popData.payNum > this.popData.quota_num) {
  497. tools.error('限购' + this.popData.quota_num + '件')
  498. this.popData.num = this.popData.quota_num
  499. } else {
  500. let cartKey = this.cartData.goods_list.findIndex(row => this.popData.goods_spec_id === row
  501. .goods_spec_id)
  502. console.log(cartKey)
  503. let addType = this.popData.num > 0 ? 2 : 1
  504. console.log('addType:' + addType)
  505. if (addType === 2 && cartKey < 0) {
  506. this.setShopIngAdd(this.popData.goods_id, this.popData.goodsItem.category_id, this.popData
  507. .goods_spec_id, this.popData.num)
  508. } else {
  509. this.setShopIngNumber(this.popData.goods_id, this.popData.goodsItem.category_id, type, this
  510. .popData
  511. .goods_spec_id, this.popData.num)
  512. }
  513. }
  514. } else {
  515. console.log('无规格信息')
  516. }
  517. this.isAjax = false
  518. }
  519. },
  520. gbPop() {
  521. this.$refs.popupGG.close();
  522. },
  523. setSub(item, type) {
  524. let cartKey = this.cartData.goods_list.findIndex(row => row.goods_id === item.goods_id)
  525. if (type === 2 && cartKey < 0) {
  526. this.setShopIngAdd(item.goods_id, item.category_id, '', 1, item)
  527. } else {
  528. this.setShopIngNumber(item.goods_id, item.category_id, type, '', 1, item)
  529. }
  530. },
  531. setShopIngAdd(goodsId, categoryId, goodsSpecId, number, item) {
  532. setShopIngAdd({
  533. 'type': 1,
  534. 'goods_id': goodsId,
  535. 'shop_id': this.shop_id,
  536. 'category_id': categoryId,
  537. 'goods_spec_id': goodsSpecId,
  538. 'number': number,
  539. }).then(res => {
  540. this.isAjax = false
  541. if (res.code === 1) {
  542. if (item) {
  543. ++item.num;
  544. }
  545. this.getShopIngList()
  546. } else if (res.code === 2) {
  547. tools.error(res.msg)
  548. if (item) {
  549. ++item.num;
  550. }
  551. this.getShopIngList()
  552. } else {
  553. tools.error(res.msg)
  554. }
  555. }).catch(() => {
  556. this.isAjax = false
  557. })
  558. },
  559. setShopIngNumber(goodsId, categoryId, operation, goodsSpecId, number, item) {
  560. setShopIngNumber({
  561. 'type': 1,
  562. 'goods_id': goodsId,
  563. 'shop_id': this.shop_id,
  564. 'category_id': categoryId,
  565. 'goods_spec_id': goodsSpecId,
  566. 'number': number,
  567. 'operation': operation === 2 ? 1 : 2,
  568. }).then(res => {
  569. this.isAjax = false
  570. if (res.code === 1) {
  571. if (item) {
  572. if (operation === 2) {
  573. ++item.num;
  574. } else {
  575. --item.num;
  576. }
  577. }
  578. this.getShopIngList()
  579. } else if (res.code === 2) {
  580. tools.error(res.msg)
  581. if (item) {
  582. if (operation === 2) {
  583. ++item.num;
  584. } else {
  585. --item.num;
  586. }
  587. }
  588. this.getShopIngList()
  589. } else {
  590. tools.error(res.msg)
  591. }
  592. }).catch(() => {
  593. this.isAjax = false
  594. })
  595. },
  596. setShopIngDel() {},
  597. // -------弹窗选择规格-----------
  598. selectSpec(info, groupKey) {
  599. let specKey = this.popData.spec_ids.indexOf(info.item_id)
  600. if (specKey >= 0) {
  601. this.popData.spec_ids.splice(specKey, 1)
  602. this.popData.spec_name.splice(specKey, 1)
  603. } else {
  604. this.popData.spec_ids.push(info.item_id)
  605. this.popData.spec_name.push(info.spec_value)
  606. for (const attrKey in this.popData.spec_attr[groupKey].spec_items) {
  607. if (this.popData.spec_attr[groupKey].spec_items[attrKey].item_id !== info.item_id) {
  608. let oldKey = this.popData.spec_ids.indexOf(this.popData.spec_attr[groupKey].spec_items[attrKey]
  609. .item_id)
  610. if (oldKey >= 0) {
  611. this.popData.spec_ids.splice(oldKey, 1)
  612. this.popData.spec_name.splice(oldKey, 1)
  613. }
  614. }
  615. }
  616. }
  617. // this.spec_ids = this.popData.spec_list.join('_')
  618. this.setGoodsSpecPrice()
  619. },
  620. },
  621. }
  622. </script>
  623. <style scoped lang="scss">
  624. .wh-44 {
  625. width: 44rpx;
  626. height: 44rpx;
  627. }
  628. .menu-box {
  629. height: 100%;
  630. .menu-box-left {
  631. width: 160rpx;
  632. height: 100%;
  633. background-color: #F7F8FA;
  634. // border-radius: 0rpx 20rpx 0 0rpx;
  635. .menu-type-list-f {
  636. width: 160rpx;
  637. height: 100%;
  638. .menu-type-list {
  639. width: 160rpx;
  640. min-height: 108rpx;
  641. padding: 18rpx 28rpx;
  642. position: relative;
  643. .menu-type-num {
  644. position: absolute;
  645. top: 2rpx;
  646. right: 8rpx;
  647. padding: 0 6rpx;
  648. min-width: 20rpx;
  649. height: 32rpx;
  650. text-align: center;
  651. line-height: 32rpx;
  652. background: #FB3D03;
  653. border-radius: 50%;
  654. }
  655. }
  656. }
  657. }
  658. .menu-box-right {
  659. // flex: 1;
  660. width: 100%;
  661. height: 100%;
  662. padding: 16rpx 12rpx 16rpx 16rpx;
  663. box-sizing: border-box;
  664. .menu-list {
  665. width: 100%;
  666. // height: 200rpx;
  667. margin-bottom: 40rpx;
  668. .goods_img {
  669. width: 200rpx;
  670. height: 200rpx;
  671. border-radius: 12rpx;
  672. margin-right: 16rpx;
  673. }
  674. .menu-list-right {
  675. flex: 1;
  676. .right-only-right {
  677. width: 100rpx;
  678. height: 44rpx;
  679. background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
  680. border-radius: 12rpx;
  681. line-height: 44rpx;
  682. position: relative;
  683. .selectedNum {
  684. position: absolute;
  685. right: 2rpx;
  686. top: -22rpx;
  687. font-size: 24rpx;
  688. color: #fff;
  689. width: 32rpx;
  690. height: 32rpx;
  691. line-height: 32rpx;
  692. background: #FB3D03;
  693. border-radius: 50%;
  694. }
  695. }
  696. .right-only-right-red {
  697. width: 44rpx;
  698. height: 44rpx;
  699. line-height: 40rpx;
  700. border-radius: 12rpx;
  701. border: 1rpx solid #41ABF5;
  702. color: #41ABF5;
  703. }
  704. .right-only-right-add {
  705. width: 44rpx;
  706. height: 44rpx;
  707. line-height: 40rpx;
  708. background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
  709. border-radius: 12rpx;
  710. }
  711. .right-only-right-2 {
  712. min-width: 50rpx;
  713. }
  714. }
  715. }
  716. }
  717. .gg-box {
  718. width: 750rpx;
  719. height: 1208rpx;
  720. background: #FFFFFF;
  721. border-radius: 24rpx 24rpx 0rpx 0rpx;
  722. .goods-info {
  723. border-bottom: 1rpx solid #EEEEEE;
  724. image {
  725. width: 170rpx;
  726. height: 160rpx;
  727. border-radius: 8rpx;
  728. margin-right: 22rpx;
  729. margin-bottom: 32rpx;
  730. }
  731. }
  732. .pop-buttom {
  733. width: 100%;
  734. // height: 250rpx;
  735. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(51, 51, 51, 0.1);
  736. .pop-buttom-left {
  737. padding-top: 12rpx;
  738. }
  739. .pop-buttom-2 {
  740. width: 100%;
  741. height: 96rpx;
  742. line-height: 96rpx;
  743. background: #41ABF5;
  744. border-radius: 200rpx
  745. }
  746. .right-only-right-red {
  747. width: 44rpx;
  748. height: 44rpx;
  749. line-height: 40rpx;
  750. border-radius: 12rpx;
  751. border: 1rpx solid #41ABF5;
  752. color: #41ABF5;
  753. }
  754. .right-only-right-add {
  755. width: 44rpx;
  756. height: 44rpx;
  757. line-height: 40rpx;
  758. background: linear-gradient(117deg, #57CAFF 0%, #41ABF5 100%);
  759. border-radius: 12rpx;
  760. }
  761. .right-only-right-2 {
  762. min-width: 50rpx;
  763. }
  764. }
  765. .spec-item {
  766. min-width: 210rpx;
  767. height: 66rpx;
  768. line-height: 66rpx;
  769. box-sizing: border-box;
  770. border-radius: 12rpx;
  771. margin: 0 26rpx 26rpx 0;
  772. padding: 0 10rpx;
  773. }
  774. .spec-item:nth-child(3) {
  775. margin-right: 0rpx !important;
  776. }
  777. .s-item {
  778. background-color: #ECF7FE;
  779. border: 2rpx solid #41ABF5;
  780. color: #41ABF5;
  781. }
  782. .n-item {
  783. border: 2rpx solid #EEEEEE;
  784. color: #000;
  785. }
  786. }
  787. }
  788. .goods-name {
  789. max-width: 310rpx;
  790. }
  791. </style>