Browse Source

dev usercenter and logs

liguorui 7 years ago
parent
commit
5b613ecec6

+ 2 - 1
app.json

@@ -7,7 +7,8 @@
     "pages/logs/logs",
     "pages/shop/shop",
     "pages/sell/sell",
-    "pages/cardetail/cardetail"
+    "pages/cardetail/cardetail",
+    "pages/usercenter/usercenter"
   ],
   "window":{
     "navigationBarBackgroundColor": "#fede18",

+ 3 - 0
app.wxss

@@ -1,4 +1,7 @@
 /**app.wxss**/
+page{
+  font-family: "NotoSansHans-Medium";
+}
 .container {
   height: 100%;
   display: flex;

+ 4 - 1
common/pathmap.js

@@ -16,5 +16,8 @@ export default{
   "cardetail":"/api/car_detail",           //获取车辆详情
   "getbrand":"/api/brand_list",
   "serieslist":"/api/series_list",
-  "collect":"/api/collect"
+  "collect":"/api/collect",
+  "login":"/api/login",
+  "yzm":"/api/get_yzm",
+  "logout":"/api/logout"
 }

+ 24 - 27
common/request.js

@@ -37,33 +37,30 @@ export const get=(url,data,callback,failback)=>{
   })
 } 
 export const post=(url,data,header,callback,failback)=>{
+  var authorization = wx.getStorageSync("authorization")
+  if(typeof header=="function"){
+    failback = callback;
+    callback = header;
+    header = {};
+  }
   addnum();
-  if(app.globalData.Authorization){
-    if(typeof header=="function"){
-      failback = callback;
-      callback = header;
-      header = {};
+  wx.request({
+    url: app.globalData.serverpath+url,
+    method: "POST",
+    header: Object.assign({
+      "Content-Type": "json",
+      "Authorization":authorization
+    },header),
+    data:data,
+    success: function (res){
+      //console.debug(res);
+      callback && callback(res);
+    },
+    fail: function (error){
+      failback && failback(error);
+    },
+    complete: function () {
+      reducenum();
     }
-    wx.request({
-      url: app.globalData.serverpath+url,
-      method: "POST",
-      header: Object.assign({
-        "Content-Type": "json",
-        "Authorization":app.globalData.Authorization
-      },header),
-      data:data,
-      success: function (res){
-        //console.debug(res);
-        callback && callback(res);
-      },
-      fail: function (error){
-        failback && failback(error);
-      },
-      complete: function () {
-        reducenum();
-      }
-    })
-  }else{
-
-  }
+  })
 } 

BIN
img/close.png


BIN
img/mybuy.png


BIN
img/mycollect.png


BIN
img/mysuggest.png


BIN
img/usercenter.png


+ 1 - 1
module/footer.wxml

@@ -49,7 +49,7 @@
     <view class="page_footer_item">
       <navigator 
         class='page_footer_navs'
-        url="../../pages/my/my"
+        url="../../pages/usercenter/usercenter"
       >
         <image
           src="../../img/footer_home{{local==3?'_active':''}}.png"

+ 123 - 0
module/logs/logs.js

@@ -0,0 +1,123 @@
+import { get,post } from "../../common/request.js"
+import pathmap from "../../common/pathmap"
+
+var app = getApp();	
+const logs = {
+	openLog:function(){
+		this.setData({openlog:true});
+	},
+	closeLog:function(){
+		this.setData({openlog:false});
+	},
+	phoneInput:function(e){
+		var number = e.detail.value;
+		var newdata = {mobilenumber:number};
+		if(number.length==11){
+			if(/^[1][3|4|5|6|7|8|9][0-9]{9}$/.test(number)){
+				if(this.data.codebtword=="获取验证码"){
+					//this.setData({,codeenable:true})
+					newdata.codeenable = true
+				}
+			}else{
+				wx.showToast({
+					title:"输入手机号不合法!",
+					duration:1000,
+					icon:"none"
+				})
+			}
+		}
+		this.setData(newdata)
+	},
+	codeInput:function(e){
+		var code =  e.detail.value;
+		this.setData({logcode:code});
+	},
+	getCode:function(){
+		var _self = this;
+		if(this.data.codeenable){
+			get(pathmap.yzm,{mobile:this.data.mobilenumber},function(json){
+				if(json.data.code=="验证码已发送"){
+					wx.showToast({
+						title:"验证码已发送!"
+					})
+					_self.startTimeing();
+				}else{
+					wx.showToast({
+						title:json.data.message,
+						icon:"none"
+					})
+				}
+			})
+			//_self.startTimeing();
+		}
+	},
+	startTimeing:function(){
+		var length = 60;
+		var _self = this;
+		this.timeingtool = setInterval(function(){
+			length--;
+			if(length>=0){
+				_self.setData({codebtword:length+"s"});
+			}else{
+				_self.endTimeing();
+			}
+		},1000)
+		this.setData({codeenable:false,logenable:true});
+	},
+	endTimeing:function(){
+		try{
+			clearTimeout(this.timeingtool);
+		}catch(e){}
+		if(/^[1][3|4|5|6|7|8|9][0-9]{9}$/.test(this.data.mobilenumber)){
+			this.setData({codeenable:true,codebtword:"获取验证码"})
+		}else{
+			this.setData({codeenable:false,codebtword:"获取验证码"})
+		}
+	},
+	logIn:function(){
+		var _self = this;
+		if(this.data.logenable){
+			wx.request({
+				url: app.globalData.serverpath+pathmap.login,
+			    method: "POST",
+			    header:{
+			      "Content-Type": "application/x-www-form-urlencoded"
+			  	},
+			    data:{
+			    	mobile:this.data.mobilenumber,
+			    	code:this.data.logcode
+			    },
+			    success: function (res){
+			    	//app.globalData.Authorization = res.data.authorization;
+			    	if(res.data.authorization){
+			    		_self.closeLog();
+				    	try{
+				    		wx.setStorageSync("mobile",_self.data.mobilenumber);
+				    		wx.setStorageSync("authorization",res.data.authorization);
+				    	}catch(e){
+
+				    	}
+				    	_self.endTimeing();
+				    	if(typeof _self.data.loginback=="function"){
+				    		_self.data.loginback();
+				    	}
+				    }else{
+				    	wx.showToast({
+				    		title:res.data.message,
+				    		icon:"none"
+				    	})
+				    }
+			    },
+			    fail: function (error){
+			      
+			    }
+			})
+		}
+	}
+}
+
+const bindLogs = function(pages){
+	pages.setData({openlog:false,codeenable:false,logenable:false,codebtword:"获取验证码",mobilenumber:""});
+	Object.assign(pages,logs);
+}
+export default bindLogs;

+ 31 - 2
module/logs/logs.wxml

@@ -1,7 +1,11 @@
-<view class="logs_content">
+<view 
+	class="logs_content"
+	style="left:{{openlog?'0rpx':'100%'}};"
+>
 	<image 
 		class="logs_back"
 		bindtap="closeLog"
+		src="../../img/close.png"
 	/>
 	<view class="logs_welcome">
 		欢迎来到第一好车
@@ -9,9 +13,34 @@
 	<view class="logs_welcome_withoutlog">
 		无需注册,急速登录
 	</view>
-	<view>
 	<input 
 		class="logs_phone_num"
+		type="text"
+		confirm-type="done"
+		placeholder="请输入手机号"
+		placeholder-class="logplaceh"
+		bindinput="phoneInput"
 	/>
+	<view class="logs_code_c">
+		<input 
+			class="logs_code_num"
+			type="text"
+			confirm-type="done"
+			placeholder="短信验证码"
+			placeholder-class="logplaceh"
+			maxlength="11"
+			bindblur="codeInput"
+		/>
+		<view 
+			class="get_code_bt {{codeenable?'active':''}}"
+			bindtap="getCode"
+		>{{codebtword}}</view>
+	</view>
+
+	<view 
+		class="logs_sub_b {{logenable?'active':''}}"
+		bindtap="logIn"
+	>
+		登陆
 	</view>
 </view>

+ 86 - 0
module/logs/logs.wxss

@@ -0,0 +1,86 @@
+.logs_content{
+	position: fixed;
+	top: 0rpx;
+	width:100%;
+	height:100%;
+	background-color: rgba(56,55,53,0.7);
+}
+
+.logs_back{
+	width: 30rpx;
+	height: 30rpx;
+	margin-top:60rpx;
+	margin-left:60rpx;
+}
+.logs_welcome{
+	margin:117rpx 0rpx 0rpx 85rpx;
+	line-height: 75rpx;
+	color: rgba(255, 255, 255, 1);
+	font-size: 50rpx;
+	font-family: NotoSansHans-Medium;
+}
+.logs_welcome_withoutlog{
+	margin-left:85rpx;
+	line-height: 42rpx;
+	color: rgba(183, 183, 183, 1);
+	font-size: 28rpx;
+	font-family: NotoSansHans-DemiLight;
+}
+.logs_phone_num{
+	width:674rpx;
+	border-bottom: 1px solid rgba(104, 104, 104, 1);
+	margin:48rpx auto 0rpx;
+	height: 88rpx;
+	line-height: 88rpx;
+	color:white;
+	font-size: 28rpx;
+	font-family: NotoSansHans-DemiLight;
+	padding-left:47rpx;
+}
+.logs_code_c{
+	width:674rpx;
+	border-bottom: 1px solid rgba(104, 104, 104, 1);
+	margin:38rpx auto 0rpx;
+	height: 88rpx;
+	color:white;
+	line-height: 88rpx;
+	font-size: 28rpx;
+	font-family: NotoSansHans-DemiLight;
+	display: flex;
+	padding-left:47rpx;
+}
+.logs_code_num{
+	height: 88rpx;
+	flex: 1;
+}
+.logplaceh{	
+	color: rgba(183, 183, 183, 1);
+}
+.get_code_bt{
+	width: 186rpx;
+	height: 57rpx;
+	line-height: 57rpx;
+	border-radius: 6rpx;
+	background-color: rgba(183, 183, 183, 1);
+	color:white;
+	text-align: center;
+}
+.get_code_bt.active{
+	background-color: #FFE600;
+	color: rgba(56, 55, 53, 1);
+}
+.logs_sub_b{
+	margin:76rpx auto 0rpx;
+	width: 620rpx;
+	height: 88rpx;
+	line-height: 88rpx;
+	border-radius: 6rpx;
+	background: linear-gradient(270deg,#FFD800,#FFE600);
+	text-align: center;
+	color: rgba(56, 55, 53, 0.2);
+	font-size: 32rpx;
+	font-family: NotoSansHans-Medium;
+}
+.logs_sub_b.active{
+	color:#383735;
+}

+ 23 - 12
pages/cardetail/cardetail.js

@@ -1,16 +1,21 @@
 // pages/cardetail/cardetail.js
 
 
-import { get } from "../../common/request.js"
+import { get,post } from "../../common/request.js"
 import pathmap from "../../common/pathmap"
 import stylemap from "../../common/stylemap"
 import { retCartData } from "../../data/car"
+import bindLog from "../../module/logs/logs"
+
+const app = getApp();
+
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
+    windowh: app.globalData.windowh,
     collocatetype:[{
       label:"基本参数",
       name:"jiben"
@@ -46,8 +51,9 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    this.setData(stylemap);
-    this.getDetail(options.id);
+    this.setData(Object.assign({id:options.id},stylemap));
+    this.getDetail();
+    bindLog(this);
   },
 
   /**
@@ -98,9 +104,9 @@ Page({
   onShareAppMessage: function () {
   
   },
-  getDetail:function(id){
+  getDetail:function(){
     var _self=this;
-    get(pathmap.cardetail,{id:id},function(json){
+    get(pathmap.cardetail,{id:this.data.id},function(json){
       var detail = json.data;
       var time = detail.first_plate_at.split('-');
       /*数据结构处理*/
@@ -112,8 +118,7 @@ Page({
       })
 
       _self.setData({
-        detail:detail,
-        id:id
+        detail:detail
       })
     })
   },
