فهرست منبع

修改首页推荐课程没数据时的显示和pc扫码登录

xuqiaoying 3 سال پیش
والد
کامیت
afc4d5dfef
5فایلهای تغییر یافته به همراه182 افزوده شده و 136 حذف شده
  1. 6 7
      common/request.js
  2. 62 72
      pages/index/index.vue
  3. 20 21
      pages2/register/register.vue
  4. 27 28
      pages4/login/login.vue
  5. 67 8
      pages4/login/pcLogin.vue

+ 6 - 7
common/request.js

@@ -4,22 +4,22 @@ import store from '@/store/index.js'
 import api from './api.js'
 var num = 1
 //接口api   
-export const BASE_URL = 'https://api.xyyxt.net'   //release
-// export const BASE_URL = 'https://test.xyyxt.net'   //预发布
+// export const BASE_URL = 'https://api.xyyxt.net'   //release
+export const BASE_URL = 'https://test.xyyxt.net'   //预发布
 // export const BASE_URL = 'http://42.192.164.187:19005'    //test
 // export const BASE_URL = 'http://192.168.1.222:5055'    //后端本地更新到222
 // export const BASE_URL = 'http://192.168.1.24:5055'    //后端本地
 // export const BASE_URL = 'http://192.168.1.7:5055'    //后端本地
 
  //图片上传api
-export const BASE_IMG_URL = 'https://file.xyyxt.net/'     //release
-// export const BASE_IMG_URL = 'https://file-dev.xyyxt.net/'  //test
+// export const BASE_IMG_URL = 'https://file.xyyxt.net/'     //release
+export const BASE_IMG_URL = 'https://file-dev.xyyxt.net/'  //test
 
 // web_view的
+// export const WEBVIEW_URL = 'https://m.xyyxt.net/'  //release
+export const WEBVIEW_URL = 'https://testm.xyyxt.net/'  //预发布
 // export const WEBVIEW_URL = 'http://192.168.1.38:8082/'  //test
 // export const WEBVIEW_URL = 'http://api.xyyxt.net:6066/'  //预发布(弃用了)
-// export const WEBVIEW_URL = 'https://testm.xyyxt.net/'  //预发布
-export const WEBVIEW_URL = 'https://m.xyyxt.net/'  //release
 
 // export const socket_url = 'ws://42.192.164.187:19005/webSocket/'  //test
 // export const socket_url = 'ws://120.79.166.78:19009/webSocket/'  //预发布
