huanggang 7 роки тому
батько
коміт
2619e1735e

+ 120 - 20
app.js

@@ -6,42 +6,142 @@ App({
     logs.unshift(Date.now())
     wx.setStorageSync('logs', logs)
 
+
     // 登录
     wx.login({
       success: res => {
-        // wx.request({
-        //   url: `https://api.weixin.qq.com/sns/jscode2session?appid=wxfdaeb25e38c4c47e&secret=e5b5055cbc608d10c6de0d877c221270&js_code=${res.code}&grant_type=authorization_code`,
-        //   data:{},
-        //   success:function(res){
-        //     // console.log(res);
-        //   }
-        // })
+        let self = this;
+        wx.request({
+          url: `https://api.weixin.qq.com/sns/jscode2session?appid=wxfdaeb25e38c4c47e&secret=e5b5055cbc608d10c6de0d877c221270&js_code=${res.code}&grant_type=authorization_code`,
+          data:{},
+          success:function(res){
+            self.globalData.userId.openid = res.data.openid;
+            self.globalData.userId.unionid = res.data.unionid;
+          }
+        })
         // 发送 res.code 到后台换取 openId, sessionKey, unionId
       }
     })
     // 获取用户信息
     wx.getSetting({
       success: res => {
+        let self = this;
         if (res.authSetting['scope.userInfo']) {
-          // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
-          wx.getUserInfo({
-            success: res => {
-              console.log(res);
-              // 可以将 res 发送给后台解码出 unionId
-              this.globalData.userInfo = res.userInfo
+          // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
+          // wx.getUserInfo({
+          //   success: res => {
+          //     // 可以将 res 发送给后台解码出 unionId
+          //     self.globalData.userInfo = res.userInfo
+          //     wx.request({
+          //       url: 'https://passport.lrlz.com/mobile/index.php?act=login&op=wxauthor&client_type=ios',
+          //       method: 'GET',
+          //       data: {
+          //         user_info: userInfo
+          //       },
+          //       success: function (res) {
+          //         wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
+          //         if (res.statusCode == 200) {
+          //           wx.switchTab({
+          //             url: '/pages/index/index'
+          //           })
+          //         }
+          //         else {
+
+          //         }
+          //       }
+          //     })
+          //     // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
+          //     // 所以此处加入 callback 以防止这种情况
+          //     if (this.userInfoReadyCallback) {
+          //       this.userInfoReadyCallback(res)
+          //     }
+          //   }
+          // })
+          wx.authorize({
+            scope: 'scope.userInfo',
+            success: function (res) {
+              wx.getUserInfo({
+                success: res => {
+
+                  // 可以将 res 发送给后台解码出 unionId
+                  self.globalData.userInfo = res.userInfo;
+                  self.globalData.userInfo.nickname = res.userInfo.nickName;
+                  let userInfo = Object.assign({}, self.globalData.userId, self.globalData.userInfo);
+                  wx.request({
+                    url: 'https://passport.lrlz.com/mobile/index.php?act=login&op=wxauthor&client_type=ios',
+                    method: 'GET',
+                    data: {
+                      user_info: userInfo
+                    },
+                    success: function (res) {
+                      wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
+                      if (res.statusCode == 200) {
+                        wx.switchTab({
+                          url: '/pages/index/index'
+                        })
+                      }
+                      else {
+
+                      }
+                    }
+                  })
+                  // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
+                  // 所以此处加入 callback 以防止这种情况
+                  if (this.userInfoReadyCallback) {
+                    this.userInfoReadyCallback(res)
+                  }
+                }
+              })
+            }
+          });
+        }
+        else {
+          wx.authorize({
+            scope:'scope.userInfo',
+            success:function(res){
+              wx.getUserInfo({
+                success: res => {
+                
+                  // 可以将 res 发送给后台解码出 unionId
+                  self.globalData.userInfo = res.userInfo;
+                  self.globalData.userInfo.nickname = res.userInfo.nickName;
+                  let userInfo = Object.assign({}, self.globalData.userId, self.globalData.userInfo);
+                  wx.request({
+                    url: 'https://passport.lrlz.com/mobile/index.php?act=login&op=wxauthor&client_type=ios',
+                    method:'GET',
+                    data:{
+                      user_info: userInfo
+                    },
+                    success:function(res){
+                      wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
+                      if (res.statusCode == 200) {
+                        wx.switchTab({
+                          url: '/pages/index/index'
+                        })
+                      }
+                      else {
 
-              // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
-              // 所以此处加入 callback 以防止这种情况
-              if (this.userInfoReadyCallback) {
-                this.userInfoReadyCallback(res)
-              }
+                      }
+                    }
+                  })
+                  // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
+                  // 所以此处加入 callback 以防止这种情况
+                  if (this.userInfoReadyCallback) {
+                    this.userInfoReadyCallback(res)
+                  }
+                }
+              })
             }
-          })
+          });
         }
       }
     })
   },
   globalData: {
-    userInfo: null
+    userId:{
+      openid:'',
+      unionid:''
+    },
+    userInfo: {}
   }
 })

