Kaynağa Gözat

Merge branch 'master' of http://47.107.53.207:3000/ymy/bc_wx_applet

# Conflicts:
#	env/dev.js
ymy 9 ay önce
ebeveyn
işleme
7ac148d112

+ 24 - 14
components/cartPopup.vue

@@ -57,7 +57,6 @@
 					storeId: e.id
 				}
 				const res = await this.$request('get', `/front/shoppingCart/list`, params)
-				console.log('res.data', res.data)
 				if (res) {
 					this.carList = res.data
 				}
@@ -86,13 +85,12 @@
 				if (this.carList.length > 0) {
 					this.allSelected = this.carList.every(car => car.selected)
 				}
-				console.log('this.carList2222222222222222222', this.carList)
 			},
 			close() {
 				this.show = false;
 			},
 			changeValue(value, v) {
-				console.log('更新后的数量=======:', value, '索引=========:', v)
+				console.log('value, v', value, v)
 				const e = uni.getStorageSync('carl')
 				const userId = uni.getStorageSync('appUserId')
 				const params = {
@@ -104,7 +102,6 @@
 					quantity: value.value,
 					extendProps: userId
 				}
-				console.log('params', params)
 				this.$request('put', `/front/shoppingCart`, params, true)
 
 			},
@@ -116,14 +113,12 @@
 				this.$emit('selected-changed', this.carList)
 				this.totalList = this.carList
 				this.totalPrice()
-				console.log('this.carList111111111111111', this.carList)
 			},
 			clearCart() {
 				const ids = this.carList.map(car => car.id);
-				console.log('ids', ids)
 				this.$request('delete', `/front/shoppingCart/${ids}`).then(response => {
 					// 请求成功
-					if (response.code = 200) {
+					if (response.code == 200) {
 						// 弹出消息
 						uni.showToast({
 							title: '已清空',
@@ -131,7 +126,7 @@
 							duration: 2000
 						})
 						this.carList = []
-						this.$emit('selected-changed', []);
+						this.$emit('selected-changed', this.carList);
 						this.show = false
 					}
 				}).catch(error => {
@@ -140,7 +135,6 @@
 				})
 			},
 			radioChange(e) {
-				console.log(e)
 				e.selected = !e.selected
 				// 检查是否所有车都被选中了
 				this.allSelected = this.carList.every(car => car.selected)
@@ -149,9 +143,6 @@
 				this.$emit('selected-changed', this.localList);
 				this.totalList = this.localList
 				this.totalPrice()
-				console.log('this.totalList', this.totalList);
-				// 打印结果
-				console.log('this.allSelected', this.allSelected);
 			},
 			//计算selected为true的
 			totalPrice() {
@@ -175,9 +166,28 @@
 
 				// 将总价格转换回浮点数(以元为单位)
 				this.total = (total / 100).toFixed(2);
-
-				console.log('total', this.total);
 			},
+			toBuy() {
+				const carlist = {
+					carlist: this.totalList,
+					total: this.total
+				}
+				console.log('carlistcarlist', carlist)
+				if (carlist.carlist.length <= 0) {
+					// this.$refs.uNotify.show({'请选择'})
+					uni.showToast({
+						title: '请选择',
+						icon: 'error',
+						duration: 2000
+					});
+				} else {
+					uni.navigateTo({
+						url: `/pages/order/submitOrder/submitOrder?data=${encodeURIComponent(JSON.stringify(carlist))}`
+					})
+					this.selectAll()
+					this.show = false;
+				}
+			}
 		}
 	}
 </script>

+ 1 - 1
components/my-goods/my-goods.vue

@@ -3,7 +3,7 @@
 		<view class="goods">
 			<view class="goods-img">
 				<image v-if="item.imgUrl" mode="aspectFit" class="wh-full" :src="item.imgUrl"></image>
-				<view else class="pic"></view>
+				<view v-else class="pic"></view>
 			</view>
 			<view class="right-info">
 				<view class="good-title">{{item.skuName}}</view>

+ 8 - 6
components/send-type/send-type.vue

@@ -2,7 +2,7 @@
 	<view class="send-type padding-lr-sm dflex-b">
 		<view class="send-label">配送方式</view>
 		<view class="send-radio">
-			<uni-data-checkbox v-model="value" :localdata="list" @change="radioGroupChange" selectedColor="#F54319"></uni-data-checkbox>
+			<uni-data-checkbox v-model="value" :localdata="list" @change="radioChange" selectedColor="#F54319"></uni-data-checkbox>
 		</view>
 	</view>
 </template>
@@ -12,22 +12,24 @@
 		name:"send-type",
 		data() {
 			return {
-				value:null,
+				value:1,
 				list:[
 					{
 						text:"自提",
 						value:1
 					},
-					{
-						text:"配送",
-						value:2
-					}
+					// {
+					// 	text:"配送",
+					// 	value:2,
+					//  disable:true
+					// }
 				]
 			};
 		},
 		methods:{
 			radioChange(v){
 				this.$emit("sendTypeChange", v)
+				
 			}
 		}
 	}

+ 167 - 55
components/specPopup.vue

@@ -24,12 +24,13 @@
 		</scroll-view>
 		<view class="purchase-num padding-lr-sm">
 			<uni-section title="购买数量"></uni-section>
-			<uni-number-box v-model="vModelValue" @change="changeValue(value)" />
+			<uni-number-box v-model="vModelValue" :min="1" @change="changeValue()" />
 		</view>
 		<view class="btn-box">
 			<view class="btn reset" @click="toShop">加入购物车</view>
 			<view class="btn confirm" @click="toBuy">立即购买</view>
 		</view>
+		<u-toast ref="uToast"></u-toast>
 	</uni-popup>
 </template>
 
@@ -49,23 +50,29 @@
 				speL: [],
 				intSkuId: [], // 选择唯一的id
 				caMsg: [], // 根据id查出来的数据
