lyy@qq.com 11 달 전
부모
커밋
fe7bd51abe

+ 3 - 0
main.js

@@ -116,6 +116,9 @@ Vue.prototype.autoLogin = async () => { // 小程序自动登录
 				})
 				if (result) {
 					uni.setStorageSync("token", result.data.access_token);
+					uni.navigateTo({
+						url: `/pages/diningList/diningList`
+					})
 					//await Vue.prototype.getUser()
 					resolve(true)
 				} else {

+ 1 - 1
manifest.json

@@ -50,7 +50,7 @@
     "quickapp" : {},
     /* 小程序特有相关 */
     "mp-weixin" : {
-        "appid": "wxfc1ae62fd810717d",
+        "appid" : "wxfa70687fbaeb7894",
         "setting" : {
             "urlCheck" : false
         },

+ 18 - 2
pages/classify/classify.vue

@@ -57,7 +57,8 @@
 			<view class="balance dflex-c background-gradient" @click="toBuy">去结算</view>
 		</view>
 		<cartPopupVue ref="cartPopup" @selected-changed="handleSelectedChanged" />
-
+		<u-modal ref="uModal" :show="modalShow" :title="modalTitle" :content="modalContent" :closeable="true"
+			@close="modalClose" @confirm="confirm"></u-modal>
 	</view>
 </template>
 
@@ -87,7 +88,10 @@
 				cList: {},
 				cardMsg: {},
 				selectedList: [],
-				buyCount: 0
+				buyCount: 0,
+				modalShow: false,
+				modalTitle: '您还未登录',
+				modalContent: '您是否确定要登录'
 			}
 		},
 		onLoad() {
@@ -100,8 +104,20 @@
 				this.carListMeg()
 				this.total = 0
 			})
