浏览代码

修改地址,商品详情

yuwenjun 4 年之前
父节点
当前提交
0e222ee13d
共有 4 个文件被更改,包括 347 次插入290 次删除
  1. 311 278
      components/cm-module/productDetails/cm-price.vue
  2. 4 3
      pages/goods/product.vue
  3. 31 8
      pages/user/address/address.vue
  4. 1 1
      services/user.service.js

+ 311 - 278
components/cm-module/productDetails/cm-price.vue

@@ -1,326 +1,359 @@
 <template name="cm-price">
 	<!-- 商品详情价格判断 -->
 	<view class="wrap-main">
-			<!-- 协销  -->
-			<template>
-				<view class="wrap-main-item">
-					<!-- <view class="p-price tui-skeleton-fillet" :class="PromotionsFormat(product.promotions) ? 'none' : ''">
-						<text class="txt sm">¥</text>
-						<text class="txt big">{{ (PromotionsFormat(product.promotions) ? product.price1 : product.retailPrice) | NumFormat }}</text>
-					</view> -->
-					<view class="p-price tui-skeleton-fillet">
-						<text class="txt big">¥{{ (PromotionsFormat(product.promotions) ? product.price1 : product.retailPrice) | NumFormat }}</text>
-					</view>
-					<!-- 如果用户登录了就显示优惠价格 -->
-					<!-- <view v-if="product.actStatus==1" class="floor-item-act">
-						<view v-if="product.promotions.type == 1 && product.promotions.mode == 1"  class="floor-tags" @click.stop="clickPopupShow(1)">
-							{{product.promotions.name}}<text v-if="hasLogin">:¥{{ product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat }}</text>
-						</view>
-						<view v-else class="floor-tags" @click.stop="clickPopupShow()">{{product.promotions.name}}</view>	
-					</view>
-					<view  v-if="product.actStatus == 0  &&  product.ladderPriceFlag == 1" class="floor-item-act">
-						<view class="floor-tags" @click.stop="clickPopupShow()">阶梯价格</view>	
-					</view> -->
-				</view>		
-			</template>	
-			
-			<!--促销活动弹窗提示-->
-			<tui-bottom-popup :radius="true" :show="popupShow" @close="hidePopup()">
-				<view class="tui-popup-box clearfix">
-					<template v-if="product.actStatus == 0  &&  product.ladderPriceFlag == 1">
-						<view class="tui-scrollview-box">
-							<view class="ladder-main clearfix">
-								<view class="ladder-item">
-									<view class="ladder-item-td">起订量</view>
-									<view class="ladder-item-td">价格</view>
-								</view>
-								<view class="ladder-item" v-for="(ladd, index) in product.ladderPriceList" :key="index">
-									<view class="ladder-item-td">{{ ladd.buyNumRangeShow }}</view>
-									<view class="ladder-item-td">{{ ladd.buyPrice | NumFormat }}</view>
-								</view>
-							</view>
-						</view>	
-					</template>	
-					<template v-else>
-						<view class="tui-scrollview-box">
-							<view class="box-text">
-								<text>促销时间:</text>
-								<text class="txt" v-if="product.promotions.status == 1">不限时</text>
-								<text class="txt" v-else>{{ product.promotions.beginTime }} ~ {{ product.promotions.endTime }}</text>
-							</view>
-							<view class="box-title" v-show="product.promotions.mode ==2">
-								<text>购买{{ product.promotions.name }}商品,满</text>
-								<text class="txt">¥{{ product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat }}</text>减
-								<text class="txt">¥{{ product.promotions == null ? '0.00' : product.promotions.reducedPrice | NumFormat }}</text>
+		<!-- 协销  -->
+		<view class="wrap-main-item">
+			<view
+				class="p-price tui-skeleton-fillet"
+				:class="promotionFormat(product.promotion) ? 'none' : ''"
+			>
+				<text class="txt sm">¥</text>
+				<text class="txt big">{{
+					(promotionFormat(product.promotion) ? product.price1 : product.retailPrice)
+						| NumFormat
+				}}</text>
+			</view>
+			<view v-if="product.actStatus == 1" class="floor-item-act">
+				<view
+					v-if="product.promotion.type == 1 && product.promotion.mode == 1"
+					class="floor-tags"
+					@click.stop="clickPopupShow(1)"
+				>
+					{{ product.promotion.name
+					}}<text v-if="hasLogin"
+						>:¥{{
+							product.promotion == null
+								? '0.00'
+								: product.promotion.touchPrice | NumFormat
+						}}</text
+					>
+				</view>
+				<view v-else class="floor-tags" @click.stop="clickPopupShow()">{{
+					product.promotion.name
+				}}</view>
+			</view>
+			<view
+				v-if="product.actStatus == 0 && product.ladderPriceFlag == 1"
+				class="floor-item-act"
+			>
+				<view class="floor-tags" @click.stop="clickPopupShow()">阶梯价格</view>
+			</view>
+		</view>
+
+		<!--促销活动弹窗提示-->
+		<tui-bottom-popup :radius="true" :show="popupShow" @close="hidePopup()">
+			<view class="tui-popup-box clearfix">
+				<template v-if="product.actStatus == 0 && product.ladderPriceFlag == 1">
+					<view class="tui-scrollview-box">
+						<view class="ladder-main clearfix">
+							<view class="ladder-item">
+								<view class="ladder-item-td">起订量</view>
+								<view class="ladder-item-td">价格</view>
 							</view>
