k.zhang 4 年之前
父節點
當前提交
af744ccb3d

+ 20 - 19
app.js

@@ -7,26 +7,27 @@ App({
     wx.setStorageSync('logs', logs)
 
     // 登录
-    wx.login({
-      success: res => {
-        // 发送 res.code 到后台换取 openId, sessionKey, unionId
-        console.log(res)
-        wx.request( { 
-          url: this.globalData.url + "/v1/user/open.id/set", 
-          header: { 
-           "Content-Type": "application/json"
-          }, 
-          method: "POST",
-          data:  { code: res.code }, 
-          complete: function( res ) { 
-           if (res.data.code == 200){
-            wx.setStorageSync('openId', res.data.data.openid)
-           }
+    // wx.login({
+    //   success: res => {
+    //     // 发送 res.code 到后台换取 openId, sessionKey, unionId
+    //     console.log(res)
+    //     wx.request( { 
+    //       url: this.globalData.url + "/v1/user/open.id/set", 
+    //       header: { 
+    //        "Content-Type": "application/json"
+    //       }, 
+    //       method: "POST",
+    //       data:  { code: res.code }, 
+    //       complete: function( res ) { 
+    //        if (res.data.code == 200){
+    //         wx.setStorageSync('openId', res.data.data.openid)
+    //        }
           
-          } 
-         }) 
-      }
-    })
+    //       } 
+    //      }) 
+    //   }
+    // })
+
   },
   globalData: {
     userInfo: null,

+ 3 - 1
app.json

@@ -6,7 +6,9 @@
     "pages/logs/logs",
     "pages/details/details",
     "pages/order/order",
-    "pages/search-details/earch-details"
+    "pages/search-details/earch-details",
+    "pages/friends/friends",
+    "pages/friends-list/friends-list"
   ],
   "window": {
     "backgroundTextStyle": "light",

+ 27 - 1
pages/boutique/outique.js

@@ -107,6 +107,8 @@ Page({
     that.channel_type = "4"
     that.pid = "9112489_209622235"
     that.cat_id = ""
+    console.log(options)
+   //var openId = options.openId
     
     wx.request( { 
       url: link + "/v1/set", 
@@ -127,7 +129,7 @@ Page({
           })
        }else{
        
-        //获取数据
+      //获取数据
       setTimeout(that._asyncData, 0);
       wx.request( { 
        url: link + "/v1/pdd/recommend/get", 
@@ -162,6 +164,30 @@ Page({
       } 
      }) 
 
+     wx.login({
+      success: res => {
+        // 发送 res.code 到后台换取 openId, sessionKey, unionId
+        console.log(res)
+        wx.request( { 
+          url: link + "/v1/user/open.id/set", 
+          header: { 
+           "Content-Type": "application/json"
+          }, 
+          method: "POST",
+          //
+          data:  { code: res.code,openId: options.openId }, 
+          complete: function( res ) { 
+            console.log(res)
+            console.log('openid='+ options.openId )
+           if (res.data.code == 200){
+            wx.setStorageSync('openId', res.data.data.openid)
+           }
+          
+          } 
+         }) 
+      }
+    })
+
   },
   search: function(options){
     wx.navigateTo({

+ 66 - 0
pages/friends-list/friends-list.js

@@ -0,0 +1,66 @@
+// pages/friends-list/friends-list.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 3 - 0
pages/friends-list/friends-list.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 2 - 0
pages/friends-list/friends-list.wxml

@@ -0,0 +1,2 @@
+<!--pages/friends-list/friends-list.wxml-->
+<text>pages/friends-list/friends-list.wxml</text>

+ 1 - 0
pages/friends-list/friends-list.wxss

@@ -0,0 +1 @@
+/* pages/friends-list/friends-list.wxss */

+ 72 - 0
pages/friends/friends.js

@@ -0,0 +1,72 @@
+// pages/friends/friends.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+    var openId = wx.getStorageSync('openId')
+    return {
+      title: '电商内部优惠券',
+      imageUrl:"../image/yhq.jpg",
+      desc: '优惠券小程序',
+      path: 'pages/boutique/outique?openId=' + openId // 路径,传递参数到指定页面。
+     }
+  }
+})

+ 3 - 0
pages/friends/friends.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 18 - 0
pages/friends/friends.wxml

@@ -0,0 +1,18 @@
+<!--pages/friends/friends.wxml-->
+
+
+
+<view class="container">
+  <view class="page-body">
+    <view class="page-section page-section-spacing">
+      <view class="text-box" scroll-y="true" scroll-top="{{scrollTop}}">
+        <text>1.你邀请A用户,A用户购物下单,\n你会获得佣金奖励。\n</text>
+        <text>2.A邀请B用户,B用户购物下单,\n你会获得佣金奖励。\n</text>
+        <text>3.点击下方的分享按钮即可分享给好友。\n</text>
+        <text>4.已经被邀请过的用户,不能重复邀请。\n</text>
+       <button open-type="share" type="default" plain="true">分享</button>
+      </view>
+     
+    </view>
+  </view>
+</view>

+ 2 - 0
pages/friends/friends.wxss

@@ -0,0 +1,2 @@
+/* pages/friends/friends.wxss */
+@import "../../lib/weui.wxss";

二進制
pages/image/dd1.png


二進制
pages/image/dd2.png


二進制
pages/image/yhq.jpg


+ 116 - 20
pages/index/index.js

@@ -71,6 +71,7 @@ Page({
   onLoad() {
     var that = this
     var opneId = wx.getStorageSync('openId')
+    var nickName = wx.getStorageSync('nickName')
     if (wx.getUserProfile) {
       this.setData({
         canIUseGetUserProfile: true
@@ -87,32 +88,99 @@ Page({
       success (res) {
         console.log(res)
        
-        // if (res.data.code == 200){
-        //   pid = res.data.data.pid
-        // }
         that.setData({
           wallet: res.data.data.wallet
          })
         
-      
       }
      }) 
+     
+     console.log(nickName)
+     if (nickName == ''){
+      wx.request( { 
+        url: link + "/v1/user/open.id/get", 
+        header: { 
+         "Content-Type": "application/json"
+        }, 
+        method: "POST",
+        data:  { openId: opneId }, 
+        success (res) {
+          console.log(res)
+          wx.setStorageSync('nickName', res.data.data.user.nickName)  
+          wx.setStorageSync('userId', res.data.data.user.id) 
+          that.setData({
+            userId: res.data.data.user.id
+           })
+        }
+       }) 
+    } else{
+      var userId = wx.getStorageSync('userId')
+      console.log(userId)
+      that.setData({
+        userId: userId
+       })
+    }
 
 
   },
   clickGrid(e) {
-
+    var that = this
+    console.log(e)
     if (e.detail.cell.text == "我的订单"){
       wx.navigateTo({
         url:"/pages/order/order"
       })
-    } else if (e.detail.cell.text == "体现") {
+    } else if (e.detail.cell.text == "联系客服"){
+      wx.showModal({
+        title: '客服微信',
+        content: '客服微信:tao1024_com,点击复制按钮,直接复制客服微信号,粘贴到微信中搜索添加客服.',
+        showCancel: true,//是否显示取消按钮
+        cancelText:"取消",//默认是“取消”
+        //cancelColor:'skyblue',//取消文字的颜色
+        confirmText:"复制",//默认是“确定”
+        //confirmColor: 'skyblue',//确定文字的颜色
+        success: function (res) {
+           if (res.cancel) {
+              //点击取消,默认隐藏弹框
+           } else {
+            wx.setClipboardData({
+              data: 'tao1024_com',
+              success (res) {
+              //点击确定
+              wx.showToast({
+                title: '复制成功',//提示文字
+                duration:2000,//显示时长
+                mask:true,//是否显示透明蒙层,防止触摸穿透,默认:false  
+                icon:'success', //图标,支持"success"、"loading"  
+                success:function(){ },//接口调用成功
+                fail: function () { },  //接口调用失败的回调函数  
+                complete: function () { } //接口调用结束的回调函数  
+             })
+              }
+            })
+           
+  
+           }
+        },
+        fail: function (res) { },//接口调用失败的回调函数
+        complete: function (res) { },//接口调用结束的回调函数(调用成功、失败都会执行)
+     })
+
+    }
+     else if (e.detail.cell.text == "提现") {
       wx.showToast({
         title: "结算金额:0元",
         icon: 'none'
       });
 
-    } else {
+    } else if (e.detail.cell.text == "邀请好友"){
+      console.log('邀请好友')
+      wx.navigateTo({
+        url:"/pages/friends/friends"
+      })
+    } 
+    
+    else {
        wx.showToast({
         title: "功能开发中...",
         icon: 'none'
@@ -122,17 +190,40 @@ Page({
    
   },
   getUserProfile(e) {
+    var that = this
+    var openId = wx.getStorageSync('openId')
+    var nickName = wx.getStorageSync('nickName')
+    console.log("'"+nickName+"'")
+    console.log(openId)
+    if (nickName == ''){
+      wx.getUserProfile({
+        desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
+        success: (res) => {
+          console.log(res)
+          //更新user
+          wx.request( { 
+            url: link + "/v1/user/update/name", 
+            header: { 
+             "Content-Type": "application/json"
+            }, 
+            method: "POST",
+            data:  { openId: openId ,nickName:res.userInfo.nickName,avatarUrl:res.userInfo.avatarUrl}, 
+            success (ress) {
+              console.log(ress)
+              wx.setStorageSync('nickName', res.userInfo.nickName)  
+              
+            }
+           }) 
+           that.clickGrid(e)
+        }
+      })
+    } else{
+      that.clickGrid(e)
+    }
+   
+
     // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
-    wx.getUserProfile({
-      desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
-      success: (res) => {
-        console.log(res)
-        this.setData({
-          userInfo: res.userInfo,
-          hasUserInfo: true
-        })
-      }
-    })
+  
   },
   getUserInfo(e) {
     // 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息
@@ -145,7 +236,12 @@ Page({
   /**
    * 用户点击右上角分享
    */
-  onShareAppMessage: function () {
-
-  }
+  // onShareAppMessage: function () {
+  //   var openId = wx.getStorageSync('openId')
+  //   return {
+  //     title: '优惠券小程序',
+  //     desc: '电商内部优惠券',
+  //     path: 'pages/boutique/outique?openId=' + openId // 路径,传递参数到指定页面。
+  //    }
+  // }
 })

+ 2 - 2
pages/index/index.wxml

@@ -1,7 +1,7 @@
 <!--index.wxml-->
 
 
-<content-card l-content="content" name="头像">
+<content-card l-content="content" name="会员编号-{{userId}}">
       <view class="content-item">
         <l-avatar open-data="{{['userAvatarUrl','userNickName']}}" />
       </view>
@@ -53,7 +53,7 @@
     <content-card class="content" name="功能">
       <view class="view-container">
         <l-grid show-border="{{true}}">
-          <l-grid-item wx:for="{{grids1}}" wx:key="index" key="{{index}}" slot="{{index}}" bind:linitemtap="clickGrid" cell="{{item}}" l-grid-item="grid-item">
+          <l-grid-item wx:for="{{grids1}}" wx:key="index" key="{{index}}" slot="{{index}}" bind:linitemtap="getUserProfile" cell="{{item}}" l-grid-item="grid-item">
             <l-icon name="{{item.image}}" />
             <view class="text">{{item.text}}</view>
           </l-grid-item>

+ 97 - 20
pages/order/order.js

@@ -10,27 +10,48 @@ Page({
     page:1,
     pageSize:10,
     openId:"",
-    // count:0,
-    // pageIndex:""
+    userStatus:0,
+    goodsList:[],
+    count:0
+  
   },
 
+  _asyncData() {
+    this.setData({
+      scrollAbleTabs: [
+        {
+          tab: '本人订单',
+          key: '4'
+        },
+        {
+        tab: '好友订单',
+        key: '1'
+      }, {
+        tab: '朋友订单',
+        key: '6'
+      }
+    ],
+    });
+  },
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    //获取产品
+    
     var  that = this; 
     that.page = 1
     that.pageSize = 18
     that.openId = wx.getStorageSync('openId')
+    that.userStatus = 0
 
+    // setTimeout(that._asyncData, 0);
     wx.request( { 
       url: link + "/v1/user/order/list", 
       header: { 
        "Content-Type": "application/json"
       }, 
       method: "POST",
-      data:  { openId: that.openId,pageIndex:that.page,pageSize: that.pageSize}, 
+      data:  { openId: that.openId,pageIndex:that.page,pageSize: that.pageSize,userStatus:that.userStatus}, 
       complete: function( res ) { 
        console.log(res)
        if( res == null || res.data == null ) { 
@@ -39,15 +60,65 @@ Page({
        } 
        console.log(res.data.data.rows)
        //that.count = res.data.data.count
-       that.setData({
-        goodsList: res.data.data.rows,
-      })
-      
+       if (res.data.data.rows.orderInfo == null){
+        that.count = res.data.data.count
+        that.setData({
+          goodsList: res.data.data.rows.orderInfo,
+          lType:"end"
+        })
+       } else{
+        that.count = res.data.data.count
+        that.data.goodsList = res.data.data.rows.orderInfo
+        that.setData({
+          goodsList: that.data.goodsList,
+          lType:"false"
+        })
+       }
+ 
+      } 
+     }) 
+
+  },
 
+  changeTabs: function (e){
+    var that = this
+    console.log(e)
+    that.userStatus = e.detail.currentIndex
+    that.setData({
+     
+      lType:"loading"
+    })
+    wx.request( { 
+      url: link + "/v1/user/order/list", 
+      header: { 
+       "Content-Type": "application/json"
+      }, 
+      method: "POST",
+      data:  { openId: that.openId,pageIndex:that.page,pageSize: that.pageSize,userStatus:that.userStatus}, 
+      complete: function( res ) { 
+       console.log(res)
+       if( res == null || res.data == null ) { 
+        console.error( '网络请求失败' ); 
+        return; 
+       } 
+       console.log(res.data.data.rows.orderInfo)
+       //that.count = res.data.data.count
+       if (res.data.data.rows.orderInfo == null){
+        that.setData({
+          goodsList: res.data.data.rows.orderInfo,
+          lType:"end"
+        })
+       } else{
+        that.data.goodsList = res.data.data.rows.orderInfo
+        that.setData({
+          goodsList: res.data.data.rows.orderInfo,
+          lType:"false"
+        })
+       }
+      
 
       } 
      }) 
-
   },
 
   /**
@@ -91,27 +162,33 @@ Page({
    onReachBottom: function () {
   //获取数据
    var  that = this; 
+
+   if (that.page * that.pageSize >= that.count ){
+    //提示页码到了
+  that.setData({
+    lType:"end"
+  })
+  return
+
+}
+
    that.page +=1
+
+   
+
   wx.request( { 
    url: link + "/v1/user/order/list", 
    header: { 
     "Content-Type": "application/json"
    }, 
    method: "POST",
-   data:  { openId: that.openId,pageIndex:that.page,pageSize: that.pageSize}, 
+   data:  { openId: that.openId,pageIndex:that.page,pageSize: that.pageSize,userStatus:that.userStatus}, 
    complete: function( res ) { 
     wx.hideLoading();
     console.log(res)
-    if (res.data.data.rows.length <= 0){
-            //提示页码到了
-          that.setData({
-            lType:"end"
-          })
-          return
-     
-    }
-    for (var i = 0; i < res.data.data.rows.length; i++) {
-      that.data.goodsList.push( res.data.data.rows[i]);
+    
+    for (var i = 0; i < res.data.data.rows.orderInfo.length; i++) {
+      that.data.goodsList.push( res.data.data.rows.orderInfo[i]);
     }
     
    that.setData({

+ 16 - 6
pages/order/order.wxml

@@ -1,31 +1,41 @@
 <!--pages/order/order.wxml-->
+
+      <l-tabs l-class-header-line="header-line" bind:linchange="changeTabs" scrollable>
+        <l-tabpanel tab="本人订单" key="0" slot="0">
+        </l-tabpanel>
+        <l-tabpanel tab="好友订单" key="1" slot="1">
+        </l-tabpanel>
+        <l-tabpanel tab="朋友订单" key="2" slot="2">
+        </l-tabpanel>
+      </l-tabs>
+
 <view wx:for="{{goodsList}}" wx:key="msg">
-  <l-card  type="primary" l-img-class="right-card" position="left" image="{{item.goodsThumbnailUrl}}"
+  <l-card  type="primary" l-img-class="right-card" position="left" image="{{item.order.goodsThumbnailUrl}}"
   bindtap="goodsDetail"  data-sign="{{item.goods_sign}}" data-searchId="{{item.search_id}}"   full="true" >
 
     <view class="super-long-test">
       <image class="empty-icon" src="/pages/image/dd.png" ></image>
-      {{item.goodsName}}
+      {{item.order.goodsName}}
     </view>
 
     <view class="containertag">
       <l-tag plain="{{true}}" font-color="#d81e06" shape="circle" size="medium"  l-class="tag" class="describe" >佣金:{{item.amount}}</l-tag>
-      <l-tag plain="{{true}}" font-color="#d81e06" shape="circle" size="medium"  l-class="tag"  class="fanli">实付:{{(item.orderAmount)}}</l-tag>
+      <l-tag plain="{{true}}" font-color="#d81e06" shape="circle" size="medium"  l-class="tag"  class="fanli">实付:{{(item.order.orderAmount)}}</l-tag>
      
     </view>
    
     <view class="price-v">
-     <text class="price">订单状态:{{item.orderStatusDesc}}</text> 
+     <text class="price">订单状态:{{item.order.orderStatusDesc}}</text> 
     </view>
   
    <text class="contentcard">
-    订单号:{{item.orderSn}}
+    订单号:{{item.order.orderSn}}
    </text>
    <!-- <text class="contentcard">
     订单状态:{{item.orderStatusDesc}}
    </text> -->
    
-  <text class="contentcard">创建时间:{{item.orderCreateTime}}</text>
+  <text class="contentcard">创建时间:{{item.order.orderCreateTime}}</text>
   </l-card>
 </view>
 

+ 33 - 55
pages/shouye/shouye.js

@@ -117,63 +117,35 @@ Page({
     var  that = this; 
     that.page = 1
     that.pageSize = 18
-        
-    wx.request( { 
-      url: link + "/v1/set", 
-      header: { 
-       "Content-Type": "application/json"
-      }, 
-      method: "POST",
-      data:  { version: "1.0.2" }, 
-      complete: function( res ) { 
-       console.log(res)
-       if( res == null || res.data == null ) { 
-        console.error( '网络请求失败' ); 
-        return; 
-       } 
-       if (res.data.data.type == "false"){
-          // wx.reLanch({
-          //   url: 'pages/search/search'
-          // })
-          wx.redirectTo({
-            url: '../search/search'
-          })
-       }else{
-       
-        //获取数据
-      setTimeout(that._asyncData, 0);
-      wx.request( { 
-       url: link + "/v1/pdd/ddk/search", 
-       header: { 
-        "Content-Type": "application/json"
-       }, 
-       method: "POST",
-       data:  { page: that.page.toString(), page_size: that.pageSize.toString()}, 
-       complete: function( res ) { 
-        wx.hideLoading();
-        console.log(res)
-        that.totalCount = res.data.data.goods_search_response.total_count
-        for (var i = 0; i < res.data.data.goods_search_response.goods_list.length; i++) {
-          that.data.goodsList.push( res.data.data.goods_search_response.goods_list[i]);
-        }
-        
-       that.setData({
-        goodsList: that.data.goodsList,
-      })
     
-        console.log(res.data.data.goods_search_response)
-        if( res == null || res.data == null ) { 
-         console.error( '网络请求失败' ); 
-         return; 
-        } 
-       } 
-      }) 
-       }
-
-
+      //获取数据
+    setTimeout(that._asyncData, 0);
+    wx.request( { 
+     url: link + "/v1/pdd/ddk/search", 
+     header: { 
+      "Content-Type": "application/json"
+     }, 
+     method: "POST",
+     data:  { page: that.page.toString(), page_size: that.pageSize.toString()}, 
+     complete: function( res ) { 
+      wx.hideLoading();
+      console.log(res)
+      that.totalCount = res.data.data.goods_search_response.total_count
+      for (var i = 0; i < res.data.data.goods_search_response.goods_list.length; i++) {
+        that.data.goodsList.push( res.data.data.goods_search_response.goods_list[i]);
+      }
+      
+     that.setData({
+      goodsList: that.data.goodsList,
+    })
+  
+      console.log(res.data.data.goods_search_response)
+      if( res == null || res.data == null ) { 
+       console.error( '网络请求失败' ); 
+       return; 
       } 
-     }) 
-
+     } 
+    }) 
    
   },
 
@@ -315,6 +287,12 @@ Page({
         var da = res.data
         if (res.data != 0){
           console.log('不为0')
+          wx.setClipboardData({
+            data: '0',
+            success (res) {
+            }
+          })
+
           wx.showModal({  
             title: '搜索产品',  
             content: res.data,