From 4ae2daba4de4f3c73444003f3be3997521360819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BD=87?= Date: Wed, 22 Jan 2025 16:17:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E7=AB=AF=E8=AF=B7=E6=B1=82=E6=88=90?= =?UTF-8?q?=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/common.js | 9 +++ api/request.js | 35 ++++++++ api/user.js | 22 ++++++ app.js | 13 ++- app.wxss | 15 +++- assets/icon/help/redpacket@2x.png | Bin 0 -> 2334 bytes pages/help/community/index.js | 26 +++++- pages/help/community/index.json | 3 +- pages/help/community/index.wxml | 19 ++--- pages/help/community/index.wxss | 1 + pages/help/index/index.js | 16 +++- pages/help/index/index.wxml | 9 ++- pages/help/index/index.wxss | 29 +++++++ pages/login/login.js | 18 ++++- pages/login/login.wxml | 48 ++++------- pages/login/login.wxss | 127 ++++++------------------------ 16 files changed, 222 insertions(+), 168 deletions(-) create mode 100644 api/common.js create mode 100644 api/request.js create mode 100644 api/user.js create mode 100644 assets/icon/help/redpacket@2x.png diff --git a/api/common.js b/api/common.js new file mode 100644 index 0000000..d664eed --- /dev/null +++ b/api/common.js @@ -0,0 +1,9 @@ +import request from './request' + +module.exports = { + community:{ + list(params){ + return request.get('/api/community') + } + } +} \ No newline at end of file diff --git a/api/request.js b/api/request.js new file mode 100644 index 0000000..8813c61 --- /dev/null +++ b/api/request.js @@ -0,0 +1,35 @@ +const baseUrl = 'https://api-dev.beefast.co'; +let token; +wx.getStorage({ + key:'accessToken', + success:(res)=>{ + token = res.data; + } +}) + +const sendRequest = (options)=>{ + return new Promise((rs,rj)=>{ + wx.request({ + url: `${baseUrl}${options.url}`, + success:(result)=>{ + rs(result.data.data); + }, + method:options.method, + data:options.data, + params:options.params, + header:{ + Authorization: `Bearer ${token}` + }, + fail:rj + }) + }) +} + +export default { + get(url,params){ + sendRequest({url,method:'get',params}); + }, + post(url,data){ + sendRequest({url,method:'post',data}); + } +} \ No newline at end of file diff --git a/api/user.js b/api/user.js new file mode 100644 index 0000000..48234d9 --- /dev/null +++ b/api/user.js @@ -0,0 +1,22 @@ +import request from './request'; + +export default { + getPhoneByCode(code){ + return request.post('/api/user/send-code',{}) + }, + loginWithPhone(phone){ + return request.post('/api/user/phone-login',{ + phone + }) + }, + loginWithCode(wxCode,phoneCode,rCode){ + return request.post('/api/wechat/phone-login',{ + login_code:wxCode, + phone_code:phoneCode, + referral_code:rCode + }); + }, + info(){ + return request.get('/api/user/info'); + } +} \ No newline at end of file diff --git a/app.js b/app.js index 1ed57c4..9a4b971 100644 --- a/app.js +++ b/app.js @@ -1,4 +1,4 @@ -// app.js +import userApi from './api/user'; App({ onLaunch() { // 展示本地存储能力 @@ -12,8 +12,17 @@ App({ // 发送 res.code 到后台换取 openId, sessionKey, unionId } }) + wx.getStorage({ + key:'accessToken', + success:(res)=>{ + console.log(res.data); + this.globalData.accessToken = res.data; + userApi.info() + } + }) }, globalData: { - userInfo: null + userInfo: null, + accessToken:null } }) diff --git a/app.wxss b/app.wxss index 63bddcd..85f5c68 100644 --- a/app.wxss +++ b/app.wxss @@ -5,6 +5,8 @@ page{ background-color:#F5F5F5; color: #222222; padding-bottom:80rpx; + --main-color:#FEC400; + --main-hover-color:#fcce39; } button{ @@ -29,10 +31,11 @@ button:not([size=mini]) .icon{ } button[type=primary]{ - background-color:#1A4DEB; + background-color:var(--main-color); + color:#222222; } button:not([plain])[type=primary]:hover{ - background-color:#043eec; + background-color:var(--main-hover-color); } button[type=default]{ color: #333333; @@ -41,8 +44,8 @@ button[type=default]{ } button[type=primary][plain]{ - border-color: #1A4DEB; - color:#1A4DEB; + border-color: var(--main-color); + color:var(--main-color); padding:28rpx 25rpx; } button[type=primary][plain]:hover{ @@ -270,4 +273,8 @@ page-container .content{ } .tab-bar .current .item::before{ opacity: 1; +} + +navigator button{ + vertical-align: middle; } \ No newline at end of file diff --git a/assets/icon/help/redpacket@2x.png b/assets/icon/help/redpacket@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..929d9fd77a0df7dc1b23f612ae48b05f24480318 GIT binary patch literal 2334 zcmY*bdpy%^AO4xcn2_mlO3a+*u+0?Nn)7jECY2^R8`iKnGp9u*snp0>=p+>jQI1ba ziPC{`&LO>$Lx^gkdZv1N-uJ#g_wT;$>wA5#@BO|1`lUNN*-1bYApihK5bUj8_`5ED zVMRswU#?Y;Gk+5bv>;gkKy{}0x{omb4D+*hAprnO69Cvp0N^X1Vow7=ls*8=cmn_~ z4*=wtMUA`h{D3o+LI@y{03ALS1waB&K#-3F_!CH@0YX190PvmoL$Flf-)Jf5PgJ*5 z@DIjr2m@3r`I!Q4w7rx_3ds@Y#|T0B_%nQ|sMrwZh5*3F;`lIx8tDUz4G9j7z{Q%t ze=2Z%yg{Sku%D7hx(S>@a)wzk!l^JLls-xyZVG|HVEAzV0Gx}p?eBE{$pju08Og+< z(J?VGsF>|2MtC3^gT-Re`UYqN10-L8jED=3^od1=MyUNV`LB;PHNr2P#*CyfLSY-e zKE8~oNE0}GqtKu6>zbN z%Kzhj*TJJVivQ1Les%hj<+o}I!K42?n<+%Wa{>$iBGUwGi@ia@-3J^px7uv33jN!N zzH1F81v-v63$n1lA7u+d)6THr;hhpTBja{LRg37&&^HARFiZ0@cT|tWDnT_=p$PlK z=AN@2@wK00SyvA=H5<+sC~%jDasrwfTe;U-EAnaaHw;TpMz^%qLYPgp1%GJy_< z>^Qwo=iIaBn8)L(=VjQh5GO_}>xQ)m8FEdoT$OA4bi7h9=fFtjjU* z4Yd!upV@mmc;_JM%;`7v2A|~TbGJV6-udXu$}VZ5*p*Xb zHwS3qM@jjbxjmC)6UnTld01oD7%4?Uy!?(IRvWJkR$ ztTFw3cE=KjE9Rs8tX(S3&o}=@cTMRr@=R8or9~Xp)|U!G!sN)Dk@-jB290`M*VSg- zl_oudt2R4cncxY#?b3SnE$AVX8$|Cs0tw z)vh=jm%Q)_jZn!s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-iG$-Rhrc%oAogPAod^L0guPY?$%>7f-a# zb!64qmp2G3<_YqIQy1T5w>@f1R*-r};MFkYxs`(74Y#bNcnFnxDLXx4vk|JVG)+}F zcUx&6JMlp!u;LZA!1w0QV$tucc7PYUf|#oJb{ZImUIbN$bev!%_Sk&2HTJSy7n={+ z#1ri&X8;TXt(CD;bzARle!Eg&zl!NiBpL9QaxHSjZMwvr4{qW>`uD0{SYvDX)695kKXwE0SGou)>W3? GDgOX4(&Y{S literal 0 HcmV?d00001 diff --git a/pages/help/community/index.js b/pages/help/community/index.js index 51b166a..9d19028 100644 --- a/pages/help/community/index.js +++ b/pages/help/community/index.js @@ -1,18 +1,38 @@ -// pages/help/community/index.js +const commonApi = require('../../../api/common'); + Page({ /** * 页面的初始数据 */ data: { - + currentCommunity:null, + communityList:[] + }, + onSelectItem(event){ + const currentCommunity = event.currentTarget.dataset.item; + this.setData({currentCommunity}) + wx.setStorage({ + key:"currentCommunity", + data:currentCommunity + }); }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { - + wx.getStorage({ + key:'currentCommunity', + success:(res)=>{ + console.log(res); + this.setData({currentCommunity:res.data}) + } + }) + commonApi.community.list().then((data)=>{ + const communityList = data.items; + this.setData({communityList}); + }); }, /** diff --git a/pages/help/community/index.json b/pages/help/community/index.json index 8835af0..1aec356 100644 --- a/pages/help/community/index.json +++ b/pages/help/community/index.json @@ -1,3 +1,4 @@ { - "usingComponents": {} + "usingComponents": {}, + "navigationBarTitleText": "开通小区" } \ No newline at end of file diff --git a/pages/help/community/index.wxml b/pages/help/community/index.wxml index 1623565..b0c5f53 100644 --- a/pages/help/community/index.wxml +++ b/pages/help/community/index.wxml @@ -1,22 +1,13 @@ - + - + - - - - - - - - - - - - + + \ No newline at end of file diff --git a/pages/help/community/index.wxss b/pages/help/community/index.wxss index 34b9bcd..0e83d34 100644 --- a/pages/help/community/index.wxss +++ b/pages/help/community/index.wxss @@ -25,6 +25,7 @@ display: flex; font-size:28rpx; margin-top:34rpx; + line-height: 1.3; } .community-list .item .sub-title .key{ color: #888; diff --git a/pages/help/index/index.js b/pages/help/index/index.js index cfc7dd2..c5fb05f 100644 --- a/pages/help/index/index.js +++ b/pages/help/index/index.js @@ -1,4 +1,4 @@ -// pages/help/index/index.js + Page({ /** @@ -6,14 +6,15 @@ Page({ */ data: { index:0, - array:[1,2,3,4] + array:[1,2,3,4], + communityList:[], + currentCommunity:null }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { - }, /** @@ -26,7 +27,14 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - + wx.getStorage({ + key:"currentCommunity", + success:(res)=>{ + this.setData({ + currentCommunity:res.data + }) + } + }) }, /** diff --git a/pages/help/index/index.wxml b/pages/help/index/index.wxml index cb60292..6c1ec41 100644 --- a/pages/help/index/index.wxml +++ b/pages/help/index/index.wxml @@ -4,7 +4,7 @@ - 选择小区 + {{currentCommunity?currentCommunity.name:'选择小区'}} @@ -41,6 +41,13 @@ + 您有免费跑腿券待领取 diff --git a/pages/help/index/index.wxss b/pages/help/index/index.wxss index 7a10066..d092d02 100644 --- a/pages/help/index/index.wxss +++ b/pages/help/index/index.wxss @@ -127,3 +127,32 @@ padding:0; line-height: 100rpx; } + +.login-panel{ + display:flex; + background-color: #000; + border-radius: 20rpx; + align-items: center; + padding:20rpx; + position: fixed; + bottom:0; + left:20rpx; + right:20rpx; +} +.login-panel .icon{ + width:42rpx;height:56rpx; +} +.login-panel .text{ + font-size:30rpx; + font-weight: 500; + color:#fff; + flex:1; + margin-left:23rpx; +} +.login-panel .button{ + font-size: 26rpx; + font-weight: 500; + line-height: 1; + padding:16rpx 22rpx; + border-radius: 60rpx; +} \ No newline at end of file diff --git a/pages/login/login.js b/pages/login/login.js index fcdc2fa..f5351e8 100644 --- a/pages/login/login.js +++ b/pages/login/login.js @@ -1,6 +1,8 @@ +import userApi from '../../api/user'; + Page({ data: { - isAgree: false + isAgree: true }, handleAgreeChange(e) { @@ -9,7 +11,7 @@ Page({ }) }, - handleLogin() { + onLogin() { if (!this.data.isAgree) { wx.showToast({ title: '请先同意用户协议和隐私政策', @@ -18,11 +20,23 @@ Page({ return } + }, + getPhoneNumber(event){ + console.log(event); wx.login({ success: (res) => { // 实现登录逻辑 console.log('登录成功', res) + this.sendLogin(res.code,event.detail.code); } }) + }, + sendLogin(wxcode,phonecode){ + userApi.loginWithCode(wxcode,phonecode).then((data)=>{ + wx.setStorage({ + key:"accessToken", + data:data.access_token + }) + }) } }) \ No newline at end of file diff --git a/pages/login/login.wxml b/pages/login/login.wxml index 0d3b1a8..f8a1d90 100644 --- a/pages/login/login.wxml +++ b/pages/login/login.wxml @@ -1,34 +1,14 @@ - \ No newline at end of file + + + + + + + + \ No newline at end of file diff --git a/pages/login/login.wxss b/pages/login/login.wxss index 426baaa..67c0123 100644 --- a/pages/login/login.wxss +++ b/pages/login/login.wxss @@ -1,106 +1,27 @@ -.login-container { - min-height: 100vh; - background-color: #4555FF; - padding: 0 40rpx; - position: relative; +.head{ + height:554rpx; + background-color: #F4BD00; } - -.nav-area { - display: flex; - justify-content: space-between; - align-items: center; - padding-top: 120rpx; -} - -.home-icon, -.more-icon { - width: 80rpx; - height: 80rpx; - background: rgba(255, 255, 255, 0.2); - border-radius: 50%; - display: flex; - align-items: center; - justify-content: center; -} - -.home-icon image, -.more-icon image { - width: 36rpx; - height: 36rpx; -} - -.title-area { - margin-top: 120rpx; - color: #fff; -} - -.main-title { - font-size: 72rpx; - font-weight: bold; - margin-bottom: 24rpx; - letter-spacing: 4rpx; -} - -.sub-title { - font-size: 36rpx; - opacity: 0.9; -} - -.login-area { - position: fixed; - left: 40rpx; - right: 40rpx; - bottom: 80rpx; -} - -.agreement { - color: #fff; - font-size: 26rpx; - margin-bottom: 40rpx; - display: flex; - align-items: center; -} - -.agreement checkbox-group { - display: flex; - align-items: center; -} - -.agreement .link { - color: #fff; - text-decoration: underline; - padding: 0 4rpx; -} - -.login-btn { - background: linear-gradient(90deg, #0BBFF5 0%, #4285FF 100%); - color: #fff; - font-size: 32rpx; - font-weight: 500; - border-radius: 45rpx; - height: 100rpx; - line-height: 100rpx; - box-shadow: 0 8rpx 20rpx rgba(66, 133, 255, 0.3); -} - -.login-btn::after { - border: none; -} - -checkbox .wx-checkbox-input { - width: 32rpx; - height: 32rpx; - border-radius: 50%; - border-color: rgba(255, 255, 255, 0.8); - margin-right: 12rpx; -} - -checkbox .wx-checkbox-input.wx-checkbox-input-checked { +.bottom{ background-color: #fff; - border-color: #fff; + position: absolute; + bottom: 0; + top:530rpx; + left:0;right:0; + border-radius: 24rpx 24rpx 0 0; + padding:60rpx 40rpx; } - -checkbox .wx-checkbox-input.wx-checkbox-input-checked::before { - color: #4555FF; - font-size: 24rpx; -} \ No newline at end of file +.bottom .yellow{ + color:#FEC400; +} +.policy{ + font-size: 26rpx; + display: flex; + align-items: center; +} +.policy .radio{ + margin-right:10rpx; +} +.button{ + margin-top:40rpx; +} \ No newline at end of file