wangguoyu 4 months ago
parent
commit
063443b7bb
6 changed files with 90 additions and 41 deletions
  1. 18 1
      App.vue
  2. 68 37
      pages/pay/svip.vue
  3. 1 1
      pages/study/index.vue
  4. 1 1
      pages/study/lookShipin.vue
  5. 1 0
      pages/study/product/shuxue.vue
  6. 1 1
      utils/common.js

+ 18 - 1
App.vue

@@ -10,7 +10,24 @@
 	export default {
 		// creat by wgy 0619  生命周期 钩子  
 		onLaunch: function() {
-			//console.log('App Launch')
+			console.log('App Launch')
+			console.log('App Launch')
+			console.log('App Launch')
+			console.log('App Launch')
+			console.log('App Launch')
+			if (cacheManager.get('auth')) {
+				uni.reLaunch({
+					url: `/pages/study/index`
+				})
+			}else if(!(cacheManager.get('wxLogin').bind)){
+					console.log('asdfadsfadsfasd')
+				// 微信登录且未绑定 
+			} else {
+				cacheManager.clearAll()
+				uni.redirectTo({
+					url: '/pages/login/index' 
+				});
+			}
 			
 		},
 		onShow: function() {

+ 68 - 37
pages/pay/svip.vue

@@ -22,65 +22,96 @@
 				<view>原价:<text class="original-price">¥598</text></view>
 				<view class="discount-price">活动价:¥198</view>
 			</view>
-			<radio-group @change="radioChange" class="pay-type-box" >
+			<radio-group @change="radioChange" class="pay-type-box">
 				<view class="type-radio-title">支付方式</view>
 				<view class="type-radio-content">
 					<view class="type-radio-box">
 						<icon class="wx-radio"></icon>
 						<text>微信</text>
 						<radio value="weixin" :checked="payType==='weixin'" activeBackgroundColor="transparent"
-						:class="{'radio-checked': payType==='weixin'}"/>
+							:class="{'radio-checked': payType==='weixin'}" />
 					</view>
 					<view class="type-radio-box">
 						<icon class="zfb-radio"></icon>
 						<text>支付宝</text>
 						<radio value="zhifubao" :checked="payType==='zhifubao'" activeBackgroundColor="transparent"
-						:class="{'radio-checked': payType==='zhifubao'}" style="margin-right: 0;"/>
+							:class="{'radio-checked': payType==='zhifubao'}" style="margin-right: 0;" />
 					</view>
 				</view>
 			</radio-group>
-			<view class="open-svip-btn">立即开通</view>
+			<view class="open-svip-btn" @click="creatOrder">立即开通</view>
 		</view>
 		<CustomTabBar></CustomTabBar>
 	</view>
 </template>
 
 <script setup>
-import {ref} from "vue";
-import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
-let payType = ref('weixin')
-const svipArr = [
-    {
-        iconPath: 'static/images/pay/svip-list-icon1.png',
-		title:'学习资源,随心畅学',
-        content: `解锁全年级数学优质学习资源,满足多样<br/>学习需求`
-    },
-    {
-        iconPath: 'static/images/pay/svip-list-icon2.png',
-        title:'名师打造,优质路径',
-        content: '资深名师精心规划学习路径,引领高效提升方向'
-    },
-    {
-        iconPath: 'static/images/pay/svip-list-icon3.png',
-        title:'进度分析,个性贴心',
-        content: '优先参与丰富真题测试,精准洞察学习状况'
-    },
-    {
-        iconPath: 'static/images/pay/svip-list-icon4.png',
-        title:'真题测试,优先体验',
-        content: '成为会员,即刻畅享专属权益,开启无忧学习之旅'
-    }
-];
-function radioChange(data){
-	payType.value = data.detail.value;
-}
-
-function goBack(data){
-	uni.redirectTo({
-		url: '/pages/study/index'
+	import {
+		ref
+	} from "vue";
+	import {
+		orderAdd
+	} from "@/api/order.js"
+	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
+	import cacheManager from "@/utils/cacheManager.js";
+	import {
+		onLoad,
+		onReady
+	} from '@dcloudio/uni-app';
+	import {
+		toast,
+		getUserIdentity
+	} from "@/utils/common";
+	let payType = ref('weixin')
+	let cardId = ref('')
+	const svipArr = [{
+			iconPath: 'static/images/pay/svip-list-icon1.png',
+			title: '学习资源,随心畅学',
+			content: `解锁全年级数学优质学习资源,满足多样<br/>学习需求`
+		},
+		{
+			iconPath: 'static/images/pay/svip-list-icon2.png',
+			title: '名师打造,优质路径',
+			content: '资深名师精心规划学习路径,引领高效提升方向'
+		},
+		{
+			iconPath: 'static/images/pay/svip-list-icon3.png',
+			title: '进度分析,个性贴心',
+			content: '优先参与丰富真题测试,精准洞察学习状况'
+		},
+		{
+			iconPath: 'static/images/pay/svip-list-icon4.png',
+			title: '真题测试,优先体验',
+			content: '成为会员,即刻畅享专属权益,开启无忧学习之旅'
+		}
+	];
+	onLoad((options) => {
+		cardId.value = options.cardId
 	})
-}
 
+	function radioChange(data) {
+		payType.value = data.detail.value;
+	}
+
+	function creatOrder(data) {
+		let req = {
+			cardId:cardId.value
+		}
+		orderAdd(req).then(res=>{
+			console.log('res');
+			cacheManager.updateObject('auth',{cardList:[cardId.value]})
+			toast('开通成功!')
+			uni.redirectTo({
+				url: '/pages/study/index'
+			})
+		})
+	}
+
+	function goBack(data) {
+		uni.redirectTo({
+			url: '/pages/study/index'
+		})
+	}
 </script>
 
 <style>

+ 1 - 1
pages/study/index.vue

@@ -215,7 +215,7 @@
 
 	function goPayPage() {
 		uni.redirectTo({
-			url: '/pages/pay/svip'
+			url: '/pages/pay/svip?cardId='+currentProduct.value
 		})
 	}
 

+ 1 - 1
pages/study/lookShipin.vue

@@ -256,7 +256,7 @@
 			},
 			svipConfirm() {
 				uni.redirectTo({
-					url: '/pages/pay/svip'
+					url: '/pages/pay/svip?cardId='+cacheManager.get('auth').cardId
 				})
 			},
 			ykConfirm() {

+ 1 - 0
pages/study/product/shuxue.vue

@@ -65,6 +65,7 @@
 		},
 	})
 	const isVip = getUserIdentity();
+	console.log('isVip',isVip);
 	const gradeMapping = {
 		1: '一年级',
 		2: '二年级',

+ 1 - 1
utils/common.js

@@ -57,7 +57,7 @@ export function catchError(promise) {
 export function getUserIdentity() {
 	const auth = cacheManager.get('auth');
 	if (auth) {
-		if (auth.cardList.some(item => item === auth.cardId)) {
+		if (auth.cardList.some(item => item == auth.cardId)) {
 			// VIP
 			return 'VIP'
 		}