lyqu hace 4 años
padre
commit
e42350b76a

+ 6 - 2
components/goods/goods.vue

@@ -34,6 +34,10 @@
 				default: () => {
 					return []
 				}
+			},
+			activityId: {
+				type: String,
+				default: '',
 			}
 		},
 		data() {
@@ -42,9 +46,9 @@
 			}
 		},
 		methods: {
-			navTap(id){
+			navTap(id) {
 				uni.navigateTo({
-					url:"/pages/activityList/goods/detail?id="+id
+					url:"/pages/activityList/goods/detail?id=" + id + "&activityId=" + this.activityId
 				})
 			}
 		}

+ 1 - 0
components/homeViews/mine-view.vue

@@ -92,6 +92,7 @@
 				isAgency: false,
 				iconList: [
 					{name: '我的礼品', icon: '/static/icon-gift.png', width: '36upx', height: '33upx', url: '/pages/activityList/mine/myGift', show: true},
+					{name: '我的商品', icon: '/static/icon-delivery.png', width: '36upx', height: '36upx', url: '/pages/activityList/mine/pointsGoods/list', show: true},
 					{name: '我的音乐', icon: '/static/icon-music.png', width: '33upx', height: '32upx', url: '/pages/activityList/mine/myMusic', show: true},
 					{name: '我的助力', icon: '/static/icon-history.png', width: '32upx', height: '32upx', url: '/pages/activityList/mine/myBoost', show: true},
 					{name: '我的公益', icon: '/static/icon-welfare.png', width: '31upx', height: '31upx', url: '/pages/activityList/mine/myWelfare', show: true},

+ 32 - 1
components/homeViews/points-view.vue

@@ -1,8 +1,39 @@
 <template>
+	<view >
+		<goods :goodsList="goodsList" :activityId="activityId"></goods>
+	</view>
 </template>
 
 <script>
+	import goods from "@/components/goods/goods.vue"
+	export default {
+		components:{
+			goods
+		},
+		props: {
+			activityId: {
+				type: String,
+				default: '',
+			}
+		},
+		data() {
+			return {
+				goodsList:[]
+			}
+		},
+		mounted() {
+			this.fetchGoodsList();
+		},
+		methods: {
+			fetchGoodsList() {
+				this.$u.api.pointsGoods.list({activityId:this.activityId}).then(res => {
+					this.goodsList = res.records;
+				})
+			}
+		}
+	}
 </script>
 
-<style>
+<style >
+
 </style>

+ 0 - 9
pages.json

@@ -152,15 +152,6 @@
                 "navigationBarTitleText": "活动列表"
             }
             
-        }
-        ,{
-            "path" : "pages/activityList/goods/goods",
-            "style" :
-            {
-                "navigationBarTitleText": "积分商城",
-                "enablePullDownRefresh": false
-            }
-
         }
         ,{
             "path" : "pages/activityList/goods/detail",

+ 73 - 46
pages/activityList/goods/detail.vue

@@ -75,11 +75,11 @@
 
 		
 		
-		<view v-if="!exchangeShow" @click="exchangeShow=true"
+		<view v-if="!exchangeShow"
 			class="footer-fixed flex align-center justify-end padding bg-white"
 			style="padding: 30rpx;;border-top: 1rpx solid #e5e5e5;z-index: 9;">
 			<button class="cu-btn round text-white theme-bg-color" style="width: 180upx;height: 80upx;"
-				@click="exchangeShow=true">兑换</button>
+				@click="exchange">兑换</button>
 		</view>
 
 		<view v-else class="footer-fixed flex align-center justify-between  bg-white"
@@ -99,11 +99,13 @@
 </template>
 
 <script>
+	import {authUrl} from '@/common/conf/config.js';
+	import {getUrlParams} from '@/common/utils/utils.js';
 	export default {
 		data() {
 			return {
-				activityId: '1407016573251153922',
-				userId: '1',
+				activityId: '',
+				userId: '',
 				id: '',
 				proportion: {},
 
@@ -124,15 +126,16 @@
 			}
 		},
 		onLoad(options) {
-			this.id = options.id
-			this.fetchGoodsDetail()
-			this.getUsableHotAndPoints()
-			this.getAddress()
+			this.id = options.id;
+			this.activityId = options.activityId;
+			this.userId = uni.getStorageSync("userId");
+			this.authorization();
+			this.fetchGoodsDetail();
 		},
 		computed:{
-			totalCash:{
-				get(){
-					let total=this.data.cashValue +this.changeCash.hotCash +this.changeCash.pointsCash
+			totalCash: {
+				get() {
+					let total = this.data.cashValue + this.changeCash.hotCash + this.changeCash.pointsCash
 					return total
 				}
 			}
@@ -142,15 +145,13 @@
 		},
 		methods: {
 			getAddress(){
-				this.$u.api.user.userAddress({userId:this.userId}).then(res=>{
-					this.address=res.records[0]
+				this.$u.api.user.userAddress({userId: this.userId}).then(res => {
+					this.address = res.records[0];
 				})
 			},
 			fetchGoodsDetail() {
-				this.$u.api.pointsGoods.list({
-					id: this.id
-				}).then(res => {
-					this.detail = res.records[0]
+				this.$u.api.pointsGoods.list({id: this.id}).then(res => {
+					this.detail = res.records[0];
 					console.log(this.detail);
 				})
 			},
@@ -165,47 +166,46 @@
 			},
 			//计数器变化
 			hotValueChange(item) {
-				this.changeCash.hotCash =this.numberMul(item.value,this.proportion.hotProportion)
+				this.changeCash.hotCash = this.numberMul(item.value,this.proportion.hotProportion)
 			},
-			pointsValueChange(item){
-				this.changeCash.pointsCash =this.numberMul(item.value,this.proportion.pointsProportion)
+			pointsValueChange(item) {
+				this.changeCash.pointsCash = this.numberMul(item.value,this.proportion.pointsProportion)
 			},
-			async confirm(){
-				if (this.$u.test.isEmpty(this.address)||this.$u.test.isEmpty(this.address.id)) {
+			async confirm() {
+				if (this.$u.test.isEmpty(this.address) || this.$u.test.isEmpty(this.address.id)) {
 					this.$u.toast('请选择地址')
-					return
+					return;
 				}
-				
-				if (this.totalCash!=this.detail.cashValue) {
+				if (this.totalCash != this.detail.cashValue) {
 					uni.showToast({
-						title:"总金额不等于商品所需金额",
-						duration:3000,
-						icon:"none"
+						title: "总金额不等于商品所需金额",
+						duration: 3000,
+						icon: "none"
 					})
-					return
+					return;
 				}
-				this.data.pointsGoodsId=this.id
-				this.data.userId=this.userId
-				let res=await this.$u.api.pointsGoods.exchange(this.data)
-				if (res.code==400) {
+				this.data.pointsGoodsId = this.id
+				this.data.userId = this.userId
+				let res = await this.$u.api.pointsGoods.exchange(this.data)
+				if (res.code == 400) {
 					uni.showToast({
-						title:res.msg,
-						duration:3000,
-						icon:"none"
+						title: res.msg,
+						duration: 3000,
+						icon: "none"
 					})
-					return
+					return;
 				}
 				uni.showModal({
-					title:"提示",
-					content:"兑换成功,可到个人中心查看!",
-					confirmColor:"#5a3ee8",
-					showCancel:true,
-					confirmText:"去查看",
-					cancelText:"暂不查看",
+					title: "提示",
+					content: "兑换成功,可到个人中心查看!",
+					confirmColor: "#5a3ee8",
+					showCancel: true,
+					confirmText: "去查看",
+					cancelText: "暂不查看",
 					success: (res) => {
 						if (res.confirm) {
 							uni.navigateTo({
-								url:"../mine/pointsGoods/list"
+								url:"/pages/activityList/mine/pointsGoods/list"
 							})
 						}
 					}
@@ -223,8 +223,35 @@
 				} catch (e) {}
 
 				return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
-			}
-
+			},
+			exchange() {
+				if (this.$u.test.isEmpty(this.userId)) {
+					let path = "pages/activityList/goods/detail?id=" + this.id + "&activityId=" + this.activityId
+					window.location.href = authUrl(path);
+				} else {
+					this.exchangeShow = true;
+					this.getUsableHotAndPoints()
+					this.getAddress()
+				}
+			},
+			async authorization() {
+				let params = getUrlParams(window.location.search);
+				if (!this.$u.test.isEmpty(params.code)) {
+					let res = await this.$u.api.wxInfo.getUserInfo({userCode: params.code});
+					let datas = {
+						nickName: res.nickname,
+						avatar: res.headimgurl,
+						gender: res.sex,
+						openid: res.openid,
+						unionid: res.unionid
+					}
+					let result = await this.$u.api.user.login(datas);
+					if (result) {
+						this.userId = result.id;
+						uni.setStorageSync("userId", result.id);
+					}
+				}
+			},
 		}
 	}
 </script>

+ 0 - 37
pages/activityList/goods/goods.vue

@@ -1,37 +0,0 @@
-<template>
-	<view >
-		<goods :goodsList="goodsList"></goods>
-	</view>
-</template>
-
-<script>
-	import goods from "../../../components/goods/goods.vue"
-	export default {
-		components:{
-			goods
-		},
-		data() {
-			return {
-				activityId:'1407016573251153922',
-				goodsList:[]
-			}
-		},
-		onLoad() {
-			this.fetchGoodsList()
-		},
-		methods: {
-			fetchGoodsList(){
-				let params={
-					activityId:this.activityId
-				}
-				this.$u.api.pointsGoods.list(params).then(res=>{
-					this.goodsList=res.records
-				})
-			}
-		}
-	}
-</script>
-
-<style >
-
-</style>

+ 7 - 1
pages/activityList/home/home.vue

@@ -4,6 +4,10 @@
 		<view v-if="current == 0">
 			<activity-view :imgList="imgList" :activityId="activityId"></activity-view>
 		</view>
+		<!--花积分-->
+		<view v-if="current == 1">
+			<points-view :activityId="activityId"></points-view>
+		</view>
 		<!--个人中心-->
 		<view v-if="current == 2">
 			<mine-view ref="mine" :activityId="activityId"></mine-view>
@@ -20,13 +24,15 @@
 	import searchBar from "@/components/basic/search-bar.vue";
 	import bottomBarHome from "@/components/basic/bottom-bar-home.vue";
 	import activityView from "@/components/homeViews/activity-view.vue";
+	import pointsView from "@/components/homeViews/points-view.vue";
 	import mineView from "@/components/homeViews/mine-view.vue";
 	export default {
 		components: {
 			searchBar,
 			bottomBarHome,
 			activityView,
-			mineView
+			mineView,
+			pointsView
 		},
 		data() {
 			return {

BIN
static/icon-delivery.png