zs 2 år sedan
förälder
incheckning
d5609ad198

+ 13 - 5
pagesHome/home/index.vue

@@ -134,6 +134,7 @@
 		data() {
 			return {
 				id: '',
+				order: '0',
 				shopInfo: {},
 				list: [],
 				active: '0',
@@ -155,6 +156,7 @@
 		onLoad: async function(e) {
 			const that = this;
 			that.$set(that, `id`, e.id);
+			that.$set(that, `order`, e.order);
 			that.search();
 		},
 		onShow() {
@@ -260,16 +262,22 @@
 					if (that.id) {
 						res = await that.$api(`cart/${that.id}`, 'GET', {});
 						if (res.errcode == '0') {
-							console.log(res.data);
-							// uni.navigateTo({
-							// 	url: `/pagesHome/order/add?id=${res.data._id}`
-							// })
+							let obj = {
+								list: [...that.buyList, ...res.data.list],
+								total: that.$plus(that.cartNum.total, res.data.total),
+							}
+							let cart = await that.$api(`cart/${res.data._id}`, 'POST', obj);
+							if (cart.errcode == '0') {
+								uni.navigateTo({
+									url: `/pagesHome/order/add?id=${cart.data._id}&order=${that.order}`
+								})
+							}
 						}
 					} else {
 						let obj = {
 							list: that.buyList,
 							total: that.cartNum.total,
-							table: '63dc9f7de85ec93564c717a0'
+							table: '63dc6a6b6a22ff30c8a11470'
 						}
 						res = await that.$api(`cart`, 'POST', obj);
 						if (res.errcode == '0') {

+ 27 - 14
pagesHome/order/add.vue

@@ -21,7 +21,9 @@
 						<view class="list-scroll-view">
 							<view class="list" v-for="(item,index) in list" :key="index">
 								<view class="img">
-									<image class="image" :src="item.file" mode=""></image>
+									<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
+										mode="">
+									</image>
 								</view>
 								<view class="info">
 									<view class="name textOver">
@@ -40,7 +42,7 @@
 					</scroll-view>
 				</view>
 				<view class="two_3">
-					共{{shopInfo.numTotal}}件商品,合计:<text>¥</text><text>{{shopInfo.total}}</text>
+					共{{list.length}}件商品,合计:<text>¥</text><text>{{shopInfo.total}}</text>
 				</view>
 			</view>
 		</view>
@@ -52,18 +54,16 @@
 				<button class="button" @tap.stop="toBuy">下单</button>
 			</view>
 		</view>
-		<uni-popup ref="popup" type="dialog">
-			<uni-popup-dialog mode="input" message="成功消息" :duration="2000" :before-close="true" @close="close"
-				@confirm="confirm"></uni-popup-dialog>
-		</uni-popup>
 	</view>
 </template>
 
 <script>
+	import moment from 'moment';
 	export default {
 		data() {
 			return {
 				id: "",
+				order: '',
 				shopInfo: {},
 				list: [],
 			}
@@ -71,6 +71,7 @@
 		onLoad: async function(e) {
 			const that = this;
 			that.$set(that, `id`, e.id);
+			that.$set(that, `order`, e.order);
 			that.search();
 		},
 		onShow() {
@@ -80,22 +81,34 @@
 			async search(e) {
 				const that = this;
 				if (that.id) {
-					let res = await that.$api(`order/${that.id}`, 'GET', {});
+					let res = await that.$api(`cart/${that.id}`, 'GET', {});
 					if (res.errcode == '0') {
 						that.$set(that, `list`, res.data.list)
 						that.$set(that, `shopInfo`, res.data)
+						let table = await that.$api(`table/${res.data.table}`, `GET`)
+						that.$set(that.shopInfo, `table`, table.data.name)
+						that.$set(that.shopInfo, `table_id`, res.data.table)
 					}
 				}
 			},
 			// 下单
-			toBuy() {
+			async toBuy() {
 				const that = this;
-				that.$refs.popup.open()
-			},
-			close() {
-				const that = this;
-				that.$refs.popup.close()
-			},
+				let type = '0';
+				if (that.is_show == true) type = '0'
+				else type = '1'
+				let obj = {
+					time: moment().format('YYYY-MM-DD HH:mm:ss'),
+					list: that.list
+				}
+				let res = await that.$api(`order/${that.order}`, 'POST', obj);
+				if (res.errcode == '0') {
+					uni.showToast({
+						title: '下单成功',
+						icon: 'none'
+					})
+				}
+			}
 		}
 	}
 </script>

+ 1 - 0
pagesHome/order/index.vue

@@ -156,6 +156,7 @@
 					money: that.shopInfo.detail_total,
 					money_num: that.shopInfo.perMoney,
 					num: that.shopInfo.person,
+					cart:that.id,
 					type: type,
 					list: that.list
 				}

+ 1 - 1
pagesHome/order/info.vue

@@ -110,7 +110,7 @@
 			toAdd() {
 				const that = this;
 				uni.navigateTo({
-					url: `/pagesHome/home/index?id=${that.shopInfo.table}`
+					url: `/pagesHome/home/index?id=${that.shopInfo.cart}&order=${that.id}`
 				})
 			},
 			// 结账

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/home/index.js.map


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/order/add.js.map


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/order/index.js.map


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/order/info.js.map


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 24 - 16
unpackage/dist/dev/mp-weixin/pagesHome/home/index.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 91 - 83
unpackage/dist/dev/mp-weixin/pagesHome/order/add.js


+ 1 - 3
unpackage/dist/dev/mp-weixin/pagesHome/order/add.json

@@ -1,8 +1,6 @@
 {
   "navigationBarTitleText": "加菜确认",
   "usingComponents": {
-    "uni-icons": "/uni_modules/uni-icons/components/uni-icons/uni-icons",
-    "uni-popup": "/uni_modules/uni-popup/components/uni-popup/uni-popup",
-    "uni-popup-dialog": "/uni_modules/uni-popup/components/uni-popup-dialog/uni-popup-dialog"
+    "uni-icons": "/uni_modules/uni-icons/components/uni-icons/uni-icons"
   }
 }

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesHome/order/add.wxml


+ 1 - 0
unpackage/dist/dev/mp-weixin/pagesHome/order/index.js

@@ -313,6 +313,7 @@ var _moment = _interopRequireDefault(__webpack_require__(/*! moment */ 108));fun
                   money: that.shopInfo.detail_total,
                   money_num: that.shopInfo.perMoney,
                   num: that.shopInfo.person,
+                  cart: that.id,
                   type: type,
                   list: that.list };_context3.next = 6;return (
 

+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesHome/order/info.js

@@ -270,7 +270,7 @@ var _default =
     toAdd: function toAdd() {
       var that = this;
       uni.navigateTo({
-        url: "/pagesHome/home/index?id=".concat(that.shopInfo.table) });
+        url: "/pagesHome/home/index?id=".concat(that.shopInfo.cart, "&order=").concat(that.id) });
 
     },
     // 结账