-							<view class="box-title" v-show="product.promotions.mode==3">
-								<text>购买{{ product.promotions.name }}商品,满</text>
-								<text class="txt">¥{{ product.promotions == null ? '0.00' : product.promotions.touchPrice | NumFormat }}</text>赠送商品
+							<view
+								class="ladder-item"
+								v-for="(ladd, index) in product.ladderPriceList"
+								:key="index"
+							>
+								<view class="ladder-item-td">{{ ladd.buyNumRangeShow }}</view>
+								<view class="ladder-item-td">{{ ladd.buyPrice | NumFormat }}</view>
 							</view>
-							<view class="box-product" v-show="product.promotions.mode==3">
-								<view class="box-product-main"  v-for="(item, index) in product.promotions.giftList" :key="index">
-									<view class="image"><image :src="item.image" mode="widthFix"></image></view>
-									<view class="info">
-										<view class="name">{{ item.name }}</view>
-										<view class="num">X{{ item.number }}</view>
-									</view>
+						</view>
+					</view>
+				</template>
+				<template v-else>
+					<view class="tui-scrollview-box">
+						<view class="box-text">
+							<text>促销时间:</text>
+							<text class="txt" v-if="product.promotion.status == 1">不限时</text>
+							<text class="txt" v-else
+								>{{ product.promotion.beginTime }} ~
+								{{ product.promotion.endTime }}</text
+							>
+						</view>
+						<view class="box-title" v-show="product.promotion.mode == 2">
+							<text>购买{{ product.promotion.name }}商品,满</text>
+							<text class="txt"
+								>¥{{
+									product.promotion == null
+										? '0.00'
+										: product.promotion.touchPrice | NumFormat
+								}}</text
+							>减
+							<text class="txt"
+								>¥{{
+									product.promotion == null
+										? '0.00'
+										: product.promotion.reducedPrice | NumFormat
+								}}</text
+							>
+						</view>
+						<view class="box-title" v-show="product.promotion.mode == 3">
+							<text>购买{{ product.promotion.name }}商品,满</text>
+							<text class="txt"
+								>¥{{
+									product.promotion == null
+										? '0.00'
+										: product.promotion.touchPrice | NumFormat
+								}}</text
+							>赠送商品
+						</view>
+						<view class="box-product" v-show="product.promotion.mode == 3">
+							<view
+								class="box-product-main"
+								v-for="(item, index) in product.promotion.giftList"
+								:key="index"
+							>
+								<view class="image"
+									><image :src="item.image" mode="widthFix"></image
+								></view>
+								<view class="info">
+									<view class="name">{{ item.name }}</view>
+									<view class="num">X{{ item.number }}</view>
 								</view>
 							</view>
 						</view>
-					</template>
-					<view class="tui-right-flex tui-popup-btn" :style="{ paddingBottom :isIphoneX ? '68rpx' : '0rpx' }">
-						<view class="tui-flex-1">
-							<view class="tui-button" v-if="product.promotions.type == 2" @click="goGoodActiveFn(product.promotions.id)">更多凑单商品</view>
-							<view class="tui-button" v-else @click="hidePopup()">了解</view>
-						</view>
 					</view>
-				</view>	
-			</tui-bottom-popup>
+				</template>
+				<view
+					class="tui-right-flex tui-popup-btn"
+					:style="{ paddingBottom: isIphoneX ? '68rpx' : '0rpx' }"
+				>
+					<view class="tui-flex-1">
+						<view
+							class="tui-button"
+							v-if="product.promotion.type == 2"
+							@click="goGoodActiveFn(product.promotion.id)"
+							>更多凑单商品</view
+						>
+						<view class="tui-button" v-else @click="hidePopup()">了解</view>
+					</view>
+				</view>
+			</view>
+		</tui-bottom-popup>
 		<!-- </template> -->
 	</view>
 </template>
 
 <script>
