微信

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <div class="mainPage flex-v">
  3. <div class="flex-item flex-v">
  4. <div class="banner">
  5. <img src="" class="centerLabel cover" alt="">
  6. <div class="bannerInfo flex-h">
  7. <div class="flex-item">
  8. <div>
  9. <span>项目名称:{{caseName}}</span>
  10. </div>
  11. </div>
  12. <span>{{userInfo.customer != undefined ? userInfo.customer.CustomerName : ''}}您好!</span>
  13. </div>
  14. </div>
  15. <div class="tableInfo flex-h">
  16. <div class="flex-item">
  17. <div>
  18. <span>桌号:{{tableNo}}</span>
  19. <!-- <span>本月已用:150杯</span> -->
  20. </div>
  21. </div>
  22. <router-link :to="{name: 'coffeeIndex', query: {}}">返回选择桌号</router-link>
  23. </div>
  24. <div class="content flex-item flex-h">
  25. <div class="slideMenus">
  26. <div>
  27. <ul>
  28. <li v-for="(item,index) in menuList" :key="index" :class="{'active': slideMenusActive == index}" @click="cutMenu(index)">
  29. <span>{{item.value}}</span>
  30. <span>{{item.eValue}}</span>
  31. </li>
  32. </ul>
  33. </div>
  34. </div>
  35. <div class="flex-item">
  36. <div>
  37. <swiper :options="swiperOption" ref="mySwiper">
  38. <swiper-slide class="swiper-slide" v-for="(item,index) in menuList" :key="index">
  39. <div class="flex-v">
  40. <h4>{{item.value + ' ' + item.eValue}}</h4>
  41. <div class="flex-item">
  42. <div>
  43. <swiper :options="subSwiperOption" ref="mySubSwiper">
  44. <swiper-slide class="swiper-slide" v-for="(subItem,subIndex) in item.list" :key="subIndex">
  45. <orderItem :data="subItem" @returnData="calcMenus" @selectSpec="selectSpec"></orderItem>
  46. </swiper-slide>
  47. </swiper>
  48. </div>
  49. </div>
  50. </div>
  51. </swiper-slide>
  52. </swiper>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. <div class="flex-h">
  58. <div class="flex-item">
  59. <div>
  60. <span>总计</span>
  61. <span>{{totalNum}}</span>
  62. <span>杯</span>
  63. <span>共</span>
  64. <span>{{totalPrice}}</span>
  65. <span>元</span>
  66. <i class="iconfont" :class="{'icon-jiantou-up': !showCalcMenu,'icon-jiantou-down': showCalcMenu}" @click="showCalcMenu = true"></i>
  67. </div>
  68. </div>
  69. <router-link :to="{name: 'placeOrderDetail', query: {info: JSON.stringify(settlementList), caseid: encodeURI(caseId), areaid: encodeURI(areaId), areaname: encodeURI(areaName), areaid: encodeURI(areaId), tableid: encodeURI(tableId), tableno: encodeURI(tableNo)}}">下单</router-link>
  70. <!-- <a @click="showCalcMenu = true">下单</a> -->
  71. </div>
  72. <orderPopup :show="showPopup" :data="currentSpec" @closePopup="closePopup" @returnData="calcMenus"></orderPopup>
  73. <calcMenu :show="showCalcMenu" :totalNum="totalCupNum" :data="settlementList" @returnData="calcMenus" @emptyMenus="emptyMenus" @closeCalcMenu="closeCalcMenu" @placeOrder="placeOrder"></calcMenu>
  74. </div>
  75. </template>
  76. <script>
  77. import { mapState, createNamespacedHelpers } from 'vuex'
  78. const { mapActions: caseTableActions } = createNamespacedHelpers('placeOrderForCoffee')
  79. import orderItem from '../../../components/orderItem/index'
  80. import orderPopup from '../../../components/orderPopup/index'
  81. import calcMenu from '../../../components/calcMenu/index'
  82. import { swiper, swiperSlide } from 'vue-awesome-swiper'
  83. import 'swiper/dist/css/swiper.css'
  84. export default {
  85. name: '',
  86. data () {
  87. const _self = this
  88. return {
  89. tableNo: decodeURI(this.$route.query.tableno),
  90. tableId: decodeURI(this.$route.query.tableid),
  91. areaId: decodeURI(this.$route.query.areaid),
  92. areaName: decodeURI(this.$route.query.areaname),
  93. caseName: decodeURI(this.$route.query.casename),
  94. caseId: decodeURI(this.$route.query.caseid),
  95. totalCupNum: 0, // 共计使用杯数
  96. showCalcMenu: false, // 显隐已点菜单弹窗
  97. currentSpec: null, // 当前选择规格
  98. showPopup: false, // 显隐选规格弹窗
  99. totalNum: 0, // 总杯数
  100. totalPrice: 0, // 总价格
  101. settlementList: [], // 商品选择清单
  102. slideMenusActive: 0, // 左侧菜单选中索引值
  103. menuList: [ // 商品数据
  104. // {
  105. // value: '咖啡',
  106. // eValue: 'Coffee',
  107. // id: '1',
  108. // status: 1,
  109. // list: [{
  110. // img: '',
  111. // name: '商品名称',
  112. // id: '1-1',
  113. // status: 1,
  114. // spec: [{
  115. // value: '去冰',
  116. // id: '1-1-1',
  117. // num: 0,
  118. // status: 0,
  119. // price: '10',
  120. // }, {
  121. // value: '少冰',
  122. // id: '1-1-2',
  123. // num: 0,
  124. // status: 1,
  125. // price: '15',
  126. // }, {
  127. // value: '正常',
  128. // id: '1-1-3',
  129. // num: 0,
  130. // status: 1,
  131. // price: '20',
  132. // }, {
  133. // value: '多冰',
  134. // id: '1-1-4',
  135. // num: 0,
  136. // status: 1,
  137. // price: '25',
  138. // }],
  139. // price: '100',
  140. // }, {
  141. // img: '',
  142. // name: '商品名称',
  143. // id: '1-2',
  144. // spec: [],
  145. // status: 0,
  146. // price: '100',
  147. // }, {
  148. // img: '',
  149. // name: '商品名称',
  150. // id: '1-3',
  151. // spec: [],
  152. // status: 1,
  153. // price: '100',
  154. // }, {
  155. // img: '',
  156. // name: '商品名称',
  157. // id: '1-4',
  158. // spec: [],
  159. // status: 1,
  160. // price: '100',
  161. // }, {
  162. // img: '',
  163. // name: '商品名称',
  164. // id: '1-5',
  165. // spec: [],
  166. // status: 1,
  167. // price: '100',
  168. // }, {
  169. // img: '',
  170. // name: '商品名称',
  171. // id: '1-6',
  172. // spec: [],
  173. // status: 1,
  174. // price: '100',
  175. // }],
  176. // }, {
  177. // value: '咖啡一',
  178. // eValue: 'Coffee',
  179. // id: '2',
  180. // status: 1,
  181. // list: [],
  182. // }, {
  183. // value: '咖啡二',
  184. // eValue: 'Coffee',
  185. // id: '3',
  186. // status: 1,
  187. // list: [],
  188. // }, {
  189. // value: '咖啡三',
  190. // eValue: 'Coffee',
  191. // id: '4',
  192. // status: 1,
  193. // list: [],
  194. // }, {
  195. // value: '咖啡四',
  196. // eValue: 'Coffee',
  197. // id: '5',
  198. // status: 1,
  199. // list: [],
  200. // }
  201. ],
  202. swiperOption: {
  203. observer: true,
  204. direction: 'vertical',
  205. on: {
  206. transitionEnd () {
  207. _self.slideMenusActive = this.activeIndex
  208. },
  209. }
  210. },
  211. subSwiperOption: {
  212. observer: true,
  213. direction: 'vertical',
  214. nested: true,
  215. slidesPerView: 'auto',
  216. freeMode: true,
  217. freeModeMomentumVelocityRatio: 2,
  218. },
  219. }
  220. },
  221. computed: {
  222. ...mapState({
  223. userInfo: x => x.userCenter.userInfo,
  224. goodsTypeList: x => x.placeOrderForCoffee.goodsTypeList,
  225. goodsList: x => x.placeOrderForCoffee.goodsList
  226. }),
  227. MySwiper () {
  228. return this.$refs.mySwiper.swiper
  229. },
  230. MySubSwiper () {
  231. return this.$refs.mySubSwiper.swiper
  232. },
  233. },
  234. components: {
  235. swiper,
  236. swiperSlide,
  237. orderItem,
  238. orderPopup,
  239. calcMenu,
  240. },
  241. created () {
  242. this.getGoodsTypeList({
  243. caseid: this.caseId,
  244. }).then((res) => {
  245. // console.log(JSON.stringify(res))
  246. this.getGoodsList({
  247. caseid: this.caseId,
  248. }).then((res) => {
  249. // console.log(JSON.stringify(res))
  250. this.mapArr()
  251. })
  252. })
  253. },
  254. methods: {
  255. ...caseTableActions([
  256. 'getGoodsTypeList',
  257. 'getGoodsList',
  258. ]),
  259. mapArr () { // 匹配商品规格
  260. var aArr = this.goodsTypeList, bArr = this.goodsList
  261. for (var n = 0; n < aArr.length; n++) {
  262. aArr[n].list = []
  263. for (var a = 0; a < bArr.length; a++) {
  264. if (aArr[n].TypeId === bArr[a].TypeId) {
  265. aArr[n].list.push(bArr[a])
  266. }
  267. }
  268. }
  269. this.menuList = []
  270. for (var x = 0; x < aArr.length; x++) {
  271. this.menuList.push({
  272. value: aArr[x].TypeName,
  273. eValue: aArr[x].EnglishName,
  274. id: aArr[x].TypeId,
  275. status: aArr[x].Status,
  276. list: []
  277. })
  278. for (var y = 0; y < aArr[x].list.length; y++) {
  279. this.menuList[x].list.push({
  280. img: aArr[x].list[y].Images,
  281. name: aArr[x].list[y].GoodsName,
  282. id: aArr[x].list[y].GoodsId,
  283. spec: [],
  284. status: aArr[x].list[y].Status,
  285. price: aArr[x].list[y].Price,
  286. })
  287. if(aArr[x].list[y].Specs !== null){
  288. for (var z = 0; z < aArr[x].list[y].Specs.length; z++) {
  289. this.menuList[x].list[y].spec.push({
  290. value: aArr[x].list[y].Specs[z].SpecName,
  291. id: aArr[x].list[y].Specs[z].SpecId,
  292. num: 0,
  293. status: aArr[x].list[y].Specs[z].Status,
  294. price: aArr[x].list[y].Specs[z].GoodsPrice,
  295. })
  296. }
  297. }
  298. }
  299. }
  300. // console.log(JSON.stringify(this.menuList))
  301. },
  302. placeOrder () { // 下单
  303. this.$router.push({ name: 'orderList', query: {} })
  304. },
  305. closeCalcMenu () { // 关闭已选菜单
  306. this.showCalcMenu = false
  307. },
  308. emptyMenus () { // 清空菜单
  309. this.settlementList = []
  310. },
  311. closePopup () { // 关闭规格弹窗
  312. this.showPopup = false
  313. this.currentSpec = null
  314. },
  315. selectSpec (val) { // 选规格
  316. this.currentSpec = val
  317. this.showPopup = true
  318. },
  319. cutMenu (index) { // 切换菜单
  320. this.MySwiper.slideTo(index, 300)
  321. },
  322. calcMenus (val) { // 计算清单
  323. var bool = true, arr = this.settlementList.slice()
  324. if (val.specId === null) {
  325. for (var n = 0; n < arr.length; n++) {
  326. if (arr[n].id === val.id && arr[n].specId === null) {
  327. bool = false
  328. arr[n] = val
  329. }
  330. }
  331. if (bool) {
  332. arr.push(val)
  333. }
  334. } else {
  335. for (var n = 0; n < arr.length; n++) {
  336. if (arr[n].specId === val.specId) {
  337. bool = false
  338. arr[n] = val
  339. }
  340. }
  341. if (bool) {
  342. arr.push(val)
  343. }
  344. }
  345. for (var n = 0; n < arr.length; n++) {
  346. if (arr[n].num === 0 || arr[n].defaultNum === 0) {
  347. arr.splice(n, 1)
  348. }
  349. }
  350. this.settlementList = arr
  351. // console.log(JSON.stringify(this.settlementList))
  352. this.calcTotalNum()
  353. },
  354. calcTotalNum () { // 计算总数量、价格
  355. var num = 0, price = 0
  356. if (!this.settlementList.length) {
  357. this.totalNum = 0
  358. this.totalPrice = 0
  359. return
  360. }
  361. for (var n = 0; n < this.settlementList.length; n++) {
  362. if (this.settlementList[n].specId === null) {
  363. num += this.settlementList[n].defaultNum
  364. price += this.settlementList[n].defaultPrice * this.settlementList[n].defaultNum
  365. } else {
  366. num += this.settlementList[n].num
  367. price += this.settlementList[n].price * this.settlementList[n].num
  368. }
  369. }
  370. this.totalNum = num
  371. this.totalPrice = price
  372. },
  373. }
  374. }
  375. </script>
  376. <!-- Add "scoped" attribute to limit CSS to this component only -->
  377. <style lang="scss" scoped>
  378. @import 'page.scss';
  379. </style>