فهرست منبع

产品详情页面放开登录限制

gcz 1 سال پیش
والد
کامیت
f2ec708834
3فایلهای تغییر یافته به همراه57 افزوده شده و 14 حذف شده
  1. 7 7
      common/config.js
  2. 1 1
      pages/login/login.vue
  3. 49 6
      shopping/productdetails.vue

+ 7 - 7
common/config.js

@@ -12,15 +12,15 @@
 // }
 
 //64
-let baseUrl='https://xusfoodapi.hw.hongweisoft.com/appapi/app';
-let upFileUrl='http://fileupload.hw.hongweisoft.com/upload/single/minio';
-// let staticUrl='http://res.hw.hongweisoft.com/xushuo/';
-let staticUrl='https://xusapi.gzxsjt.cn/miniores/imgs/app';
+// let baseUrl='https://xusfoodapi.hw.hongweisoft.com/appapi/app';
+// let upFileUrl='http://fileupload.hw.hongweisoft.com/upload/single/minio';
+// // let staticUrl='http://res.hw.hongweisoft.com/xushuo/';
+// let staticUrl='https://xusapi.gzxsjt.cn/miniores/imgs/app';
 
 //正式
-// let baseUrl='https://xusapi.gzxsjt.cn/appapi/app';
-// let upFileUrl='https://xusapi.gzxsjt.cn/thirdapi/upload/single/minio';
-// let staticUrl='https://xusapi.gzxsjt.cn/miniores/imgs/app';
+let baseUrl='https://xusapi.gzxsjt.cn/appapi/app';
+let upFileUrl='https://xusapi.gzxsjt.cn/thirdapi/upload/single/minio';
+let staticUrl='https://xusapi.gzxsjt.cn/miniores/imgs/app';
 
 const commonConfig = {
 	wxAppid: '', // 测试wxAppid

+ 1 - 1
pages/login/login.vue

@@ -318,7 +318,7 @@
 					key: 'backUrl',
 					success: function (res) {
 						// console.log('success');
-						uni.reLaunch({url: url});
+						uni.reLaunch({url: decodeURIComponent(url)});
 					}
 				});
 			},

+ 49 - 6
shopping/productdetails.vue

@@ -98,7 +98,7 @@
 		<view class="details-tool-wrap">
 			<view class="details-tool u-flex u-row-between">
 				<view class="left u-flex">
-					<view class="icon-wrap" @click="shareShow=true">
+					<view class="icon-wrap" @click="openShare">
 						<u-icon name="share" color="#676767" size="30"></u-icon>
 						分享
 						<!-- <button class="share-btn" data-name="shareBtn" open-type="share">
@@ -195,9 +195,11 @@
 			this.getDetails(this.id);
 		},
 		onShow(){
-			this.getCartList();
-			this.getAddrList();
-			this.goodsAddView(this.id)
+			if(this.vuex_member_info.name){
+				this.getCartList();
+				this.getAddrList();
+				this.goodsAddView(this.id)
+			}
 		},
 		methods: {
 			leftClick(e){
@@ -246,6 +248,10 @@
 				})
 			},
 			async addCart(id,buyNow){
+				// 检测是否登录
+				if (!this.checkLogin()) {
+					return;
+				}
 				try {
 					let authResult = await this.checkAuth();
 					console.log('实名认证结果:', authResult);
@@ -275,7 +281,41 @@
 					console.log('addCart',err);
 				})
 			},
+			checkLogin() {
+			    if (!this.vuex_member_info.name) {
+			        let that = this;
+			        let pageUrl = encodeURIComponent(`shopping/productdetails?id=${that.id}`);
+			        uni.showModal({
+			            title: '提示',
+			            content: '你需要登录后,才可使用此功能!',
+			            success: res => {
+			                if (res.confirm) {
+			                    uni.setStorage({
+			                        key: 'backUrl',
+			                        data: pageUrl,
+			                        success: function () {
+			                            uni.$u.route('/pages/login/login')
+			                        }
+			                    });
+			                }
+			            }
+			        });
+			        return false;
+			    }
+			    return true;
+			},
+			openShare(){
+				// 检测是否登录
+				// if (!this.checkLogin()) {
+				// 	return;
+				// }
+				this.shareShow = true;
+			},
 			async buyNow(id){
+				// 检测是否登录
+				if (!this.checkLogin()) {
+				    return;
+				}
 				try {
 					let authResult = await this.checkAuth();
 					console.log('实名认证结果:', authResult);
@@ -288,7 +328,6 @@
 					// 例如返回上一页或者跳转到实名认证页等操作
 				}
 				// this.addCart(id,'buyNow')//跳购物车
-				let that = this;
 				if(!this.hasAddr){
 					uni.showModal({
 						title: '温馨提示',
@@ -309,6 +348,10 @@
 				uni.$u.route('/shopping/submitorder', {fromPage: 'productdetails'});
 			},
 			async addCreditOrder(id){
+				// 检测是否登录
+				if (!this.checkLogin()) {
+					return;
+				}
 				try {
 					let authResult = await this.checkAuth();
 					console.log('实名认证结果:', authResult);
@@ -380,7 +423,7 @@
 				let that = this;
 			    return new Promise((resolve, reject) => {
 			        console.log('vuex_member_info', this.vuex_member_info.isAuth);
-			        if (that.details.isBuy&&that.details.isBuy!=1) {
+			        if (that.details.isBuy!=1&&that.details.isAuth==1) {
 			            uni.showModal({
 			                title: '温馨提示',
 			                content: '购买该商品需要实名认证,请先实名认证!',