diff --git a/App.vue b/App.vue
index 0f20f9e..da04a07 100644
--- a/App.vue
+++ b/App.vue
@@ -11,20 +11,45 @@
}
}
-
diff --git a/api/api.js b/api/api.js
index 234cb05..81049c0 100644
--- a/api/api.js
+++ b/api/api.js
@@ -1,5 +1,10 @@
const url_ = "http://ld.win.sa0.online:81";
let url_array = {};
+url_array['设置账号'] = `${url_}/api/mp/user/set_user_account`;
+url_array['设置手机号'] = `${url_}/api/mp/user/set_user_phone`;
+url_array['修改昵称'] = `${url_}/api/mp/user/set_user_nickname`;
+url_array['上传头像'] = `${url_}/api/mp/user/set_user_avatar`;
+url_array['基础参数'] = `${url_}/api/mp/config`;
url_array['微信登录'] = `${url_}/api/mp/login`;
url_array['用户信息'] = `${url_}/api/mp/get_info`;
url_array['YO'] = `${url_}/api/yo`;
diff --git a/api/img.js b/api/img.js
new file mode 100644
index 0000000..a59e576
--- /dev/null
+++ b/api/img.js
@@ -0,0 +1,6 @@
+const url_ = "http://ld.win.sa0.online:81";
+const img = (mark) => {
+ if (mark === '') return url_;
+ return `${url_}/${mark}`;
+}
+export default img;
diff --git a/api/index.js b/api/index.js
index 83b7412..1d92088 100644
--- a/api/index.js
+++ b/api/index.js
@@ -4,7 +4,103 @@ import $api from "./api.js"
import {
delToken
} from '../tool/member.js'
-export function userLoginAction(code, then) {
+
+export function setUserAccountAction(data, then, error = () => {}) {
+ $post({
+ url: $api('设置账号'),
+ data,
+ then: (response) => {
+ $res({
+ response,
+ then: (response) => {
+ then()
+ },
+ error: (res) => {
+ error()
+ uni.$lu.toast(res.message);
+ }
+ })
+ }
+ })
+}
+export function bindUserPhoneAction(data, then, error = () => {}) {
+ $post({
+ url: $api('设置手机号'),
+ data,
+ then: (response) => {
+ $res({
+ response,
+ then: (response) => {
+ then()
+ },
+ error: (res) => {
+ error()
+ uni.$lu.toast(res.message);
+ }
+ })
+ }
+ })
+}
+export function editUserNicknameAction(nickname, then, error = () => {}) {
+ $post({
+ url: $api('修改昵称'),
+ data: {
+ nickname
+ },
+ then: (response) => {
+ $res({
+ response,
+ then: (response) => {
+ then()
+ },
+ error: (res) => {
+ error()
+ uni.$lu.toast(res.message);
+ }
+ })
+ }
+ })
+}
+export function uploadUserAvatarAction(avatar, then, error = () => {}) {
+ $post({
+ url: $api('上传头像'),
+ data: {
+ avatar
+ },
+ then: (response) => {
+ $res({
+ response,
+ then: (response) => {
+ then()
+ },
+ error: (res) => {
+ error()
+ uni.$lu.toast(res.message);
+ }
+ })
+ }
+ })
+}
+export function getConfigAction(config_arr, then) {
+ $post({
+ url: $api('基础参数'),
+ data: {
+ config_arr
+ },
+ then: (response) => {
+ $res({
+ response,
+ then: (response) => {
+ then(response.data.list)
+ },
+ error: (res) => {
+ uni.$lu.toast(res.message);
+ }
+ })
+ }
+ })
+}
+export function userLoginAction(code, then, error = () => {}) {
$post({
url: $api('微信登录'),
data: {
@@ -17,6 +113,7 @@ export function userLoginAction(code, then) {
then(response.data.token)
},
error: (res) => {
+ error()
uni.$lu.toast(res.message);
}
})
@@ -32,7 +129,7 @@ export function getUserInfoAction(then, msg = true) {
then: (response) => {
then(response.data)
},
- error: (res) => {
+ error: (res) => {
delToken()
if (msg) uni.$lu.toast(res.message);
}
diff --git a/components/Loading/Loading.vue b/components/Loading/Loading.vue
new file mode 100644
index 0000000..58e9a6d
--- /dev/null
+++ b/components/Loading/Loading.vue
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/Login/Login.vue b/components/Login/Login.vue
index 3ef27b3..4782201 100644
--- a/components/Login/Login.vue
+++ b/components/Login/Login.vue
@@ -8,16 +8,25 @@
ref
} from 'vue'
import {
- getUserInfoAction
+ getUserInfoAction,
+ getConfigAction
} from '@/api/index.js'
import {
getToken
} from '@/tool/member.js'
- const mask_show = ref(true)
+ const is_login = ref(false)
const login_show = ref(true)
+ const phone_show = ref(true)
+
+ const props = defineProps({
+ type: {
+ type: String,
+ default: 'fixed'
+ }
+ });
import {
- onShow
+ onShow,
} from '@dcloudio/uni-app'
onShow(() => {
@@ -25,31 +34,76 @@
})
const toLogin = () => {
+ let routes = getCurrentPages();
+ let curRoute = routes[routes.length - 1].route
+ uni.setStorageSync('JUMP_PATH', '/' + curRoute)
uni.navigateTo({
url: '/pages/main/login/login'
})
}
+ const getConfigPhone = () => {
+ getConfigAction("'设置手机号'", (list) => {
+ if (Number(list["设置手机号"].content) === 2) {
+ login_show.value = false
+ phone_show.value = false
+ }
+ })
+ }
const getUserInfo = () => {
login_show.value = true
- mask_show.value = true
+ phone_show.value = true
+ is_login.value = false
if (getToken()) {
getUserInfoAction((info) => {
- login_show.value = false
- mask_show.value = false
+ is_login.value = true
+ if (info.phone) {
+ login_show.value = false
+ } else {
+ getConfigPhone()
+ }
+
}, false)
}
}
+ const toUserSetInfo = () => {
+ uni.navigateTo({
+ url: '/pages/user/set_info/set_info'
+ })
+ }
+
defineExpose({
getUserInfo
})
-
+
+
diff --git a/main.js b/main.js
index 1a6d8a4..0157f60 100644
--- a/main.js
+++ b/main.js
@@ -2,12 +2,14 @@ import App from './App'
import uView from './uni_modules/vk-uview-ui';
import Store from './store'
-import $lu from './lu'
+import $lu from './lu'
+import $img from './api/img.js'
import {
createSSRApp
} from 'vue'
-uni.$lu = $lu
+uni.$lu = $lu
+uni.$img = $img
export function createApp() {
const app = createSSRApp(App)
diff --git a/manifest.json b/manifest.json
index 7a770fd..886e1e7 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,5 +1,5 @@
{
- "name" : "uniapp_default",
+ "name" : "鹿和开发套件",
"appid" : "__UNI__4C3CB5F",
"description" : "",
"versionName" : "1.0.0",
diff --git a/pages.json b/pages.json
index 8d4cd54..d3a1690 100644
--- a/pages.json
+++ b/pages.json
@@ -11,16 +11,14 @@
"navigationBarTitleText": "我的",
"enablePullDownRefresh": false
}
- } ,{
- "path" : "pages/main/login/login",
- "style" :
- {
- "navigationBarTitleText": "",
- "enablePullDownRefresh": false
- }
-
- }
- ],
+ }, {
+ "path": "pages/main/login/login",
+ "style": {
+ "navigationBarTitleText": "",
+ "enablePullDownRefresh": false
+ }
+
+ }],
"subPackages": [{
"root": "pages/dev",
"pages": [{
@@ -31,6 +29,16 @@
"navigationStyle": "custom"
}
+ }]
+ }, {
+ "root": "pages/user",
+ "pages": [{
+ "path": "set_info/set_info",
+ "style": {
+ "navigationBarTitleText": "个人信息",
+ "enablePullDownRefresh": false
+ }
+
}]
}],
"tabBar": {
@@ -55,8 +63,9 @@
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
- },
- "easycom": {
- "Login": "@/components/Login/Login.vue"
+ },
+ "easycom": {
+ "Login": "@/components/Login/Login.vue",
+ "Loading": "@/components/Loading/Loading.vue"
}
}
diff --git a/pages/dev/dev/Vuex/Vuex.vue b/pages/dev/dev/Vuex/Vuex.vue
index d9e8bfe..2aed34c 100644
--- a/pages/dev/dev/Vuex/Vuex.vue
+++ b/pages/dev/dev/Vuex/Vuex.vue
@@ -8,9 +8,6 @@
useStore
} from 'vuex'
const $store = useStore()
- const changeCount = (val) => {
- console.log($store.state.count)
- }
diff --git a/pages/main/login/login.vue b/pages/main/login/login.vue
index a4c69cc..11b9120 100644
--- a/pages/main/login/login.vue
+++ b/pages/main/login/login.vue
@@ -8,13 +8,49 @@
ref
} from 'vue'
import {
- userLoginAction
+ getUserInfoAction,
+ userLoginAction,
+ getConfigAction
} from '@/api/index.js'
+ import {
+ loginJump
+ } from '@/tool/login.js'
import {
setToken
} from '@/tool/member.js'
import config from '@/config.js'
+ import {
+ useStore
+ } from 'vuex'
+ const $store = useStore()
+
+ const getConfigPhone = () => {
+ getConfigAction("'设置手机号'", (list) => {
+ $store.commit('loadingDone')
+ if (Number(list["设置手机号"].content) === 1) {
+ uni.navigateTo({
+ url: '/pages/user/set_info/set_info'
+ })
+ } else {
+ loginJump()
+ }
+ })
+ }
+
+ const getUserInfo = () => {
+ getUserInfoAction((info) => {
+ if (!info.phone) {
+ getConfigPhone()
+ } else {
+ $store.commit('loadingDone')
+ loginJump()
+ }
+ })
+ }
+
+
const wxGetUserInfo = (res) => {
+ $store.commit('loadingStart')
if (!res.detail.iv) {
uni.$lu.toast("您取消了授权,登录失败");
return false;
@@ -24,22 +60,27 @@
success: (loginRes) => {
userLoginAction(loginRes.code, (token) => {
setToken(token)
- uni.switchTab({
- url: '/pages/main/user/user'
- })
+ getUserInfo()
+ }, () => {
+ $store.commit('loadingDone')
})
},
});
}
+
{{ config.title }}
-
+
+
+ 微信登录
+
+
diff --git a/pages/main/user/user.vue b/pages/main/user/user.vue
index cd05ed1..7fce453 100644
--- a/pages/main/user/user.vue
+++ b/pages/main/user/user.vue
@@ -16,14 +16,20 @@
getUserInfoAction
} from '@/api/index.js'
const login_ref = ref(null)
+ const quit_show = ref(false)
const user_info = ref(false)
const loginRef = (e) => {
login_ref.value = e
}
- const quitClick = () => {
+ const quitDo = () => {
+ quit_show.value = false
delToken()
+ user_info.value = false
login_ref.value.getUserInfo()
}
+ const quitClick = () => {
+ quit_show.value = true
+ }
import {
onShow
@@ -33,6 +39,12 @@
getUserInfo()
})
+ const toUserSetInfo = () => {
+ uni.navigateTo({
+ url: '/pages/user/set_info/set_info'
+ })
+ }
+
const getUserInfo = () => {
if (getToken()) {
getUserInfoAction((info) => {
@@ -40,15 +52,19 @@
}, false)
}
}
+
+ const $img = (mark) => {
+ return uni.$img(mark)
+ }
+
-
+
-
-
+
{{ user_info.info.nickname }}
@@ -57,7 +73,7 @@
-
+
点击登录
@@ -65,6 +81,16 @@
+
+
+ 设置信息
+
+
+
+
+ 退出登录
+
+
diff --git a/store/index.js b/store/index.js
index 89c8232..dc2990d 100644
--- a/store/index.js
+++ b/store/index.js
@@ -5,8 +5,17 @@ import {
export default createStore({
state: {
count: 1,
+ loading: 0,
+ },
+ mutations: {
+ loadingStart(state) {
+ state.loading++
+ },
+ loadingDone(state) {
+ state.loading--
+ if (state.loading < 0) state.loading = 0
+ }
},
- mutations: {},
actions: {},
getters: {},
modules: {}
diff --git a/tool/login.js b/tool/login.js
new file mode 100644
index 0000000..1c52c52
--- /dev/null
+++ b/tool/login.js
@@ -0,0 +1,23 @@
+const switchTab = [
+ '/pages/main/user/user',
+ '/pages/main/home/home',
+];
+export function loginJump() {
+ let jump_path = uni.getStorageSync('JUMP_PATH')
+ if (jump_path) {
+ uni.removeStorageSync('JUMP_PATH')
+ if (switchTab.indexOf(jump_path) !== -1) {
+ uni.switchTab({
+ url: jump_path
+ })
+ } else {
+ uni.navigateTo({
+ url: jump_path
+ })
+ }
+ } else {
+ uni.switchTab({
+ url: '/pages/main/user/user'
+ })
+ }
+}