zs %!s(int64=2) %!d(string=hai) anos
pai
achega
bd2706d115
Modificáronse 3 ficheiros con 171 adicións e 96 borrados
  1. 22 10
      pagesHome/order/detail.vue
  2. 15 83
      pagesHome/order/order.vue
  3. 134 3
      pagesMy/address/index.vue

+ 22 - 10
pagesHome/order/detail.vue

@@ -2,10 +2,12 @@
 	<mobile-frame>
 		<view class="main">
 			<view class="onemain">
-				<scroll-view scroll-y="true" class="scroll-view" scroll-with-animation :scroll-into-view="topItem" @scroll="handleScroll">
+				<scroll-view scroll-y="true" class="scroll-view" scroll-with-animation :scroll-into-view="topItem"
+					@scroll="handleScroll">
 					<view class="list-scroll-view" id="top">
 						<view class="one">
-							<swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff" indicator-active-color="#FB1438" :autoplay="true" :interval="3000" :duration="1000">
+							<swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff"
+								indicator-active-color="#FB1438" :autoplay="true" :interval="3000" :duration="1000">
 								<swiper-item class="list" v-for="(item,index) in bannerList" :key="index">
 									<image class="image" :src="item.url" mode="aspectFit">
 									</image>
@@ -72,7 +74,8 @@
 				</scroll-view>
 			</view>
 			<view class="foot">
-				<uni-goods-nav :options="options" :button-group="buttonGroup" @click="onClick" @buttonClick="buttonClick" />
+				<uni-goods-nav :options="options" :button-group="buttonGroup" @click="onClick"
+					@buttonClick="buttonClick" />
 			</view>
 		</view>
 		<view class="collect">
@@ -83,7 +86,8 @@
 			<text @click="toMenu" class="iconfont icon-gengduo"></text>
 		</view>
 		<view class="menu_1" v-if="menu">
-			<view class="title" v-for="(item,index) in barList" :key="index" @click="toPath(item)" v-if="item.is_use=='0'">
+			<view class="title" v-for="(item,index) in barList" :key="index" @click="toPath(item)"
+				v-if="item.is_use=='0'">
 				<image class="image" :src="item.normal&&item.normal.length>0?item.normal[0].url:''"></image>
 				<view class="name">{{item.name}}</view>
 			</view>
@@ -94,7 +98,8 @@
 		<uni-popup ref="popup" background-color="#fff" type="bottom">
 			<view class="content">
 				<view class="one">
-					<image class="image" v-if="specsInfo.file&&specsInfo.file.length>0" :src="specsInfo.file&&specsInfo.file.length>0?specsInfo.file[0].url:''"></image>
+					<image class="image" v-if="specsInfo.file&&specsInfo.file.length>0"
+						:src="specsInfo.file&&specsInfo.file.length>0?specsInfo.file[0].url:''"></image>
 					<image class="image" v-else :src="info.file&&info.file.length>0?info.file[0].url:''"></image>
 					<view class="other">
 						<view class="money">
@@ -112,14 +117,16 @@
 				<view class="two">
 					<view class="two_1">规格</view>
 					<view class="two_2">
-						<text v-for="(item,index) in specs" :key="index" @click="toStyle(item,index)" :class="{ 'style': isActive==index}">{{item.name}}
+						<text v-for="(item,index) in specs" :key="index" @click="toStyle(item,index)"
+							:class="{ 'style': isActive==index}">{{item.name}}
 						</text>
 					</view>
 				</view>
 				<view class="thr">
 					<text>数量</text>
 					<view class="count">
-						<uni-number-box :min="1" :max="specsInfo.num" :disabled="disabled" v-model="num" @change="toCount">
+						<uni-number-box :min="1" :max="specsInfo.num" :disabled="disabled" v-model="num"
+							@change="toCount">
 						</uni-number-box>
 					</view>
 					<text>库存{{specsInfo.num||0}}</text>
@@ -128,7 +135,8 @@
 					<text @click="toBuy(type)" :class="{ 'button': specsInfo._id&&specsInfo.can_group=='0'&&type=='1'}">
 						{{type=='0'?'加入购物车':'立即购买'}}
 					</text>
-					<text v-if="specsInfo._id&&specsInfo.can_group=='0'&&type=='1'" @click="toGroup" class="button2">参团</text>
+					<text v-if="specsInfo._id&&specsInfo.can_group=='0'&&type=='1'" @click="toGroup"
+						class="button2">参团</text>
 				</view>
 			</view>
 		</uni-popup>
