huanggang il y a 6 ans
Parent
commit
257e29afde

+ 100 - 102
app.js

@@ -1,17 +1,16 @@
 //app.js
+const api = require('./config.js');
+
 App({
-  // host:"https://passport.lrlz.com/mobile/index.php",
-  host:"https://121.43.114.153/mobile/index.php",
-  // host: "http://192.168.0.131/mobile/index.php",
+  host:api.host,
 
   onLaunch: function () {
     let self = this;
     // 登录
     wx.login({
       success: res => {
-        let self = this;
         wx.request({
-          // url: self.host,
+          url: self.host,
           // data:{
           //   act:"login",
           //   op:"ministart",
@@ -20,112 +19,111 @@ App({
           // },
           url: `https://api.weixin.qq.com/sns/jscode2session?appid=wxfdaeb25e38c4c47e&secret=e5b5055cbc608d10c6de0d877c221270&js_code=${res.code}&grant_type=authorization_code`,
           success:function(res){
-            console.log(res);
+            // console.log(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']) {
-          let local_session_id = wx.getStorageSync('session_id');
-          if (local_session_id == '') {
-            wx.getUserInfo({
+            // 获取用户信息
+            wx.getSetting({
               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);
-                console.log(userInfo);
-                wx.request({
-                  url: self.host,
-                  method: 'GET',
-                  data: {
-                    user_info: userInfo,
-                    act:"login",
-                    op:"wxauthor",
-                    client_type:"ios"
-                  },
-                  success: function (res) {
-                    console.log(res.data.datas.HPHPSESSID);
-                    wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
-                    if (res.statusCode == 200) {
-                      let current_url = "/" + getCurrentPages()[0].route;
-                      wx.reLaunch({
-                        url: current_url
-                      });
-                    }
-                    else {
+                if (res.authSetting['scope.userInfo']) {
+                  let local_session_id = wx.getStorageSync('session_id');
+                  if (local_session_id == '') {
+                    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);
+                        // console.log(userInfo);
+                        wx.request({
+                          url: self.host,
+                          method: 'GET',
+                          data: {
+                            user_info: userInfo,
+                            act: "login",
+                            op: "wxauthor",
+                            client_type: "ios"
+                          },
+                          success: function (res) {
+                            console.log(res.data.datas.HPHPSESSID);
+                            wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
+                            if (res.statusCode == 200) {
+                              let current_url = "/" + getCurrentPages()[0].route;
+                              wx.reLaunch({
+                                url: current_url
+                              });
+                            }
+                            else {
 
-                    }
+                            }
+                          }
+                        })
+                        // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
+                        // 所以此处加入 callback 以防止这种情况
+                        if (this.userInfoReadyCallback) {
+                          this.userInfoReadyCallback(res)
+                        }
+                      }
+                    })
                   }
-                })
-                // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
-                // 所以此处加入 callback 以防止这种情况
-                if (this.userInfoReadyCallback) {
-                  this.userInfoReadyCallback(res)
-                }
-              }
-            })
-          }
-          else {
-            wx.getUserInfo({
-              success: res => {
-                self.globalData.userInfo = res.userInfo;
-              }
-            })
-          }
-        }
-        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);
-                  console.log(userInfo);
-                  wx.request({
-                    url: self.host,
-                    method:'GET',
-                    data:{
-                      user_info: userInfo,
-                      act:"login", 
-                      op:"wxauthor",
-                      client_type:"ios"
-                    },
-                    success:function(res){
-                      console.log(res);
-                      // console.log(res.data.datas.HPHPSESSID)
-                      wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
-                      if (res.statusCode == 200) {
-                        let current_url = "/" + getCurrentPages()[0].route;
-                        wx.reLaunch({
-                          url: current_url
-                        });
+                  else {
+                    wx.getUserInfo({
+                      success: res => {
+                        self.globalData.userInfo = res.userInfo;
                       }
-                      else {
+                    })
+                  }
+                }
+                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);
+                          // console.log(userInfo);
+                          wx.request({
+                            url: self.host,
+                            method: 'GET',
+                            data: {
+                              user_info: userInfo,
+                              act: "login",
+                              op: "wxauthor",
+                              client_type: "ios"
+                            },
+                            success: function (res) {
+                              // console.log(res);
+                              // console.log(res.data.datas.HPHPSESSID)
+                              wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
+                              if (res.statusCode == 200) {
+                                let current_url = "/" + getCurrentPages()[0].route;
+                                wx.reLaunch({
+                                  url: current_url
+                                });
+                              }
+                              else {
 
-                      }
+                              }
+                            }
+                          })
+                          // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
+                          // 所以此处加入 callback 以防止这种情况
+                          if (this.userInfoReadyCallback) {
+                            this.userInfoReadyCallback(res)
+                          }
+                        }
+                      })
                     }
-                  })
-                  // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
-                  // 所以此处加入 callback 以防止这种情况
-                  if (this.userInfoReadyCallback) {
-                    this.userInfoReadyCallback(res)
-                  }
+                  });
                 }
