Parcourir la source

dev usercenter subpage

liguorui il y a 6 ans
Parent
commit
573eff75b1

+ 4 - 1
app.json

@@ -1,6 +1,8 @@
 {
   "pages":[
+    "pages/mysuggest/mysuggest",
     "pages/index/index",
+    "pages/collect/collect",
     "pages/buy/buy",
     "pages/search/search",
     "pages/searchresult/searchresult",
@@ -8,7 +10,8 @@
     "pages/shop/shop",
     "pages/sell/sell",
     "pages/cardetail/cardetail",
-    "pages/usercenter/usercenter"
+    "pages/usercenter/usercenter",
+    "pages/mybuy/mybuy"
   ],
   "window":{
     "navigationBarBackgroundColor": "#fede18",

+ 5 - 1
common/pathmap.js

@@ -17,7 +17,11 @@ export default{
   "getbrand":"/api/brand_list",
   "serieslist":"/api/series_list",
   "collect":"/api/collect",
+  "collectdel":"/api/collect_del",
   "login":"/api/login",
   "yzm":"/api/get_yzm",
-  "logout":"/api/logout"
+  "logout":"/api/logout",
+  "collectlist":"/api/collect_list",
+  "orderlist":"/api/order_list",
+  "feedback":"/api/feedback"
 }

+ 32 - 22
common/request.js

@@ -17,11 +17,13 @@ const reducenum = function(){
 }
 export const get=(url,data,callback,failback)=>{
   addnum();
+  var authorization = wx.getStorageSync("authorization");
   wx.request({
     url: app.globalData.serverpath+url,
     method: "GET",
     header: {
-      "Content-Type": "json"
+      "Content-Type": "json",
+      "Authorization":authorization
     },
     data:data,
     success: function (res){
@@ -36,31 +38,39 @@ export const get=(url,data,callback,failback)=>{
     }
   })
 } 
-export const post=(url,data,header,callback,failback)=>{
+export const post=(url,data,header,callback,failback,noauth)=>{
   var authorization = wx.getStorageSync("authorization")
   if(typeof header=="function"){
+    noauth = failback;
     failback = callback;
     callback = header;
     header = {};
   }
-  addnum();
-  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();
+  if(authorization){
+    addnum();
+    wx.request({
+      url: app.globalData.serverpath+url,
+      method: "POST",
+      header: Object.assign({
+        "Content-Type": "application/json",
+        "Authorization":authorization,
+        "Accept": "application/vnd.vpgame.v1+json"
+      },header),
+      data:data,
+      success: function (res){
+        //console.debug(res);
+        callback && callback(res);
+      },
+      fail: function (error){
+        failback && failback(error);
+      },
+      complete: function () {
+        reducenum();
+      }
+    })
+  }else{
+    if(typeof noauth=="function"){
+      noauth();
     }
-  })
-} 
+  }
+} 

BIN
img/delete.png


+ 8 - 0
module/caritem/caritem.wxss

@@ -6,6 +6,7 @@
   margin-top:20rpx;
   border-top:1px solid #F9F9F9;
   background: white;
+  position: relative;
 }
 
 .caritem_img{
@@ -61,4 +62,11 @@
 .caritem_guidep{
   display: inline;
   text-decoration:line-through;
+}
+.delete_collect{
+  position: absolute;
+  width: 26rpx;
+  height: 26rpx;
+  bottom: 22rpx;
+  right: 40rpx;
 }

+ 31 - 0
module/caritem/collectcaritem.wxml

@@ -0,0 +1,31 @@
+<template name="collectcaritem">
+  <view class="caritem_b">
+    <navigator 
+      class="caritem_img" 
+      style="background-image:url({{car.img}})"
+      url="../cardetail/cardetail?id={{car.id}}"
+    />
+    <view class="caritem_info">
+      <navigator 
+        class="caritem_t"
+        url="../cardetail/cardetail?id={{car.id}}"
+      >{{car.title?car.title:'--'}}</navigator>
+      <view class="caritem_time">
+        {{car.licensetime}}年上牌|{{car.mileage}}万公里
+        <navigator 
+          url="../shop/shop?id={{car.store_id}}"
+          class="caritem_store"
+        >
+          {{car.store_name}}
+        </navigator>
+      </view>
+      <view class="caritem_p">
+        {{car.saleprice}}万
+      </view>
+      <view class="caritem_guide_p">
+        新手指导价:<view class="caritem_guidep">{{car.guideprice}}万</view>
+        <image class="delete_collect" bindtap="deleteCollect" data-id="{{car.id}}" data-ind="{{index}}" src="../../img/delete.png"/>
+      </view>
+    </view>
+  </view>
+</template>

+ 5 - 2
module/logs/logs.js

@@ -8,6 +8,9 @@ const logs = {
 	},
 	closeLog:function(){
 		this.setData({openlog:false});
+		if(typeof this.closeLogBack=="function"){
+			this.closeLogBack();
+		}
 	},
 	phoneInput:function(e){
 		var number = e.detail.value;
@@ -98,8 +101,8 @@ const logs = {
 
 				    	}
 				    	_self.endTimeing();
-				    	if(typeof _self.data.loginback=="function"){
-				    		_self.data.loginback();
+				    	if(typeof _self.loginback=="function"){
+				    		_self.loginback();
 				    	}
 				    }else{
 				    	wx.showToast({

+ 55 - 17
pages/cardetail/cardetail.js

@@ -104,22 +104,33 @@ Page({
   onShareAppMessage: function () {
   
   },
+  loginback:function(){
+    this.getDetail();
+  },
   getDetail:function(){
     var _self=this;
     get(pathmap.cardetail,{id:this.data.id},function(json){
-      var detail = json.data;
-      var time = detail.first_plate_at.split('-');
-      /*数据结构处理*/
-      detail.imgs = detail.imgs&&detail.imgs.split(",");
-      detail.imgslength = detail.imgs.length;
-      detail.first_plate_at = time[0]+"/"+time[1];
-      detail.check_info.forEach(function(item){
+      if(json.statusCode==200){
+        var detail = json.data;
+        var time = detail.first_plate_at.split('-');
+        /*数据结构处理*/
+        detail.imgs = detail.imgs&&detail.imgs.split(",");
+        detail.imgslength = detail.imgs.length;
+        detail.first_plate_at = time[0]+"/"+time[1];
+        detail.check_info.forEach(function(item){
 
-      })
+        })
 
-      _self.setData({
-        detail:detail
-      })
+        _self.setData({
+          detail:detail
+        })
+      }else{
+        wx.showToast({
+          title:json.data.message,
+          icon:"none",
+          duration:2000
+        })
+      }
     })
   },
   switchTab:function(e){
@@ -144,16 +155,43 @@ Page({
     this.setData({collocatetype:collocatetype});
   },
   collectCar:function(){
-    var authorization = wx.getStorageSync("authorization");
-    if(authorization){
+    var _self=this;
+    if(this.data.detail.is_collect=="0"){
       post(pathmap.collect,{
         id:this.data.id
       },function(json){
-        
+        if(json.statusCode==200){
+          wx.showToast({
+            title:json.data.message
+          });
+          _self.setData({detail:Object.assign(_self.data.detail,{is_collect:'1'})});        
+        }else{
+          wx.showToast({
+            title:json.data.message,
+            icon:"none"
+          });
+        }
+      },null,function(){
+        _self.openLog();
       })
     }else{
-      this.openLog();
-      //setData({openlog:true});
+      post(pathmap.collectdel,{
+        id:this.data.id
+      },function(json){
+        if(json.statusCode==200){
+          wx.showToast({
+            title:json.data.msg
+          });
+          _self.setData({detail:Object.assign(_self.data.detail,{is_collect:'0'})});        
+        }else{
+          wx.showToast({
+            title:json.data.message,
+            icon:"none"
+          });
+        }
+      },null,function(){
+        _self.openLog();
+      })
     }
   }
-})
+})

+ 1 - 1
pages/cardetail/cardetail.wxml

@@ -192,7 +192,7 @@
 			bindtap="collectCar"			
 		>
 			<image 
-				src="../../img/uncollect.png"
+				src="../../img/{{detail.is_collect=='1'?'collect':'uncollect'}}.png"
 			/>
 			<view>收藏</view>
 		</view>

+ 1 - 0
pages/cardetail/cardetail.wxss

@@ -44,6 +44,7 @@
 .cardetail_info_c{
 	height: 282rpx;
 	background-color:white;
+	overflow: hidden;
 }
 .cardetail_t{
 	margin-top:30rpx;

+ 128 - 0
pages/collect/collect.js

@@ -0,0 +1,128 @@
+// pages/collect/collect.js
+import { get,post } from "../../common/request.js"
+import pathmap from "../../common/pathmap"
+import stylemap from "../../common/stylemap"
+import { retCartData } from "../../data/car"
+
+const app = getApp();
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: { 
+    windowh: app.globalData.windowh, 
+    limit:10,
+    pageindex:0,
+    lock:false,
+    list:[],
+    hasloadall:false
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    this.getCollect();
+    this.setData(stylemap);
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+  
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+  
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+  
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+  
+  },
+  getCollect:function(){
+    var _self=this;
+    if(!this.data.lock){
+      var para = {
+        offset : this.data.offset,
+        limit : this.data.limit
+      }
+      this.setData({
+        lock:true
+      })
+      get(pathmap.collectlist, para, function (json) {
+        var list = retCartData(json.data&&json.data.list);
+        var obj = {          
+          list:_self.data.list.concat(list),
+          offset:_self.data.offset+_self.data.limit,
+          lock:false
+        }
+        if(json.data.total<=_self.data.limit){
+          obj.hasloadall=true;
+        }else{
+          obj.hasloadall=false;
+        }
+        _self.setData(obj);
+      })
+    }
+  },
+  deleteCollect:function(e){
+    var _self=this;
+    var id = e.currentTarget.dataset.id;
+    var index = e.currentTarget.dataset.ind;
+    post(pathmap.collectdel,{
+      id:id
+    },function(json){
+      if(json.statusCode==200){
+        var list = _self.data.list.slice();
+        wx.showToast({
+          title:json.data.msg
+        });
+        list.splice(index,1);
+        _self.setData({
+          list:list
+        })
+      }else{
+        wx.showToast({
+          title:json.data.message,
+          icon:"none"
+        });
+      }
+    })
+  }
+})

+ 1 - 0
pages/collect/collect.json

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

+ 26 - 0
pages/collect/collect.wxml

@@ -0,0 +1,26 @@
+<!--pages/collect/collect.wxml-->
+
+<import src="../../module/header.wxml"/>
+<import src="../../module/caritem/collectcaritem.wxml"/>
+<scroll-view 
+  class="conent"
+  style="height:{{windowh}}rpx;"
+  scroll-y="{{selectbar==''?'true':'false'}}"
+  bindscrolltolower="{{hasloadall?'':'getCollect'}}"
+>
+  <template 
+    is="header"
+    data="{{title:'我的收藏',headerheight:headerheight,hasback:true}}"
+  />
+
+  <view wx:if="{{list.length>0}}" class="collect_list">
+    <block wx:for="{{list}}" wx:key="id">
+      <template is="collectcaritem" data="{{car:item,index:index}}"/>
+    </block>
+  </view>
+  <view wx:else class="collect_empty"> 
+    <view class="collect_empty_w">还没有收藏哦~</view>
+    <navigator url="../buy/buy" class="collect_empty_bt">去逛逛</navigator>
+  </view> 
+  
+</scroll-view>

+ 32 - 0
pages/collect/collect.wxss

@@ -0,0 +1,32 @@
+/* pages/collect/collect.wxss */
+
+@import "../../module/caritem/caritem.wxss"
+
+.conent{
+	background-color:#F9F9F9;
+}
+.collect_list{
+	margin-top:-20rpx;
+}
+.collect_empty{
+	margin-top:260rpx;
+	height: 39rpx;
+	line-height: 39rpx;
+	color: rgba(104, 104, 104, 1);
+	font-size: 26rpx;
+	text-align: center;
+	font-family: NotoSansHans-DemiLight;
+}
+.collect_empty_bt{
+	margin:60rpx auto 0rpx;
+	width: 280rpx;
+	height: 68rpx;
+	line-height: 68rpx;
+	border-radius: 6rpx;
+	background: linear-gradient(270deg,#FFD800,#FFE600);
+	color: rgba(56, 55, 53, 1);
+	font-size: 26rpx;
+	text-align: center;
+	font-family: NotoSansHans-DemiLight;
+	font-weight: bold;
+}

+ 104 - 0
pages/mybuy/mybuy.js

@@ -0,0 +1,104 @@
+
+import { get,post } from "../../common/request.js"
+import pathmap from "../../common/pathmap"
+import stylemap from "../../common/stylemap"
+import { retCartData } from "../../data/car"
+
+const app = getApp();
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: { 
+    windowh: app.globalData.windowh, 
+    limit:10,
+    pageindex:0,
+    lock:false,
+    list:[],
+    hasloadall:false
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    this.getMyBuy();
+    this.setData(stylemap);
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+  
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+  
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+  
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+  
+  },
+  getMyBuy:function(){
+    var _self=this;
+    if(!this.data.lock){
+      var para = {
+        offset : this.data.offset,
+        limit : this.data.limit
+      }
+      this.setData({
+        lock:true
+      })
+      get(pathmap.orderlist, para, function (json) {
+        var list = retCartData(json.data&&json.data.list);
+        var obj = {          
+          list:_self.data.list.concat(list),
+          offset:_self.data.offset+_self.data.limit,
+          lock:false
+        }
+        if(json.data.total<=_self.data.limit){
+          obj.hasloadall=true;
+        }else{
+          obj.hasloadall=false;
+        }
+        _self.setData(obj);
+      })
+    }
+  }
+})

+ 1 - 0
pages/mybuy/mybuy.json

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

+ 24 - 0
pages/mybuy/mybuy.wxml

@@ -0,0 +1,24 @@
+<import src="../../module/header.wxml"/>
+<import src="../../module/caritem/mybuycaritem.wxml"/>
+<scroll-view 
+  class="conent"
+  style="height:{{windowh}}rpx;"
+  scroll-y="{{selectbar==''?'true':'false'}}"
+  bindscrolltolower="{{hasloadall?'':'getMyBuy'}}"
+>
+  <template 
+    is="header"
+    data="{{title:'我买的车',headerheight:headerheight,hasback:true}}"
+  />
+
+  <view wx:if="{{list.length>0}}" class="mybuy_list">
+    <block wx:for="{{list}}" wx:key="id">
+      <template is="mybuycaritem" data="{{car:item,index:index}}"/>
+    </block>
+  </view>
+  <view wx:else class="mybuy_empty"> 
+    <view class="mybuy_empty_w">您还没有相关订单,快去预约吧!</view>
+    <navigator url="../buy/buy" class="mybuy_empty_bt">去逛逛</navigator>
+  </view> 
+  
+</scroll-view>

+ 28 - 0
pages/mybuy/mybuy.wxss

@@ -0,0 +1,28 @@
+.conent{
+	background-color:#F9F9F9;
+}
+.mybuy_list{
+	margin-top:-20rpx;
+}
+.mybuy_empty{
+	margin-top:260rpx;
+	height: 39rpx;
+	line-height: 39rpx;
+	color: rgba(104, 104, 104, 1);
+	font-size: 26rpx;
+	text-align: center;
+	font-family: NotoSansHans-DemiLight;
+}
+.mybuy_empty_bt{
+	margin:60rpx auto 0rpx;
+	width: 280rpx;
+	height: 68rpx;
+	line-height: 68rpx;
+	border-radius: 6rpx;
+	background: linear-gradient(270deg,#FFD800,#FFE600);
+	color: rgba(56, 55, 53, 1);
+	font-size: 26rpx;
+	text-align: center;
+	font-family: NotoSansHans-DemiLight;
+	font-weight: bold;
+}

+ 95 - 0
pages/mysuggest/mysuggest.js

@@ -0,0 +1,95 @@
+// pages/mysuggest/mysuggest.js
+import { get,post } from "../../common/request.js"
+import pathmap from "../../common/pathmap"
+import stylemap from "../../common/stylemap"
+const app = getApp();
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    windowh: app.globalData.windowh, 
+    value:""
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {  
+    this.setData(stylemap);
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+  
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+  
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+  
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+  
+  },
+  getSuggestValue:function(e){
+    var value = e.detail.value;
+    this.setData({value:value});
+  },
+  subSuggest:function(){
+    if(this.data.value){
+      post(pathmap.feedback,{
+        content:this.data.value
+      },function(json){
+        var obj = {          
+          title:json.data.message
+        }
+        if(json.statusCode!=200){
+          obj.icon="none"
+        }
+        wx.showToast(obj);
+      })
+    }else{
+      wx.showToast({
+        title:"内容不能为空哦!",
+        icon:"none"
+      })
+    }
+  }
+})

+ 1 - 0
pages/mysuggest/mysuggest.json

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

+ 23 - 0
pages/mysuggest/mysuggest.wxml

@@ -0,0 +1,23 @@
+<!--pages/mysuggest/mysuggest.wxml-->
+<import src="../../module/header.wxml"/>
+<scroll-view 
+  class="conent"
+  style="height:{{windowh}}rpx;"
+  scroll-y="{{selectbar==''?'true':'false'}}"
+  bindscrolltolower="{{hasloadall?'':'getMyBuy'}}"
+>
+	<template 
+	is="header"
+	data="{{title:'意见反馈',headerheight:headerheight,hasback:true}}"
+	/>
+	<view class="mysuggest_c">
+		<textarea 
+			class="mysuggest_area" 
+			placeholder="你的满意是我们前进的动力"
+			placeholder-style="color:rgba(183, 183, 183, 1)"
+			maxlength="400"
+			bindinput="getSuggestValue"
+			name="textarea"/>
+		<view bindtap="subSuggest" class="mysuggest_bt">提交反馈</view>
+	</view>
+</scroll-view>

+ 29 - 0
pages/mysuggest/mysuggest.wxss

@@ -0,0 +1,29 @@
+/* pages/mysuggest/mysuggest.wxss */
+.conent{
+	background-color:#F9F9F9;
+}
+.mysuggest_area{
+	display: block;
+	padding: 30rpx 38rpx;
+	height: 220rpx;
+	width:674rpx;
+	line-height: 36rpx;
+	color: black;
+	font-size: 24rpx;
+	text-align: left;
+	font-family: NotoSansHans-DemiLight;
+	background-color: white;
+}
+.mysuggest_bt{
+	margin:40rpx auto 0rpx;
+	width: 620rpx;
+	height: 68rpx;
+	line-height: 68rpx;
+	border-radius: 6rpx;
+	background: linear-gradient(270deg,#FFD800,#FFE600);
+	color: rgba(56, 55, 53, 1);
+	font-size: 26rpx;
+	text-align: center;
+	font-family: NotoSansHans-DemiLight;
+	font-weight: bold;
+}

+ 3 - 0
pages/usercenter/usercenter.js

@@ -79,5 +79,8 @@ Page({
    */
   onShareAppMessage: function () {
   
+  },
+  closeLogBack:function(){
+    wx.navigateBack();
   }
 })

+ 3 - 3
pages/usercenter/usercenter.wxml

@@ -10,19 +10,19 @@
 		<view class="usercenter_top_p">{{phonenumber}}</view>
 	</view>
 	<view class="usercenter_op_list">
-		<navigator class="usercenter_op_i">
+		<navigator class="usercenter_op_i" url="../collect/collect">
 			<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">
+		<navigator class="usercenter_op_i" url="../mybuy/mybuy">
 			<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">
+		<navigator class="usercenter_op_i" url="../mysuggest/mysuggest">
 			<image class="usercenter_op_img" src="../../img/mysuggest.png"/>
 			<view class="usercenter_op_w">意见反馈</view>
 			<image class="usercenter_op_bt" src="../../img/right.png"/>