@@ -139,10 +144,16 @@ Page({
     this.setData({collocatetype:collocatetype});
   },
   collectCar:function(){
-    post(pathmap.collect,{
-      id:this.data.id
-    },function(json){
-      
-    })
+    var authorization = wx.getStorageSync("authorization");
+    if(authorization){
+      post(pathmap.collect,{
+        id:this.data.id
+      },function(json){
+        
+      })
+    }else{
+      this.openLog();
+      //setData({openlog:true});
+    }
   }
 })

+ 8 - 5
pages/cardetail/cardetail.wxml

@@ -2,8 +2,8 @@
 <import src="../../module/header.wxml"/>
 <scroll-view 
   class="conent"
-  style="height:{{windowh}}rpx;"
-  scroll-y="{{selectbar==''?'true':'false'}}"
+  style="height:{{windowh}}rpx;{{openlog?'filter: blur(5rpx)':''}}"
+  scroll-y="{{openlog?'false':'true'}}"
 >
 	<template 
 		is="header"
@@ -187,10 +187,12 @@
 		</view>
 	</view>
 	<view class="cardetail_op_list">
-		<view class="cardetail_op_collect">
+		<view 
+			class="cardetail_op_collect"
+			bindtap="collectCar"			
+		>
 			<image 
 				src="../../img/uncollect.png"