@@ -448,11 +456,15 @@
 				});
 				if (res.errcode == '0') {
 					let data = res.data;
-					if (data.goods.brief) data.goods.brief = data.goods.brief.replace(/\<img/gi, '<img class="rich-img"');
+					if (data.goods.brief) data.goods.brief = data.goods.brief.replace(/\<img/gi,
+						'<img class="rich-img"');
 					that.$set(that, `info`, data.goods)
 					that.$set(that, `specs`, data.specs)
 					that.$set(that, `shop`, data.shop)
-					if (data.specs.length > 0) that.$set(that.specsInfo, `sell_money`, data.specs[0].sell_money)
+					if (data.specs.length > 0) {
+						that.$set(that, `specsInfo`, data.specs[0])
+						that.$set(that, `isActive`, 0)
+					}
 					that.$set(that, `bannerList`, data.goods.file)
 					let con = await that.$api(`/goodsRate`, `GET`, {
 						goods: data.goods._id

+ 15 - 83
pagesHome/order/order.vue

@@ -4,7 +4,7 @@
 			<view class="one">
 				<scroll-view scroll-y="true" class="scroll-view">
 					<view class="list-scroll-view">
-						<view class="one_1" @click="toChoose">
+						<view class="one_1" @tap="toChoose">
 							<text class="localicon iconfont icon-dingweixiao"></text>
 							<view class="other" v-if="address._id">
 								<view class="name">
@@ -93,39 +93,6 @@
 		</view>
 		<uni-popup ref="popup" background-color="#fff" type="bottom">
 			<view class="popup" v-if="popup.type=='1'">
-				<scroll-view scroll-y="true" class="scroll-view">
-					<view class="list" v-for="(item,index) in addressList" :key="index">
-						<view class="one">
-							<view class="one_1">
-								<view class="name">
-									<text>{{item.name}},</text>{{item.phone}}
-								</view>
-								<view class="address">
-									<text>{{item.province}}</text><text>{{item.city}}</text>
-									<text>{{item.area}}</text><text>{{item.address}}</text>
-								</view>
-							</view>
-							<text class="iconfont icon-jiantouyou"></text>
-						</view>
-						<view class="two">
-							<view class="two_1">
-								<checkbox-group @change="toCheckbox">
-									<label>
-										<checkbox :value="item._id" :checked="item.checked"
-											style="transform:scale(0.7)" />
-										选择地址
-									</label>
-								</checkbox-group>
-							</view>
-							<view class="two_2">
-								<text class="text" v-if="item.is_default=='1'">默认</text>
-								<text @click="toDel(item)" class="iconfont icon-del"></text>
-							</view>
-						</view>
-					</view>
-				</scroll-view>
-			</view>
-			<view class="popup" v-else-if="popup.type=='2'">
 				<scroll-view scroll-y="true" class="scroll-view">
 					<discount :Style="Style" :couponList="couponList" @toDiscount="toDiscount"></discount>
 				</scroll-view>
@@ -169,8 +136,14 @@
 				group_id: '',
 			};
 		},
-		onLoad: async function(e) {
+		onLoad: function(e) {
 			const that = this;
+			uni.$on("id", async (id) => {
+				let arr = await that.$api(`/address/${id}`, `GET`)
+				if (arr.errcode == '0') {
+					that.$set(that, `address`, arr.data)
+				}
+			})
 			that.$set(that, `key`, e.key || '');
 			that.$set(that, `group_id`, e.group_id || '');
 			that.watchLogin()
@@ -187,64 +160,23 @@
 			// 选择收货地址
 			toChoose() {
 				const that = this;
-				if (that.addressList.length > 0) {
-					that.$set(that.popup, 'type', '1')
-					that.$refs.popup.open();
+				if (that.address?._id) {
+					uni.navigateTo({
+						url: `/pagesMy/address/index?type=${"shopping"}&id=${that.address._id}`
+					})
 				} else {
-					uni.showToast({
-						title: `暂无收货地址`,
-						icon: 'none'
+					uni.navigateTo({
+						url: `/pagesMy/address/index?type=${"shopping"}`
 					})
 				}
 			},
 			// 选择优惠劵
 			toCoupon() {
 				const that = this;
-				that.$set(that.popup, 'type', '2')
+				that.$set(that.popup, 'type', '1')
 				that.$set(that, 'coupon', [])
 				that.$refs.popup.open();
 			},
-			// 是否选中
-			toCheckbox(e) {
-				const that = this;
-				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, `address`, item);
-					} else {
-						that.$set(item, 'checked', false)
-					}
-				}
-				that.$refs.popup.close();
-			},
-			// 删除收货地址
-			toDel(e) {
-				const that = this;
-				uni.showModal({
-					title: '提示',
-					content: '确定删除该地址吗?',
-					success: async function(res) {
-						if (res.confirm) {
-							const arr = await that.$api(`/address/${e._id}`, 'DELETE');
-							if (arr.errcode == '0') {
-								uni.showToast({
-									title: '删除信息成功',
-									icon: 'none'
-								})
-								that.search();
-							} else {
-								uni.showToast({
-									title: arr.errmsg,
-									icon: 'none'
-								})
-							}
-						}
-					}
-				});
-			},
 			// 提交订单
 			async toSubmit() {
 				const that = this;

+ 134 - 3
pagesMy/address/index.vue

@@ -4,7 +4,39 @@
 			<view class="one">
 				<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
 					<view class="list-scroll-view">
-						<view class="list" v-for="(item,index) in list" :key="index">
+						<radio-group @change="addressChange" v-if="type=='shopping'">
+							<label class="radio" v-for="(item, index) in list" :key="index">
+								<radio :value="item._id" :checked="index === address" />
+								<view class="radio_1">
+									<view class="name">
+										<text>{{item.name}}</text>
+										<text>{{item.phone}}</text>
+									</view>
+									<view class="address">
+										<text>{{item.province}}</text>
+										<text>{{item.city}}</text>
+										<text>{{item.area}}</text>
+										<text>{{item.address}}</text>
+										<text>{{item.number}}</text>
+									</view>
+									<view class="btn">
+										<view class="btn_1" v-if="item.is_default==false">
+											<button type="default" size="mini" @click="toDefa(item)">设为默认</button>
+										</view>
+										<view class="btn_1">
+											<button type="default" size="mini" @click="toCommon(item)">编辑</button>
+										</view>
+										<view class="btn_1">
+											<button type="default" size="mini" @click="toDel(item)">删除</button>
+										</view>
+									</view>
+									<view class="default" v-if="item.is_default==true">
+										<text>默认</text>
+									</view>
+								</view>
+							</label>
+						</radio-group>
+						<view v-else class="list" v-for="(item,index) in list" :key="index">
 							<view class="name">
 								<text>{{item.name}}</text>
 								<text>{{item.phone}}</text>
@@ -53,6 +85,10 @@
 	export default {
 		data() {
 			return {
+				// 购物选地址
+				id: '',
+				type: '',
+				address: 0,
 				// 系统设置
 				config: {},
 				user: {},
@@ -66,11 +102,12 @@
 				scrollTop: 0,
 			};
 		},
-		onLoad: function() {
+		onLoad: async function(e) {
 			const that = this;
+			that.$set(that, `type`, e && e.type || '');
+			that.$set(that, `id`, e && e.id || '');
 			that.searchConfig();
 			that.watchLogin();
-			
 		},
 		methods: {
 			// 查询基本设置
@@ -119,6 +156,14 @@
 					let list = [...that.list, ...res.data];
 					that.$set(that, `list`, list);
 					that.$set(that, `total`, res.total)
+					if (that.id) {
+						for (let i = 0; i < list.length; i++) {
+							if (list[i]._id === that.id) {
+								that.address = i;
+								break;
+							}
+						}
+					}
 				}
 			},
 			// 分页
@@ -146,6 +191,20 @@
 				let num = Math.sign(up - e.detail.scrollTop);
 				if (num == 1) that.$set(that, `is_bottom`, false);
 			},
+			// 选择收货地址
+			addressChange(e) {
+				const that = this;
+				for (let i = 0; i < that.list.length; i++) {
+					if (that.list[i]._id === e.detail.value) {
+						that.address = i;
+						break;
+					}
+				}
+				uni.$emit("id", e.detail.value)
+				uni.navigateBack({
+					delta: 1
+				})
+			},
 			// 获取微信地址
 			toWxaddress() {
 				const that = this;
@@ -287,6 +346,78 @@
 			flex-grow: 1;
 			background-color: var(--f5Color);
 
+			.radio {
+				position: relative;
+				display: flex;
+				background: var(--fffColor);
+				padding: 2vw;
+				width: 92vw;
+				margin: 2vw 2vw 0 2vw;
+				border-radius: 5px;
+
+				.radio_1 {
+					.name {
+						font-size: var(--font16Size);
+						margin: 0 0 2vw 0;
+
+						text {
+							padding: 0 2vw 0 0;
+						}
+					}
+
+					.address {
+						font-size: var(--font14Size);
+						margin: 0 0 1vw 0;
+
+						text {
+							padding: 0 2vw 0 0;
+						}
+					}
+
+					.btn {
+						display: flex;
+						flex-direction: row;
+						justify-content: space-around;
+						border-top: 1px solid var(--font16Size);
+						padding: 2vw 0 0 0;
+
+						.btn_1 {
+							button {
+								width: 100%;
+								color: var(--fffColor);
+								background-color: var(--f35BColor);
+							}
+						}
+
+						.btn_1:nth-child(2) {
+							button {
+								background-color: var(--f0fColor);
+							}
+						}
+
+						.btn_1:last-child {
+							button {
+								background-color: var(--fFB1Color);
+							}
+						}
+					}
+
+					.default {
+						position: absolute;
+						top: 0;
+						right: 0;
+
+						text {
+							background: var(--ff0Color);
+							color: var(--fffColor);
+							font-size: var(--font12Size);
+							padding: 1vw;
+							border-radius: 5px;
+						}
+					}
+				}
+			}
+
 			.list {
 				position: relative;
 				background: var(--fffColor);