group.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <template>
  2. <view class="group">
  3. <view class="head">
  4. <view class="head_left">
  5. <span class="cuIcon-back" @click="back"></span>
  6. </view>
  7. <view class="case">
  8. 商品详情
  9. </view>
  10. </view>
  11. <view class="content">
  12. <view class="center">
  13. <view class="title">
  14. 组合套餐
  15. </view>
  16. <view class="list" v-for="(item,index) in groupList" :key="index">
  17. <view class="name">{{item.name}}</view>
  18. <view class="single" v-for="(row,ind) in item.singleList">
  19. <view class="single_name">
  20. {{row.name}}
  21. </view>
  22. <view class="single_price">
  23. {{row.num}}{{row.unit}}/{{row.price}}元
  24. <!-- <span class="cuIcon-deletefill"></span> -->
  25. <span @click="remove(index,ind)">删除</span>
  26. </view>
  27. </view>
  28. <view class="handle">
  29. <view class="delete" @click="deleteGroup(index)">
  30. 删除
  31. </view>
  32. <view class="addSingle" @click="addSingle(item,index)">
  33. 添加单品
  34. </view>
  35. </view>
  36. </view>
  37. <view class="add_group" @click="isAddGroup = true">
  38. <image src="/static/product/add.png" mode=""></image>
  39. 添加商品组
  40. </view>
  41. </view>
  42. </view>
  43. <view class="foot">
  44. <view class="btn" @click="save">
  45. 保存
  46. </view>
  47. </view>
  48. <!-- 添加商品组 -->
  49. <view class="popup" v-if="isAddGroup">
  50. <view class="model">
  51. <view class="title">
  52. 输入商品组名称
  53. <image src="/static/index/cut.png" mode="" @click="isAddGroup = false"></image>
  54. </view>
  55. <view class="inp">
  56. <u-input v-model="name" placeholder="限30字" />
  57. </view>
  58. <view class="btn">
  59. <view class="cancel" @click="cancel">取消</view>
  60. <view class="sub" @click="addGroup">确定</view>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 添加单品 -->
  65. <view class="popup" v-if="isAddSingle">
  66. <view class="model">
  67. <view class="title">
  68. 添加单品
  69. <image src="/static/index/cut.png" mode="" @click="isAddSingle = false"></image>
  70. </view>
  71. <view class="inp">
  72. <view class="single">
  73. 名称<u-input v-model="single.name" placeholder="请输入单品名称" />
  74. </view>
  75. <view class="single">
  76. 数量<u-input v-model="single.num" placeholder="请输入数量" />
  77. </view>
  78. <view class="single">
  79. 单位<u-input v-model="single.unit" placeholder="请输入单位" />
  80. </view>
  81. <view class="single">
  82. 价格<u-input v-model="single.price" placeholder="请输入价格" />
  83. </view>
  84. </view>
  85. <view class="btn">
  86. <view class="cancel" @click="cancelSingle">取消</view>
  87. <view class="continue" @click="continu">确定并继续添加</view>
  88. <view class="subSingle" @click="subSingle">确定</view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </template>
  94. <script>
  95. export default {
  96. data() {
  97. return {
  98. name: '',
  99. groupList: [],
  100. isAddGroup: false,
  101. isAddSingle: false,
  102. single: {
  103. name: '',
  104. num: '',
  105. unit: '',
  106. price: ''
  107. },
  108. singleIndex: null,//商品组下标
  109. }
  110. },
  111. methods: {
  112. //添加商品组
  113. addGroup() {
  114. if (this.name !== '') {
  115. this.isAddGroup = false
  116. this.groupList.push({
  117. name: this.name,
  118. singleList: []
  119. })
  120. this.name = ''
  121. this.isAddSingle = true
  122. this.singleIndex = this.groupList.length - 1
  123. }
  124. },
  125. //取消添加商品组
  126. cancel() {
  127. this.isAddGroup = false
  128. this.name = ''
  129. },
  130. //添加单品弹窗出现
  131. addSingle(item, index) {
  132. this.isAddSingle = true
  133. this.singleIndex = index
  134. },
  135. //继续添加单品
  136. continu() {
  137. this.subSingle()
  138. },
  139. //取消添加单品
  140. cancelSingle() {
  141. this.isAddSingle = false
  142. this.isAddGroup = false
  143. this.single = {
  144. name: '',
  145. num: '',
  146. unit: '',
  147. price: ''
  148. }
  149. },
  150. //确定添加单品
  151. subSingle() {
  152. this.groupList[this.singleIndex].singleList.push(this.single)
  153. this.isAddGroup = false
  154. this.isAddSingle = false
  155. this.single = {
  156. name: '',
  157. num: '',
  158. unit: '',
  159. price: ''
  160. }
  161. },
  162. //删除单品
  163. remove(index, ind) {
  164. this.groupList[index].singleList.splice(ind, 1)
  165. },
  166. //删除商品组
  167. deleteGroup(index){
  168. this.groupList.splice(index,1)
  169. },
  170. //返回
  171. back() {
  172. uni.navigateBack({
  173. delta: 1
  174. });
  175. },
  176. //保存
  177. save(){
  178. console.log(this.groupList)
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .group {
  185. width: 100vw;
  186. height: 100vh;
  187. display: flex;
  188. flex-direction: column;
  189. justify-content: space-between;
  190. background: #F7F8FC;
  191. .head {
  192. width: 100%;
  193. padding: 20rpx;
  194. background-color: #fff;
  195. display: flex;
  196. justify-content: space-between;
  197. align-items: center;
  198. position: relative;
  199. .head_left {
  200. font-size: 40rpx;
  201. }
  202. .case {
  203. position: absolute;
  204. left: 50%;
  205. top: 50%;
  206. transform: translate(-50%, -50%);
  207. font-size: 36rpx;
  208. font-weight: 600;
  209. }
  210. }
  211. .content {
  212. width: 100%;
  213. flex: 1;
  214. padding: 20rpx;
  215. overflow-y: auto;
  216. .center {
  217. background-color: #fff;
  218. padding: 16rpx 20rpx;
  219. .title {
  220. font-size: 28rpx;
  221. font-weight: 600;
  222. margin-bottom: 20rpx;
  223. }
  224. }
  225. .add_group {
  226. width: 100%;
  227. height: 135rpx;
  228. margin: 20rpx auto 0px;
  229. background: #F7F8FC;
  230. display: flex;
  231. flex-direction: column;
  232. justify-content: center;
  233. align-items: center;
  234. font-size: 22rpx;
  235. color: #449AFF;
  236. image {
  237. width: 52rpx;
  238. height: 52rpx;
  239. }
  240. }
  241. .list {
  242. width: 100%;
  243. // height: 70rpx;
  244. background: #F7F8FC;
  245. border-radius: 8rpx;
  246. margin-top: 20rpx;
  247. border-radius: 20rpx;
  248. padding: 20rpx;
  249. .name {
  250. width: 100%;
  251. height: 40rpx;
  252. // padding: 20rpx;
  253. font-weight: 600;
  254. margin-bottom: 16rpx;
  255. }
  256. .single {
  257. width: 100%;
  258. // display: flex;
  259. // align-items: center;
  260. // justify-content: space-between;
  261. margin-bottom: 16rpx;
  262. .single_name {
  263. width: 100%;
  264. font-size: 26rpx;
  265. }
  266. .single_price {
  267. font-size: 24rpx;
  268. color: #888888;
  269. display: flex;
  270. justify-content: space-between;
  271. align-items: center;
  272. span {
  273. display: block;
  274. width: 112rpx;
  275. height: 47rpx;
  276. background: #FFFFFF;
  277. border-radius: 4rpx;
  278. border: 1px solid #EEEEEE;
  279. text-align: center;
  280. line-height: 47rpx;
  281. font-size: 24rpx;
  282. }
  283. }
  284. }
  285. .handle{
  286. width: 100%;
  287. display: flex;
  288. justify-content: space-between;
  289. .delete{
  290. width: 45%;
  291. height: 61rpx;
  292. background: rgba(243,79,79,0.1);
  293. border-radius: 12rpx;
  294. border: 1px solid #F34F4F;
  295. font-size: 28rpx;
  296. color: #F34F4F;
  297. display: flex;
  298. align-items: center;
  299. justify-content: center;
  300. }
  301. .addSingle {
  302. width: 45%;
  303. height: 61rpx;
  304. background: rgba(68, 154, 255, 0.1);
  305. border-radius: 12rpx;
  306. border: 1px solid #449AFF;
  307. display: flex;
  308. align-items: center;
  309. justify-content: center;
  310. }
  311. }
  312. }
  313. }
  314. .foot {
  315. width: 100%;
  316. height: 112rpx;
  317. background-color: #fff;
  318. display: flex;
  319. align-items: center;
  320. justify-content: center;
  321. .operate {
  322. width: 100%;
  323. display: flex;
  324. justify-content: space-between;
  325. align-items: center;
  326. padding: 0px 20rpx;
  327. .delete {
  328. width: 205rpx;
  329. height: 76rpx;
  330. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  331. border-radius: 49rpx;
  332. font-size: 28rpx;
  333. color: #FFFFFF;
  334. display: flex;
  335. justify-content: center;
  336. align-items: center;
  337. margin-right: 24rpx;
  338. margin-left: 140rpx;
  339. }
  340. .all {
  341. width: 25%;
  342. // height: 60rpx;
  343. // border: 1px solid #999;
  344. display: flex;
  345. justify-content: center;
  346. align-items: center;
  347. image {
  348. width: 40rpx;
  349. height: 40rpx;
  350. margin-right: 10rpx;
  351. }
  352. }
  353. }
  354. .btn {
  355. width: 672rpx;
  356. height: 76rpx;
  357. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  358. border-radius: 75rpx;
  359. font-size: 28rpx;
  360. color: #FFFFFF;
  361. display: flex;
  362. align-items: center;
  363. justify-content: center;
  364. }
  365. }
  366. .popup {
  367. width: 100vw;
  368. height: 100vh;
  369. position: fixed;
  370. top: 0;
  371. left: 0;
  372. background: rgba(0, 0, 0, 0.4);
  373. display: flex;
  374. align-items: end;
  375. z-index: 99;
  376. .model {
  377. width: 100%;
  378. background-color: #fff;
  379. border-radius: 20rpx 20rpx 0rpx 0rpx;
  380. padding: 0rpx 24rpx;
  381. padding-bottom: 20rpx;
  382. .title {
  383. width: 100%;
  384. height: 86rpx;
  385. display: flex;
  386. align-items: center;
  387. justify-content: center;
  388. position: relative;
  389. border-bottom: 1px solid #eeeeee;
  390. margin-bottom: 24rpx;
  391. image {
  392. width: 40rpx;
  393. height: 40rpx;
  394. position: absolute;
  395. right: 0px;
  396. }
  397. }
  398. .inp {
  399. width: 100%;
  400. min-height: 68rpx;
  401. background: #F7F8FC;
  402. border-radius: 4rpx;
  403. //
  404. .single {
  405. width: 100%;
  406. padding: 0rpx 20rpx;
  407. display: flex;
  408. align-items: center;
  409. // justify-content: space-between;
  410. background-color: #eee;
  411. margin-bottom: 20rpx;
  412. }
  413. }
  414. .btn {
  415. width: 100%;
  416. height: 100rpx;
  417. display: flex;
  418. justify-content: space-around;
  419. align-items: center;
  420. border-top: 1px solid #eeeeee;
  421. margin-top: 24rpx;
  422. .cancel {
  423. width: 205rpx;
  424. height: 76rpx;
  425. border-radius: 54rpx;
  426. border: 1px solid #CCCCCC;
  427. font-size: 28rpx;
  428. color: #999999;
  429. display: flex;
  430. align-items: center;
  431. justify-content: center;
  432. }
  433. .sub {
  434. width: 443rpx;
  435. height: 76rpx;
  436. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  437. border-radius: 53rpx;
  438. display: flex;
  439. align-items: center;
  440. justify-content: center;
  441. font-size: 28rpx;
  442. color: #FFFFFF;
  443. }
  444. .continue {
  445. width: 232rpx;
  446. height: 76rpx;
  447. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  448. border-radius: 53rpx;
  449. display: flex;
  450. align-items: center;
  451. justify-content: center;
  452. font-size: 28rpx;
  453. color: #FFFFFF;
  454. }
  455. .subSingle {
  456. width: 232rpx;
  457. height: 76rpx;
  458. background: linear-gradient(90deg, #FFA05B 0%, #FF7918 100%);
  459. border-radius: 49rpx;
  460. display: flex;
  461. align-items: center;
  462. justify-content: center;
  463. font-size: 28rpx;
  464. color: #FFFFFF;
  465. }
  466. }
  467. }
  468. }
  469. }
  470. /deep/.u-input {
  471. text-align: right !important;
  472. }
  473. </style>