+				isSelected: false,
+				isData: null,
+				preSele: [],
+				itemsL: [],
+				toList: [],
+				total: 0
 			}
 		},
 		methods: {
-			changeValue(e) {},
+			changeValue(value) {},
 			change(e) {
 				if (!e.show) { // 当弹出层关闭时
 					// 重置规格选择
-					if (this.specs.length > 0) {
+					if (this.specs.length > 0 && this.preSele.length < 0) {
 						this.specs.forEach(e => {
 							e.values.forEach(s => {
 								s.selected = false
 							})
 						})
+						//this.vModelValue = 1
 					}
 					this.speL = []
-					// 重置购买数量
-					this.vModelValue = 1
+					this.seleBack()
 				}
 			},
 			async selectSpec1(item, spec) {
@@ -73,19 +80,25 @@
 				item.values.forEach(value => {
 					value.selected = false
 				})
-				// 然后,选择当前点击的选项
-				spec.selected = true
-				if (spec.selected) {
-					this.speL.push(spec)
+
+				spec.selected = !spec.selected
+				const newIds = spec.ids
+				if (this.preSele.length > 0) {
+					this.speL = this.preSele
 				}
+				const filSpeL = this.speL.filter(value => value.ids !== newIds);
+
+				filSpeL.push(spec)
+
+				this.speL = filSpeL
 
 				const seleList = this.speL.filter(item => item.selected == true)
-				const items = seleList.map(item => item.label)
+				this.itemsL = seleList.map(item => item.label)
+
 				// 计算选中规格项的skuIds数组的交集
 				if (seleList.length > 0) {
 					let intersection = seleList[0].skuIds
 
-					// 遍历数组中的每个对象
 					for (let i = 1; i < seleList.length; i++) {
 						// 使用filter和includes方法找到交集
 						intersection = intersection.filter(skuId => {
@@ -101,78 +114,176 @@
 					// 如果没有选中的规格项,返回空字符串
 					this.intSkuId = '';
 				}
-				console.log('speL', this.speL)
-				// 确定每一个都有选择后发起请求
-				const isSelected = this.specs.every(spec => spec.values.some(value => value.selected))
-				if (isSelected) {
+
+				this.isSelected = this.specs.every(spec => spec.values.some(value => value.selected))
+
+				if (this.isSelected) {
 					// 如果所有规格都至少有一个选项被选中
-					const res = await this.$request('get', `/item/sku/${this.intSkuId}`)
-					this.caMsg = res.data
-					// 返回选中规格项的label值
-					console.log('intSkuId', this.intSkuId)
-					console.log('items', items)
-					console.log('所有规格都已选择')
-					const itemDetal = {
-						id: this.intSkuId,
-						item: Array.from(items).join(','),
-						count: this.vModelValue
+					const res = await this.$request('get', `/item/sku/queryItem/${this.intSkuId}`)
+					if (res) {
+						this.caMsg = res.data
+						this.vModelValue = 1
+						console.log('this.caMsg', this.caMsg)
+					}
+
+					//console.log('所有规格都已选择')
+					if (this.isData == true) {
+						this.preSele = seleList
 					}
-					this.$emit('seChanged', itemDetal);
+
 				} else {}
 			},
-			async open() {
+			// 返回选中的数据
+			seleBack() {
+				const itemDetal = {
+					id: this.intSkuId,
+					item: Array.from(this.itemsL).join(','),
+					count: this.vModelValue
+				}
+				this.$emit('seChanged', itemDetal);
+			},
+			async open(e) {
+				if (e || e != null) {
+					this.isData = e
+				}
 				this.$refs.popup.open('bottom')
-				console.log("this.cardMsg")
+
 				const spuId = this.cardMsg.spuId
 				const res = await this.$request('get', `/item/sku/queryPropMapping?spuId=${spuId}`)
-				this.specs = res.data.filter(item => item.values && item.values.length > 0);
+				this.specs = res.data.filter(item => item.values && item.values.length > 0)
 				this.specs.forEach(item => {
 					Object.assign(item, {
 						values: item.values.map(value => ({
 							...value,
-							ids: item.id,
-							selected: false
+							ids: item.id
+							// selected: false
 						}))
 					})
+					if (this.preSele.length <= 0) {
+						Object.assign(item, {
+							values: item.values.map(value => ({
+								...value,
+								selected: false
+							}))
+						})
+					} else {
+						Object.assign(item, {
+							values: item.values.map(value => ({
+								...value,
+								selected: this.preSele.some(prevSpe =>
+									prevSpe.label === value.label && prevSpe.ids ===
+									value.ids)
+							}))
+						})
+					}
 				})
 			},
 			toShop() {
+				if (this.isSelected == false) {
+					uni.showToast({
+						title: '还有规格未选择',
+						icon: 'error',
+						duration: 1000
+					});
+				} else {
+					const e = uni.getStorageSync('carl')
+					const userId = uni.getStorageSync('appUserId')
+					const count = this.vModelValue
+					const params = {
+						storeId: e.id,
+						storeName: e.name,
+						skuId: this.caMsg.skuId,
+						basePrice: this.caMsg.retailPrice,
+						price: this.caMsg.retailPrice,
+						quantity: count,
+						extendProps: userId
+					}
+					this.$request('post', `/front/shoppingCart`, params, true).then(response => {
+						// 请求成功
+						if (response.code == 200) {
+							// 弹出消息
+							// uni.showToast({
+							// 	title: '加入购物车成功',
+							// 	icon: 'success',
+							// 	duration: 2000
+							// })
+							this.$refs.uToast.show({
+								type: 'success',
+								title: '默认主题',
+								message: "加入购物车成功",
+								position: 'center'
+							})
+							this.$emit('addShop');
+						} else if (response.code == 500) {
+							uni.showToast({
+								title: response.msg,
+								icon: 'error',
+								duration: 2000
+							});
+						}
+					}).catch(error => {
+						// 请求失败
+						console.error('请求失败:', error);
+					})
+					// 关闭弹出层
+					this.$refs.popup.close()
+				}
+			},
+			totalPrice() {
 				const e = uni.getStorageSync('carl')
 				const userId = uni.getStorageSync('appUserId')
-				const count = this.vModelValue
-				const params = {
+				const toList = {
 					storeId: e.id,
 					storeName: e.name,
 					skuId: this.caMsg.skuId,
 					basePrice: this.caMsg.retailPrice,
 					price: this.caMsg.retailPrice,
-					quantity: count,
-					extendProps: userId
+					quantity: this.vModelValue,
+					extendProps: userId,
+					imgUrl: this.caMsg.img,
+					spuId: this.caMsg.spuId,
+					skuName: this.caMsg.skuName,
+					skuProperties: this.caMsg.skuProperties,
+					skuTitle: this.caMsg.title,
 				}
-				console.log('params', params)
-				this.$request('post', `/front/shoppingCart`, params, true).then(response => {
-					// 请求成功
-					if (response.code = 200) {
-						// 弹出消息
-						uni.showToast({
-							title: '加入购物车成功',
-							icon: 'success',
-							duration: 2000
-						})
-						this.$emit('addShop');
-					}
-				}).catch(error => {
-					// 请求失败
-					console.error('请求失败:', error);
-				})
-				// this.$emit('update-shopmsg', this.shopMsg);
-				// 关闭弹出层
-				this.$refs.popup.close()
+				let total = 0;
+				// 如果 selected 属性不存在,直接计算所有商品
+				let priceInCents = Math.round(toList.price * 100);
+				let quant = toList.quantity;
+				total += priceInCents * quant;
+				
+				this.toList.push(toList)
+				// 将总价格转换回浮点数(以元为单位)
+				this.total = (total / 100).toFixed(2);
 			},
 			toBuy() {
+				this.totalPrice()
+				const carlist = {
+					carlist: this.toList,
+					total: this.total
+				}
 				uni.navigateTo({
-					url: `/pages/order/submitOrder/submitOrder`
+					url: `/pages/order/submitOrder/submitOrder?data=${encodeURIComponent(JSON.stringify(carlist))}`
 				})
+				this.toList = []
+				console.log('carlist', carlist)
+				this.$refs.popup.close()
+				// if (carlist.carlist.length <= 0) {
+				// 	// this.$refs.uNotify.show({'请选择'})
+				// 	uni.showToast({
+				// 		title: '请选择',
+				// 		icon: 'error',
+				// 		duration: 2000
+				// 	});
+				// } else {
+				// 	uni.navigateTo({
+				// 		url: `/pages/order/submitOrder/submitOrder?data=${encodeURIComponent(JSON.stringify(carlist))}`
+				// 	})
+				// 	this.$refs.popup.close()
+				// }
+				// uni.navigateTo({
+				// 	url: `/pages/order/submitOrder/submitOrder`
+				// })
 			}
 		}
 	}
@@ -185,6 +296,7 @@
 		justify-content: space-around;
 		align-items: center;
 		padding-top: 80upx;
+		padding-bottom: 40upx;
 
 		.btn {
 			width: 45%;

+ 19 - 13
main.js

@@ -66,12 +66,10 @@ Vue.prototype.$request = function(method, url, data, isJSON, hideLoading, showEr
 				'Content-Type': isJSON ? 'application/json' : 'application/x-www-form-urlencoded',
 				'Authorization': 'Bearer ' + token,
 				'clientId': 'e5cd7e4891bf95d1d19206ce24a7b32e',
-				//"isEncrypt": false,
 				// 'tenantId': Vue.prototype.tenantId 或者 'tenantId': `${tenantId}`
 				// application/x-www-form-urlencoded application/json
 			},
 			success: (res) => {
-				console.log('resres', res)
 				uni.hideLoading();
 				if (res.statusCode === 200) {
 					resolve(res.data);
@@ -79,18 +77,23 @@ Vue.prototype.$request = function(method, url, data, isJSON, hideLoading, showEr
 					if (showErrMsg) {
 						resolve({
 							result: false,
-							msg: res.data.msg
+							msg: res.data.data.msg
 						})
 					} else {
 						resolve(false);
-						if (this.$refs && this.$refs.uNotify) {
-							this.$refs.uNotify.show({
-								type: 'error',
-								top: 0,
-								message: res.data.msg,
-								icon: 'error-circle'
-							})
-						}
+						uni.showToast({
+							title: res.data.data.msg,
+							icon: 'error',
+							duration: 2000
+						});
+						// if (this.$refs && this.$refs.uNotify) {
+						// 	this.$refs.uNotify.show({
+						// 		type: 'error',
+						// 		top: 0,
+						// 		message: res.data.msg,
+						// 		icon: 'error-circle'
+						// 	})
+						// }
 					}
 				}
 			},
@@ -106,13 +109,16 @@ Vue.prototype.autoLogin = async () => { // 小程序自动登录
 	return new Promise(resolve => {
 		uni.login({
 			success: async (res) => {
-				const result = await Vue.prototype.$request('post', '/miniLogin', {
+				const result = await Vue.prototype.$request('post', '/auth/miniLogin', {
 					code: res.code,
-					appid: '000000'
+					tenantId: '000000'
 					//appid: Vue.prototype.appId
 				})
 				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

@@ -1,6 +1,6 @@
 {
     "name" : "yx_wx_applet",
-    "appid" : "__UNI__8DC0664",
+    "appid" : "__UNI__A586034",
     "description" : "",
     "versionName" : "1.0.0",
     "versionCode" : "100",

+ 65 - 87
pages.json

@@ -1,123 +1,108 @@
 {
 	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
 		{
-			"path" : "pages/login/login",
-			"style" : 
-			{
-				"navigationBarTitleText" : "登录"
-			}
-		},
-		
-		{
-			"path": "pages/index/index",
+			"path": "pages/login/login",
 			"style": {
-				"navigationBarTitleText": "首页"
+				"navigationBarTitleText": "登录"
 			}
 		},
 		{
-			"path" : "pages/classify/classify",
-			"style" : 
-			{
-				"navigationBarTitleText" : "首页",
-				"enablePullDownRefresh" : false
+			"path": "pages/home/home",
+			"style": {
+				"navigationBarTitleText": "首页",
+				"enablePullDownRefresh": false
 			}
 		},
+		// {
+		// 	"path": "pages/index/index",
+		// 	"style": {
+		// 		"navigationBarTitleText": "首页"
+		// 	}
+		// },
 		{
-			"path" : "pages/user/user",
-			"style" : 
-			{
-				"navigationBarTitleText" : "我的",
-				"enablePullDownRefresh" : false
+			"path": "pages/user/user",
+			"style": {
+				"navigationBarTitleText": "我的",
+				"enablePullDownRefresh": false
 			}
 		},
 		{
-			"path" : "pages/user/myInfo",
-			"style" : 
-			{
-				"navigationBarTitleText" : "个人中心",
-				"enablePullDownRefresh" : false
+			"path": "pages/user/myInfo",
+			"style": {
+				"navigationBarTitleText": "个人中心",
+				"enablePullDownRefresh": false
 			}
 		},
 		{
-			"path" : "pages/order/orderPaid/orderPaid",
-			"style" : 
-			{
-				"navigationBarTitleText" : "订单详情"
+			"path": "pages/order/orderPaid/orderPaid",
+			"style": {
+				"navigationBarTitleText": "订单详情"
 			}
 		},
 		{
-			"path" : "pages/order/submitOrder/submitOrder",
-			"style" : 
-			{
-				"navigationBarTitleText" : "提交订单",
-				"enablePullDownRefresh" : false
+			"path": "pages/order/submitOrder/submitOrder",
+			"style": {
+				"navigationBarTitleText": "提交订单",
+				"enablePullDownRefresh": false
 			}
 		},
 		{
-			"path" : "pages/login/qrCode",
-			"style" : 
-			{
-				"navigationBarTitleText" : "登录"
+			"path": "pages/login/qrCode",
+			"style": {
+				"navigationBarTitleText": "登录"
 			}
 		},
-		
+
 		{
-			"path" : "pages/diningList/diningList",
-			"style" : 
-			{
-				"navigationBarTitleText" : "餐车列表"
+			"path": "pages/diningList/diningList",
+			"style": {
+				"navigationBarTitleText": "餐车列表"
 			}
 		},
-			
+
 		{
-			"path" : "pages/diningCar/diningCar",
-			"style" : 
-			{
-				"navigationBarTitleText" : "餐车信息",
-				"enablePullDownRefresh" : false
+			"path": "pages/diningCar/diningCar",
+			"style": {
+				"navigationBarTitleText": "餐车信息",
+				"enablePullDownRefresh": false
 			}
 		},
 		{
-			"path" : "pages/bindPhone/bindPhone",
-			"style" : 
-			{
-				"navigationBarTitleText" : "登录",
-				"enablePullDownRefresh" : false
+			"path": "pages/bindPhone/bindPhone",
+			"style": {
+				"navigationBarTitleText": "登录",
+				"enablePullDownRefresh": false
 			}
 		},
 		{
-			"path" : "pages/order/myOrder/myOrder",
-			"style" : 
-			{
-				"navigationBarTitleText" : "我的订单",
-				"enablePullDownRefresh" : false
+			"path": "pages/order/myOrder/myOrder",
+			"style": {
+				"navigationBarTitleText": "我的订单",
+				"enablePullDownRefresh": false
 			}
 		},
 		{
-			"path" : "pages/order/paySuccess/paySuccess",
-			"style" : 
-			{
-				"navigationBarTitleText" : "支付成功",
-				"enablePullDownRefresh" : false
+			"path": "pages/order/paySuccess/paySuccess",
+			"style": {
+				"navigationBarTitleText": "支付成功",
+				"enablePullDownRefresh": false
 			}
 		},
 		{
-			"path" : "pages/order/orderDetail/orderDetail",
-			"style" : 
-			{
-				"navigationBarTitleText" : "订单详情",
-				"enablePullDownRefresh" : false
+			"path": "pages/order/orderDetail/orderDetail",
+			"style": {
+				"navigationBarTitleText": "订单详情",
+				"enablePullDownRefresh": false
 			}
 		},
 		{
-			"path" : "pages/goodDetail/goodDetail",
-			"style" : 
-			{
-				"navigationBarTitleText" : "商品详情",
-				"enablePullDownRefresh" : false
+			"path": "pages/goodDetail/goodDetail",
+			"style": {
+				"navigationBarTitleText": "商品详情",
+				"enablePullDownRefresh": false
 			}
 		},
-		
+
 		{
 			"path": "pages/index/home",
 			"style": {
@@ -125,10 +110,9 @@
 			}
 		},
 		{
-			"path" : "pages/order/orderDetails/orderDetails",
-			"style" : 
-			{
-				"navigationBarTitleText" : ""
+			"path": "pages/order/orderDetails/orderDetails",
+			"style": {
+				"navigationBarTitleText": ""
 			}
 		}
 	],
@@ -142,17 +126,11 @@
 		"borderStyle": "black",
 		"backgroundColor": "#ffffff",
 		"list": [{
-				"pagePath": "pages/index/index",
+				"pagePath": "pages/home/home",
 				"iconPath": "static/ic_hone.png",
 				"selectedIconPath": "static/ic_hone.png",
 				"text": "首页"
 			},
-			// {
-			// 	"pagePath": "pages/classify/classify",
-			// 	"iconPath": "static/ic_hone.png",
-			// 	"selectedIconPath": "static/ic_hone.png",
-			// 	"text": "分类"
-			// },
 			{
 				"pagePath": "pages/index/home",
 				"iconPath": "static/ic_hone.png",
@@ -168,4 +146,4 @@
 		"backgroundColor": "#EEEEEE"
 	},
 	"uniIdRouter": {}
-}
+}

+ 14 - 8
pages/diningList/diningList.vue

@@ -96,8 +96,8 @@
 				}
 				uni.setStorageSync("carl", carl)
 				console.log('---------------------', carl)
-				uni.navigateTo({
-					url: `/pages/classify/classify`
+				uni.switchTab({
+					url: `/pages/home/home`
 				})
 			},
 			async fatchDate() {
@@ -148,11 +148,16 @@
 		background-color: #fff;
 
 		.btnbor {
-			margin: -32rpx -20rpx 0;
-			// margin-right: -11px;
-			margin-top: 12px;
-			float: right;
-			position: relative; // 设置为相对定位
+			position: absolute;
+			/* 设置为绝对定位 */
+			right: 16px;
+			/* 相对于父元素的右边缘 */
+			bottom: 30px;
+			/* 相对于父元素的下边缘 */
+			margin: 0;
+			/* 清除 margin 属性 */
+			padding: 0;
+			/* 清除 padding 属性 */
 
 			&::after {
 				content: '';
@@ -165,7 +170,8 @@
 				top: 0;
 				right: 0;
 				background-color: #fff;
-				z-index: -1; // 使边框在图片下面
+				z-index: -1;
+				/* 使边框在图片下面 */
 			}
 		}
 	}

+ 86 - 22
pages/goodDetail/goodDetail.vue

@@ -30,8 +30,8 @@
 					</view> -->
 				</view>
 				<view class="container">
-					<u-tag type="error" icon="coupon"></u-tag>
-					<u-tag text="平台活动" type="error" plain plainFill></u-tag>
+					<u-tag type="error" icon="coupon" size="mini"></u-tag>
+					<u-tag text="平台活动" type="error" plain plainFill  size="mini"></u-tag>
 				</view>
 				<!-- <view class="coupon">
 					<view class="mj-tag">
@@ -49,7 +49,7 @@
 			<!-- 06. 详情区 -->
 			<view class="gap"></view>
 			<view class="spec-cell">
-				<u-cell title="已选" isLink clickable @click="clickSpec" :border="false">
+				<u-cell title="规格" isLink clickable @click="clickSpec" :border="false">
 					<text slot="value" class="u-slot-value">{{specValue}}</text>
 				</u-cell>
 			</view>
@@ -73,11 +73,11 @@
 		<!-- 07. 操作区 -->
 		<view class="cart-bottom padding-sm dflex-b">
 			<view style="width: 60px;">
-				<u-icon :name="service" label="客服" labelPos="bottom" size="32" @click="call"></u-icon>
+				<u-icon :name="service" label="客服" labelSize="10px" color="#9A9A9A" labelPos="bottom" size="24" @click="call"></u-icon>
 			</view>
 			<view style="width: 60px;">
 				<uni-badge size="small" :text="buyCount" absolute="rightTop">
-					<u-icon :name="shoppingCart" label="购物车" labelPos="bottom" size="32" @click="showCart"></u-icon>
+					<u-icon :name="shoppingCart" label="购物车" labelSize="10px" labelPos="bottom" size="24" @click="showCart"></u-icon>
 				</uni-badge>
 			</view>
 			<view class="go-cart dflex-c" @click="toShop">加入购物车</view>
@@ -87,7 +87,8 @@
 		<!-- 置顶 -->
 		<use-totop ref="usetop" bottom="120"></use-totop>
 		<specPopup ref="specPopup" :cardMsg="cardMsg" @seChanged="seChanged" @addShop="carListMeg"></specPopup>
-		<cartPopupVue ref="cartPopup" />
+		<cartPopupVue ref="cartPopup" @selected-changed="handleSelectedChanged" />
+		<u-toast ref="uToast"></u-toast>
 	</view>
 </template>
 
@@ -104,7 +105,7 @@
 		data() {
 			return {
 				cardMsg: {},
-				buyCount: '',
+				buyCount: 0,
 				total: 0,
 				carList: {},
 				detailMsg: {},
@@ -118,7 +119,9 @@
 				// 轮播图
 				scrollTop: 0,
 				count: 1,
-				dataDel: {}
+				dataDel: {},
+				toList: [],
+				selel: false
 			}
 		},
 		onLoad(option) {
@@ -150,10 +153,17 @@
 					})
 				}
 			},
+			handleSelectedChanged(selectedItems) {
+				console.log('选中的数据:', selectedItems)
+				//this.carList = selectedItems
+				this.carListMeg()
+
+			},
 			clickSpec() {
 				this.cardMsg = this.goods
 				this.$nextTick(() => {
-					this.$refs.specPopup.open();
+					this.$refs.specPopup.open(true);
+
 				});
 			},
 			showCart() {
@@ -175,16 +185,22 @@
 				console.log('params', params)
 				this.$request('post', `/front/shoppingCart`, params, true).then(response => {
 					// 请求成功
-					console.log('response',response)
+					console.log('response', response)
 					if (response.code = 200) {
 						// 弹出消息
-						uni.showToast({
-							title: '加入购物车成功',
-							icon: 'success',
-							duration: 2000
+						// uni.showToast({
+						// 	title: '加入购物车成功',
+						// 	icon: 'success',
+						// 	duration: 2000
+						// })
+						this.$refs.uToast.show({
+							type: 'success',
+							title: '默认主题',
+							message: "加入购物车成功",
+							position: 'center'
 						})
 						this.carListMeg()
-					} else if (response.code = 500){
+					} else if (response.code = 500) {
 						uni.showToast({
 							title: response.msg,
 							icon: 'warning',
@@ -209,7 +225,7 @@
 			//获取详情列表
 			async fatchDate() {
 				const id = this.dataDel.spuId
-				const res = await this.$request('get', `/item/spu/${id}`)
+				const res = await this.$request('get', `/item/spu/queryProduct/${id}`)
 				if (res) {
 					this.goods = res.data
 				}
@@ -217,19 +233,67 @@
 			},
 			//根据skuid获取选择商品信息
 			async seChanged(e) {
+				
 				console.log('==================3e', e)
 				this.specValue = e.item
 				this.count = e.count
-				const res = await this.$request('get', `/item/sku/${e.id}`)
+				const res = await this.$request('get', `/item/sku/queryItem/${e.id}`)
 				this.detailMsg = res.data
+				this.selel = true
 				console.log('this.detailMsg', this.detailMsg)
 			},
+			totalPrice() {
+				const e = uni.getStorageSync('carl')
+				const userId = uni.getStorageSync('appUserId')
+				const toList = {
+					storeId: e.id,
+					storeName: e.name,
+					skuId: this.detailMsg.skuId,
+					basePrice: this.detailMsg.retailPrice,
+					price: this.detailMsg.retailPrice,
+					quantity: this.count,
+					extendProps: userId,
+					imgUrl: this.detailMsg.img,
+					spuId: this.detailMsg.spuId,
+					skuName: this.detailMsg.skuName,
+					skuProperties: this.detailMsg.skuProperties,
+					skuTitle: this.detailMsg.title,
+				}
+				let total = 0;
+				// 如果 selected 属性不存在,直接计算所有商品
+				let priceInCents = Math.round(toList.price * 100);
+				let quant = toList.quantity;
+				total += priceInCents * quant;
+
+				this.toList.push(toList)
+				// 将总价格转换回浮点数(以元为单位)
+				this.total = (total / 100).toFixed(2);
+			},
 			// 去购买
 			toBuy() {
-				
-				uni.navigateTo({
-					url: `/pages/order/submitOrder/submitOrder`
-				})
+				console.log('this.detailMsg', this.detailMsg)
+				if (this.selel == true) {
+					this.totalPrice()
+					const carlist = {
+						carlist: this.toList,
+						total: this.total
+					}
+					console.log('carlist', carlist)
+					uni.navigateTo({
+						url: `/pages/order/submitOrder/submitOrder?data=${encodeURIComponent(JSON.stringify(carlist))}`
+					})
+					this.toList = []
+				} else {
+					uni.showToast({
+						title: '请选择规格',
+						icon: 'error',
+						duration: 2000
+					});
+
+				}
+				// uni.navigateTo({
+				// 	url: `/pages/order/submitOrder/submitOrder`
+				// })
 			}
 		}
 	}
@@ -366,7 +430,7 @@
 	}
 
 	.u-slot-value {
-		font-size: 12px;
+		font-size: 16px;
 	}
 
 	.cart-bottom {

+ 3 - 4
pages/classify/classify.vue → pages/home/home.vue

@@ -12,8 +12,9 @@
 				<view class="container">
 					<u-tag plain :text="cList.openState ? '营业中' : '离线'" :type="cList.openState ? 'success' : 'error'"
 						size="mini"></u-tag>
-					<view @click="btnIc">
-						<u-icon :label="cList.name" labelPos="left" size="16" name="arrow-down"></u-icon>
+					<view>
+						<text>{{cList.name}}</text>
+						<!-- <u-icon :label="cList.name" labelPos="left" size="16" name="arrow-down"></u-icon> -->
 					</view>
 				</view>
 				<u-col span="3">
@@ -99,7 +100,6 @@
 		methods: {
 			// 加购
 			goCart(e) {
-				console.log('================', e)
 				this.cardMsg = e
 				this.$nextTick(() => {
 					this.$refs.specPopup.open();
@@ -199,7 +199,6 @@
 				const res = await this.$request('get', `/front/shoppingCart/list`, {
 					storeId: this.cList.id
 				})
-				console.log('res.data==============', res.data)
 				if (res) {
 					const carList = res.data
 					this.buyCount = carList.length

+ 2 - 1
pages/index/index.vue

@@ -20,10 +20,11 @@
 				},{
 					img:'../../static/banner2.png'
 				}],
+				dinnerId:''
 			}
 		},
 		onLoad() {
-
+			this.dinnerId = uni.getStorageSync('dinnerId');
 		},
 		methods: {
 			searchClick(){

+ 32 - 125
pages/login/login.vue

@@ -1,118 +1,3 @@
-<!-- <template>
-	<view>
-		<image :src="src" class="img"></image>
-		<view class="btn">
-			<view style="width: 80%;">
-				<u-button v-if="canIUseGetUserProfile" shape="circle" color="linear-gradient(to right, #F54319, #FF6D20)"
-					@click="getUserProfile">选择餐车</u-button>
-			</view>
-		</view>
-	</view>
-</template>
-
-<script>
-	export default {
-		name: 'MyLogin',
-		data() {
-			return {
-				infoData: {},
-				src: '../../static/first.png',
-				userInfo: {},
-				hasUserInfo: false,
-				canIUseGetUserProfile: wx.getUserProfile ? true : false,
-			}
-		},
-		methods: {
-			getUserProfile() {
-				wx.login({
-					success: async (e) => {
-						console.log('数据:', e)
-						try {
-							const result = await this.$request('post', '/auth/miniLogin', {
-								tenantId: '000000',
-								clientId: '8871d05eacc4406083d3bb0a085b6999',
-								code: e.code
-							})
-							console.log('登录成功:', result);
-							if (result && result.result !== false) {
-								var token = result.data.accessToken;
-								var haveOpenid = result.data.openId;
-								var tenantId = result.data.tenantId
-								uni.setStorageSync("token", token);
-								wx.getUserProfile({
-									desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
-									success: (res) => {
-										this.setData({
-											userInfo: res.userInfo,
-											hasUserInfo: true
-										})
-									}
-								})
-								console.log('userInfo', this.userInfo)
-								uni.navigateTo({
-									url: `/pages/diningList/diningList`
-								});
-							} else {
-								// 处理错误情况
-							}
-						} catch (error) {
-							// 处理请求失败的情况
-							console.error('登录失败:', error);
-						}
-					}
-				})
-
-				// let that = this;
-				// wx.login({
-				// 	success: function(e) {
-				// 		console.log('数据:', e)
-
-				// 		uni.request({
-				// 			url: 'http://36.137.224.81:8030/auth/miniLogin?tenantId=000000&code=' + e
-				// 				.code,
-				// 			header: {
-				// 				"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", //
-				// 				// "Content-Type": "application/json;charset=UTF-8", //
-				// 			},
-				// 			method: 'post',
-				// 			success: res => {
-				// 				console.log('登录成功:', res)
-				// 				uni.hideLoading()
-				// 				var token = res.data.data.accessToken;
-				// 				console.log('token:', token)
-				// 				uni.setStorageSync("token", token);
-				// 				uni.navigateTo({
-				// 					url: `/pages/classify/classify`
-				// 				})
-				// 				// if (res.data.code == 200) {
-				// 				// 	that.infoData = res.data.data
-				// 				// }
-				// 			},
-				// 			fail: err => {
-				// 				uni.hideLoading()
-				// 			}
-				// 		})
-				// 	}
-				// })
-
-			}
-		}
-	}
-</script>
-
-<style lang="scss" scoped>
-	.img {
-		height: 375px;
-		width: 100%;
-	}
-
-	.btn {
-		display: flex;
-		justify-content: center;
-		align-items: center;
-		margin-top: 20px;
-	}
-</style> -->
 <template>
 	<view>
 		<image :src="src" class="img"></image>
@@ -135,11 +20,33 @@
 				canIUseGetUserProfile: false,
 			}
 		},
-		onLoad() {
+		onLoad(e) {
 			// 检查微信版本是否支持 getUserProfile
 			if (wx.getUserProfile) {
 				this.canIUseGetUserProfile = true;
 			}
+			uni.setStorageSync('dinnerId', '1806258588536201217')
+			if(e.id){
+				uni.setStorageSync('dinnerId', e.id)
+			}
+			
+			let infoData = uni.getStorageSync('infoData');
+			if(infoData){
+				try{
+					infoData = JSON.parse(infoData)
+					// console.log('用户数据',infoData)
+					if (infoData.expire_in && Date.now() / 1000 - infoData.time > infoData.expire_in) {
+					  uni.removeStorageSync('infoData')
+					  return null
+					}
+					
+					if(infoData && infoData.access_token){
+						uni.switchTab({
+							url:'/pages/home/home'
+						})
+					}
+				}catch(e){}
+			}
 		},
 		methods: {
 			getUserProfile() {
@@ -158,13 +65,8 @@
 								// 发送code到开发者服务器换取用户信息
 								const result = await this.$request('post', '/auth/miniLogin', {
 									tenantId: '000000',
-									// clientId: 'e5cd7e4891bf95d1d19206ce24a7b32e',
 									code: loginRes.code
 								})
-								// headers: {
-								// 	isToken: false,
-								// 	repeatSubmit: false
-								// },
 									console.log('登录成功:', result);
 								if (result && result.data !== false) {
 									// 保存token
@@ -172,17 +74,22 @@
 									uni.setStorageSync("openId", result.data.open_id);
 									//uni.setStorageSync("tenantId", result.data.tenantId);
 									uni.setStorageSync("appUserId", result.data.app_user_id);
+									
+									let d = result.data;
+									d.time = Date.now() / 1000;
+									uni.setStorageSync('infoData', JSON.stringify(d))
+									
 									// 跳转到下一个页面
-									uni.navigateTo({
-										url: `/pages/diningList/diningList`
-									});
+									uni.switchTab({
+										url:'/pages/home/home'
+									})
 								} else {
 									// 处理错误情况
 								}
 								// 更新用户信息
 								const id = uni.getStorageSync('appUserId');
 								console.log('id', id)
-
+								uni.setStorageSync("userName", res.userInfo.nickName);
 								const userInfo = {
 									"userId": id,
 									"nickName": res.userInfo.nickName,

+ 1 - 1
pages/login/qrCode.vue

@@ -15,7 +15,7 @@ export default {
   methods: {
     async createQRCode() {
       // 生成二维码
-      const qrcode = await this.generateQRCode('pages/classify/classify');
+      const qrcode = await this.generateQRCode('pages/home/home');
       this.qrCodeImage = qrcode;
     },
     async generateQRCode(sceneStr) {

+ 68 - 20
pages/order/myOrder/myOrder.vue

@@ -17,42 +17,53 @@
 				<!-- 滚动区 -->
 				<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>
+					<view v-if="!tabItem.loaded && (!tabItem.orderList || tabItem.orderList.length === 0)"
+						class="emptys">
+						<u-empty text="订单是空的~"
+							v-if="!tabItem.loaded && (!tabItem.orderList || tabItem.orderList.length === 0)"
+							mode="order">
+						</u-empty>
+					</view>
 					<!-- 订单列表区 -->
 					<view class="margin-bottom-sm" :class="index === 0 ? 'padding-top-sm' : ''"
 						v-for="(item, index) in tabItem.orderList" :key="index">
 						<!-- 订单项 -->
 						<view class="order-item padding bg-main border-radius">
-							<view @click="todetail(item.order)">
+							<view @click="todetail(item)">
 								<view class="dflex-b padding-bottom-sm">
-									<view class="fs fwb dflex">
-										<u-tag text="打包" size="mini" bgColor="#FFF4E4" color="#F5821F" shape="circle"
+									<view class="fs-xs fwb dflex">
+										<u-tag :text="item.pickupInfo.pickupType ? '堂食' : '打包'" size="mini"
+											bgColor="#FFF4E4" color="#F5821F" shape="circle"
 											borderColor="#FFF4E4"></u-tag>
-										订单编号:M000003332
+										订单编号:{{ item.orderId }}
 									</view>
-									<text class="fs active">等待付款</text>
+									<text class="fs-xs active">
+										<text v-if="item.orderState == '1'">待付款</text>
+										<text v-else-if="item.orderState == '6'">已完成</text>
+									</text>
 								</view>
 								<!-- 订单商品明细 -->
 								<view class="goods-area dflex-b">
 									<view class="pic-list dflex">
-										<view class="pic"></view>
-										<view class="pic"></view>
-										<view class="pic"></view>
+										<view v-for="(i, gindex) in item.orderItemVoList" :key="gindex"
+											class="margin-right-sm">
+											<image v-if="i.picUrl" mode="aspectFit" class="wh-full" :src="i.picUrl">
+											</image>
+											<view v-else class="pic"></view>
+										</view>
 									</view>
 									<view class="next-detail">
-										<text>共3件</text>
+										<text v-if="item.orderItemVoList">共{{item.orderItemVoList.length}}件</text>
 										<u-icon name="arrow-right" size="20"></u-icon>
 									</view>
-
 								</view>
 
 								<!-- 实付款 -->
 								<view class="dflex-e padding-top-sm">
-									<text class="fs-xs margin-right-xs">共3件</text>
-									<text class="fs-xs margin-right-xs">共6份商品</text>
+									<text class="fs-xs margin-right-xs"
+										v-if="item.orderItemVoList">共{{item.orderItemVoList.length}}份商品</text>
 									<text class="fs-xs margin-right-xs">实付</text>
-									<text class="price ft-main">{{ item.order.order_actural_paid}}</text>
+									<text class="price ft-main">{{ item.payAmount}}</text>
 								</view>
 							</view>
 
@@ -64,9 +75,12 @@
 
 								<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="todetail">订单详情</button>
-										<button class="action-btn border-radius-big bg-main main-btn">去支付</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"
+											@click="todetail(item)">去支付</button>
 									</view>
 								</view>
 							</view>
@@ -79,7 +93,7 @@
 				</scroll-view>
 			</swiper-item>
 		</swiper>
-
+		<u-toast ref="uToast"></u-toast>
 	</view>
 </template>
 
@@ -159,8 +173,25 @@
 		},
 		onLoad(e) {
 			this.tabCurrentIndex = parseFloat(e.type);
+			this.fatchDate()
 		},
 		methods: {
+			async fatchDate() {
+				const e = uni.getStorageSync('carl')
+				const params = {
+					storeId: e.id
+				}
+				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.orderState == '1')
+					this.navList[2].orderList = result.rows.filter(item => item.orderState == '3')
+					this.navList[3].orderList = result.rows.filter(item => item.orderState == '8')
+					this.navList[4].orderList = result.rows.filter(item => item.orderState == '6')
+				}
+			},
 			loadData() {},
 			// swiper 切换
 			changeTab(e) {
@@ -173,16 +204,25 @@
 
 			// 点击跳转详情页面
 			todetail(order) {
+				console.log('order', order)
 				// uni.navigateTo({
 				// 	url: `/pages/user/order/order-detail?order_id=${order.order_id}`
 				// });
 				uni.navigateTo({
-					url: `/pages/order/orderPaid/orderPaid`
+					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) {
@@ -247,6 +287,14 @@
 		background: $page-color-base;
 	}
 
+	.emptys {
+		display: flex;
+		flex-direction: column;
+		align-items: center;
+		justify-content: center;
+		height: 100%;
+	}
+
 	/* 订单状态区 */
 	.navbar-area {
 		white-space: nowrap;

+ 191 - 20
pages/order/orderPaid/orderPaid.vue

@@ -6,7 +6,7 @@
 				<view class="state-info">待支付 </view>
 				<view class="order-code">剩余 09:59 逾期未支付将自动取消</view>
 			</view>
-			<uni-icons type="right" size="24" color="#FFF"></uni-icons>
+			<!-- <uni-icons type="right" size="24" color="#FFF"></uni-icons> -->
 		</view>
 		<view class="gap"></view>
 		<view class="padding-sm dflex-b bg-main" @click="show = true">
@@ -15,7 +15,8 @@
 					取餐时间
 				</view>
 			</view>
-			<u-icon slot="icon" size="20" name="arrow-right" label="04:00" 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,7 +26,9 @@
 				</view>
 			</view>
 			<view>
-				<radio style="transform: scale(0.85)" value="r1" :checked="true" color="#ff0000" class="radio">店内用餐
+				<!-- 字段返回数据有问题 -->
+				<radio style="transform: scale(0.85)" value="r1" :checked="true" color="#ff0000" class="radio">
+					{{goods.pickupType.pickupType == '0' ? '打包带走' : '店内用餐'}}
 				</radio>
 			</view>
 		</view>
@@ -34,29 +37,39 @@
 		<view class="goods-order-list padding-lr-sm">
 			<view class="shop dflex-b ">
 				<view class="shop-check">
-					<text class="send-label">店铺名称</text>
+					<text class="send-label">{{goods.storeName}}</text>
 				</view>
-				<view class="total-goods">共计2件商品</view>
+				<view class="total-goods">共计{{lists}}件商品</view>
 			</view>
-			<view class="goods-cart">
+			<view class="goods-cart w-full">
+				<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>
+				</view>
+			</view>
+			<!-- <view class="goods-cart" v-for="(item, index)  in goods.itemList" :key="index">
 				<view class="goods-cont dflex-b padding-tb-16">
 					<view class="goods-cart-info dflex-b">
-						<view class="pic"></view>
-						<view class="goods-cart-right">
-							<view class="cart-title">商品名称商品名称</view>
+						 <view class="pic"></view>
+						<my-goods :item="item">
+							<view class="good-num">×{{item.quantity}}</view>
+						</my-goods>
+						 <view class="goods-cart-right">
+							<view class="cart-title">{{item.skuName}}</view>
 							<view class="order-spec">
 								<text>500g</text>
 							</view>
 							<view class="cart-row-info dflex-s">
 								<view class="cart-price">
-									¥<text>12.30</text>
+									¥<text>{{item.price}}</text>
 								</view>
-								<view class="goods-num">×1</view>
+								<view class="goods-num">×{{item.quantity}}</view>
 							</view>
-						</view>
+						</view> 
 					</view>
 				</view>
-				<view class="goods-cont dflex-b padding-tb-16">
+				 <view class="goods-cont dflex-b padding-tb-16">
 					<view class="goods-cart-info dflex-b">
 						<view class="pic"></view>
 						<view class="goods-cart-right">
@@ -72,23 +85,24 @@
 							</view>
 						</view>
 					</view>
-				</view>
-			</view>
+				</view> 
+			</view> -->
 		</view>
 		<view class="gap"></view>
 		<!-- 金额明细 -->
 		<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>46.32</view>
+				<view class="price">{{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-buy dflex-c background-gradient">去支付</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>
 
@@ -96,11 +110,158 @@
 	export default {
 		data() {
 			return {
-
+				goods: {},
+				lists: 0
 			}
 		},
+		onLoad(e) {
+			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) {
+				console.log('e', e)
+				const result = await this.$request('get', `/order/tradeOrder/queryTradeOrder/${e.id}`,
+					true)
+				if (result) {
+					console.log('result', result.data)
+					this.goods = result.data
+					this.lists = this.goods.itemList.length
+					this.goods.itemList.forEach(item => {
+						item.imgUrl = item.picUrl
+					})
+					console.log('this.goods', this.goods)
+					console.log('this.goods.itemList', this.goods.itemList)
+				}
+			},
+			uuid() {
+				return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+					var r = Math.random() * 16 | 0,
+						v = c == 'x' ? r : (r & 0x3 | 0x8);
+					return v.toString(16);
+				});
+			},
+			toDelete() {
+				this.$refs.uToast.show({
+					type: 'default',
+					title: '默认主题',
+					message: "演示阶段暂时不能取消",
+					position: 'center'
+				})
+			},
+			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())
+				const openId = uni.getStorageSync('openId');
+				const token = uni.getStorageSync('token');
+				if (!token) {
+					await this.autoLogin()
+				}
+				const that = this;
+				uni.request({
+					url: 'http://36.137.224.81:8030/weChatPay/payment/miniPay',
+					header: {
+						// "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", //
+						"Content-Type": "application/json;charset=UTF-8", //
+						'Authorization': 'Bearer ' + token,
+					},
+					method: 'post',
+					data: {
+						tenantId: '000000',
+						outTradeNo: this.uuid(),
+						openId: openId,
+						total: Math.round(this.goods.payment * 10), //以分为单位
+						profitSharing: false // 是否分销
+					},
 
+					success: res => {
+						console.log('预支付成功')
+						that.data = res.data;
+						wx.requestPayment({
+							"timeStamp": res.data.timeStamp,
+							"nonceStr": res.data.nonceStr,
+							"package": res.data.packageValue,
+							"signType": "RSA",
+							"paySign": res.data.paySign,
+							"success": function(res) {
+								console.log('调用支付接口成功', res)
+							},
+							"fail": function(res) {
+								console.log('调用支付接口fail', res)
+							},
+							"complete": function(res) {
+								console.log('调用支付接口完成', res)
+							}
+						})
+					},
+					fail: err => {
+						uni.hideLoading()
+					}
+				})
+				// const params = {
+				// 	tenantId: '000000',
+				// 	outTradeNo: this.uuid(),
+				// 	openId: openId,
+				// 	total: Math.round(this.goods.payment * 10),	//以分为单位
+				// 	profitSharing: false // 是否分销
+				// }
+				// console.log('params', params)
+				// this.$request('post', `/weChatPay/payment/miniPay`, params, true).then(res => {
+				// 	// 请求成功
+				// 	console.log('response', res)
+				// 	console.log('预支付成功')
+				// 	that.data = res.data;
+				// 	wx.requestPayment({
+				// 		"timeStamp": res.data.timeStamp,
+				// 		"nonceStr": res.data.nonceStr,
+				// 		"package": res.data.packageValue,
+				// 		"signType": "RSA",
+				// 		"paySign": res.data.paySign,
+				// 		"success": function(res) {
+				// 			console.log('调用支付接口成功', res)
+				// 		},
+				// 		"fail": function(res) {
+				// 			console.log('调用支付接口fail', res)
+				// 		},
+				// 		"complete": function(res) {
+				// 			console.log('调用支付接口完成', res)
+				// 		}
+				// 	})
+				// }).catch(error => {
+				// 	// 请求失败
+				// 	uni.hideLoading()
+				// 	console.error('请求失败:', error);
+				// })
+			}
 		}
 	}
 </script>
@@ -112,7 +273,7 @@
 		color: #FFF;
 
 		.state-info {
-			font-size: 14px;
+			font-size: 18px;
 			padding-bottom: 4px;
 		}
 
@@ -269,4 +430,14 @@
 			font-size: 14px;
 		}
 	}
+
+	.good-num {
+		font-size: 12px;
+		padding-top: 65rpx;
+	}
+
+	.goods-cont {
+		width: 100%;
+		box-sizing: border-box;
+	}
 </style>

+ 151 - 21
pages/order/submitOrder/submitOrder.vue

@@ -30,10 +30,12 @@
 				</view>
 			</view>
 			<view>
-				<radio style="margin: 0 10px; transform: scale(0.85)" value="r1" :checked="true" color="#ff0000" class="radio">店内用餐
+				<uni-data-checkbox v-model="val" :localdata="list" @change="radioChange"
+					selectedColor="#F54319"></uni-data-checkbox>
+				<!-- <radio style="margin: 0 10px; transform: scale(0.85)" value="r1" :checked="typePicking" color="#ff0000" class="radio">店内用餐
 				</radio >
-				<radio style="transform: scale(0.85)" value="r1" :checked="true" color="#ff0000" class="radio">打包带走
-				</radio>
+				<radio style="transform: scale(0.85)" value="r1" :checked="typePickings" color="#ff0000" class="radio">打包带走
+				</radio> -->
 			</view>
 			<!-- <view class="iconfont iconjiantou-01 fs-sm"></view> -->
 		</view>
@@ -41,23 +43,24 @@
 		<view class="goods-order-list w-full padding-lr-sm">
 			<view class="shop dflex-b ">
 				<view class="shop-check">
-					<text class="shop-name">xxx学校xx年级xx班级</text>
+					<text class="shop-name">{{cList.name}}</text>
 				</view>
 			</view>
 			<view class="goods-cart w-full">
-				<view class="goods-cont padding-tb" v-for="index in 1" :key="index">
-					<my-goods :data="data">
-						<view class="good-num">×1</view>
+				<view class="goods-cont padding-tb" v-for="(item, index) in data.carlist" :key="index">
+					<my-goods :item="item">
+						<view class="good-num">×{{item.quantity}}</view>
 					</my-goods>
 				</view>
 
 			</view>
 		</view>
 		<!-- 金额明细 -->
+		<view class="gap"></view>
 		<view class="bg-main">
 			<view class="dflex-b padding-lr padding-tb-sm">
 				<view class="flex1">总金额</view>
-				<view class=""><text style="font-size: 24rpx;">¥</text>46.32</view>
+				<view class="price">{{data.total}}</view>
 			</view>
 			<!-- <view class="dflex-b padding-lr padding-tb-sm">
 				<view class="flex1">运费 (总重:4.960 kg )</view>
@@ -71,7 +74,7 @@
 			</view> -->
 		</view>
 		<view class="gap"></view>
-		<my-gap :height="130" />
+		<!-- <my-gap :height="130" /> -->
 		<view class="submit-bar padding-sm dflex-b">
 			<view class="submit-btn dflex-c background-gradient" @click="toBuy">立即下单</view>
 		</view>
@@ -79,22 +82,50 @@
 </template>
 
 <script>
+	import {
+		multiply
+	} from '@/utils/accuracy.js'
 	export default {
 		data() {
 			return {
-				data: {
-					src: '../../static/x0.jpg',
-					title: '标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题',
-					spec: '180cm',
-					price: '53.30'
-				},
+				data: [],
 				show: false,
 				value: '',
+				cList: {},
+				val: null,
+				vals: null,
+				list: [{
+						text: "店内用餐",
+						value: 0
+					},
+					{
+						text: "打包带走",
+						value: 1
+					}
+				]
+			}
+		},
+		onLoad(option) {
+			const e = uni.getStorageSync('carl')
+			this.cList = e
+			console.log('233333333333333', e)
+			// 解码 URL 编码的字符串
+			var dataString = decodeURIComponent(option.data);
+			// 尝试将字符串转换为 JSON 对象
+			var data = JSON.parse(dataString);
+			if(data.carlist[0].imgUrl.url) {
+				data.carlist[0].imgUrl = data.carlist[0].imgUrl.url;
 			}
+			
+			this.data = data
+			// 打印解码后的数据
+			console.log('eeeeeeeeeeeee============data', data);
 		},
 		methods: {
-			sendTypeChange(v) {
-				console.log(v)
+			sendTypeChange(v) {},
+			radioChange(v) {
+				console.log('2=================', v)
+				console.log('2=================22222', this.val)
 			},
 			onConfirm(v) {
 				console.log('vvvvvvvvvvvvvvv', v)
@@ -105,8 +136,106 @@
 				this.show = false
 			},
 			toBuy() {
-				uni.navigateTo({
-					url: `/pages/order/orderPaid/orderPaid`
+				console.log('this.val', this.val)
+				if (this.value == '') {
+					uni.showToast({
+						title: '请选择取餐时间',
+						icon: 'error',
+						duration: 1000
+					})
+					return
+				}
+				if (this.val == null && this.val == undefined && this.val == '') {
+					uni.showToast({
+						title: '请选择取餐方式',
+						icon: 'error',
+						duration: 1000
+					})
+					return
+				}
+				const userId = uni.getStorageSync('appUserId');
+				const userName = uni.getStorageSync('userName');
+				const itemListArray = this.data.carlist.map(item => ({
+					skuId: item.skuId,
+					gift: 1, // 假设所有商品都不是礼物
+					basePrice: Number(item.basePrice),
+					price: Number(item.price),
+					quantity: item.quantity,
+					sellerType: 'C', // 假设所有商品卖家类型都是 'C'
+					spuId: item.spuId,
+					skuName: item.skuName,
+					title: item.skuTitle,
+					picUrl: item.imgUrl,
+					skuProperties: item.skuProperties,
+					totalFee: multiply(Number(item.price), item.quantity),
+					adjustFee: 0
+				}))
+
+				const params = {
+					orderState: 1,
+					orderType: 1,
+					serviceType: 1,
+					payAmount: Number(this.data.total),
+					totalAmount: Number(this.data.total),
+					discountAmount: 0,
+					adjustAmount: 0,
+					postAmount: 0,
+					receivedAmount: Number(this.data.total),
+					commissionAmount: 0,
+					payOnDeliveryAmount: 0,
+					payOnDelivery: 1,
+					payType: 1,
+					payChannel: 1,
+					invoice: 1,
+					storeId: this.cList.id,
+					storeName: this.cList.name,
+					sellerNick: this.cList.name,
+					buyerNick: userName,
+					customerId: userId,
+					orderItemList: itemListArray,
+					shippingType: 4,
+					orderPickup: {
+						pickupType: this.val,
+						verify: 2,
+						// writeOffTime: this.value
+					}
+				}
+				console.log('params', params);
+				// uni.navigateTo({
+				// 	url: `/pages/order/orderPaid/orderPaid`
+				// })
+				this.$request('post', `/order/tradeOrder/addTradeOrder`, params, true).then(response => {
+					// 请求成功
+					console.log('response', response)
+					if (response.code == 200) {
+						const ids = this.data.carlist.map(car => car.id);
+						this.$request('delete', `/front/shoppingCart/${ids}`)
+						console.log('response.data', response.data)
+						uni.$emit('register_refresh');
+						uni.showToast({
+							title: '已下单,因目前是演示阶段,暂时不能付款',
+							icon: 'success',
+							duration: 2000,
+							complete: () => {
+								// 页面跳转放在complete回调中
+								uni.navigateTo({
+									url: `/pages/order/myOrder/myOrder?type=0`
+								})
+							}
+						})
+						// uni.navigateTo({
+						// 	url: `/pages/order/orderPaid/orderPaid?id=${response.data}`
+						// })
+					} else if (response.code == 500) {
+						uni.showToast({
+							title: response.msg,
+							icon: 'error',
+							duration: 2000
+						});
+					}
+				}).catch(error => {
+					// 请求失败
+					console.error('请求失败:', error);
 				})
 			}
 		}
@@ -171,9 +300,10 @@
 
 	.good-num {
 		font-size: 12px;
-		padding-top: 40rpx;
+		padding-top: 65rpx;
 	}
-	.send-label{
+
+	.send-label {
 		font-size: 14px;
 		font-weight: 700;
 	}

+ 48 - 7
pages/user/myInfo.vue

@@ -3,13 +3,14 @@
 		<view style="margin: 20px; background-color: #fff;">
 			<!-- 注意,如果需要兼容微信小程序,最好通过setRules方法设置rules规则 -->
 			<u--form labelPosition="left" :model="userInfo" :rules="rules" ref="uForm">
-				<u-form-item label="姓名" prop="userInfo.name">
-					<u--input v-model="userInfo.name" border="none"></u--input>
+				<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.avg">
+				<u-form-item label="头像" prop="iAvg">
 					<view slot="right" class="flex-row" @click="onInfo">
-						<u-avatar :src="getFilePath(userInfo.avg ? userInfo.avg : 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: [{
@@ -67,7 +71,44 @@
 
 			}
 		},
+		onLoad() {
+			this.fatchDate()
+		},
 		methods: {
+			fatchDate() {
+				wx.getUserInfo({
+				    success: (res)=>{
+				        console.log(res)
+						this.userInfo = res.userInfo
+						console.log(res.userInfo)
+				    }
+				})
+				// const result = await this.$request('post',
+				// 	'/auth/getUserInfo', true)
+				
+				// wx.getUserProfile({
+				// 	desc: '获取用户信息',
+				// 	success: (res) => {
+				// 		console.log('res', res)
+				// 	},
+				// })
+			},
+			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) => {

+ 54 - 15
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="getFilePath(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.phone ? userdata.phone : '22222'}}</view>
+							<view class="fz16px mt5px">{{userdata && userdata.nickName ? userdata.nickName : '22222'}}
+							</view>
 						</view>
 					</view>
 				</view>
@@ -34,16 +36,18 @@
 						</u-row>
 						<view class="flex-box mt20px">
 							<view class="flex-box-item" @click="openPage('/pages/order/myOrder/myOrder?type=1')">
-								<u-icon name="rmb-circle" labelColor="#96989e" labelPos="bottom" labelSize="14px"
-									label="待付款" size="40"></u-icon>
+								<uni-badge size="normal" :text="txts" absolute="rightTop">
+									<u-icon name="rmb-circle" labelColor="#96989e" labelPos="bottom" labelSize="14px"
+										label="待付款" size="40"></u-icon>
+								</uni-badge>
 							</view>
 							<view class="flex-box-item" @click="openPage('/pages/order/myOrder/myOrder?type=2')">
 								<u-icon name="clock" labelColor="#96989e" label="待核销" labelSize="14px" labelPos="bottom"
 									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 +64,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,19 +84,29 @@
 </template>
 
 <script>
+	import iAvg from '../../static/avg.png'
 	export default {
 		data() {
 			return {
-				userdata:{
-					avatarUrl:'',
-					phone:''
+				userdata: {
+					avg: '../../static/avg.png',
+					phone: '',
+					nickName: ''
 				},
-				cPhone: ''
+				src: iAvg,
+				cPhone: '',
+				cList: {},
+				txts: 0
 			}
 		},
 		onLoad() {
 			const e = uni.getStorageSync('info')
 			this.cPhone = e
+			this.fatchDate()
+			this.tables()
+
+			const q = uni.getStorageSync('carl')
+			this.cList = q
 		},
 		methods: {
 			openPage(path) {
@@ -100,6 +114,30 @@
 					url: path
 				})
 			},
+			
+			fatchDate() {
+				wx.getUserInfo({
+					success: (res) => {
+						console.log(res)
+						this.userdata = res.userInfo
+						console.log(res.userInfo)
+					}
+				})
+			},
+			async tables() {
+				const q = uni.getStorageSync('carl')
+				const params = {
+					storeId: q.id
+				}
+				const res = await this.$request('get', '/order/tradeOrder/queryTradeOrder', params)
+				if (res) {
+					console.log('result11111111111111111', res.rows)
+					const l = res.rows.filter(item => item.orderState == '1')
+					console.log('==========', l)
+					this.txts = l.length
+					// 目前仅弄了待付款的
+				}
+			},
 			call() {
 				console.log('eeeeeeeeeeeeeeee===============', this.cPhone)
 				if (this.cPhone.customerPhone) {
@@ -188,6 +226,7 @@
 			}
 		}
 	}
+
 	.pageBg {
 		background-color: #EFF2F7
 	}

BIN
static/avg.png


BIN
static/banner1.jpg


BIN
static/banner2.png


BIN
static/dangq.png


BIN
static/nice.jpg


BIN
static/service.png


BIN
static/shoppingCart.png


BIN
static/x0.jpg


BIN
static/x1.jpg


+ 2 - 2
style/common.scss

@@ -31,7 +31,7 @@ view[class*='-round-area']{ border-radius: 20rpx; }
 /**
  * 组件公共样式
  **/
-.price{font-size: 36rpx; color: #ff6a6c; line-height: 1; font-weight: 580;}.m-price{font-size: 24rpx;text-decoration: line-through;color: #909399;margin-left: 20rpx;}
+.price{font-size: 36rpx; color: #FF0000; line-height: 1; font-weight: 580;}.m-price{font-size: 24rpx;text-decoration: line-through;color: #909399;margin-left: 20rpx;}
 .price::before{ content: '¥'; font-size: 24rpx; } .m-price::before{ content: '¥'; font-size: 24rpx; }
 .price::after{ content: attr(data-decimal); font-size: 24rpx; }
 .price-add::before { content: '+'; font-weight: 600; }
@@ -127,7 +127,7 @@ view[class*='border-radius']{ overflow: hidden;}
 /* 外边距 */
 .margin-0{margin: 0;}.margin-xs{margin: 10rpx;}.margin-sm{margin: 20rpx;}.margin{margin: 30rpx;}.margin-lg{margin: 40rpx;}.margin-xl{margin: 50rpx;}.margin-big{margin: 100rpx;}
 .margin-top-xs{margin-top: 10rpx;}.margin-top-sm{margin-top: 20rpx;}.margin-top{margin-top: 30rpx;}.margin-top-lg{margin-top: 40rpx;}.margin-top-xl{margin-top: 50rpx;}.margin-top-big{margin-top: 100rpx;}
-.margin-right-xs{margin-right: 10rpx;}.margin-right-sm{margin-right: 20rpx;}.margin-right{margin-right: 30rpx;}.margin-right-lg{margin-right: 40rpx;}.margin-right-xl{margin-right: 50rpx;}
+.margin-right-xs{margin-right: 10rpx;}.margin-right-sm{margin-right: 16rpx;}.margin-right{margin-right: 30rpx;}.margin-right-lg{margin-right: 40rpx;}.margin-right-xl{margin-right: 50rpx;}
 .margin-bottom-xs{margin-bottom: 10rpx;}.margin-bottom-sm{margin-bottom: 20rpx;}.margin-bottom{margin-bottom: 30rpx;}.margin-bottom-lg{margin-bottom: 40rpx;}.margin-bottom-xl{margin-bottom: 50rpx;} .margin-bottom-big {margin-bottom: 100rpx;}
 .margin-left-xs{margin-left: 10rpx;}.margin-left-sm{margin-left: 20rpx;}.margin-left{margin-left: 30rpx;}.margin-left-lg{margin-left: 40rpx;}.margin-left-xl{margin-left: 50rpx;}
 

+ 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
+//   }
+// }()
+
+