+			const token = uni.getStorageSync('token')
+			if (!token) {
+				this.modalShow = true;
+			}
 		},
 		methods: {
+			modalClose() {
+				this.modalShow = false;
+			},
+			confirm() {
+				//调用登录方法,autoLogin方法在mian.js中
+				this.autoLogin()
+				this.modalShow = false
+			},
 			// 加购
 			goCart(e) {
 				// console.log('================', e)

+ 1 - 1
pages/diningList/diningList.vue

@@ -150,7 +150,7 @@
 		.btnbor {
 			margin: -32rpx -20rpx 0;
 			// margin-right: -11px;
-			margin-top: 12px;
+			margin-top: 8px;
 			float: right;
 			position: relative; // 设置为相对定位
 

+ 17 - 8
pages/order/myOrder/myOrder.vue

@@ -17,8 +17,10 @@
 				<!-- 滚动区 -->
 				<scroll-view class="h-full" scroll-y @scrolltolower="loadData">
 					<!-- 空白页 -->
-					<use-empty v-if="tabItem.orderList.length === 0 && tabItem.loaded" e-style="round" e-type="cart"
-						tip="订单数据为空" height="93vh"></use-empty>
+					<u-empty text="订单是空的~"
+						v-if="!tabItem.loaded && (!tabItem.orderList || tabItem.orderList.length === 0)" mode="order"
+						style="padding-top: 100rpx;">
+					</u-empty>
 					<!-- 订单列表区 -->
 					<view class="margin-bottom-sm" :class="index === 0 ? 'padding-top-sm' : ''"
 						v-for="(item, index) in tabItem.orderList" :key="index">
@@ -70,7 +72,8 @@
 
 								<view class="dflex-e">
 									<view class="dflex">
-										<button class="action-btn border-radius-big bg-main">取消订单</button>
+										<button class="action-btn border-radius-big bg-main"
+											@click="toDelete()">取消订单</button>
 										<button class="action-btn border-radius-big bg-main"
 											@click="todetail(item)">订单详情</button>
 										<button class="action-btn border-radius-big bg-main main-btn"
@@ -87,7 +90,7 @@
 				</scroll-view>
 			</swiper-item>
 		</swiper>
-
+		<u-toast ref="uToast"></u-toast>
 	</view>
 </template>
 
@@ -177,12 +180,10 @@
 				}
 				const result = await this.$request('get', '/order/tradeOrder/queryTradeOrder', params)
 				if (result) {
-
 					console.log('result', result.rows)
 					this.navList[0].orderList = result.rows
 					console.log('orderList', this.navList[0].orderList)
-					this.navList[1].orderList = result.rows.filter(item => item.status == 'TRADE_NO_CREATE_PAY');
-
+					// this.navList[1].orderList = result.rows.filter(item => item.status == 'TRADE_NO_CREATE_PAY');
 				}
 			},
 			loadData() {},
@@ -202,12 +203,20 @@
 				// 	url: `/pages/user/order/order-detail?order_id=${order.order_id}`
 				// });
 				uni.navigateTo({
-					url: `/pages/order/orderPaid/orderPaid?id=${order.orderId}`
+					url: `/pages/order/orderPaid/orderPaid?data=${encodeURIComponent(JSON.stringify(order))}`
 				});
 			},
 			// 立即支付
 			payment(order) {
 
+			},
+			toDelete() {
+				this.$refs.uToast.show({
+					type: 'default',
+					title: '默认主题',
+					message: "演示阶段暂时不能取消",
+					position: 'center'
+				})
 			},
 			// 删除订单
 			delOrder(item) {

+ 44 - 18
pages/order/orderPaid/orderPaid.vue

@@ -15,7 +15,8 @@
 					取餐时间
 				</view>
 			</view>
-			<u-icon slot="icon" size="20" name="arrow-right" :label="goods.arriveCutTime" labelPos="left"></u-icon>
+			<u-icon slot="icon" size="20" name="arrow-right" label="15:00" labelPos="left"></u-icon>
+			<!-- <u-icon slot="icon" size="20" name="arrow-right" :label="goods.orderPickup.writeOffTime" labelPos="left"></u-icon> -->
 		</view>
 		<view class="gap"></view>
 		<view class="padding-sm dflex-b bg-main">
@@ -25,8 +26,9 @@
 				</view>
 			</view>
 			<view>
+				<!-- 字段返回数据有问题 -->
 				<radio style="transform: scale(0.85)" value="r1" :checked="true" color="#ff0000" class="radio">
-					{{goods.pickupType.pickupType ? '店内用餐' : '打包带走'}}
+					{{goods.pickupType.pickupType == '0' ? '打包带走' : '店内用餐'}}
 				</radio>
 			</view>
 		</view>
@@ -40,7 +42,7 @@
 				<view class="total-goods">共计{{lists}}件商品</view>
 			</view>
 			<view class="goods-cart w-full">
-				<view class="goods-cont padding-tb" v-for="(item, index) in goods.itemList" :key="index">
+				<view class="goods-cont padding-tb" v-for="(item, index) in goods.orderItemVoList" :key="index">
 					<my-goods :item="item">
 						<view class="good-num">×{{item.quantity}}</view>
 					</my-goods>
@@ -91,15 +93,16 @@
 		<view class="bg-main">
 			<view class="dflex-b padding-lr padding-tb-sm">
 				<view class="flex1 send-label">总金额</view>
-				<view class=""><text style="font-size: 24rpx;">¥</text>{{goods.payment}}</view>
+				<view class=""><text style="font-size: 24rpx;">¥</text>{{goods.totalAmount}}</view>
 			</view>
 		</view>
 		<view class="gap"></view>
 		<view class="bar-space"></view>
 		<view class="cart-bottom padding-sm dflex-b">
-			<view class="go-cart dflex-c">取消订单</view>
+			<view class="go-cart dflex-c" @click="toDelete()">取消订单</view>
 			<view class="go-buy dflex-c background-gradient" @click="toPay()">去支付</view>
 		</view>
+		<u-toast ref="uToast"></u-toast>
 	</view>
 </template>
 
@@ -112,13 +115,16 @@
 			}
 		},
 		onLoad(e) {
-			this.fatchDate(e)
-		},
-		onUnload() {
-			// uni.redirectTo({
-			// 	url: `/pages/classify/classify` // 指定页面的路径
-			// });
-			// return true;
+			var dataString = decodeURIComponent(e.data)
+			var data = JSON.parse(dataString);
+			console.log('data', data)
+			this.goods = data
+			this.lists = this.goods.orderItemVoList.length
+			this.goods.orderItemVoList.forEach(item => {
+				item.imgUrl = item.picUrl
+			})
+			console.log('this.lists', this.lists)
+			// this.fatchDate(e)
 		},
 		methods: {
 			async fatchDate(e) {
@@ -143,15 +149,35 @@
 					return v.toString(16);
 				});
 			},
