Browse Source

盲盒页面

mr-zhou-zhou 2 năm trước cách đây
mục cha
commit
f990eb3c76

+ 2 - 23
common/mixin.js

@@ -21,27 +21,6 @@ export default{
 			return   this.userInfo && Boolean(Object.keys(this.userInfo).length > 0) && this.userInfo.id;
 		},
 		
-		// checkIsAuth(){
-		// 	return new Promise( async (resolve,reject)=>{
-		// 		if(this.userInfo.is_auth === 2){
-		// 			resolve(true);
-		// 			return;
-		// 		}
-		// 		let userInfo = await this.$store.dispatch('user/getUserInfo');
-		// 		if(userInfo.is_auth === 2){
-		// 			resolve(true);
-		// 		}else if(userInfo.is_auth === 0){
-		// 			this.$tools.msg('您尚未实名认证')
-		// 			reject(false);
-		// 		}else if(userInfo.is_auth === 1){
-		// 			this.$tools.msg('您实名认证审核中..')
-		// 			reject(false);
-		// 		}else if(userInfo.is_auth === -1){
-		// 			this.$tools.msg('您实名未通过,请重新申请')
-		// 			reject(false);
-		// 		}
-		// 	})
-		// },
 		
 		
 		/**
@@ -89,13 +68,13 @@ export default{
 			})
 			
 		},
-		goBack() {
+		goBack(delta=1) {
 			if (getCurrentPages().length < 2 && 'undefined' !== typeof __wxConfig) {
 				let url = '/' + __wxConfig.pages[0]
 				return uni.redirectTo({url})
 			}
 			uni.navigateBack({
-				delta: 1
+				delta
 			});
 		},
 		// stopPrevent(){},

+ 37 - 28
common/request/api.js

@@ -4,10 +4,9 @@
  * name:Request内做判断,url,auth,method,cacheType: local,session,isNprogress
  */
 export default {
-	/**  用户 ↓ **/
 	login:{
-		login:{
-			url:'api/user/login',
+		getPhoneNumber:{
+			url:'api/user/getPhoneNumber',
 			auth:false,
 			method:'POST',
 			isNprogress:true
@@ -18,25 +17,18 @@ export default {
 			method:'POST',
 			isNprogress:true
 		},
-		register:{
-			url:'api/user/register',
-			auth:false,
-			method:'POST',
-			isNprogress:true
-		},
-		registerAdd:{
-			url:'api/user/register',
-			auth:false,
-			method:'POST',
-			isNprogress:true
-		},
-		
-		resetpwd:{
-			url:'api/user/resetpwd',
-			auth:false,
-			method:'POST',
-			isNprogress:true
-		},
+		// register:{
+		// 	url:'api/user/register',
+		// 	auth:false,
+		// 	method:'POST',
+		// 	isNprogress:true
+		// },
+		// resetpwd:{
+		// 	url:'api/user/resetpwd',
+		// 	auth:false,
+		// 	method:'POST',
+		// 	isNprogress:true
+		// },
 		logout:{
 			url:'api/user/resetpwd',
 			auth:false,
@@ -50,20 +42,37 @@ export default {
 			isNprogress:true
 		}
 	},
-    /**  用户 ↓ **/
+
 	user:{
 		userInfo:{
-			url:'api/user/userInfo',
+			url:'api/user/info',
 			auth:false,
 			method:'POST',
-			isNprogress:true,
+			isNprogress:false,
 		},
-		getUserOpenid:{
+		getopenid:{
 			url:'api/user/getopenid',
 			auth:false,
 			method:'POST',
-			isNprogress:true,
+			isNprogress:false,
+		},
+	},
+	goods:{
+		list:{
+			url:'api/user_goods/list',
+			auth:false,
+			method:'POST',
+			isNprogress:false,
 		},
-	}
+		catelist:{
+			url:'api/user_goods/catelist',
+			auth:false,
+			method:'POST',
+			isNprogress:false
+		},
+	},
+	addr:{
+		
+	},
 	
 };

+ 46 - 1
common/tools.js

@@ -113,6 +113,50 @@ function inAction(fn, that, timeout = 2000){
 	return false;
 }
 
+function match(str, type, showMsg=true){
+	let exp = '';
+	switch(type){
+		case 'mobile':
+			if(str === ''){
+				showMsg && msg('请填写手机号码');
+				return false;
+			}
+			exp = /(^1[3|4|5|6|7|8|9][0-9]{9}$)/; //手机号
+			if(!exp.test(str)){
+				showMsg && msg('手机号码格式不正确');
+				return false;
+			}
+			break;
+		case 'pwd':
+			if(str === ''){
+				showMsg && msg('请填写密码');
+				return false;
+			}
+			//必须加break; 否则pwd校验正确后会进入 case 'code'
+			break;
+		case 'code':
+				if(str === ''){
+					showMsg && msg('请填写验证码');
+					return false;
+				}
+				if(!/^[0-9]+$/.test(str)){
+					showMsg && msg('验证码不正确');
+					return false;
+				}
+			break;
+		case 'idcard':
+				if(str === ''){
+					showMsg && msg('请填写身份证号码');
+					return false;
+				}
+				if(!/^(\d{17}[\d|x|X]|\d{15})$/.test(str)){
+					showMsg && msg('请输入正确身份证号');
+					return false;
+				}
+			break;
+	}
+	return true;
+}
 
 // 返回上一页
 const prePage = (num=1) => {
@@ -365,5 +409,6 @@ export default {
 	checkDeviceAuthorize,
 	replaceDetail,
 	handleDate,
-	handleDateTime
+	handleDateTime,
+	match
 }

+ 14 - 14
pages.json

@@ -18,20 +18,20 @@
                 "navigationStyle": "custom"
             }
         },
-		{
-		    "path" : "pages/login/register",
-		    "style" :                                                                                    
-		    {
-		        "navigationBarTitleText": "注册"
-		    }
-		},
-		{
-		    "path" : "pages/login/forget",
-		    "style" :                                                                                    
-		    {
-		        "navigationBarTitleText": ""
-		    }
-		},
+		// {
+		//     "path" : "pages/login/register",
+		//     "style" :                                                                                    
+		//     {
+		//         "navigationBarTitleText": "注册"
+		//     }
+		// },
+		// {
+		//     "path" : "pages/login/forget",
+		//     "style" :                                                                                    
+		//     {
+		//         "navigationBarTitleText": ""
+		//     }
+		// },
 		{
 		    "path" : "pages/login/mobileLogin",
 		    "style" :                                                                                    

+ 4 - 7
pages/home/home.vue

@@ -1,7 +1,7 @@
 <template>
 	<view class="page">
 		<navbar-line>
-			<image src="" mode="" class="logo"></image>
+			<image src="/static/home_logo.png" mode="widthFix" class="logo"></image>
 		</navbar-line>
 		<view class="content">
 			
@@ -32,13 +32,10 @@ page{
 }
 
 	.logo{
-		width: 141rpx;
-		height: 36rpx;
-		font-size: 34rpx;
+		width: 60rpx;
+		height: 60rpx;
 		font-family: PingFang SC;
-		font-weight: bold;
-		background-color: #333333;
-		line-height: 37rpx;
+		
 		margin-left: 30rpx;
 		position: absolute;
 		top: 50%;

+ 1 - 1
pages/login/components/phoneCode.vue

@@ -62,7 +62,7 @@ export default {
 		    }
 		    this.isCountDown=true;
 		    try{
-		        await this.$request('user.sms',{mobile:this.mobile,event:this.event});
+		        await this.$request('login.sms',{mobile:this.mobile,event:this.event});
 		    }catch(err){
 				// console.log('err---',err)
 				this.$tools.msg(err.msg || '请求失败')

+ 0 - 0
pages/login/forget.vue → pages/login/forget-删除.vue


+ 20 - 5
pages/login/login.vue

@@ -1,10 +1,10 @@
 <template>
 	<view class="page align-center flex-col">
-	    <view class="header-sec align-center flex-col">
-			<image src="" mode="" class="logo"></image>
+	    <view class="header-sec align-center flex-col justify-center">
+			<image src="/static/log_logo.png" mode="widthFix" class="logo"></image>
 			<text class="txt">盲go小程序</text>
 		</view>
-		<view class="btn-auth">微信用户一键登录</view>
+		<button open-type="getPhoneNumber"  class="btn-auth" @getphonenumber="getphonenumber">微信用户一键登录</button>
 		<view class="btn-mobile" @tap="navTo('/pages/login/mobileLogin')">手机号码登录</view>
 	</view>
 </template>
@@ -19,6 +19,21 @@
 	    async onLoad() {
 	    	
 	    },
+		methods:{
+			async getphonenumber(e){
+				if(!e.detail.code){
+					return;
+				}
+				// this.code = e.detail.code
+				let res  = await this.$request('login.getPhoneNumber',{code:e.detail.code});
+				uni.setStorageSync("token",res.data.userinfo.token);
+				this.$store.dispatch('userInfo/getinfo');
+				this.$tools.msg(res.msg);
+				setTimeout(()=>{
+					this.goBack();
+				},800)
+			}
+		}
 	}
 </script>
 
@@ -33,8 +48,8 @@ page{
 	.logo{
 		width: 180rpx;
 		height: 180rpx;
-		border-radius: 180rpx;
-		background-color: $base-color;
+		// border-radius: 180rpx;
+		// background-color: $base-color;
 	}
 	.txt{
 		margin-top: 33rpx;

+ 28 - 37
pages/login/mobileLogin.vue

@@ -1,7 +1,8 @@
 <template>
 	<view class="page">
 		<view class="p-header flex-col align-center justify-center">
-			<image src="/static/login_logo.png" mode="widthFix" class="img"></image>
+			<image src="/static/log_logo.png" mode="widthFix" class="img"></image>
+			<text class="txt">盲go小程序</text>
 			<!-- <image src="/static/home_logo.png" mode="widthFix" class="ic"></image> -->
 		</view>
 		
@@ -13,19 +14,20 @@
 				</view>
 			</view>
 			
-			<view class="c-item align-center ">
+			<view class="c-item align-center last-c-item">
 				<image src="/static/log_yan.png" mode="widthFix" class="i-ic"></image>
 				<view class="i-inpt">
 					<input type="number" class="inpt" placeholder="请输入验证码" v-model="code"/>
 				</view>
 				<view class="code-wrap" @tap="chgeCode">
-					<phoneCode ref="codeRef" :mobile="mobile" event="register" />
+					<phoneCode ref="codeRef" :mobile="mobile" event="mobilelogin" />
 				</view>
 			</view>
+			<!-- 
 			<view class="c-pwd last-c-item" @tap="navTo('/pages/login/forget')">
 				忘记密码?
 			</view>
-			
+			 -->
 			<!-- 
 			<view class="c-item align-center last-c-item">
 				<image src="/static/log_yao.png" mode="widthFix" class="i-ic"></image>
@@ -35,7 +37,6 @@
 			</view>
 			 -->
 		</view>
-		
 		<submit-btn @submit="submit" ref="submitRef">
 			<template v-slot:btns="{isSubmitted}">
 				<view class="p-btn" :class="{'disabled':isSubmitted}">
@@ -43,13 +44,12 @@
 				</view>
 			</template>
 		</submit-btn>
-		<view class="p-reg" @tap="navTo('/pages/login/register')">
-			
-		</view>
+		<!-- 
 		<view class="p-login" @tap="navTo('/pages/login/register')">
 			<text class="stxt">还没有账号,请点击</text>
 			<text class="mtxt">注册</text>
 		</view>
+		 -->
 	</view>
 </template>
 
@@ -64,9 +64,9 @@
 				// isAgree:true,
 				mobile:'',
 				code:'',
-				password:'',
-				repassword:'',
-				invite_no:'',
+				// password:'',
+				// repassword:'',
+				// invite_no:'',
 			};
 		},
 		onLoad(opt) {
@@ -91,30 +91,19 @@
 					return;
 				}else if(!this.$tools.match(this.code,'code') ){
 					return;
-				}else if(!this.$tools.match(this.password,'pwd') ){
-					return;
-				}else if(!this.repassword){
-					this.$tools.msg('请输入确认密码')
-					return;
-				}else if( this.repassword !== this.password){
-					this.$tools.msg('两次密码不一致')
-					return;
 				}
-				
 				let sendData={
 					mobile:this.mobile,
 					code:this.code,
-					password: this.password,
-					repassword: this.repassword,
-					invite_no: this.invite_no,
+					user_type: 1,
 				}
-				let res=await this.$request('user.register',sendData);
-				// let userInfo = res.data.userinfo || {};
-				// localStorage.setItem('token',userInfo.token)
+				let res=await this.$request('login.mobilelogin',sendData);
+				let userInfo = res.data.userinfo || {};
+				uni.setStorageSync("token",userInfo.token);
 				this.$tools.msg(res.msg);
 				this.$refs.submitRef.chgeStatus();
 				setTimeout(()=>{
-					this.navTo('/pages/login/login')
+					this.goBack(2)
 				},800)
 			},
 		},
@@ -136,16 +125,18 @@
 		height: 400rpx;
 		position: relative;
 		.img{
-			// width: 160rpx;
-			// height: 160rpx;
-			width: 300rpx;
-			height: 300rpx;
+			width: 180rpx;
+			height: 180rpx;
+			// border-radius: 180rpx;
+			// background-color: $base-color;
+		}
+		.txt{
+			margin-top: 33rpx;
+			font-size: 28rpx;
+			font-family: PingFang SC;
+			font-weight: 500;
+			color: #92B99C;
 		}
-		// .ic{
-		// 	margin-top: 16rpx;
-		// 	width: 112rpx;
-		// 	height: 38rpx;	
-		// }
 	}
 	.p-form{
 		width: 630rpx;
@@ -209,7 +200,7 @@
 	
 	}
 	.last-c-item{
-		margin-bottom: 40rpx !important;
+		margin-bottom: 100rpx !important;
 	}
 	.p-btn{
 		margin: 0 auto;

+ 0 - 0
pages/login/register.vue → pages/login/register-删除.vue


+ 1 - 12
pages/mang/components/zetank-notice.vue

@@ -15,18 +15,7 @@ export default {
   data() {
     return {};
   },
-  props: {
-	noticeList:{
-	  type:Array,
-	  default(){
-		  return [{id:0,title:"暂无"}]
-	  }
-	},
-	interval:{
-		type:Number,
-		default:5000
-	},
-  },
+  props: ['noticeList','interval'],
   methods: {
 	  clickNotice(e){
 		  this.$emit('clickNotice',e)

+ 101 - 74
pages/mang/mang.vue

@@ -1,7 +1,7 @@
 <template>
 	<view class="page">
 		<navbar-line :bgColor="bgColor" :hasPlacer="false">
-			<view class="header-loc  align-center" @tap="chooseLoc">
+			<view class="header-loc  align-center" @tap="navTo('/pages/address/address')">
 				<image src="/static/mang-loc.png" class="image_19" mode="aspectFill" />
 				<text class="text_43">沂蒙云谷·创意孵化中心</text>
 			</view>
@@ -13,95 +13,42 @@
 			<view class="group_20"><zetank-notice colors="#55aaff" :noticeList="ads" :interval="3000"></zetank-notice></view>
 		</view>
 		<view class="p-entry">
-			<view class="flex-col items-center grid-item">
+			<view class="flex-col items-center grid-item" v-for="(item,i) in cats" :key="i">
 				<image
-					src="/static/mang-dianxin.png"
+					:src="item.cate_logo"
 					class="image"
+					mode="aspectFill"
 				/>
-				<text class="text">点心</text>
-			</view>
-			<view class="flex-col items-center grid-item">
-				<image
-					src="/static/mang-dangao.png"
-					class="image"
-				/>
-				<text class="text">蛋糕</text>
-			</view>
-			<view class="flex-col items-center grid-item">
-				<image
-					src="/static/mang-buding.png"
-					class="image"
-				/>
-				<text class="text">布丁</text>
-			</view>
-			<view class="flex-col items-center grid-item">
-				<image
-					src="/static/mang-pdangao.png"
-					class="image"
-				/>
-				<text class="text">纸杯蛋糕</text>
-			</view>
-			<view class="flex-col items-center grid-item">
-				<image
-					src="/static/mang-pisa.png"
-					class="image"
-				/>
-				<text class="text">披萨</text>
-			</view>
-			<view class="flex-col items-center grid-item">
-				<image
-					src="/static/mang-tusi.png"
-					class="image"
-				/>
-				<text class="text">吐司</text>
-			</view>
-			<view class="flex-col items-center grid-item">
-				<image
-					src="/static/mang-all.png"
-					class="image"
-				/>
-				<text class="text">全部</text>
+				<text class="text">{{item.cate_name}}</text>
 			</view>
 		</view>
 	
 	    <view class="p-tabs align-center justify-between">
-			  <view class="flex-col text-wrapper">
+			  <view class="flex-col text-wrapper" :class="{active: i === tabCurrentIndex}" 
+			   v-for="(item,i) in tabs" :key="i"  @tap="tapTab(i)"
+			  >
 				   <image
 					  src="/static/mang-tabbg.png"
 					  class="image_8"
 				   />
-				  <text class="text_9">智能排序</text>
-			  </view>
-			  <view class="flex-col text-wrapper active">
-				  <image
-					  src="/static/mang-tabbg.png"
-					  class="image_8"
-				  />
-				  <text class="text_9">距离最近</text>
+				  <text class="text_9">{{item.name}}</text>
 			  </view>
-			  <view class="flex-col text-wrapper">
-				  <image
-					  src="/static/mang-tabbg.png"
-					  class="image_8"
-				  />
-				  <text class="text_9">评分最高</text>
-			 </view>
 		</view>
 		
 		<view class="p-list">
-			<view class="flex-row section_2 view_6" v-for="(item,idx) in 3" :key="idx" @tap="navTo('/pages/mang/detail')">
+			<view class="flex-row section_2 view_6" v-for="(item,idx) in tabs[tabCurrentIndex].list" :key="idx" @tap="navTo('/pages/mang/detail')">
 			  <image
-			    src="/static/temp/pro.png"
+			    :src="item.goods_img"
 			    class="group_11"
 				mode="aspectFill"
 			  />
 			  <view class="flex-col text_21 view_7">
-			    <text class="text_25 clamp">稻香村糕点随机盲盒</text>
+			    <text class="text_25 clamp">{{item.goods_name}}</text>
 				<view class="stars align-center">
 					 <image
 					  src="/static/mang_star.png"
 					  class="image_14"
-					  v-for="(item,idx) in 3"
+					  v-for="(item,idx) in item.rank"
 					  :key="idx"
 					/>	
 				</view>
@@ -109,13 +56,13 @@
 			    <view class="flex-row group_16">
 			      <view class="group_17">
 			        <text class="text_27">¥</text>
-			        <text class="text_28">38.8</text>
+			        <text class="text_28">{{item.shop_price}}</text>
 			      </view>
-			      <text class="text_29">¥44~68</text>
+			      <text class="text_29">¥{{item.market_price}}</text>
 			    </view>
 			  </view>
-			  <text class="text_30">898m</text>
-			  <view class="flex-col text-wrapper_2"><text class="text_23 text_31 clamp">仅剩3份</text></view>
+			  <text class="text_30" v-if="item.distance">{{item.distance}}</text>
+			  <view class="flex-col text-wrapper_2"><text class="text_23 text_31 clamp">仅剩{{item.num}}份</text></view>
 			</view>
 		</view>
 		
@@ -133,8 +80,18 @@ export default {
 	},
 	data() {
 		return {
-			ads: [{ title: '1已帮助减少2486g数量的食品浪费' }, { title: '2已帮助减少2486g数量的食品浪费' }],
+			ads: [],
 			bgColor:'transparent',
+			cats:[
+				{img:'/static/mang-all.png',name:'全部'},
+			],
+			tabCurrentIndex: 0,
+			tabs:[
+				{name:'智能排序',type:1,loadingType: 'more', list: [], page: 1,loaded:false},
+				{name:'距离最近',type:2,loadingType: 'more', list: [], page: 1,loaded:false},
+				{name:'评分最高',type:3,loadingType: 'more', list: [], page: 1,loaded:false},
+			],
+			pageSize: 20,
 		};
 	},
 	onPageScroll(e) {
@@ -146,10 +103,80 @@ export default {
 			this.bgColor = "transparent";
 		}
 	},
+	onShow() {
+		this.getList('refresh')
+		this.getCats();
+		this.getAds();
+	},
+	onPullDownRefresh() {
+		this.getList('refresh')
+		this.getCats();
+		this.getAds();
+	},
+	onReachBottom() {
+		this.getList()
+	},
 	methods:{
-		async chooseLoc(){
-			this.navTo('/pages/address/address')
-		}
+		getAds(){
+			this.ads=[{ title: '1已帮助减少2486g数量的食品浪费' }, { title: '2已帮助减少2486g数量的食品浪费' }]
+		},
+		async getCats(){
+			let res = await this.$request('goods.catelist')
+			let cats =res.data || [];
+			this.cats = cats.slice(0,7);
+			this.cats.push({cate_logo:'/static/mang-all.png',cate_name:'全部'})
+		},
+		async getList(source){
+			//这里是将订单挂载到tab列表下
+			let index = this.tabCurrentIndex;
+			let navItem = this.tabs[index];
+			if (source === 'refresh') {
+				if(navItem.loadingType == 'loading'){
+					return;
+				}
+				navItem.loadingType = 'more';
+				navItem.page=1;
+				navItem.list=[];
+				navItem.loaded=false;
+			}
+			if (navItem.loadingType === 'loading' || navItem.loadingType == 'noMore') {
+				//防止重复加载
+				return;
+			}
+			navItem.loadingType = 'loading';
+			let res = await this.$request('goods.list',{
+				sort_type:navItem.type,
+				page: navItem.page,
+				limit: this.pageSize
+			});
+			uni.stopPullDownRefresh();
+			let result = res.data.row || [];
+			if ( this.pageSize > result.length) {
+				navItem.loadingType = 'noMore';
+			} else {
+				navItem.loadingType = 'more';
+			}
+			// 页数加一
+			navItem.page++;
+			navItem.loaded = true;
+			if(source === 'refresh'){
+				navItem.page=2;
+				navItem.list = result;
+				return;
+			}
+			result.forEach(item => {
+				navItem.list.push(item);
+			});
+		},
+		tapTab(idx){
+			if(idx === this.tabCurrentIndex){
+				return;
+			}
+			this.tabCurrentIndex = idx;
+			this.getList('refresh');
+		},
+		
+		
 	}
 };
 </script>

BIN
static/home_logo.png


BIN
static/log_logo.png


+ 0 - 0
static/mang-buding.png → static/temp/mang-buding.png


+ 0 - 0
static/mang-dangao.png → static/temp/mang-dangao.png


+ 0 - 0
static/mang-dianxin.png → static/temp/mang-dianxin.png


+ 0 - 0
static/mang-pdangao.png → static/temp/mang-pdangao.png


+ 0 - 0
static/mang-pisa.png → static/temp/mang-pisa.png


+ 0 - 0
static/mang-tusi.png → static/temp/mang-tusi.png