From ec0870c2077ac95b60f5502373b32f8ce42b6d65 Mon Sep 17 00:00:00 2001 From: fengyuexingzi Date: Sat, 25 Aug 2018 08:16:43 +0800 Subject: [PATCH] change --- database/seeds/AdminMenuTableSeeder.php | 2 +- mini/app.js | 65 ++++++++- mini/app.json | 1 - mini/pages/start/start.js | 39 ------ mini/pages/start/start.json | 5 - mini/pages/start/start.wxml | 22 --- mini/pages/start/start.wxss | 179 ------------------------ mini/services/user.js | 3 + mini/utils/util.js | 2 + 9 files changed, 64 insertions(+), 254 deletions(-) delete mode 100644 mini/pages/start/start.js delete mode 100644 mini/pages/start/start.json delete mode 100644 mini/pages/start/start.wxml delete mode 100644 mini/pages/start/start.wxss diff --git a/database/seeds/AdminMenuTableSeeder.php b/database/seeds/AdminMenuTableSeeder.php index 45df7fb..ff12a31 100644 --- a/database/seeds/AdminMenuTableSeeder.php +++ b/database/seeds/AdminMenuTableSeeder.php @@ -99,7 +99,7 @@ class AdminMenuTableSeeder extends Seeder 'id' => 8, 'parent_id' => 0, 'order' => 8, - 'title' => '定制科技项目商品板块', + 'title' => '项目定制', 'icon' => 'fa-diamond', 'uri' => NULL, 'created_at' => '2018-05-07 08:18:24', diff --git a/mini/app.js b/mini/app.js index ca4660a..0385a5f 100644 --- a/mini/app.js +++ b/mini/app.js @@ -4,14 +4,65 @@ var user = require('./services/user.js'); App({ onLaunch: function () { - //获取用户的登录信息 - user.checkLogin().then(res => { - console.log('app login') - this.globalData.userInfo = wx.getStorageSync('userInfo'); - this.globalData.token = wx.getStorageSync('token'); - }).catch(() => { - + + // 获取用户信息 + wx.getSetting({ + success: res => { + if (res.authSetting['scope.userInfo']) { + // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框 + wx.getUserInfo({ + success: res => { + console.log('success'); + // 可以将 res 发送给后台解码出 unionId + this.globalData.userInfo = res.userInfo + + // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 + // 所以此处加入 callback 以防止这种情况 + if (this.userInfoReadyCallback) { + this.userInfoReadyCallback(res) + } + }, + fail: error => { + console.log('error:'); + } + }) + } + } + }); + + wx.login({ + success: function (res) { + console.log('登录成功' + res); + if (res.code) { + //发起网络请求 + wx.request({ + url: 'https://mp.fengyuexingzi.top/api/login', + data: { + code: res.code + }, + success: res => { + console.log(res); + }, + fail: error => { + console.log(error) + } + }) + } else { + console.log('登录失败!' + res.errMsg) + } + } }); + + + // //获取用户的登录信息 + // user.checkLogin().then(res => { + // console.log('app login') + // this.globalData.userInfo = wx.getStorageSync('userInfo'); + // this.globalData.token = wx.getStorageSync('token'); + // }).catch(() => { + + // }); + }, globalData: { diff --git a/mini/app.json b/mini/app.json index 17f9114..b975298 100644 --- a/mini/app.json +++ b/mini/app.json @@ -1,6 +1,5 @@ { "pages": [ - "pages/start/start", "pages/index/index", "pages/projectType/projectType", "pages/technologyGoods/technologyGoods", diff --git a/mini/pages/start/start.js b/mini/pages/start/start.js deleted file mode 100644 index 02271a9..0000000 --- a/mini/pages/start/start.js +++ /dev/null @@ -1,39 +0,0 @@ -//login.js -//获取应用实例 -var app = getApp(); -Page({ - data: { - remind: '加载中', - angle: 0, - userInfo: {} - }, - goToIndex:function(){ - wx.switchTab({ - url: '/pages/index/index', - }); - }, - onLoad:function(){ - - }, - onShow:function(){ - - }, - onReady: function(){ - var that = this; - setTimeout(function(){ - that.setData({ - remind: '' - }); - }, 1000); - wx.onAccelerometerChange(function(res) { - var angle = -(res.x*30).toFixed(1); - if(angle>14){ angle=14; } - else if(angle<-14){ angle=-14; } - if(that.data.angle !== angle){ - that.setData({ - angle: angle - }); - } - }); - } -}); \ No newline at end of file diff --git a/mini/pages/start/start.json b/mini/pages/start/start.json deleted file mode 100644 index fc6cb2e..0000000 --- a/mini/pages/start/start.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "navigationBarTitleText": " ", - "enablePullDownRefresh": false, - "disableScroll": true -} \ No newline at end of file diff --git a/mini/pages/start/start.wxml b/mini/pages/start/start.wxml deleted file mode 100644 index 6d2b416..0000000 --- a/mini/pages/start/start.wxml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/mini/pages/start/start.wxss b/mini/pages/start/start.wxss deleted file mode 100644 index f112f1d..0000000 --- a/mini/pages/start/start.wxss +++ /dev/null @@ -1,179 +0,0 @@ -/**start.wxss**/ -page{ - font-family: -apple-system-font, Helvetica Neue, Helvetica, sans-serif; - font-size: 10pt; - line-height: 150%; - min-height: 100%; - position: relative; - display: flex; - flex-direction: column; - align-items: stretch; -} -.container { - position: relative; - flex: 1; - display: flex; - flex-direction: column; - background: #69C3AA; - align-items: stretch; - padding: 0; - height: 100%; - overflow: hidden; - justify-content: space-between; - box-sizing: border-box; -} -.content{ - flex: 1; - display: flex; - position: relative; - z-index: 10; - flex-direction: column; - align-items: stretch; - justify-content: center; - width: 100%; - height: 100%; - padding-bottom: 450rpx; - background: -webkit-gradient(linear, left top, left bottom, from(rgba(244,244,244,0)), color-stop(0.1, #f4f4f4), to(#f4f4f4)); - opacity: 0; - transform: translate3d(0,100%,0); - animation: rise 3s cubic-bezier(0.19, 1, 0.22, 1) .25s forwards; -} - -.remind-box { - flex: 1; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - padding-bottom: 300rpx; -} -.remind-img { - width: 250rpx; - height: 250rpx; - padding-bottom: 25rpx; -} - -@keyframes rise{ - 0% {opacity: 0;transform: translate3d(0,100%,0);} - 50% {opacity: 1;} - 100% {opacity: 1;transform: translate3d(0,450rpx,0);} -} -.title{ - position: absolute; - top: 30rpx; - left: 50%; - width: 600rpx; - height: 200rpx; - margin-left: -300rpx; - opacity: 0; - animation: show 2.5s cubic-bezier(0.19, 1, 0.22, 1) .5s forwards; -} - -.smalltitle{ - position: absolute; - top: 50rpx; - left: 50%; - width: 600rpx; - height: 200rpx; - margin-left: -300rpx; - opacity: 0; - animation: show 2.5s cubic-bezier(0.19, 1, 0.22, 1) .5s forwards; -} - -@keyframes show{ - 0% {opacity: 0;} - 100% {opacity: .95;} -} - -.hd { - position: absolute; - top: 0; - left: 50%; - width: 1000rpx; - margin-left: -500rpx; - height: 200rpx; - transition: all .35s ease; -} -.logo { - position: absolute; - z-index: 2; - left: 50%; - bottom: 200rpx; - width: 160rpx; - height: 160rpx; - margin-left: -80rpx; - border-radius: 160rpx; - animation: sway 10s ease-in-out infinite; - opacity: .95; -} -@keyframes sway{ - 0% {transform: translate3d(0,20rpx,0) rotate(-15deg); } - 17% {transform: translate3d(0,0rpx,0) rotate(25deg); } - 34% {transform: translate3d(0,-20rpx,0) rotate(-20deg); } - 50% {transform: translate3d(0,-10rpx,0) rotate(15deg); } - 67% {transform: translate3d(0,10rpx,0) rotate(-25deg); } - 84% {transform: translate3d(0,15rpx,0) rotate(15deg); } - 100% {transform: translate3d(0,20rpx,0) rotate(-15deg); } -} -.wave { - position: absolute; - z-index: 3; - right: 0; - bottom: 0; - opacity: 0.725; - height: 260rpx; - width: 2250rpx; - animation: wave 10s linear infinite; -} -.wave-bg { - z-index: 1; - animation: wave-bg 10.25s linear infinite; -} -@keyframes wave{ - from {transform: translate3d(125rpx,0,0);} - to {transform: translate3d(1125rpx,0,0);} -} -@keyframes wave-bg{ - from {transform: translate3d(375rpx,0,0);} - to {transform: translate3d(1375rpx,0,0);} -} - -.bd { - position: relative; - flex: 1; - display: flex; - flex-direction: column; - align-items: stretch; - animation: bd-rise 2s cubic-bezier(0.23,1,0.32,1) .75s forwards; - opacity: 0; -} -@keyframes bd-rise{ - from {opacity: 0; transform: translate3d(0,60rpx,0); } - to {opacity: 1; transform: translate3d(0,0,0); } -} - -.confirm-btn { - font-size: 13pt; - line-height: 85rpx; - height: 85rpx; - background: #69C3AA; - color: #fff; - text-align: center; - border-radius: 100rpx; - margin: 40% 20%; -} -.confirm-btn:active { - opacity: .8; -} - - -.copyright { - font-size: 28rpx; - color: #999; - position: fixed; - bottom: 0; - left: 0; - right: 0; - padding: 30rpx; - text-align: center; -} \ No newline at end of file diff --git a/mini/services/user.js b/mini/services/user.js index f41a0ab..730da76 100644 --- a/mini/services/user.js +++ b/mini/services/user.js @@ -12,7 +12,9 @@ const api = require('../config/api.js'); function loginByWeixin() { let code = null; + console.log('promise') return new Promise(function (resolve, reject) { + console.log('promise') return util.login().then((res) => { code = res.code; return util.getUserInfo(); @@ -32,6 +34,7 @@ function loginByWeixin() { reject(err); }); }).catch((err) => { + console.log('code: '); reject(err); }) }); diff --git a/mini/utils/util.js b/mini/utils/util.js index 01df12f..ef45a76 100644 --- a/mini/utils/util.js +++ b/mini/utils/util.js @@ -117,6 +117,7 @@ function login() { success: function (res) { if (res.code) { //登录远程服务器 + console.log(res.code); resolve(res); } else { reject(res); @@ -130,6 +131,7 @@ function login() { } function getUserInfo() { + console('abc'); return new Promise(function (resolve, reject) { wx.getUserInfo({ withCredentials: true,