+			toDelete() {
+				this.$refs.uToast.show({
+					type: 'default',
+					title: '默认主题',
+					message: "演示阶段暂时不能取消",
+					position: 'center'
+				})
+			},
 			toPay() {
-				const params = {
-					orderId: this.goods.orderId,
-					amount: this.goods.payment,
-				}
-				this.$request('post', `/order/orderPay/addOrderPay`, params, true).then(res => {
-					this._toPay()
+				// 显示提示
+				this.$refs.uToast.show({
+					type: 'default',
+					title: '默认主题',
+					message: "演示阶段暂时不能支付",
+					position: 'center'
 				})
 
+				// uni.showToast({
+				// 	title: '演示阶段暂时不能支付',
+				// 	icon: 'error',
+				// 	duration: 1000
+				// });
+				// const params = {
+				// 	orderId: this.goods.orderId,
+				// 	amount: this.goods.payment,
+				// }
+				// this.$request('post', `/order/orderPay/addOrderPay`, params, true).then(res => {
+				// 	this._toPay()
+				// })
 			},
 			async _toPay() {
 				console.log('this.uuid()', this.uuid())

+ 2 - 1
pages/order/submitOrder/submitOrder.vue

@@ -192,7 +192,8 @@
 					shippingType: 4,
 					orderPickup: {
 						pickupType: this.val,
-						verify: 2
+						verify: 2,
+						// writeOffTime: this.value
 					}
 				}
 				console.log('params', params);

+ 25 - 5
pages/user/myInfo.vue

@@ -6,10 +6,11 @@
 				<u-form-item label="姓名" prop="userInfo.nickName">
 					<u--input v-model="userInfo.nickName" border="none"></u--input>
 				</u-form-item>
-				<u-form-item label="头像" prop="userInfo.avatarUrl">
+				<u-form-item label="头像" prop="iAvg">
 					<view slot="right" class="flex-row" @click="onInfo">
-						<u-avatar :src="userInfo.avatarUrl ? userInfo.avatarUrl : null" size="50"
+						<u-avatar :src="avg"
 							@click="uploadAvator"></u-avatar>
+							<!-- :src="userInfo.avatarUrl ? userInfo.avatarUrl : null" -->
 						<view class="flex-grow-1">
 							<u-icon name="arrow-right" color="#96989e"></u-icon>
 						</view>
@@ -28,22 +29,25 @@
 			</u--form>
 		</view>
 		<view class="cart-bottom padding-sm dflex-b">
-			<view class="go-cart dflex-c">保存编辑</view>
-			<view class="go-buy dflex-c background-gradient">退出登录</view>
+			<view class="go-cart dflex-c" @click="toSubim()">保存编辑</view>
+			<view class="go-buy dflex-c background-gradient" @click="toLogout()">退出登录</view>
 		</view>
+		<u-toast ref="uToast"></u-toast>
 	</view>
 </template>
 
 <script>
+	import iAvg from '../../static/avg.png'
 	export default {
 		data() {
 			return {
 				userInfo: {
 					name: 'uView UI',
-					avg: '',
+					//avg: 'iAvg',
 					birthday: '',
 					phone: ''
 				},
+				avg: iAvg,
 				rules: {
 					// 字段名称
 					phone: [{
@@ -89,6 +93,22 @@
 				// 	},
 				// })
 			},
+			toSubim() {
+				this.$refs.uToast.show({
+					type: 'default',
+					title: '默认主题',
+					message: "演示阶段暂时不能提交",
+					position: 'center'
+				})
+			},
+			toLogout() {
+				this.$refs.uToast.show({
+					type: 'default',
+					title: '默认主题',
+					message: "演示阶段暂时不能退出",
+					position: 'center'
+				})
+			},
 			uploadAvator() { // 上传头像
 				uni.chooseImage({
 					success: (file) => {

+ 26 - 17
pages/user/user.vue

@@ -5,12 +5,14 @@
 				<view class="page-header-content">
 					<view class="page-header-content-left">
 						<view class="" @click="onInfo">
-							<u-avatar :src="userdata ? userdata.avatarUrl : null" size="100"></u-avatar>
+							<u-avatar :src="src" size="100"></u-avatar>
+							<!-- :src="userdata ? userdata.avatarUrl : null" -->
 						</view>
 					</view>
 					<view class="page-header-content-center">
 						<view>
-							<view class="fz16px mt5px">{{userdata && userdata.nickName ? userdata.nickName : '22222'}}</view>
+							<view class="fz16px mt5px">{{userdata && userdata.nickName ? userdata.nickName : '22222'}}
+							</view>
 						</view>
 					</view>
 				</view>
@@ -42,8 +44,8 @@
 									size="40"></u-icon>
 							</view>
 							<view class="flex-box-item" @click="openPage('/pages/order/myOrder/myOrder?type=3')">
-								<u-icon name="close-circle" label="已取消" labelColor="#96989e" labelSize="14px" labelPos="bottom"
-									size="40"></u-icon>
+								<u-icon name="close-circle" label="已取消" labelColor="#96989e" labelSize="14px"
+									labelPos="bottom" size="40"></u-icon>
 							</view>
 							<view class="flex-box-item" @click="openPage('/pages/order/myOrder/myOrder?type=4')">
 								<u-icon name="bag" label="已完成" labelColor="#96989e" labelSize="14px" labelPos="bottom"
@@ -60,16 +62,16 @@
 					<view class="mb10px">我的应用</view>
 					<view class="flex-box mt20px">
 						<view class="flex-box-item" @click="openPage('/pages/user/myInfo')">
-							<u-icon name="account" labelColor="#96989e" labelPos="bottom" labelSize="14px"
-								label="个人信息" size="40"></u-icon>
+							<u-icon name="account" labelColor="#96989e" labelPos="bottom" labelSize="14px" label="个人信息"
+								size="40"></u-icon>
 						</view>
-						<view class="flex-box-item" @click="openPage('/pages/classify/classify')">
+						<view class="flex-box-item" @click="openPage(`/pages/diningCar/diningCar?id=${cList.id}`)">
 							<u-icon name="car" labelColor="#96989e" label="餐车信息" labelSize="14px" labelPos="bottom"
 								size="40"></u-icon>
 						</view>
 						<view class="flex-box-item" @click="call">
-							<u-icon name="kefu-ermai" label="客服电话" labelColor="#96989e" labelSize="14px" labelPos="bottom"
-								size="40"></u-icon>
+							<u-icon name="kefu-ermai" label="客服电话" labelColor="#96989e" labelSize="14px"
+								labelPos="bottom" size="40"></u-icon>
 						</view>
 					</view>
 				</view>
@@ -80,21 +82,27 @@
 </template>
 
 <script>
+	import iAvg from '../../static/avg.png'
 	export default {
 		data() {
 			return {
-				userdata:{
-					avatarUrl:'',
-					phone:'',
-					nickName:''
+				userdata: {
+					avg: '../../static/avg.png',
+					phone: '',
+					nickName: ''
 				},
-				cPhone: ''
+				src: iAvg,
+				cPhone: '',
+				cList: {}
 			}
 		},
 		onLoad() {
 			const e = uni.getStorageSync('info')
 			this.cPhone = e
 			this.fatchDate()
+
+			const q = uni.getStorageSync('carl')
+			this.cList = q
 		},
 		methods: {
 			openPage(path) {
@@ -104,11 +112,11 @@
 			},
 			fatchDate() {
 				wx.getUserInfo({
-				    success: (res)=>{
-				        console.log(res)
+					success: (res) => {
+						console.log(res)
 						this.userdata = res.userInfo
 						console.log(res.userInfo)
-				    }
+					}
 				})
 			},
 			call() {
@@ -199,6 +207,7 @@
 			}
 		}
 	}
+
 	.pageBg {
 		background-color: #EFF2F7
 	}

BIN
static/avg.png


+ 108 - 0
utils/accuracy.js

@@ -0,0 +1,108 @@
+// var floatObj = function () {
+  /*
+   * 判断obj是否为一个整数
+   */
+  function isInteger(obj) {
+    return Math.floor(obj) === obj
+  }
+
+  /*
+   * 将一个浮点数转成整数,返回整数和倍数。如 3.14 >> 314,倍数是 100
+   * @param floatNum {number} 小数
+   * @return {object}
+   *   {times:100, num: 314}
+   */
+  function toInteger(floatNum) {
+    var ret = {
+      times: 1,
+      num: 0
+    };
+    if (isInteger(floatNum)) {
+      ret.num = floatNum;
+      return ret
+    }
+    var strfi = floatNum + '';
+    var dotPos = strfi.indexOf('.');
+    var len = strfi.substr(dotPos + 1).length;
+    var times = Math.pow(10, len);
+    var intNum = parseInt(floatNum * times + 0.5, 10);
+    ret.times = times;
+    ret.num = intNum;
+    return ret
+  }
+
+  /*
+   * 核心方法,实现加减乘除运算,确保不丢失精度
+   * 思路:把小数放大为整数(乘),进行算术运算,再缩小为小数(除)
+   *
+   * @param a {number} 运算数1
+   * @param b {number} 运算数2
+   * @param op {string} 运算类型,有加减乘除(add/subtract/multiply/divide)
+   *
+   */
+  function operation(a, b, op) {
+    let a1 = a < 0 ? Math.abs(a) : a;
+    let b1 = b < 0 ? Math.abs(b) : b;
+    var o1 = toInteger(a1);
+    var o2 = toInteger(b1);
+    var n1 = a < 0 ? -o1.num : o1.num;
+    var n2 = b < 0 ? -o2.num : o2.num;
+    var t1 = o1.times;
+    var t2 = o2.times;
+    var max = t1 > t2 ? t1 : t2;
+    var result = null;
+    switch (op) {
+      case 'add':
+        if (t1 === t2) { // 两个小数位数相同
+          result = n1 + n2
+        } else if (t1 > t2) { // o1 小数位 大于 o2
+          result = n1 + n2 * (t1 / t2)
+        } else { // o1 小数位 小于 o2
+          result = n1 * (t2 / t1) + n2
+        }
+        return result / max;
+      case 'subtract':
+        if (t1 === t2) {
+          result = n1 - n2
+        } else if (t1 > t2) {
+          result = n1 - n2 * (t1 / t2)
+        } else {
+          result = n1 * (t2 / t1) - n2
+        }
+        return result / max;
+      case 'multiply':
+        result = (n1 * n2) / (t1 * t2);
+        return result;
+      case 'divide':
+        result = (n1 / n2) * (t2 / t1);
+        return result
+    }
+  }
+
+  // 加减乘除的四个接口
+  export function add(a, b) {
+    return operation(a, b, 'add')
+  }
+
+  export function subtract(a, b) {
+    return operation(a, b, 'subtract')
+  }
+
+  export function multiply(a, b) {
+    return operation(a, b, 'multiply')
+  }
+
+  export function divide(a, b) {
+    return operation(a, b, 'divide')
+  }
+
+//   // exports
+//   return {
+//     add: add,
+//     subtract: subtract,
+//     multiply: multiply,
+//     divide: divide
+//   }
+// }()
+
+