Преглед изворни кода

Merge branch 'master' of http://git.cc-lotus.info/pointToNetwork/point-app

guhongwei пре 2 година
родитељ
комит
cd849755ce
2 измењених фајлова са 76 додато и 30 уклоњено
  1. 28 13
      pagesHome/order/detail.vue
  2. 48 17
      pagesHome/order/order.vue

+ 28 - 13
pagesHome/order/detail.vue

@@ -309,17 +309,17 @@
 					success: async function(res) {
 						let user = that.$jwt(res.data);
 						if (that.Selected) {
+							let specs_id;
+							let specs = that.specs.find(i => i.name == that.Selected)
+							if (specs) specs_id = specs._id
+							let data = {
+								customer: user._id,
+								shop: that.shop._id,
+								goods: that.info._id,
+								goodsSpec: specs_id,
+								num: that.num
+							}
 							if (e == '0') {
-								let specs_id;
-								let specs = that.specs.find(i => i.name == that.Selected)
-								if (specs) specs_id = specs._id
-								let data = {
-									customer: user._id,
-									shop: that.shop._id,
-									goods: that.info._id,
-									goodsSpec: specs_id,
-									num: that.num
-								}
 								let arr = await that.$api(`/cart`, 'POST', data)
 								if (arr.errcode == '0') {
 									uni.showToast({
@@ -334,9 +334,24 @@
 									})
 								}
 							} else {
-								uni.navigateTo({
-									url: `/pagesHome/order/order?id=${e._id}`
-								})
+								let arr = await that.$api(`/util/checkCanBuy`, 'POST', data)
+								if (arr.errcode == '0') {
+									if (arr.data.result == true) {
+										uni.navigateTo({
+											url: `/pagesHome/order/order?key=${arr.data.key}`
+										})
+									} else {
+										uni.showToast({
+											title: arr.data.msg,
+											icon: 'none'
+										})
+									}
+								} else {
+									uni.showToast({
+										title: arr.errmsg,
+										icon: 'none'
+									})
+								}
 							}
 						} else {
 							uni.showModal({

+ 48 - 17
pagesHome/order/order.vue

@@ -19,29 +19,29 @@
 							<text @click="toChoose" class="iconfont icon-jiantouyou"></text>
 						</view>
 						<view class="one_2">
-							<view class="list">
+							<view class="list" v-for="(item,index) in orderList" :key="index">
 								<view class="list_1">
 									<view class="l">
 										<text class="iconfont icon-shangdian"></text>
-										<text>{{shop.shop}}</text>
+										<text>{{item.shop}}</text>
 									</view>
 								</view>
 								<view class="list_2">
 									<view class="l">
-										<image class="image" :src="shop.url&&shop.url.length>0?shop.url[0].url:''"
+										<image class="image" :src="item.url&&item.url.length>0?item.url[0].url:''"
 											mode=""></image>
 									</view>
 									<view class="c">
 										<view class="name">
-											{{shop.name}}
+											{{item.name}}
 										</view>
 									</view>
 									<view class="r">
 										<view class="price">
-											¥{{shop.price}}
+											¥{{item.price}}
 										</view>
 										<view class="num">
-											×{{shop.buy_num}}
+											×{{item.buy_num}}
 										</view>
 									</view>
 								</view>
@@ -54,7 +54,8 @@
 							</view>
 							<view class="other">
 								<view class="other_1">运费</view>
-								<view class="other_2">¥{{shop.freight}}</view>
+								<view class="other_2" v-if="!shop.freight==0">¥{{shop.freight}}</view>
+								<view class="other_2" v-else>包邮</view>
 							</view>
 							<view class="other">
 								<view class="other_1">订单备注</view>
@@ -92,9 +93,9 @@
 				</view>
 				<view class="two">
 					<view class="two_1">
-						<checkbox-group @change="toCheckbox(item)">
+						<checkbox-group @change="toCheckbox">
 							<label>
-								<checkbox style="transform:scale(0.7)" />选择地址
+								<checkbox :value="item._id" :checked="item.checked" style="transform:scale(0.7)" />选择地址
 							</label>
 						</checkbox-group>
 					</view>
@@ -113,9 +114,13 @@
 		data() {
 			return {
 				user: {},
-				id: {},
+				key: '',
 				info: {},
 				shop: {
+					money: 58,
+					freight: 7
+				},
+				orderList: [{
 					shop: '官方自营店',
 					status: '1',
 					url: [{
@@ -129,7 +134,21 @@
 					market_num: 1,
 					money: 58,
 					freight: 7
-				},
+				}, {
+					shop: '官方自营店',
+					status: '1',
+					url: [{
+						name: "20220928155634.jpg",
+						uri: "/files/point/20220928155634.jpg",
+						url: "https://broadcast.waityou24.cn/files/point/20220928155634.jpg"
+					}],
+					name: '饮用水',
+					price: 58,
+					buy_num: 1,
+					market_num: 1,
+					money: 58,
+					freight: 7
+				}],
 				// 收货地址
 				addressList: [],
 			};
@@ -140,7 +159,7 @@
 		},
 		onLoad: async function(e) {
 			const that = this;
-			that.$set(that, `id`, e.id || '');
+			that.$set(that, `key`, e.key || '');
 		},
 		methods: {
 			// 选择收货地址
@@ -151,7 +170,17 @@
 			// 是否选中
 			toCheckbox(e) {
 				const that = this;
-				that.$set(that, `info`, e);
+				var addressList = that.addressList;
+				var values = e.detail.value;
+				for (var i = 0, lenI = addressList.length; i < lenI; ++i) {
+					const item = addressList[i]
+					if (values.includes(item._id)) {
+						that.$set(item, 'checked', true)
+						that.$set(that, `info`, item);
+					} else {
+						that.$set(item, 'checked', false)
+					}
+				}
 				that.$refs.popup.close();
 			},
 			// 删除收货地址
@@ -267,15 +296,15 @@
 
 			.one_2 {
 				margin: 2vw 0 0 0;
-				background-color: var(--mainColor);
 
 				.list {
 					width: 96vw;
 					padding: 0 2vw;
+					margin: 2vw 0;
 
 					.list_1 {
-						margin: 0 0 1vw 0;
-						padding: 1vw 0;
+						padding: 2vw;
+						background-color: var(--mainColor);
 						border-bottom: 0.1vw solid var(--fcColor);
 
 						text {
@@ -284,8 +313,9 @@
 					}
 
 					.list_2 {
-						margin: 0 0 1vw 0;
+						padding: 2vw;
 						display: flex;
+						background-color: var(--mainColor);
 
 						.l {
 							width: 20vw;
@@ -388,6 +418,7 @@
 		display: flex;
 		flex-direction: column;
 		background-color: var(--f1Color);
+
 		.one {
 			display: flex;
 			justify-content: space-between;