+ 1 - 0
app.json

@@ -1,5 +1,6 @@
 {
   "pages": [
+    "pages/login/login",
     "pages/index/index",
     "pages/discover/discover",
     "pages/shopCart/shopCart",

+ 4 - 2
config.js

@@ -6,12 +6,14 @@ function getReq(data, callback, fail) {
   let options = {
     client_type: 'ios'
   }
-  data = Object.assign({}, options, data)
+  data = Object.assign({}, options, data);
+  let session_id = wx.getStorageSync('session_id');
   return wx.request({
     url: api,
     data,
     header: {
-      'content-type': 'application/json' // 默认值
+      'content-type': 'application/json', // 默认值
+      'Cookie': 'MPHPSESSID=' + session_id
     },
     success(res) {
       callback(res.data)

+ 30 - 0
pages/components/blockItem/blockItem.js

@@ -0,0 +1,30 @@
+// pages/components/blockItem/blockItem.js
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    item_data: {
+      type:Object
+    } 
+  },
+
+  ready(){
+    // console.log(this.properties.item_data);
+  },
+
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+
+  }
+})

+ 4 - 0
pages/components/blockItem/blockItem.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 4 - 0
pages/components/blockItem/blockItem.wxml

@@ -0,0 +1,4 @@
+<block wx:if="{{item_data.show_type == 'image'}}">
+  <image mode="scaleToFill" src="{{item_data.image}}" style="width:{{(item_data.width/1080*750)+'rpx'}}; height:{{(item_data.height/1080*750)+'rpx'}}"></image>
+</block>
+

+ 1 - 0
pages/components/blockItem/blockItem.wxss

@@ -0,0 +1 @@
+/* pages/components/blockItem/blockItem.wxss */

+ 3 - 1
pages/components/blocks/carousel/carousel.json

@@ -1,4 +1,6 @@
 {
   "component": true,
-  "usingComponents": {}
+  "usingComponents": {
+    "blockItem":"../../blockItem/blockItem"
+  }
 }

+ 1 - 1
pages/components/blocks/carousel/carousel.wxml

@@ -2,7 +2,7 @@
 <swiper autoplay indicator-dots style="height:{{(750 / scale)+'rpx'}}">
   <block wx:key="item" wx:for="{{image_list}}">
     <swiper-item>
-        <image mode='scaleToFill' src="{{item.show_data}}"></image>
+        <blockItem item_data="{{item}}"></blockItem>   
     </swiper-item>
   </block> 
 </swiper> 

+ 1 - 6
pages/components/blocks/goods_item/goods_item.js

@@ -33,11 +33,6 @@ Component({
    * 组件的方法列表
    */
   methods: {
-    updateSummery(datas){
-      if (app.proxy.summaryList.length <= 0)return;
-      this.setData({
-        getSummery: app.proxy.getSummery(datas)
-      })
-    }
+  
   }
 })

+ 20 - 2
pages/components/blocks/goods_item/goods_item.wxml

@@ -11,9 +11,27 @@
           <text>{{goods.goods_jingle}}</text>
       </view>
     </view>
-    <view class="goods_price">
+    <view class="goods_price" wx:if="{{goods.act_type == 0}}">
       <view>
-        <text class="current_price">{{goods.bonus_price}}</text>
+        <text class="current_price">¥{{goods.bonus_price}}</text>
+      </view>
+      <view class='deduction'>
+        <view class="original_price">天猫价{{goods.goods_price}}</view>
+        <text class="discount">红包抵{{goods.goods_price - goods.bonus_price}}元</text>
+      </view>
+    </view>
+    <view class="goods_price" wx:if="{{goods.act_type == 1}}">
+      <view>
+        <text class="current_price">¥{{goods.bonus_price}}</text>
+      </view>
+      <view>
+        <text class="original_price">天猫价{{goods.goods_price}}</text>
+        <text class="discount">红包抵{{goods.goods_price - goods.bonus_price}}元</text>
+      </view>
+    </view>
+    <view class="goods_price" wx:if="{{goods.act_type == 2}}">
+      <view>
+        <text class="current_price">¥{{goods.bonus_price}}</text>
       </view>
       <view>
         <text class="original_price">天猫价{{goods.goods_price}}</text>

+ 38 - 6
pages/components/blocks/goods_item/goods_item.wxss

@@ -1,14 +1,14 @@
 .goods_item {
    background: #fff;
    font-size: 22rpx;
-   max-width: 367rpx;
+   width: 368rpx;
    overflow: hidden;
-   margin-top: 6.5rpx;
-   margin-left: 6.5rpx;
+   margin-top: 6rpx;
+   margin-left: 6rpx;
 }
 .goods_item .img {
-  width: 368rpx;
-  height: 368rpx;
+  width: 367rpx;
+  height: 367rpx;
 }
 .goods_item .goods_name {
   color: #4a4a4a;
@@ -22,8 +22,40 @@
     -webkit-line-clamp: 2;
     overflow: hidden;
     color: #7e7e7e;
-    min-height: 60rpx;
+    min-height: 62rpx;
 }
 .goods_item .goods_box {
   padding: 12rpx;
+}
+.goods_item .goods_thumbnail {
+  border-bottom: 1rpx solid #f9f9f9;
+}
+.goods_item .current_price {
+  font-size: 28rpx;
+  color: #ff4e4e;
+}
+.goods_item .original_price,.goods_item .discount {
+  display: inline-block;
+  position: relative;
+  font-size: 18rpx;
+  color:#7e7e7e;
+}
+.goods_item .original_price::after {
+  content: "";
+  position: absolute;
+  top: 14rpx;
+  left: 0;
+  height: 1rpx;
+  width: 100%;
+  background: #7e7e7e;
+  z-index: 5;
+}
+.goods_item .discount {
+  float: right;
+}
+.goods_item .original_price {
+  float: left;
+}
+.goods_item .deduction {
+  overflow: hidden;
 }

+ 3 - 1
pages/components/blocks/home1/homeOne.json

@@ -1,4 +1,6 @@
 {
   "component": true,
-  "usingComponents": {}
+  "usingComponents": {
+    "blockItem": "../../blockItem/blockItem"
+  }
 }

+ 1 - 1
pages/components/blocks/home1/homeOne.wxml

@@ -1,6 +1,6 @@
 <!--components/blocks/home1/home_one.wxml-->
 <view style="overflow:hidden;height:{{(items[0].height/1080*750)+'rpx'}}">
   <block wx:key="{{item}}" wx:for="{{items}}">
-      <image src='{{item.show_data}}' style="width:{{(item.width/1080*750)+'rpx'}}; height:{{(item.height/1080*750)+'rpx'}}"></image>
+      <blockItem item_data="{{item}}"></blockItem>  
   </block>
 </view> 

+ 3 - 1
pages/components/blocks/home3/homeThree.js

@@ -4,7 +4,9 @@ Component({
    * 组件的属性列表
    */
   properties: {
-    items: Array
+    items: {
+      type: Array
+    }
   },
 
   /**

+ 3 - 1
pages/components/blocks/home3/homeThree.json

@@ -1,4 +1,6 @@
 {
   "component": true,
-  "usingComponents": {}
+  "usingComponents": {
+    "blockItem": "../../blockItem/blockItem"
+  }
 }

+ 1 - 2
pages/components/blocks/home3/homeThree.wxml

@@ -1,7 +1,6 @@
 <!--components/blocks/home3/home3.wxml-->
  <view class="home_three_item" style="height:{{(items[0].height/1080*750)+'rpx'}}"> 
     <block wx:key="{{item}}" wx:for="{{items}}">
-      
-      <image src="{{item.show_data}}" style="width:{{(item.width/1080*750)+'rpx'}}; height:{{(item.height/1080*750)+'rpx'}}"></image>
+      <blockItem item_data="{{item}}"></blockItem>
     </block>
  </view> 

+ 2 - 1
pages/components/blocks/homeGrid/homeGrid.json

@@ -1,4 +1,5 @@
 {
   "component": true,
-  "usingComponents": {}
+  "usingComponents": {
+  }
 }

+ 1 - 1
pages/components/blocks/homeGrid/homeGrid.wxml

@@ -1,6 +1,6 @@
 <!--pages/components/blocks/homeGrid/homeGrid.wxml-->
 <view class="home_grid">
   <view class="home_grid_item" wx:key="{{item}}" wx:for="{{items}}">
-    <image class="home_grid_img" src="{{item.image}}" mode="widthFix"></image>
+     <image class="home_grid_img" src="{{item.image}}" mode="widthFix"></image> 
   </view>  
 </view>

+ 3 - 2
pages/components/blocks/home_goods/home_goods.wxss

@@ -1,8 +1,9 @@
 .home_goods {
   width: 750rpx;
-  /* background: #f9f9f9; */
-  background: red;
+   background: #f9f9f9; 
+  /* background: red; */
   display: -webkit-flex;
   flex: 1;
   flex-wrap:wrap;
+  margin-top: -6rpx;
 }

+ 66 - 0
pages/login/login.js

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

+ 1 - 0
pages/login/login.json

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

+ 1 - 0
pages/login/login.wxml

@@ -0,0 +1 @@
+

+ 1 - 0
pages/login/login.wxss

@@ -0,0 +1 @@
+/* pages/login/login.wxss */

+ 13 - 3
project.config.json

@@ -1,7 +1,7 @@
 {
 	"description": "项目配置文件。",
 	"setting": {
-		"urlCheck": true,
+		"urlCheck": false,
 		"es6": true,
 		"postcss": true,
 		"minified": true,
@@ -21,13 +21,23 @@
 			"current": -1,
 			"list": []
 		},
+		"plugin": {
+			"current": -1,
+			"list": []
+		},
 		"game": {
 			"currentL": -1,
 			"list": []
 		},
 		"miniprogram": {
-			"current": -1,
-			"list": []
+			"current": 0,
+			"list": [
+				{
+					"id": -1,
+					"name": "index",
+					"pathName": "pages/index/index"
+				}
+			]
 		}
 	}
 }