-				bindtap="collectCar"
 			/>
 			<view>收藏</view>
 		</view>
@@ -206,4 +208,5 @@
 			分期购车
 		</view>
 	</view>
-</scroll-view>
+</scroll-view>
+<include src="../../module/logs/logs.wxml"/>

+ 2 - 0
pages/cardetail/cardetail.wxss

@@ -1,4 +1,6 @@
 /* pages/cardetail/cardetail.wxss */
+
+@import "../../module/logs/logs.wxss"
 .conent{
 	background-color:#F9F9F9;
 }

+ 3 - 2
pages/index/index.wxss

@@ -110,7 +110,7 @@
 .brand_r{
   display: flex;
   flex-wrap:wrap;
-  margin: 0rpx -4rpx 4rpx;
+  margin: 0rpx -2rpx 2rpx;
 }
 .brand_item_b{  
   height: 150rpx;
@@ -119,7 +119,8 @@
 }
 .brand_item{
   background: white;
-  margin:4px 4px 0px 0px;
+  height: 148rpx;
+  margin:2rpx 2rpx 0px 0px;
 }
 .brand_item_link{
   text-align: center;

+ 83 - 0
pages/usercenter/usercenter.js

@@ -0,0 +1,83 @@
+// pages/usercenter/usercenter.js
+
+import bindLog from "../../module/logs/logs"
+
+var app = getApp();
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {  
+    windowh: app.globalData.windowh
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {    
+    bindLog(this);
+    try{
+      var number = wx.getStorageSync("mobile");
+    }catch(e){
+
+    }
+    if(!number){      
+      this.openLog();
+    }else{      
+      var numbers = number.split("");
+      numbers.splice(3,4,"****");
+      number = numbers.join("");
+      this.setData({phonenumber:number});
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+  
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+  
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+  
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+  
+  }
+})

+ 1 - 0
pages/usercenter/usercenter.json

@@ -0,0 +1 @@
+{}

+ 36 - 0
pages/usercenter/usercenter.wxml

@@ -0,0 +1,36 @@
+<!--pages/usercenter/usercenter.wxml-->
+<import src="../../module/footer.wxml"/>
+<view 
+	class="content"
+	style="height:{{windowh}}rpx;"
+>
+	<view class="usercenter_top_b">
+		<view class="usercenter_top_w">用户中心</view>
+		<image class="usercenter_top_img" src="../../img/usercenter.png"/>
+		<view class="usercenter_top_p">{{phonenumber}}</view>
+	</view>
+	<view class="usercenter_op_list">
+		<navigator class="usercenter_op_i">
+			<image class="usercenter_op_img" src="../../img/mycollect.png"/>
+			<view class="usercenter_op_w">我的收藏</view>
+			<image class="usercenter_op_bt" src="../../img/right.png"/>
+		</navigator>
+
+		<navigator class="usercenter_op_i">
+			<image class="usercenter_op_img" src="../../img/mybuy.png"/>
+			<view class="usercenter_op_w">我买的车</view>
+			<image class="usercenter_op_bt" src="../../img/right.png"/>
+		</navigator>
+
+		<navigator class="usercenter_op_i">
+			<image class="usercenter_op_img" src="../../img/mysuggest.png"/>
+			<view class="usercenter_op_w">意见反馈</view>
+			<image class="usercenter_op_bt" src="../../img/right.png"/>
+		</navigator>
+	</view>
+	<template 
+      is="footer" 
+      data="{{local:3}}"
+    /> 
+</view>
+<include src="../../module/logs/logs.wxml"/>

+ 63 - 0
pages/usercenter/usercenter.wxss

@@ -0,0 +1,63 @@
+/* pages/usercenter/usercenter.wxss */
+
+@import "../../module/logs/logs.wxss"
+.content{
+  background-color:#F9F9F9;
+}
+.usercenter_top_b{
+	width: 750rpx;
+	height: 398rpx;
+	background:linear-gradient(270deg,#FFD800,#FFE600);
+	overflow: hidden;
+}
+.usercenter_top_w{
+	margin-top: 55px;
+	height: 54rpx;
+	line-height: 54rpx;
+	color: rgba(56, 55, 53, 1);
+	font-size: 36rpx;
+	text-align: center;
+	font-family: NotoSansHans-Medium;
+}
+.usercenter_top_img{
+	margin: 50rpx auto 0rpx;
+	display: block;
+	width: 134rpx;
+	height: 134rpx;
+}
+.usercenter_top_p{
+	height: 54rpx;
+	line-height: 65rpx;
+	color: rgba(56, 55, 53, 1);
+	font-size: 36rpx;
+	text-align: center;
+	font-family: NotoSansHans-Medium;
+}
+.usercenter_op_list{
+	margin-top: 20rpx;
+	background-color: white;
+}
+.usercenter_op_i{
+	height: 98rpx;
+	line-height: 98rpx;
+	color: rgba(56, 55, 53, 1);
+	font-size: 28rpx;
+	font-family: NotoSansHans-DemiLight;
+}
+.usercenter_op_img{
+	width:34rpx;
+	height: 34rpx;
+	margin-left: 30rpx;
+	display: inline-block;
+}
+.usercenter_op_w{
+	margin-left: 5rpx;
+	display: inline;
+}
+.usercenter_op_bt{
+	float: right;
+	margin-right: 43rpx;
+	margin-top:38rpx;
+	width: 22rpx;
+	height: 22rpx;
+}