-	import { mapState,mapMutations } from 'vuex'
-	import uniGrader from '@/components/uni-grade/uni-grade.vue'
-	export default{
-		name:'cm-price',
-		components:{
-			uniGrader
+import { mapState, mapMutations } from 'vuex'
+import uniGrader from '@/components/uni-grade/uni-grade.vue'
+export default {
+	name: 'cm-price',
+	components: {
+		uniGrader
+	},
+	props: {
+		product: {
+			type: Object
 		},
-		props:{
-			product:{
-				type:Object,
-			},
-			userIdentity: {
-				type: Number,
-				default: 2
-			},
-			shopID: {
-				type: Number,
-				default: 2
-			},
-			ladderPriceList:{
-				type: Array,
-			},
-			promotions:{
-				type:Object,
-			}
+		userIdentity: {
+			type: Number,
+			default: 2
 		},
-		data() {
-			return{
-				popupShow:false,
-				promotionsType:0,
-				isIphoneX:this.$store.state.isIphoneX,
-			}
+		shopID: {
+			type: Number,
+			default: 2
 		},
-		filters: {
-			NumFormat:function(text) {//处理金额
-				return Number(text).toFixed(2);
-			},
+		ladderPriceList: {
+			type: Array
 		},
-		created() {
-			
+		promotion: {
+			type: Object
+		}
+	},
+	data() {
+		return {
+			popupShow: false,
+			promotionType: 0,
+			isIphoneX: this.$store.state.isIphoneX
+		}
+	},
+	filters: {
+		NumFormat: function(text) {
+			//处理金额
+			return Number(text).toFixed(2)
+		}
+	},
+	created() {},
+	computed: {
+		...mapState(['hasLogin', 'isWxAuthorize'])
+	},
+	methods: {
+		clickPopupShow(type) {
+			this.popupShow = true
+			this.promotionType = type
 		},
-		computed: {
-			...mapState(['hasLogin','isWxAuthorize'])
+		hidePopup() {
+			this.popupShow = false
 		},
-		methods:{
-			clickPopupShow(type){
-				this.popupShow = true
-				this.promotionsType = type
-			},
-			hidePopup(){
-				this.popupShow = false
-			},
-			PromotionsFormat(promo){//促销活动类型数据处理
-				if(promo!=null){
-					if(promo.type == 1 && promo.mode == 1){
-						return true
-					}else{
-						return false
-					}
+		promotionFormat(promo) {
+			//促销活动类型数据处理
+			if (promo != null) {
+				if (promo.type == 1 && promo.mode == 1) {
+					return true
+				} else {
+					return false
 				}
-				return false
-			},
-			goUpgradeApply(){
-				this.$api.navigateTo('/pages/login/apply')
-			},
-			loginClick(){
-				this.$api.navigateTo('/pages/login/login')
-			},
-			goGoodActiveFn(id){
-				this.$parent.popupShow = false
-				this.$api.navigateTo('/pages/goods/goods-active?id='+id)
 			}
+			return false
 		},
-		
+		goUpgradeApply() {
+			this.$api.navigateTo('/pages/login/apply')
+		},
+		loginClick() {
+			this.$api.navigateTo('/pages/login/login')
+		},
+		goGoodActiveFn(id) {
+			this.$parent.popupShow = false
+			this.$api.navigateTo('/pages/goods/goods-active?id=' + id)
+		}
 	}
+}
 </script>
 
-<style lang="scss">	
-	.tui-flex-1 {
-		flex: 1;
-	}
-	.tui-popup-box {
-		position: relative;
-		box-sizing: border-box;
-		min-height: 220rpx;
-		padding:24rpx 24rpx 0 24rpx;
-	}
-	.tui-scrollview-box{
+<style lang="scss">
+.tui-flex-1 {
+	flex: 1;
+}
+.tui-popup-box {
+	position: relative;
+	box-sizing: border-box;
+	min-height: 220rpx;
+	padding: 24rpx 24rpx 0 24rpx;
+}
+.tui-scrollview-box {
+	width: 100%;
+	height: auto;
+	float: left;
+	box-sizing: border-box;
+	.ladder-main {
 		width: 100%;
-		height: auto;
-		float: left;
-		box-sizing: border-box;
-		.ladder-main{
+		min-height: 240rpx;
+		border: 1px solid rgba(225, 86, 22, 0.3);
+		border-radius: 10rpx;
+		.ladder-item {
 			width: 100%;
-			min-height: 240rpx;
-			border: 1px solid rgba(225,86,22,0.3);
-			border-radius: 10rpx;
-			.ladder-item{
-				width: 100%;
-				height: 80rpx;
-				float: left;
-				border-bottom: 1px solid rgba(225,86,22,0.3);
-				&:nth-child(1){
-					.ladder-item-td{
-						color: #333333;
-					}
-				}
-				&:last-child{
-					border-bottom: none;
-				}
-				.ladder-item-td{
-					width:50%;
-					text-align: center;
-					line-height: 80rpx;
-					font-size: $font-size-24;
-					color: $color-system;
-					box-sizing: border-box;
-					float: left;
-					&:nth-child(1){
-						border-right: 1px solid rgba(225,86,22,0.3);
-					}
+			height: 80rpx;
+			float: left;
+			border-bottom: 1px solid rgba(225, 86, 22, 0.3);
+			&:nth-child(1) {
+				.ladder-item-td {
+					color: #333333;
 				}
 			}
-		}
-		.box-title{
-			font-size: $font-size-26;
-			color: $text-color;
-			text-align: left;
-			line-height: 56rpx;
-			.txt{
+			&:last-child {
+				border-bottom: none;
+			}
+			.ladder-item-td {
+				width: 50%;
+				text-align: center;
+				line-height: 80rpx;
+				font-size: $font-size-24;
 				color: $color-system;
-				margin: 0 8rpx;
+				box-sizing: border-box;
+				float: left;
+				&:nth-child(1) {
+					border-right: 1px solid rgba(225, 86, 22, 0.3);
+				}
 			}
 		}
-		.box-text{
-			font-size: $font-size-26;
+	}
+	.box-title {
+		font-size: $font-size-26;
+		color: $text-color;
+		text-align: left;
+		line-height: 56rpx;
+		.txt {
+			color: $color-system;
+			margin: 0 8rpx;
+		}
+	}
+	.box-text {
+		font-size: $font-size-26;
+		color: $text-color;
+		text-align: left;
+		line-height: 56rpx;
+		.txt {
+			color: $color-system;
+		}
+	}
+	.box-product {
+		width: 100%;
+		height: auto;
+		margin-top: 20rpx;
+		.title {
+			font-size: $font-size-24;
 			color: $text-color;
 			text-align: left;
-			line-height: 56rpx;
-			.txt{
-				color: $color-system;
-			}
+			line-height: 54rpx;
 		}
-		.box-product{
+		.box-product-main {
 			width: 100%;
-			height: auto;
-			margin-top: 20rpx;
-			.title{
-				font-size: $font-size-24;
-				color: $text-color;
-				text-align: left;
-				line-height: 54rpx;
+			height: 136rpx;
+			float: left;
+			margin: 10rpx 0;
+			.image {
+				width: 134rpx;
+				height: 134rpx;
+				border: 1px solid #ebebeb;
+				float: left;
+				image {
+					width: 100%;
+					height: 100%;
+					display: block;
+				}
 			}
-			.box-product-main{
-				width: 100%;
-				height: 136rpx;
+			.info {
+				width: 540rpx;
+				height: 134rpx;
 				float: left;
-				margin: 10rpx 0;
-				.image{
-					width: 134rpx;
-					height: 134rpx;
-					border: 1px solid #EBEBEB;
+				margin-left: 16rpx;
+				position: relative;
+				.name {
+					width: 100%;
 					float: left;
-					image{
-						width: 100%;
-						height: 100%;
-						display: block;
-					}
+					line-height: 40rpx;
+					font-size: $font-size-28;
+					color: $text-color;
+					-o-text-overflow: ellipsis;
+					text-overflow: ellipsis;
+					display: -webkit-box;
+					word-break: break-all;
+					-webkit-box-orient: vertical;
+					-webkit-line-clamp: 2;
+					overflow: hidden;
 				}
-				.info{
-					width: 540rpx;
-					height: 134rpx;
-					float: left;
-					margin-left: 16rpx;
-					position: relative;
-					.name{
-						width: 100%;
-						float: left;
-						line-height: 40rpx;
-						font-size: $font-size-28;
-						color: $text-color;
-						-o-text-overflow: ellipsis;
-						text-overflow: ellipsis;
-						display: -webkit-box;
-						word-break: break-all;
-						-webkit-box-orient: vertical;
-						-webkit-line-clamp: 2;
-						overflow: hidden;
-					}
-					.num{
-						width: 100%;
-						height: 44rpx;
-						font-size: $font-size-24;
-						color: $text-color;
-						text-align: left;
-						line-height: 44rpx;
-						position: absolute;
-						bottom: 0;
-						left: 0;
-					}
+				.num {
+					width: 100%;
+					height: 44rpx;
+					font-size: $font-size-24;
+					color: $text-color;
+					text-align: left;
+					line-height: 44rpx;
+					position: absolute;
+					bottom: 0;
+					left: 0;
 				}
 			}
 		}
 	}
-	
-	.tui-popup-btn {
+}
+
+.tui-popup-btn {
+	width: 100%;
+	height: auto;
+	float: left;
+	margin-top: 24rpx;
+	.tui-button {
 		width: 100%;
-		height: auto;
-		float: left;
-		margin-top: 24rpx;
-		.tui-button{
-			width: 100%;
-			height: 88rpx;
-			background: $btn-confirm;
-			line-height: 88rpx;
-			text-align: center;
-			color: #FFFFFF;
-			font-size: $font-size-28;
-			border-radius: 44rpx;
-		}
+		height: 88rpx;
+		background: $btn-confirm;
+		line-height: 88rpx;
+		text-align: center;
+		color: #ffffff;
+		font-size: $font-size-28;
+		border-radius: 44rpx;
 	}
+}
 </style>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

+ 4 - 3
pages/goods/product.vue

@@ -100,7 +100,7 @@
 										:product="product"
 										:userIdentity="userIdentity"
 										:shopID="shopID"
-										:promotions="product.promotions"
+										:promotion="product.promotion"
 										:ladderPriceList="ladderPriceList"
 									/>
 								</view>
@@ -1029,19 +1029,20 @@ page {
 			float: left;
 			padding: 10rpx 0;
 			margin-left: 10rpx;
+			margin-top: 5rpx;
 			.floor-tags {
 				float: right;
 				height: 28rpx;
 				border-radius: 6rpx;
 				background-color: #ffffff;
 				line-height: 28rpx;
-				color: $color-system;
 				text-align: center;
 				display: inline-block;
 				padding: 0 16rpx;
 				font-size: $font-size-20;
 				margin-left: 15rpx;
-				border: 1px solid #e15616;
+				color: #ff2a2a;
+				border: 1px solid #ff2a2a;
 			}
 		}
 		.floor-item-btn {

+ 31 - 8
pages/user/address/address.vue

@@ -38,7 +38,7 @@
 								>
 							</view>
 							<view v-else class="tag-left">
-								<view class="tag"
+								<view class="tag" @click.stop="setDefaultAddress(item.addressId)"
 									><text class="iconfont icon-weixuanze"></text
 									><text>设为默认地址</text></view
 								>
@@ -108,8 +108,14 @@ export default {
 		console.log(option && option)
 		this.setScrollHeight()
 		// console.log(this.addressList)
-		this.initAddressList()
+		// this.initAddressList()
 	},
+	onShow() {
+		this.pageNum = 1
+		this.addressList = []
+		this.initAddressList()
+	}
+	,
 	onReachBottom() {
 		if (this.isLoadMore) {
 			this.initAddressList()
@@ -133,16 +139,15 @@ export default {
 		// 初始化地址列表
 		initAddressList() {
 			this.$api.getComStorage('clubInfo').then(resolve => {
-				this.userId = resolve.userId
+				// this.userId = resolve.userId
 				// 设置默认地址 测试使用
 				// const clubInfo = uni.getStorageSync('clubInfo')
-				// this.userId = clubInfo.userId
+				this.userId = clubInfo.userId
 				// this.userId = '13914'
-				console.log(this.userId)
+				// console.log(this.userId)
 				let params = { pageNum: this.pageNum, pageSize: this.pageSize, userId: this.userId }
 				this.UserService.QueryAddressList(params)
 					.then(response => {
-						console.log(response)
 						if (response.data.list == '') {
 							this.isEmpty = true
 						} else {
@@ -216,9 +221,27 @@ export default {
 			this.modal = true
 			this.contentModalText = '确认删除该地址吗?'
 			this.deleteaddressId = id
+		},
+		// 修改默认地址
+		setDefaultAddress(id) {
+			this.UserService.DefaultAddress({
+				addressId: id,
+				userId: this.userId
+			})
+				.then(res => {
+					if (res.code === 0) {
+						this.pageNum = 1
+						this.addressList = []
+						this.initAddressList()
+					}
+				})
+				.catch(err => {
+					this.pageNum = 1
+					this.addressList = []
+					this.initAddressList()
+				})
 		}
-	},
-	onShow() {}
+	}
 }
 </script>
 

+ 1 - 1
services/user.service.js

@@ -79,7 +79,7 @@ export default class UserService {
 		return this.AjaxService.get({
 			url: '/other/defaultAddress',
 			data,
-			isLoading: true
+			isLoading: false
 		})
 	}
 }