Browse Source

Merge branch 'develop_yh2.0' of chelingzhu-web/zxyj-mini-html into master

李文文 4 năm trước cách đây
mục cha
commit
16c42ed926
5 tập tin đã thay đổi với 71 bổ sung14 xóa
  1. 1 1
      App.vue
  2. 21 1
      components/uni-coods/uni-coods.vue
  3. 4 4
      pages/goods/index.vue
  4. 12 5
      pages/index/index.vue
  5. 33 3
      pagesA/goods/goodsDetail.vue

+ 1 - 1
App.vue

@@ -4,7 +4,7 @@
 	const pro_domain = 'https://lese.sxzxyj.net' // 生产
 	const uat_URL = uat_domain+'/gc-shop/' // 预发布
 	const pro_URL = pro_domain+'/gc-shop/'  // 生产
-	const buildType = 0 // 打包环境对应类型,1 生产 0 预发布
+	const buildType = 1 // 打包环境对应类型,1 生产 0 预发布
 	const buildURL = buildType ? pro_URL : uat_URL // 打包后实际对应的url
 	const envText = ['预发布环境','生产环境']
 	const envTips = process.env.NODE_ENV == 'development' ? envText[0] : envText[buildType]

+ 21 - 1
components/uni-coods/uni-coods.vue

@@ -50,6 +50,10 @@
 				default: function(){
 					return []
 				}
+			},
+			hasLogin:{
+				type: Boolean,
+				default: false
 			}
 		},
 		data() {
@@ -102,7 +106,23 @@
 			},
 			// 加入购物车
 			addCart(item) {
-				this.addGoodToCart({goodsNo:item.goodsNo,buyQty:1,hasCunzai:this.hasCunzai(item)})
+				if(!this.hasLogin){
+					uni.showModal({
+					  title: '提示',
+					  content: '您尚未登录或登录已过期,请先进行登录',
+					  success (res) {
+					    if (res.confirm) {
+					      uni.navigateTo({
+					          url: '/pages/login/login'
+					      });
+					    } else if (res.cancel) {
+					      console.log('用户点击取消');
+					    }
+					  }
+					});
+				} else {
+					this.addGoodToCart({goodsNo:item.goodsNo,buyQty:1,hasCunzai:this.hasCunzai(item)})
+				}
 			},
 			// 商品详情
 			toDetail(item){

+ 4 - 4
pages/goods/index.vue

@@ -11,16 +11,16 @@
 					<view slot="right" style="color: #01c9b2;font-size: 30rpx;">更多<u-icon name="arrow-right"></u-icon></view>
 				</u-section>
 				<view class="goods-list">
-					<uni-coods :goldLimit="item.type.goldLimit" :list="item.list"></uni-coods>
+					<uni-coods :goldLimit="item.type.goldLimit" :hasLogin="hasLogin" :list="item.list"></uni-coods>
 				</view>
 			</view>
-			<view v-if="goodsListLength==0&&hasLogin">
+			<view v-if="goodsListLength==0">
 				<u-empty icon-size="60" :text="noDataText" mode="list"></u-empty>
 			</view>
-			<view class="nologin" v-if="!hasLogin"> 
+			<!-- <view class="nologin" v-if="!hasLogin"> 
 				<view>您还未登录,请登录后再浏览商品</view>
 				<u-button plain size="mini" shape="circle" @click="toLoginPage">立即登录</u-button>
-			</view>
+			</view> -->
 		</view>
 		<!-- 购物车 -->
 		<uni-cart-fix :dragPic="dragPic"></uni-cart-fix>

+ 12 - 5
pages/index/index.vue

@@ -275,9 +275,9 @@
 				let row = this.imageTopList[index]
 				console.log(index,row)
 				if(row.jumpType !== 'NONE'){
-					if(this.hasLogin){
-						// 如果是大转盘
-						if(row.jumpUrl.indexOf('pagesA/luckDraw') >= 0){
+					// 如果是大转盘
+					if(row.jumpUrl.indexOf('pagesA/luckDraw') >= 0){
+						if(this.hasLogin){
 							if(this.showFixedLottery){
 								uni.navigateTo({
 									url:row.jumpUrl
@@ -288,13 +288,20 @@
 									title: '活动已结束'
 								})
 							}
+						}else{
+							this.toLoginPage()
+						}
+					}else{
+						// 判断是否是调整tab页
+						if(row.jumpType == "TAB_PAGE"){
+							uni.switchTab({
+								url:row.jumpUrl
+							})
 						}else{
 							uni.navigateTo({
 								url: row.jumpUrl
 							})
 						}
-					}else{
-						this.toLoginPage()
 					}
 				}
 			},

+ 33 - 3
pagesA/goods/goodsDetail.vue

@@ -48,8 +48,8 @@
 		</view>
 		<!-- 底部浮动按钮 -->
 		<view class="bottom-btns" v-if="goodContent&&goodContent.inventoryQty > 0&&goodContent.state==1">
-			<view><u-button :custom-style="addCartButton" type="warning" @click="addCart">加入购物车</u-button></view>
-			<view><u-button :custom-style="toOrderButton" type="error" @click="toOrder()">立即下单</u-button></view>
+			<view><u-button :custom-style="addCartButton" type="warning" @click="checkLogin(0)">加入购物车</u-button></view>
+			<view><u-button :custom-style="toOrderButton" type="error" @click="checkLogin(1)">立即下单</u-button></view>
 		</view>
 		<!-- 购物车 -->
 		<uni-cart-fix :closeCurPage="true" :dragPic="dragPic"></uni-cart-fix>
@@ -63,6 +63,7 @@
 	import {
 		addGoodsToCart
 	} from '@/api/shoppingCart.js'
+	import {checkLogin} from '@/api/login.js'
 	import jyfParser from "@/components/jyf-parser/jyf-parser";
 	export default {
 		components: {
@@ -83,7 +84,8 @@
 				goodContent: null,
 				goldLimit: 0,
 				dragPic: '/static/cart.png',  //  购物车图标
-				userData: null
+				userData: null,
+				hasLogin: false
 			};
 		},
 		onLoad(opts) {
@@ -141,6 +143,34 @@
 				let row = list.find(item=> item.goodsTypeNo == data.goodsTypeNo)
 				return row
 			},
+			// 是否登录 flag: 0 加入购物车 1 立即下单
+			checkLogin(flag) {
+				// 是否登录
+				checkLogin().then(res => {
+					this.hasLogin = res.status == 200
+					if(this.hasLogin) {
+						if(flag) {
+							this.toOrder()
+						} else {
+							this.addCart()
+						}
+					} else {
+						uni.showModal({
+						  title: '提示',
+						  content: '您尚未登录或登录已过期,请先进行登录',
+						  success (res) {
+						    if (res.confirm) {
+						      uni.navigateTo({
+						          url: '/pages/login/login'
+						      });
+						    } else if (res.cancel) {
+						      console.log('用户点击取消');
+						    }
+						  }
+						});
+					}
+				})
+			},
 			// 加入购物车
 			addCart() {
 				let item = this.goodContent