-              })
-            }
-          });
-        }
+              }
+            })
+          }
+        })
+        // 发送 res.code 到后台换取 openId, sessionKey, unionId
       }
     })
   },

+ 1 - 1
app.json

@@ -23,7 +23,7 @@
     "navigationBarBackgroundColor": "#eb4e4f",
     "navigationBarTitleText": "熊猫美妆",
     "navigationBarTextStyle": "white",
-    "onReachBottomDistance":200
+    "onReachBottomDistance": 200
   },
   "tabBar": {
     "selectedColor": "#FF6760",

+ 1 - 1
app.wxss

@@ -163,5 +163,5 @@ mr16 {
   position: fixed;
   right: 50rpx;
   bottom: 50rpx;
-  width: 70rpx;
+  width: 106rpx;
 }

+ 4 - 3
config.js

@@ -1,6 +1,6 @@
 
-// let api = "https://passport.lrlz.com/mobile/index.php";
-let api = "https://121.43.114.153/mobile/index.php"
+let api = "https://passport.lrlz.com/mobile/index.php";
+// let api = "http://121.43.114.153/mobile/index.php"
 // let api = "http://192.168.0.131/mobile/index.php";
 
 
@@ -26,5 +26,6 @@ function getReq(data, callback, fail) {
   })
 }
 module.exports = {
-  getReq
+  getReq,
+  host: api
 }

BIN
image/back_top.png


+ 0 - 7
pages/addAddress/addAddress.js

@@ -291,12 +291,5 @@ Page({
    */
   onReachBottom: function () {
 
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-
   }
 })

+ 0 - 7
pages/address/address.js

@@ -103,12 +103,5 @@ Page({
    */
   onReachBottom: function () {
 
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-
   }
 })

+ 0 - 7
pages/brand/brand.js

@@ -158,12 +158,5 @@ Page({
           }
         })
       }
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-
   }
 })

+ 0 - 7
pages/comments/comments.js

@@ -129,12 +129,5 @@ Page({
     }
     this.data.curpage++
     this.getDatas(this.data.common_id, this.data.curpage) 
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-
   }
 })

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

@@ -1,5 +1,5 @@
 <!--components/blocks/swiper_list/swiper_list.wxml-->
-<swiper indicator-active-color="#eb4e4f" autoplay indicator-dots style="height:{{(750 / scale)+'rpx'}}">
+<swiper circular="true" indicator-active-color="#eb4e4f" autoplay indicator-dots style="height:{{(750 / scale)+'rpx'}}">
   <block wx:key="item" wx:for="{{image_list}}">
     <swiper-item>
         <blockItem block_type="adv_list" item_data="{{item}}"></blockItem>   

+ 11 - 15
pages/confirmOrder/confirmOrder.js

