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) - }