7145d1c6 by 华明祺

手机登录

1 parent 023f830b
...@@ -28,9 +28,8 @@ function pcLogin(data) { ...@@ -28,9 +28,8 @@ function pcLogin(data) {
28 method: 'post', 28 method: 'post',
29 params: data 29 params: data
30 }).then((res) => { 30 }).then((res) => {
31 uni.setStorageSync('userName', data.username)
32 uni.setStorageSync('token', 'Bearer ' + res.data.token) 31 uni.setStorageSync('token', 'Bearer ' + res.data.token)
33 }) 32 }).then(getInfo)
34 } 33 }
35 34
36 function h5Login(userName) { 35 function h5Login(userName) {
...@@ -42,7 +41,7 @@ function h5Login(userName) { ...@@ -42,7 +41,7 @@ function h5Login(userName) {
42 } 41 }
43 }).then((res) => { 42 }).then((res) => {
44 uni.setStorageSync('token', 'Bearer ' + res.data.token) 43 uni.setStorageSync('token', 'Bearer ' + res.data.token)
45 }) 44 }).then(getInfo)
46 } 45 }
47 46
48 function h5LoginAuto() { 47 function h5LoginAuto() {
...@@ -205,6 +204,60 @@ function getCodeImg() { ...@@ -205,6 +204,60 @@ function getCodeImg() {
205 }) 204 })
206 } 205 }
207 206
207 // 代退图形认证的获取手机验证码
208 function getSmsCode(data) {
209 return request({
210 url: '/captchaSmsWithCaptchaImage',
211 method: 'post',
212 params: data
213 })
214 }
215
216 function loginByPhone(phonenumber, code) {
217 const data = {
218 phonenumber,
219 code
220 }
221 return request({
222 url: '/userLoginByPhone',
223 method: 'post',
224 params: data
225 }).then((res) => {
226 uni.setStorageSync('token', 'Bearer ' + res.data.token)
227 }).then(getInfo)
228 }
229
230 // 获取用户详细信息
231 function getInfo() {
232 return request({
233 url: '/getInfo',
234 method: 'get'
235 }).then(res => {
236 const user = res.data.user
237 uni.setStorageSync('userName', user.userName)
238
239 switch (user.dept.deptType) {
240 case '1':// 中跆协
241 uni.setStorageSync('userType', '1')
242 break
243 case '2':// 省
244 case '3':
245 uni.setStorageSync('userType', '2')
246 break
247 case '6':// 道馆
248 uni.setStorageSync('userType', '4')
249 break
250 default:// 市、区
251 uni.setStorageSync('userType', '3')
252 break
253 }
254
255 delete user.dept
256 uni.setStorageSync('user', JSON.stringify(user))
257 })
258 }
259
260
208 export { 261 export {
209 getNowOpenId, 262 getNowOpenId,
210 wxLogin, 263 wxLogin,
...@@ -215,6 +268,8 @@ export { ...@@ -215,6 +268,8 @@ export {
215 checkUserAuth, 268 checkUserAuth,
216 initData, 269 initData,
217 getCodeImg, 270 getCodeImg,
271 getSmsCode,
218 h5Login, 272 h5Login,
219 h5LoginAuto 273 h5LoginAuto,
274 loginByPhone
220 } 275 }
......
1 <template> 1 <template>
2 <view class="page"> 2 <view class="page">
3 <view> 3 <view>
4 <view class="welcome">您好!<br />欢迎使用中跆协会员管理系统</view> 4 <view class="welcome">您好!<br />欢迎使用中跆协会员管理系统</view>
5 <view class="flexbox"> 5 <view class="flexbox">
6 <view>添加会员</view> 6 <view>添加会员</view>
7 <view>会员缴费</view> 7 <view>会员缴费</view>
8 <view>缴费审核</view> 8 <view>缴费审核</view>
9 </view> 9 </view>
10 10
11 </view> 11 </view>
12 <uni-section padding> 12 <uni-section padding>
13 <uni-grid :column="4" :show-border="false" :square="false" @change="change"> 13 <uni-grid :column="4" :show-border="false" :square="false" @change="change">
14 <uni-grid-item v-for="(item ,index) in list" :index="index" :key="index"> 14 <uni-grid-item v-for="(item ,index) in list" :index="index" :key="index">
15 <view class="grid-item-box"> 15 <view class="grid-item-box">
16 <image class="image" :src="item.url" mode="aspectFill" /> 16 <image class="image" :src="item.url" mode="aspectFill" />
17 <text class="text">{{item.text}}</text> 17 <text class="text">{{item.text}}</text>
18 <view v-if="item.badge" class="grid-dot"> 18 <view v-if="item.badge" class="grid-dot">
19 <uni-badge :text="item.badge" :type="item.type" /> 19 <uni-badge :text="item.badge" :type="item.type" />
20 </view> 20 </view>
21 </view> 21 </view>
22 </uni-grid-item> 22 </uni-grid-item>
23 </uni-grid> 23 </uni-grid>
24 </uni-section> 24 </uni-section>
25 <uni-section title="待办提醒" padding> 25 <uni-section title="待办提醒" padding>
26 <template v-slot:right> 26 <template v-slot:right>
27 <text @click="goMsgList" class="more">更多></text> 27 <text @click="goMsgList" class="more">更多></text>
28 </template> 28 </template>
29 <view class="msglist"> 29 <view class="msglist">
30 <view class="msgitem" v-for="n in 4"> 30 <view class="msgitem" v-for="n in 4">
31 <text class="dot" :class="n.isRead?'done':''"></text> 31 <text class="dot" :class="n.isRead?'done':''"></text>
32 <view class="tt esp">你有一条会员缴费等待审批,点击前去处理!</view> 32 <view class="tt esp">你有一条会员缴费等待审批,点击前去处理!</view>
33 <view class="date">2023-09-23</view> 33 <view class="date">2023-09-23</view>
34 </view> 34 </view>
35 </view> 35 </view>
36 </uni-section> 36 </uni-section>
37 </view> 37 </view>
38 </template> 38 </template>
39 39
40 <script setup> 40 <script setup>
41 import * as api from '@/common/api.js'; 41 import * as api from '@/common/api.js';
42 import * as loginServer from '@/common/login.js'; 42 import * as loginServer from '@/common/login.js';
43 import { 43 import {
44 getWxUser, 44 getWxUser,
45 getWxUserPhone 45 getWxUserPhone
46 } from '@/common/login.js'; 46 } from '@/common/login.js';
47 import { 47 import {
48 onLoad, 48 onLoad,
49 onShow, 49 onShow,
50 onReady, 50 onReady,
51 onShareAppMessage, 51 onShareAppMessage,
52 onShareTimeline, 52 onShareTimeline,
53 onPullDownRefresh 53 onPullDownRefresh
54 } from '@dcloudio/uni-app'; 54 } from '@dcloudio/uni-app';
55 import { 55 import {
56 ref, 56 ref,
57 getCurrentInstance 57 getCurrentInstance
58 } from 'vue'; 58 } from 'vue';
59 59
60 60
61 const { 61 const {
62 proxy 62 proxy
63 } = getCurrentInstance() 63 } = getCurrentInstance()
64 const app = getApp(); 64 const app = getApp();
65 65
66 66
67 let proId; 67 let proId;
68 let goPath; 68 let goPath;
69 const svId = ref(null); 69 const svId = ref(null);
70 const list = ref([{ 70 const list = ref([{
71 url: '/static/c1.png', 71 url: '/static/c1.png',
72 text: '会员调动', 72 text: '会员调动',
73 badge: '0', 73 badge: '0',
74 type: "primary" 74 type: "primary"
75 }, 75 },
76 { 76 {
77 url: '/static/c2.png', 77 url: '/static/c2.png',
78 text: '调动审核', 78 text: '调动审核',
79 badge: '1', 79 badge: '1',
80 type: "success" 80 type: "success"
81 }, 81 },
82 { 82 {
83 url: '/static/c3.png', 83 url: '/static/c3.png',
84 text: '级位考试申请', 84 text: '级位考试申请',
85 badge: '99', 85 badge: '99',
86 type: "warning" 86 type: "warning"
87 }, 87 },
88 { 88 {
89 url: '/static/c4.png', 89 url: '/static/c4.png',
90 text: '级位考试审核', 90 text: '级位考试审核',
91 badge: '2', 91 badge: '2',
92 type: "error" 92 type: "error"
93 }, 93 },
94 { 94 {
95 url: '/static/c5.png', 95 url: '/static/c5.png',
96 text: '段位考试申请' 96 text: '段位考试申请'
97 }, 97 },
98 { 98 {
99 url: '/static/c6.png', 99 url: '/static/c6.png',
100 text: '段位考试审核' 100 text: '段位考试审核'
101 }, 101 },
102 { 102 {
103 url: '/static/c7.png', 103 url: '/static/c7.png',
104 text: '级位证书发送' 104 text: '级位证书发送'
105 }, 105 },
106 { 106 {
107 url: '/static/c8.png', 107 url: '/static/c8.png',
108 text: '段位证书发送' 108 text: '段位证书发送'
109 } 109 }
110 ]); 110 ]);
111 111
112 onShow(() => { 112 onShow(() => {
113 if (app.globalData.isLogin) { 113 if (app.globalData.isLogin) {
114 init(); 114 init();
115 } else { 115 } else {
116 116
117 app.firstLoadCallback = () => { 117 app.firstLoadCallback = () => {
118 init(); 118 init();
119 }; 119 };
120 } 120 }
121 }) 121 })
122 onLoad(option => { 122 onLoad(option => {
123 if (option.scene) { 123 if (option.scene) {
124 proId = decodeURIComponent(option.scene); 124 proId = decodeURIComponent(option.scene);
125 } else { 125 } else {
126 proId = option.proId; 126 proId = option.proId;
127 } 127 }
128 128
129 }); 129 });
130 130
131 function gologin(){ 131 function gologin(){
132 let path = '/pages/index/login'; 132 let path = '/pages/index/login';
133 uni.navigateTo({ 133 uni.navigateTo({
134 url: path 134 url: path
135 }); 135 });
136 } 136 }
137 137
138 function goCenter() { 138 function goCenter() {
139 let path = '/pages/usercenter/usercenter'; 139 let path = '/pages/usercenter/usercenter';
140 if (checkUserPhone(path)) { 140 if (checkUserPhone(path)) {
141 uni.navigateTo({ 141 uni.navigateTo({
142 url: path 142 url: path
143 }); 143 });
144 } 144 }
145 } 145 }
146 146
147 function init() { 147 function init() {
148 148 uni.showToast({
149 } 149 title:uni.getStorageSync('userType')
150 150 })
151 function goMsgList(){ 151 }
152
153 function goMsgList(){
152 154
153 } 155 }
154 156
155 function goItem(item) { 157 function goItem(item) {
156 if (item.path) { 158 if (item.path) {
157 let path = item.path 159 let path = item.path
158 // if (checkUserPhone(path)) { 160 // if (checkUserPhone(path)) {
159 uni.navigateTo({ 161 uni.navigateTo({
160 url: item.path 162 url: item.path
161 }); 163 });
162 // } 164 // }
163 } else { 165 } else {
164 uni.showToast({ 166 uni.showToast({
165 title: `暂未开放`, 167 title: `暂未开放`,
166 icon: 'none' 168 icon: 'none'
167 }); 169 });
168 } 170 }
169 171
170 } 172 }
171 </script> 173 </script>
172 <style scope lang="scss"> 174 <style scope lang="scss">
173 .welcome{padding: 55rpx; 175 .welcome{padding: 55rpx;
......
...@@ -31,17 +31,20 @@ ...@@ -31,17 +31,20 @@
31 <form v-if="isActive==1"> 31 <form v-if="isActive==1">
32 <view class="round-input-item"> 32 <view class="round-input-item">
33 <image class="icon" src="@/static/login/tag01@2x.png"></image> 33 <image class="icon" src="@/static/login/tag01@2x.png"></image>
34 <input placeholder="请输入手机号" /> 34 <uni-easyinput placeholder="请输入手机号" v-model="form2.telNo" />
35 </view> 35 </view>
36 <view class="round-input-item"> 36 <view class="round-input-item">
37 <image class="icon" src="@/static/login/tag02@2x.png"></image> 37 <image class="icon" src="@/static/login/tag02@2x.png"></image>
38 <input placeholder="图形验证码" /> 38 <uni-easyinput placeholder="图形验证码" v-model="form2.captcha" />
39 <image /> 39 <image :src="codeUrl" @click="getCode" />
40 </view> 40 </view>
41 <view class="round-input-item"> 41 <view class="round-input-item">
42 <image class="icon" src="@/static/login/tag04@2x.png"></image> 42 <image class="icon" src="@/static/login/tag04@2x.png"></image>
43 <input placeholder="短信验证码" /> 43 <uni-easyinput placeholder="短信验证码" v-model="form2.code" />
44 <text>获取验证码</text> 44 <text v-if="!countDown.start" @click="getCaptchaSms">获取验证码</text>
45 <uni-countdown v-if="countDown.start" color="#014A9F" :show-day="false" :show-hour="false"
46 :show-min="false" @timeup="timeup" :start="countDown.start"
47 :second="countDown.second"></uni-countdown>
45 </view> 48 </view>
46 49
47 </form> 50 </form>
...@@ -68,9 +71,9 @@ ...@@ -68,9 +71,9 @@
68 </view> 71 </view>
69 <image class="ren2" src="@/static/login/ren2.png" /> 72 <image class="ren2" src="@/static/login/ren2.png" />
70 <view class="fixedagree"> 73 <view class="fixedagree">
71 <image @click="changeAgree(agree)" v-if="agree" src="@/static/login/xz_dwn@2x.png"></image> 74 <!-- <image @click="changeAgree(agree)" v-if="agree" src="@/static/login/xz_dwn@2x.png"></image>
72 <image v-else src="@/static/login/xz2@2x.png"></image> 75 <image v-else src="@/static/login/xz2@2x.png"></image>
73 <view>登录即代表您同意<text>《用户协议》</text><text>《隐私策略》</text></view> 76 <view>登录即代表您同意<text>《用户协议》</text><text>《隐私策略》</text></view> -->
74 </view> 77 </view>
75 </view> 78 </view>
76 </template> 79 </template>
...@@ -82,8 +85,10 @@ import { ...@@ -82,8 +85,10 @@ import {
82 } from 'vue' 85 } from 'vue'
83 86
84 import { 87 import {
85 getCodeImg, 88 getCodeImg,
86 pcLogin 89 getSmsCode,
90 pcLogin,
91 loginByPhone
87 } from '@/common/login.js' 92 } from '@/common/login.js'
88 93
89 const isActive = ref(0) 94 const isActive = ref(0)
...@@ -96,6 +101,16 @@ const form = ref({ ...@@ -96,6 +101,16 @@ const form = ref({
96 code: null, 101 code: null,
97 uuid: null 102 uuid: null
98 }) 103 })
104 const form2 = ref({
105 telNo: null,
106 captcha: null,
107 code: null,
108 uuid: null
109 })
110 const countDown = ref({
111 start: false,
112 second: 60
113 })
99 114
100 const app = getApp() 115 const app = getApp()
101 116
...@@ -113,14 +128,61 @@ function changeAgree(item) { ...@@ -113,14 +128,61 @@ function changeAgree(item) {
113 } 128 }
114 129
115 function login() { 130 function login() {
116 pcLogin(form.value) 131 if (isActive.value == 0) {
117 .then(() => { 132 if (!form.value.username) {
118 app.globalData.isLogin = true 133 uni.showToast({
119 uni.redirectTo({ 134 title: '账号不能为空',
120 url: '/pages/index/index' 135 icon: 'none'
121 }) 136 })
122 }) 137 return
123 .catch(getCode) 138 }
139 if (!form.value.password) {
140 uni.showToast({
141 title: '密码不能为空',
142 icon: 'none'
143 })
144 return
145 }
146 if (!form.value.code) {
147 uni.showToast({
148 title: '验证码不能为空',
149 icon: 'none'
150 })
151 return
152 }
153
154 pcLogin(form.value)
155 .then(() => {
156 app.globalData.isLogin = true
157 uni.redirectTo({
158 url: '/pages/index/index'
159 })
160 })
161 .catch(getCode)
162 } else if (isActive.value == 1) {
163 if (!form2.value.telNo) {
164 uni.showToast({
165 title: '手机号不能为空',
166 icon: 'none'
167 })
168 return
169 }
170 if (!form2.value.code) {
171 uni.showToast({
172 title: '短信验证码不能为空',
173 icon: 'none'
174 })
175 return
176 }
177
178 loginByPhone(form2.value.telNo,form2.value.code)
179 .then(() => {
180 app.globalData.isLogin = true
181 uni.redirectTo({
182 url: '/pages/index/index'
183 })
184 })
185 }
124 } 186 }
125 187
126 function goRegister() { 188 function goRegister() {
...@@ -134,8 +196,46 @@ function getCode() { ...@@ -134,8 +196,46 @@ function getCode() {
134 getCodeImg().then((res) => { 196 getCodeImg().then((res) => {
135 codeUrl.value = 'data:image/gif;base64,' + res.data.img 197 codeUrl.value = 'data:image/gif;base64,' + res.data.img
136 form.value.uuid = res.data.uuid 198 form.value.uuid = res.data.uuid
199 form2.value.uuid = res.data.uuid
137 }) 200 })
138 } 201 }
202
203 // 发送短信验证码
204 function getCaptchaSms() {
205 if (!form2.value.telNo) {
206 uni.showToast({
207 title: '手机号不能为空',
208 icon: 'none'
209 })
210 return
211 }
212 if (!form2.value.captcha) {
213 uni.showToast({
214 title: '图形验证码不能为空',
215 icon: 'none'
216 })
217 return
218 }
219
220 getSmsCode({
221 uuid: form2.value.uuid,
222 telNo: form2.value.telNo,
223 code: form2.value.captcha
224 }).then(res => {
225 uni.showToast({
226 title: '短信验证码下发成功',
227 icon: 'none'
228 })
229 countDown.value.start = true
230 }).catch(getCode)
231 }
232
233 function timeup() {
234 countDown.value.start = false
235 countDown.value.second = 60
236 getCode()
237 }
238
139 </script> 239 </script>
140 240
141 <style scoped lang="scss"> 241 <style scoped lang="scss">
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!