Quellcode durchsuchen

Merge branch 'master' of ssh://git.9026.com:2212/Z1hgq/Furniture

Mike vor 7 Jahren
Ursprung
Commit
f04e583519

+ 4 - 59
Furniture/app.js

xqd
@@ -9,66 +9,11 @@ App({
   onHide: function () {
     console.log('App Hide')
   },
-  request: function (object) {
-    if (!object.data)
-      object.data = {};
-    var access_token = wx.getStorageSync("access_token");
-    if (access_token) {
-      object.data.access_token = access_token;
-    }
-    wx.request({
-      url: object.url,
-      header: object.header || {
-        'content-type': 'application/x-www-form-urlencoded'
-      },
-      data: object.data || {},
-      method: object.method || "GET",
-      dataType: object.dataType || "json",
-      success: function (res) {
-      
-        // console.log(object.url)
 
-        object.success(res.data);
-
-      },
-      fail: function (res) {
-        console.warn('--- request fail >>>');
-        console.warn(res);
-        console.warn('<<< request fail ---');
-        var app = getApp();
-        if (app.is_on_launch) {
-          app.is_on_launch = false;
-          wx.showModal({
-            title: "网络请求出错",
-            content: res.errMsg,
-            showCancel: false,
-            success: function (res) {
-              if (res.confirm) {
-                if (object.fail)
-                  object.fail(res);
-              }
-            }
-          });
-        } else {
-          wx.showToast({
-            title: res.errMsg,
-            image: "/images/icon-warning.png",
-          });
-          if (object.fail)
-            object.fail(res);
-        }
-      },
-      complete: function (res) {
-        if (res.statusCode != 200) {
-          console.log('--- request http error >>>');
-          console.log(res);
-          console.log('<<< request http error ---');
-        }
-        if (object.complete)
-          object.complete(res);
-      }
-    });
-  },
+  login: require("utils/login.js"),
+  request: require("utils/request.js"),
+  utils: require("utils/utils.js"),
+  
   globalData: {
     hasLogin: false,
     store_id: 1

+ 3 - 2
Furniture/app.json

xqd
@@ -1,12 +1,13 @@
 {
   "pages": [
-    "page/login/login",
     "page/homePage/homePage",
     "page/user/user",
     "page/lifeCircle/lifeCircle",
     "page/contact/contact",
     "page/homePage/detail/detail",
-    "page/homePage/detail/conment/conment"
+    "page/homePage/detail/conment/conment",
+    "page/login/login"
+   
   ],
   "window": {
     "navigationBarTextStyle": "black",

+ 5 - 6
Furniture/page/homePage/homePage.js

xqd xqd xqd xqd
@@ -23,8 +23,6 @@ Page({
    */
   onLoad: function (options) {
     var that = this
-    var userinfo = wx.getStorageSync("user_info")
-    console.log(userinfo)
 
     var myAmapFun = new amapFile.AMapWX({ key: 'f74da0d1484bbbefb69059efa771b01d' });
     myAmapFun.getWeather({
@@ -44,11 +42,12 @@ Page({
     app.request({
       url: api.setting,
       success: function (e) {
-        //console.log(e.data)
+        console.log(e.data)
         that.setData({
           slide: e.data.banner,
           nav: e.data.navbar,
           sysinfo: e.data.setting,
+          menus: e.data.menus
         }),
           app.avatar = e.data.setting.avatar,
           app.username = e.data.setting.name
@@ -63,9 +62,9 @@ Page({
       app.request({
       url: api.news_list,
         success: function (e) {
-        
+     
           that.setData({
-            news: e.data.news.data,
+            news: e.data.data,
           })
         }
       }),
@@ -74,7 +73,7 @@ Page({
         success: function (e) {
 
           that.setData({
-            goods: e.data.goods.data,
+            goods: e.data.data,
           })
         }
       })

+ 37 - 12
Furniture/page/homePage/homePage.wxml

xqd
@@ -49,19 +49,44 @@
       </view>
     </view>
     <view class='weui-flex' style='border-bottom: 2rpx #D3D3D3 solid'>
-      <view class='weui-flex__item'>
-        <image src='../../images/xinpinganniu.png' style='height:110rpx;width:40%;margin-left:30%;margin-top:10rpx'></image>
-      </view>
-      <view class='weui-flex__item'>
-        <image src='../../images/tehuianniu.png' style='height:110rpx;width:40%;margin-left:30%;margin-top:10rpx'></image>
-      </view>
-      <view class='weui-flex__item'>
-        <image src='../../images/pingtuananniu.png' style='height:110rpx;width:40%;margin-left:30%;margin-top:10rpx'></image>
-      </view>
-      <view class='weui-flex__item'>
-        <image src='../../images/miaoshaanniu.png' style='height:110rpx;width:40%;margin-left:30%;margin-top:10rpx'></image>
-      </view>
+    <block>
+  <view class="bus-bg">
+    <view class="bus">
+    <block wx:for="{{menus}}" wx:key="{{index}}" wx:for-item="item">
+      <block wx:if="{{item.open_type == 3}}">
+          <view class="bus-item">
+           <navigator target="miniProgram" open-type="navigate" app-id="{{item.app_id}}" path="{{item.url}}" extra-data="" version="release"><image src='{{item.pic_url}}'></image>
+        </navigator>
+          <text>{{item.name}}</text>
+          </view>
+      </block>
+
+      <block wx:if="{{item.open_type == 4}}">
+          <view class="bus-item" bindtap="navigatorClick" data-url="{{item.url}}" data-open_type="{{item.open_type}}">
+          <image src="{{item.pic_url}}"></image>
+          <text>{{item.name}}</text>
+          </view>
+      </block>
+
+      <block wx:if="{{item.open_type == 1}}">
+          <view class="bus-item" bindtap="navigatorClick" data-phone="{{item.mobile}}" data-open_type="{{item.open_type}}">
+          <image src="{{item.pic_url}}"></image>
+          <text>{{item.name}}</text>
+          </view>
+      </block>
+
+      <block wx:if="{{item.open_type == 2}}">
+          <view class="bus-item" bindtap="navigatorClick" data-address="{{item.address}}" data-lon="{{item.lon}}" data-lat="{{item.lat}}" data-open_type="{{item.open_type}}">
+            <image src="{{item.pic_url}}"></image>
+            <text>{{item.name}}</text>
+          </view>
+      </block>
+    </block>
+    </view>
+  </view>
+</block>
     </view>
+
     <view class="relative" style='height:360rpx;border-bottom: 2rpx #D3D3D3 solid'>
       <image class="pic_background" src="../../images/jiajudapei.png"></image>
       <scroll-view  class="marketlist" scrollX="true">

+ 12 - 0
Furniture/page/homePage/homePage.wxss

xqd
@@ -101,3 +101,15 @@
   text-align: center;
   margin-top: 10rpx;
 }
+
+.bus-bg{ width: 100%; background: white; padding-bottom: 10rpx; }
+.bus{ width: 100%; margin: 0px auto; padding-top:10px; display: flex; justify-content:left; flex-wrap: wrap; }
+.bus-item{ width: 25%; height: 150rpx; text-align: center; }
+.bus-item wx-image{ width: 40px; height: 40px; display: block; margin: 5px auto; }
+.bus-item wx-text{ font-size:13px; color:#333; height:35rpx; display:block; }
+.bus2{ width: 95%; justify-content: center; }
+.bus-item2{ width: 50%; height: 135rpx; text-align: center; }
+.bus-item2 wx-image{ width: 90%; height: 120rpx; display: block; margin: 0 auto; }
+.bus3{ width: 100%; justify-content: space-between; padding-top: 0px; }
+.bus-item3{ width: 32%; height: 175px; margin-top: 13rpx; border: 1px solid #f2f2f2; }
+.bus-item3 wx-image{ height: 175px; display: block; margin: 0 auto; }

+ 14 - 12
Furniture/page/login/login.js

xqd
@@ -42,24 +42,26 @@ Page({
               store_id: app.globalData.store_id
             },
             success: function (e) {
-          
-              if (e.data.userinfo.id) {
-                wx.setStorageSync("user_info", e.data.userinfo);
-
+              if (0 == e.status_code) {
+                wx.setStorageSync("access_token",'Bearer '+e.data.token), wx.setStorageSync("user_info", e.data.userinfo);
                 var t = wx.getStorageSync("login_pre_page");
-                t && t.route || wx.switchTab({
-                  url: "/page/homePage/homePage"
+                t && t.route || wx.redirectTo({
+                  url: "/pages/homePage/homePage"
+                });
+                var o = 0;
+                (o = t.options && t.options.user_id ? t.options.user_id : t.options && t.options.scene ? t.options.scene : wx.getStorageSync("parent_id")) && 0 != o && getApp().bindParent({
+                  parent_id: o
+                }), wx.redirectTo({
+                  url: "/" + t.route + "?" + getApp().utils.objectToUrlParams(t.options)
                 });
-              } else ({
-                /*title: "提示",
+              } else console.log(e), wx.showModal({
+          
+                title: "提示",
                 content: e.msg,
-                showCancel: !1*/
+                showCancel: !1
               });
             },
             complete: function () {
-              wx.redirectTo({
-                url: "/page/homePage/homePage"
-              });
               wx.hideLoading();
             }
           });

+ 1 - 1
Furniture/project.config.json

xqd
@@ -12,7 +12,7 @@
 	},
 	"compileType": "miniprogram",
 	"libVersion": "2.2.0",
-	"appid": "wx6c4f3d16cf576f49",
+	"appid": "wx18494553a568fbd1",
 	"projectname": "%E5%AE%B6%E5%85%B7%E6%B1%87",
 	"condition": {
 		"search": {

+ 10 - 0
Furniture/utils/login.js

xqd
@@ -0,0 +1,10 @@
+module.exports = function (e) {
+  var g;
+  if ((g = getCurrentPages()).length) {
+    var r = g[g.length - 1];
+    r && "page/login/login" != r.route && wx.setStorageSync("login_pre_page", r);
+  }
+  wx.redirectTo({
+    url: "/page/login/login"
+  });
+};

+ 46 - 0
Furniture/utils/request.js

xqd
@@ -0,0 +1,46 @@
+module.exports = function (e) {
+  e.data || (e.data = {});
+  var a = wx.getStorageSync("access_token");
+  a && (e.data.access_token = a),
+    wx.request({
+      url: e.url,
+      header: e.header || {
+        "content-type": "application/x-www-form-urlencoded"
+      },
+      data: e.data || {},
+      method: e.method || "GET",
+      dataType: e.dataType || "json",
+      success: function (a) {
+        401 == a.data.data.code ? getApp().login() : e.success && e.success(a.data);
+      },
+      fail: function (a) {
+        console.warn("--- request fail >>>"), console.warn(a), console.warn("<<< request fail ---");
+        var t = getApp();
+        t.is_on_launch ? (t.is_on_launch = !1, wx.showModal({
+          title: "网络请求出错",
+          content: a.errMsg,
+          showCancel: !1,
+          success: function (a) {
+            a.confirm && e.fail && e.fail(a);
+          }
+        })) : (wx.showToast({
+          title: a.errMsg,
+          image: "/images/icon-warning.png"
+        }), e.fail && e.fail(a));
+      },
+      complete: function (t) {
+        200 != t.statusCode && (t.data.code && 500 == t.data.code && wx.showModal({
+          title: "系统错误",
+          content: t.data.data.type + "\r\n事件ID:" + t.data.data.event_id,
+          cancelText: "关闭",
+          confirmText: "复制",
+          success: function (a) {
+            a.confirm && wx.setClipboardData({
+              data: t.data.data.type + "\r\n事件ID:" + t.data.data.event_id + "\r\n " + e.url
+            });
+          }
+        }), console.log("--- request http error >>>"), console.log(t.statusCode), console.log(t.data),
+          console.log("<<< request http error ---")), e.complete && e.complete(t);
+      }
+    });
+};

+ 34 - 0
Furniture/utils/utils.js

xqd
@@ -0,0 +1,34 @@
+function formatTime(t) {
+  var r = t.getFullYear(), e = t.getMonth() + 1, a = t.getDate(), o = t.getHours(), n = t.getMinutes(), m = t.getSeconds();
+  return [r, e, a].map(formatNumber).join("/") + " " + [o, n, m].map(formatNumber).join(":");
+}
+
+function formatData(t) {
+  var r = t.getFullYear(), e = t.getMonth() + 1, a = t.getDate();
+  t.getHours(), t.getMinutes(), t.getSeconds();
+  return [r, e, a].map(formatNumber).join("-");
+}
+
+function formatNumber(t) {
+  return (t = t.toString())[1] ? t : "0" + t;
+}
+
+function objectToUrlParams(t) {
+  var r = "";
+  for (var e in t) r += "&" + e + "=" + t[e];
+  return r.substr(1);
+}
+
+module.exports = {
+  formatTime: formatTime,
+  objectToUrlParams: objectToUrlParams,
+  formatData: formatData,
+  scene_decode: function (t) {
+    var r = (t + "").split(","), e = {};
+    for (var a in r) {
+      var o = r[a].split(":");
+      0 < o.length && o[0] && (e[o[0]] = o[1] || null);
+    }
+    return e;
+  }
+};