menu.vue 23 KB

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