@@ -52,18 +52,21 @@ Page({
       cart_id: goods_datas,
       ifcart,
     }, function (res) {
+      console.log(res);
       wx.hideLoading()
       if (res.code == 200) {
         let datas = res.datas
         let goods_list = self.getGoodsList(datas.summary, datas.goods_list)
-        let { true_name, mob_phone, area_info, address, address_id } = datas.address
-        appInstance.checkDefaultAddress({
-          true_name,
-          mob_phone,
-          area_info,
-          address,
-          address_id
-        })
+        if (datas.address) {
+          let { true_name, mob_phone, area_info, address, address_id } = datas.address;
+          appInstance.checkDefaultAddress({
+            true_name,
+            mob_phone,
+            area_info,
+            address,
+            address_id
+          })
+        }
         self.setData({
           datas,
           goods_list,
@@ -217,12 +220,5 @@ Page({
    */
   onReachBottom: function () {
 
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-
   }
 })

+ 8 - 1
pages/details/details.js

@@ -287,6 +287,13 @@ Page({
    * 用户点击右上角分享
    */
   onShareAppMessage: function () {
-
+    let goods_id = this.data.options_goods_id
+    let goods_name = this.data.getOneSummary.goods_mobile_name
+    let imageUrl = this.data.imgUrls[0];
+    return {
+      title: `熊猫美妆为您推荐:${goods_name}`,
+      path: `/pages/details/details?goods_id=${goods_id}`,
+      imageUrl: imageUrl
+    }
   }
 })

+ 0 - 7
pages/discover/discover.js

@@ -102,12 +102,5 @@ Page({
    */
   onReachBottom: function () {
   
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-  
   }
 })

+ 0 - 7
pages/fcode/fcode.js

@@ -73,12 +73,5 @@ Page({
    */
   onReachBottom: function () {
   
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-  
   }
 })

+ 1 - 1
pages/index/index.js

@@ -100,7 +100,7 @@ Page({
   },
   onShareAppMessage: function () {
     return {
-      title:"熊猫美妆",
+      title:"熊猫美妆小程序",
       path:"/pages/index/index"
     }
   },

+ 2 - 8
pages/login/login.js

@@ -1,4 +1,5 @@
 // pages/login/login.js
+const api = require('../../config.js');
 let app = getApp();
 Page({
 
@@ -57,20 +58,13 @@ Page({
   onReachBottom: function () {
   
   },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-  
-  },
   userInfoHandler(e){
     if (e.detail.errMsg == "getUserInfo:ok") {
       app.globalData.userInfo = e.detail.userInfo;
       app.globalData.userInfo.nickname = e.detail.userInfo.nickName;
       let userInfo = Object.assign({}, app.globalData.userId, app.globalData.userInfo);
       wx.request({
-        url: 'https://passport.lrlz.com/mobile/index.php?act=login&op=wxauthor&client_type=ios',
+        url: `${api.host}?act=login&op=wxauthor&client_type=ios`,
         method: 'GET',
         data: {
           user_info: userInfo

+ 0 - 7
pages/orderPaySn/orderPaySn.js

@@ -109,12 +109,5 @@ Page({
    */
   onReachBottom: function () {
 
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-
   }
 })

+ 0 - 7
pages/order_tabs/orderTabs.js

@@ -183,13 +183,6 @@ Page({
     }
   },
 
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-
-  },
-
   timeFormat(time) {
     let date = new Date(time * 1000);
     let year = date.getFullYear();

+ 0 - 7
pages/person/person.js

@@ -99,13 +99,6 @@ Page({
   
   },
 
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-  
-  },
-
   bonus_list(){
     this.setData({
       bonus_list_show: !this.data.bonus_list_show

+ 0 - 7
pages/search/search.js

@@ -78,12 +78,5 @@ Page({
    */
   onReachBottom: function () {
   
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-  
   }
 })

+ 15 - 6
pages/special/special.js

@@ -7,18 +7,23 @@ Page({
    */
   data: {
     special_datas: {},
-    summery: []
+    summery: [],
+    special_id:0
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    let title = options.title ? options.title : "熊猫美妆";
+    let special_id = options.special_id;
     wx.setNavigationBarTitle({
-      title: options.title ? options.title : "熊猫美妆"
+      title: title
     })
-    // console.log(options);
-    const special_id = options.special_id;
+    this.setData({
+      special_id,
+      title
+    });
     var self = this;
     getReq({
       act: 'special',
@@ -27,7 +32,6 @@ Page({
       page: 10,
       curpage: 1
     }, function (res) {
-      console.log(res);
       if (res.code == 200) {
         self.setData({
           special_datas: res.datas,
@@ -83,6 +87,11 @@ Page({
    * 用户点击右上角分享
    */
   onShareAppMessage: function () {
-  
+    let special_id = this.data.special_id;
+    let title = this.data.title;
+    return {
+      title: `熊猫美妆为您推荐:${title}`,
+      path: `/pages/special/special?title=${title}&special_id=${special_id}`
+    }
   }
 })

+ 0 - 7
pages/webView/webView.js

@@ -59,12 +59,5 @@ Page({
    */
   onReachBottom: function () {
   
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-  
   }
 })