@@ -62,7 +62,6 @@ export const myRequest = (options) => {
 				// 	num++
 				// }
 				// doRequest(options)
-					
 				if (res.data.code == 401) {
 					if (num <= 2) {
 						if (!uni.getStorageSync('user_account')) {

+ 62 - 72
pages/index/index.vue

@@ -100,84 +100,72 @@
 				<view v-for="(item, index) in menu" :key="index" class="tab_item" :class="{nactive: tabNum == index}" @click="tab(index)">{{ item.name }}</view>
 			</view>
 			<view class="course-list" v-show="tabCurrent==0">
-				<navigator  hover-class="none" class="list_item" v-for="(item,index) in list1" :key="index" :url="'/pages3/course/detail?id='+item.goodsId">
-                    <view class="course_content">
-						<view class="c_title">{{item.goodsName}}</view>
-						<view class="c_downs">
-							<view class="img">
-                            	<image :src="$method.splitImgHost(item.coverUrl, true)"></image>
-								<view class="time" v-if="item.year">{{item.year?item.year:''}}</view>
-							</view>
-							<view class="text">
-								<view class="desc">
-									<view class="left">
-										<text class="mon_t">¥ {{toFixed(item.standPrice)}}</text>
-										<text class="sale">/限时优惠</text>
+				<template v-if="list1.length">
+					<navigator  hover-class="none" class="list_item" v-for="(item,index) in list1" :key="index" :url="'/pages3/course/detail?id='+item.goodsId">
+						<view class="course_content">
+							<view class="c_title">{{item.goodsName}}</view>
+							<view class="c_downs">
+								<view class="img">
+									<image :src="$method.splitImgHost(item.coverUrl, true)"></image>
+									<view class="time" v-if="item.year">{{item.year?item.year:''}}</view>
+								</view>
+								<view class="text">
+									<view class="desc">
+										<view class="left">
+											<text class="mon_t">¥ {{toFixed(item.standPrice)}}</text>
+											<text class="sale">/限时优惠</text>
+										</view>
+										<view class="right">
+											<view class="regiser_row">立即购买</view>
+										</view>
 									</view>
-									<view class="right">
-										<view class="regiser_row">立即购买</view>
+									<view v-if="item.buyUserNum" class="joins">
+										<!-- <image class="people" src="/static/index/people.png"></image> -->
+										<!-- 为0时,不显示 -->
+										<view class="people">{{ item.buyUserNum }}人参与</view>
 									</view>
 								</view>
-								<view v-if="item.buyUserNum" class="joins">
-									<!-- <image class="people" src="/static/index/people.png"></image> -->
-									<!-- 为0时,不显示 -->
-									<view class="people">{{ item.buyUserNum }}人参与</view>
-								</view>
 							</view>
-						</view>
-                        
-                    </view>
-					
-					
-				</navigator>
+						</view>					
+					</navigator>
+				</template>
+				<template v-else>
+					<u-empty text="暂无推荐课程" mode="list" margin-top="100"></u-empty>
+				</template>
 			</view>
 			<view class="course-list" v-show="tabCurrent==1">
-			 	<navigator  hover-class="none" class="list_item" v-for="(item,index) in list2" :key="index" :url="'/pages2/bank/detail?id='+item.goodsId">
-					<!-- <view class="img">
-						<image :src="$method.splitImgHost(item.coverUrl, true)"></image>
-						<view class="time" v-if="item.year">{{item.year?item.year:''}}</view>
-					</view>
-					<view class="text">
-						<view class="title">{{item.goodsName}}</view>
-						<view class="desc">
-							<view class="left" v-if="false">
-								{{item.classHours || '-'}}
-								<text>学时</text>
-							</view>
-							<view class="right">¥ {{toFixed(item.standPrice)}}</view>
-						</view>
-					</view> -->
-
-                    <view class="course_content">
-						<view class="c_title">{{item.goodsName}}</view>
-						<view class="c_downs">
-							<view class="img">
-								<image :src="$method.splitImgHost(item.coverUrl, true)"></image>
-								<view class="time" v-if="item.year">{{item.year?item.year:''}}</view>
-							</view>
-							<view class="text">
-								<view class="desc">
-									<view class="left">
-										<text class="mon_t">¥ {{toFixed(item.standPrice)}}</text>
-										<text class="sale">/限时优惠</text>
+				<template v-if="list2.length">
+					<navigator hover-class="none" class="list_item" v-for="(item,index) in list2" :key="index" :url="'/pages2/bank/detail?id='+item.goodsId">
+						<view class="course_content">
+							<view class="c_title">{{item.goodsName}}</view>
+							<view class="c_downs">
+								<view class="img">
+									<image :src="$method.splitImgHost(item.coverUrl, true)"></image>
+									<view class="time" v-if="item.year">{{item.year?item.year:''}}</view>
+								</view>
+								<view class="text">
+									<view class="desc">
+										<view class="left">
+											<text class="mon_t">¥ {{toFixed(item.standPrice)}}</text>
+											<text class="sale">/限时优惠</text>
+										</view>
+										<view class="right">
+											<view class="regiser_row">立即购买</view>
+										</view>
 									</view>
-									<view class="right">
-										<view class="regiser_row">立即购买</view>
+									<view v-if="item.buyUserNum" class="joins">
+										<!-- 为0时,不显示 -->
+										<view class="people">{{ item.buyUserNum }}人参与</view>
 									</view>
+									
 								</view>
-								<!-- <view class="c_title">{{item.goodsName}}</view> -->
-								<view v-if="item.buyUserNum" class="joins">
-									<!-- <image class="people" src="/static/index/people.png"></image> -->
-									<!-- 为0时,不显示 -->
-									<view class="people">{{ item.buyUserNum }}人参与</view>
-								</view>
-								
 							</view>
 						</view>
-                        
-                    </view>
-					
-				</navigator> 
+					</navigator>
+				</template>
+				<template v-else>
+					<u-empty text="暂无推荐题库" mode="list" margin-top="100"></u-empty>
+				</template>
 			</view>
 		</view>
 
@@ -653,6 +641,11 @@ export default {
 };
 </script>
 
+<style>
+page {
+	background: #eaeef1;
+}
+</style>
 <style lang="scss" scoped>
 @mixin threeDot {
 	overflow: hidden;
@@ -716,7 +709,7 @@ export default {
 	
 	.content {
 		overflow: hidden;
-		padding:0 16rpx 16rpx;
+		padding:0 16rpx;
 		background: rgba(234, 238, 241, 1);
 		
 		.notice {
@@ -1105,10 +1098,7 @@ export default {
 	text-align: center;
 	color: #7f8caf;
 }
-page {
-	background: #ffffff;
-	font-size: 28rpx;
-}
+
 .calendar_card {
 	width: 100%;
 	background: #ffffff;

+ 20 - 21
pages2/register/register.vue

@@ -355,7 +355,7 @@ export default {
 				],
 			},
 			isUse:false,
-			scanCode: '', // 标识码
+			// scanCode: '', // 标识码
 		};
 	},
 	mounted() {},
@@ -414,9 +414,10 @@ export default {
 													that.$api.getInfo().then(resdata => {
 														if(resdata.data.code == 200){
 															that.$store.state.userInfo = resdata.data.data;
-															if (this.scanCode) { // pc扫码进来登录成功
-																this.submitCode()
-															} else if(!that.isBack){
+															// if (this.scanCode) { // pc扫码进来登录成功
+															// 	this.submitCode()
+															// } else 
+															if(!that.isBack){
 																uni.reLaunch({
 																	url:'/pages/index/index'
 																})
@@ -431,9 +432,9 @@ export default {
 													//未完善信息,存为临时信息
 													uni.setStorageSync('user_account_temp', res.data.data.user_account);
 													uni.setStorageSync('token_temp', res.data.data.token);
-													let url = this.scanCode ? '/pages2/register/bind?scanCode=' + this.scanCode : '/pages2/register/bind'
+													// let url = this.scanCode ? '/pages2/register/bind?scanCode=' + this.scanCode : '/pages2/register/bind'
 													uni.redirectTo({
-														url: url
+														url: '/pages2/register/bind'
 													})
 												}	
 											} else {
@@ -456,18 +457,18 @@ export default {
 			
 		},
 		// scanLoginCheck小程序校验PC登录二维码,执行登录获取到令牌,然后把扫码的路径最后面的6位标识码提交给后台就行
-		submitCode() {
-			console.log('注册:跳转请求提交code到接口', this.scanCode)
-			this.$api.scanLoginCheck({
-				scanCode: this.scanCode
-			}).then((res) => {
-				if (res.data.code == 200) {
-					uni.navigateTo({
-						url: '/pages4/login/pcLoginSuccess'
-					})
-				}
-			})
-		},
+		// submitCode() {
+		// 	console.log('注册:跳转请求提交code到接口', this.scanCode)
+		// 	this.$api.scanLoginCheck({
+		// 		scanCode: this.scanCode
+		// 	}).then((res) => {
+		// 		if (res.data.code == 200) {
+		// 			uni.navigateTo({
+		// 				url: '/pages4/login/pcLoginSuccess'
+		// 			})
+		// 		}
+		// 	})
+		// },
 		codeChange(text) {
 			this.codeTips = text;
 		},
@@ -499,11 +500,9 @@ export default {
 		},
 	},
 	onLoad(option) {
-		console.log(option)
 		let that = this;
 		this.$refs.uForm.setRules(this.rules)
-		option.scanCode && (this.scanCode = option.scanCode)
-		console.log('跳转注册时的scanCode', this.scanCode)
+		// option.scanCode && (this.scanCode = option.scanCode)
 		uni.login({
 			provider: 'weixin',
 			success: function(loginRes) {

+ 27 - 28
pages4/login/login.vue

@@ -120,14 +120,14 @@ export default {
 		};
 	},
 	onLoad(option) {
-		console.log('dsfs-----:', option)
 		this.$refs.uForm1.setRules(this.rules)
 		this.$refs.uForm2.setRules(this.rules)
 		if(option.isBack){
 			this.isBack = option.isBack;
-		} else if (option.scanCode) {
-			this.scanCode = option.scanCode
-		}
+		} 
+		// else if (option.scanCode) {
+		// 	this.scanCode = option.scanCode
+		// }
 		// this.from = option.from; 
 		
 	},
@@ -154,7 +154,7 @@ export default {
 				if (res.data.code == 200) {
 					this.loginCallback(res, 'wxlogin')
 				} else {
-					this.getwxCode()
+					this.getwxCode() // code用完一次就会过期,防止用户点击取消后再点微信登录后code过期
 					// this.$u.toast(res.data.msg);
 				}
 			})
@@ -349,7 +349,6 @@ export default {
 		},
 		// 微信、密码、验证码 登录成功的回调
 		loginCallback(res, types) {
-			console.log('登录后的回调',res, res.data)
 			if(res.data.data && res.data.data.full_info){
 				//信息完善,直接进入页面
 				uni.setStorageSync('user_account', res.data.data.user_account);
@@ -359,9 +358,10 @@ export default {
 					if(resdata.data.code == 200){
 						this.$store.state.userInfo = resdata.data.data;
 						
-						if (this.scanCode) { // pc扫码进来登录成功
-							this.submitCode()
-						} else if(!this.isBack){
+						// if (this.scanCode) { // pc扫码进来登录成功
+						// 	this.submitCode()
+						// } else 
+						if(!this.isBack){
 							let goPath = ''
 							if (types == 'wxlogin' || types == 'smslogin') { //密码登录不用判断电脑goPath, 直接到首页
 								goPath = uni.getStorageSync('goPath')
@@ -393,30 +393,29 @@ export default {
 				//未完善信息,存为临时信息
 				uni.setStorageSync('user_account_temp', res.data.data.user_account);
 				uni.setStorageSync('token_temp', res.data.data.token);
-				console.log('scanCode====', this.scanCode)
-				if (this.scanCode) {
-					this.$navTo.togo('/pages2/register/bind', {scanCode: this.scanCode})
-				} else {
+				// if (this.scanCode) {
+				// 	this.$navTo.togo('/pages2/register/bind', {scanCode: this.scanCode})
+				// } else {
 					this.$navTo.togo('/pages2/register/bind');
-				}
+				// }
 				
 			}	
 		},
 		// scanLoginCheck小程序校验PC登录二维码,执行登录获取到令牌,然后把扫码的路径最后面的6位标识码提交给后台就行
-		submitCode() {
-			console.log('跳转请求提交code到接口', this.scanCode)
-			this.$api.scanLoginCheck({
-				scanCode: this.scanCode
-			}).then((res) => {
-				if (res.data.code == 200) {
-					uni.navigateTo({
-						url: '/pages4/login/pcLoginSuccess'
-					})
-				} else {
-					this.$u.toast(res.data.msg)
-				}
-			})
-		}
+		// submitCode() {
+		// 	console.log('跳转请求提交code到接口', this.scanCode)
+		// 	this.$api.scanLoginCheck({
+		// 		scanCode: this.scanCode
+		// 	}).then((res) => {
+		// 		if (res.data.code == 200) {
+		// 			uni.navigateTo({
+		// 				url: '/pages4/login/pcLoginSuccess'
+		// 			})
+		// 		} else {
+		// 			this.$u.toast(res.data.msg)
+		// 		}
+		// 	})
+		// }
 	}
 
 };

+ 67 - 8
pages4/login/pcLogin.vue

@@ -10,7 +10,8 @@
             <!-- 正文内容 -->
             <image class="logo" src="/static/me/logo.png" style="width: 360rpx;height: 72rpx;"></image>
             <text>登录后您可在网页端继续浏览课程</text>
-            <view class="login_bt" @click="pcLogin()">微信登录</view>
+            <!-- <view class="login_bt" @click="pcLogin()">微信登录</view> -->
+            <button type="default" open-type="getPhoneNumber" @getphonenumber="wxLogin" class="login_bt">微信登录</button>
         </view>
     </view>
 </template>
@@ -20,6 +21,7 @@ export default {
     data() {
         return {
             scanCode: '', // 获取扫码的路径最后面的6位标识码
+            code: '',
         }
     },
     onLoad(query) {
@@ -28,21 +30,78 @@ export default {
         console.log('扫描后得:', q, this.scanCode)
         // 扫描二维码后调用,小程序已扫码
         if (this.scanCode) {
-            console.log('进入扫码后的接口')
             this.$api.scanhasCode({scanCode: this.scanCode}).then((res) => {
                 console.log('调用扫码接口返回的:', res)
                 if (res.data.code == 200) {
-                    console.log('扫码成功')
+                    console.log()
                 }
             })
         }
 	},
+    onShow() {
+		// 获取code
+		this.getwxCode()
+	},
     methods: {
-        pcLogin() {
-            uni.navigateTo({
-                url: '/pages4/login/login?scanCode=' + this.scanCode
-            });
-        },
+        getwxCode() {
+			uni.login({
+				provider: 'weixin',
+				success: (loginRes) => {
+					this.code = loginRes.code
+					console.log('获取的code:', this.code)
+				}
+			})
+		},
+        wxLogin(e) {
+			this.$api.wxLogin({
+				code: this.code,
+				encryptedData: e.detail.encryptedData,
+				iv:  e.detail.iv
+			}).then(res => {
+				if (res.data.code == 200) {
+					this.loginCallback(res)
+				} else {
+					this.getwxCode() // code用完一次就会过期,防止用户点击取消后再点微信登录后code过期
+				}
+			})
+		},
+        // 微信登录成功的回调
+		loginCallback(res) {
+			console.log('登录后的回调',res)
+			if(res.data.data && res.data.data.full_info){
+				//信息完善,直接进入页面
+				uni.setStorageSync('user_account', res.data.data.user_account);
+				uni.setStorageSync('token', res.data.data.token);
+				// /app/user/getInfo 登录用户信息
+				this.$api.getInfo().then(resdata => {
+					if(resdata.data.code == 200){
+						this.$store.state.userInfo = resdata.data.data;
+						
+                        this.submitCode()
+					}
+					
+				});
+			} else {
+				//未完善信息,存为临时信息
+				uni.setStorageSync('user_account_temp', res.data.data.user_account);
+				uni.setStorageSync('token_temp', res.data.data.token);
+                this.$navTo.togo('/pages2/register/bind', {scanCode: this.scanCode})
+			}	
+		},
+		// scanLoginCheck小程序校验PC登录二维码,执行登录获取到令牌,然后把扫码的路径最后面的6位标识码提交给后台就行
+		submitCode() {
+			this.$api.scanLoginCheck({
+				scanCode: this.scanCode
+			}).then((res) => {
+				if (res.data.code == 200) {
+					uni.navigateTo({
+						url: '/pages4/login/pcLoginSuccess'
+					})
+				} else {
+					this.$u.toast(res.data.msg)
+				}
+			})
+		},
     }
 }
 </script>