no message

SPY×FAMILY
鹿和sa0ChunLuyu 4 years ago
parent c55f482e44
commit 4534cde5fa

@ -11,20 +11,45 @@
}
}
</script>
<style lang="scss">
@import "./uni_modules/vk-uview-ui/index.scss";
<style lang="scss">
@import "./uni_modules/vk-uview-ui/index.scss";
</style>
<style>
/*每个页面公共css */
page {
background-color: #f7f7f7;
}
.blank-wrapper {
height: calc(20rpx + var(--safe-area-inset-bottom));
}
.navbar-wrapper {
height: calc(100rpx + var(--safe-area-inset-top));
/*每个页面公共css */
page {
background-color: #f7f7f7;
}
.opentype_button_wrapper {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
opacity: 0;
}
.primary_button_wrapper {
position: relative;
width: 580rpx;
height: 90rpx;
background: linear-gradient(90deg, #67b163, #529051);
border-radius: 45rpx;
font-size: 31rpx;
font-weight: 500;
color: #F6FDFD;
line-height: 90rpx;
text-align: center;
margin: 200rpx auto 0;
box-shadow: 0 0 50rpx #00000060;
}
.blank-wrapper {
height: calc(20rpx + var(--safe-area-inset-bottom));
}
.navbar-wrapper {
height: calc(100rpx + var(--safe-area-inset-top));
}
</style>

@ -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`;

@ -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;

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

@ -0,0 +1,35 @@
<script setup>
/**
* name
* usersa0ChunLuyu
* date2022-04-24 22:18:55
*/
import {
ref,
computed
} from 'vue'
import {
useStore
} from 'vuex'
const $store = useStore()
const loading_show = computed(() => {
return $store.state.loading
})
</script>
<template>
<view v-if="loading_show > 0">
<u-mask :show="true" :mask-click-able="false">
<view class="loading_icon_wrapper">
<u-loading mode="circle"></u-loading>
</view>
</u-mask>
</view>
</template>
<style scoped>
.loading_icon_wrapper {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>

@ -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
})
</script>
<template>
<view v-if="login_show">
<u-mask :custom-style="{
opacity: 0
}" :show="mask_show" @click="toLogin()"></u-mask>
<view class="login_wrapper" v-if="!is_login" :style="{
position: props.type
}" @click="toLogin()"></view>
<view class="phone_wrapper" v-if="phone_show" :style="{
position: props.type
}" @click="toUserSetInfo()"></view>
</view>
</template>
<style scoped>
.phone_wrapper {
top: 0;
bottom: 0;
left: 0;
right: 0;
background: #000000;
opacity: 0;
z-index: 9998;
}
.login_wrapper {
top: 0;
bottom: 0;
left: 0;
right: 0;
background: #000000;
opacity: 0;
z-index: 9999;
}
</style>

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

@ -1,5 +1,5 @@
{
"name" : "uniapp_default",
"name" : "鹿和开发套件",
"appid" : "__UNI__4C3CB5F",
"description" : "",
"versionName" : "1.0.0",

@ -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"
}
}

@ -8,9 +8,6 @@
useStore
} from 'vuex'
const $store = useStore()
const changeCount = (val) => {
console.log($store.state.count)
}
</script>
<template>
<u-tr>

@ -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')
})
},
});
}
</script>
<template>
<Loading></Loading>
<view class="home_wrapper u-text-center">
<view class="home_logo_wrapper">
<u-image width="200rpx" height="200rpx" src="/static/logo.png"></u-image>
</view>
<view class="home_title_wrapper">{{ config.title }}</view>
<button class="open_type_button_wrapper" open-type="getUserInfo" @getuserinfo="wxGetUserInfo"
withCredentials="true">微信登录</button>
<view class="primary_button_wrapper">
<button class="opentype_button_wrapper" open-type="getUserInfo" @getuserinfo="wxGetUserInfo"
withCredentials="true"></button>
微信登录
</view>
</view>
</template>

@ -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)
}
</script>
<template>
<u-modal v-model="quit_show" confirm-color="#529051" :show-cancel-button="true" @confirm="quitDo"
content="是否退出当前账号?"></u-modal>
<Login :ref="loginRef"></Login>
<view class="user_top_wrapper">
<view v-if="user_info" class="user_info_wrapper">
<view v-if="user_info" class="user_info_wrapper" @click="toUserSetInfo()">
<view class="user_info_avatar_wrapper">
<u-image v-if="user_info.info.avatar" :src="`${user_info.info.nickname}?s=140`" width="140rpx"
height="140rpx"></u-image>
<u-image v-else src="/static/logo.png" width="140rpx" height="140rpx"></u-image>
<u-image :src="user_info.info.avatar" width="140rpx" height="140rpx"></u-image>
</view>
<view class="user_info_nickname_wrapper">
<view v-if="user_info.info.nickname">{{ user_info.info.nickname }}</view>
@ -57,7 +73,7 @@
</view>
<view v-else class="user_info_wrapper">
<view class="user_info_avatar_wrapper">
<u-image src="/static/logo.png" width="140rpx" height="140rpx"></u-image>
<u-image :src="$img('upload/user/avatar/default.png')" width="140rpx" height="140rpx"></u-image>
</view>
<view class="user_info_nickname_wrapper">
点击登录
@ -65,6 +81,16 @@
</view>
<view class="user_top_bottom_bg_wrapper"></view>
</view>
<view>
<view v-if="user_info" @click="toUserSetInfo()" class="primary_button_wrapper set_info_wrapper">
设置信息
</view>
</view>
<view>
<view v-if="user_info" @click="quitClick()" class="primary_button_wrapper quit_wrapper">
退出登录
</view>
</view>
</template>
<style>
page {
@ -72,12 +98,22 @@
}
</style>
<style scoped>
.set_info_wrapper {
margin: 200rpx auto 0;
}
.quit_wrapper {
margin: 50rpx auto 0;
}
.user_info_avatar_wrapper {
width: 140rpx;
height: 140rpx;
border-radius: 6rpx;
background: #ffffff;
margin: 30rpx auto 0;
margin: 30rpx auto 0;
border-radius: 6rpx;
overflow: hidden;
box-shadow: 0 0 50rpx #00000060;
}

@ -0,0 +1,296 @@
<script setup>
/**
* name
* usersa0ChunLuyu
* date2022-04-23 21:25:04
*/
import {
ref,
onMounted
} from 'vue'
import config from '@/config.js'
import {
bindUserPhoneAction,
setUserAccountAction,
editUserNicknameAction,
uploadUserAvatarAction,
getUserInfoAction,
getConfigAction
} from '@/api/index.js'
import {
loginJump
} from '@/tool/login.js'
import {
useStore
} from 'vuex'
const $store = useStore()
const user_info = ref(false)
const edit_nickname = ref(false)
onMounted(() => {
getUserInfo()
})
const getConfigPhone = () => {
getConfigAction("'设置手机号'", (list) => {
if (Number(list["设置手机号"].content) === 1) {
uni.$lu.toast('根据规定,请绑定手机号');
}
})
}
const getUserInfo = () => {
getUserInfoAction((info) => {
user_info.value = info
if (!user_info.value.phone) getConfigPhone()
if (user_info.value.account) user_account.value = user_info.value.account.account
})
}
const uploadUserAvatar = (toast = true) => {
$store.commit('loadingStart')
uploadUserAvatarAction(user_info.value.info.avatar, () => {
$store.commit('loadingDone')
if (toast) uni.$lu.toast('上传成功');
getUserInfo()
}, () => {
$store.commit('loadingDone')
})
}
const onChooseAvatar = (e) => {
checkAvatarUrl(e.detail.avatarUrl)
}
const checkAvatarUrl = (avatar, toast = true) => {
if (avatar.indexOf('thirdwx.qlogo.cn') === -1) {
wx.getFileSystemManager().readFile({
filePath: avatar,
encoding: 'base64',
success: res => {
let base64 = 'data:image/png;base64,' + res.data;
user_info.value.info.avatar = base64
uploadUserAvatar(toast)
}
});
} else {
uni.request({
url: avatar,
method: 'GET',
responseType: 'arraybuffer',
success: res => {
let base64 = 'data:image/png;base64,' + uni.arrayBufferToBase64(res.data);
user_info.value.info.avatar = base64
uploadUserAvatar(toast)
}
});
}
}
const updateUserInfo = (res) => {
wx.getUserProfile({
desc: '新用户完善用户资料',
success: (res) => {
let d = res.userInfo
user_info.value.info.nickname = d.nickName
editUserNickname()
user_info.value.info.avatar = d.avatarUrl
checkAvatarUrl(user_info.value.info.avatar, false)
}
})
}
const phoneLoginButtonClick = (e) => {
uni.login({
provider: 'weixin',
success: (loginRes) => {
bindUserPhone({
code: loginRes.code,
iv: e.detail.iv,
encrypted_data: e.detail.encryptedData,
})
},
});
}
const user_account = ref('')
const edit_account = ref(false)
const user_password = ref('')
const check_password = ref('')
const old_password = ref('')
const editAccountClick = () => {
if (!user_info.value.account) {
edit_account.value = true
}
}
const editUserNickname = () => {
$store.commit('loadingStart')
editUserNicknameAction(user_info.value.info.nickname, () => {
$store.commit('loadingDone')
uni.$lu.toast('设置成功');
getUserInfo()
}, () => {
$store.commit('loadingDone')
})
}
const editNicknameDone = () => {
edit_nickname.value = false
editUserNickname()
}
const bindUserPhone = (data) => {
$store.commit('loadingStart')
bindUserPhoneAction(data, () => {
$store.commit('loadingDone')
uni.$lu.toast('设置成功');
getUserInfo()
let jump_path = uni.getStorageSync('JUMP_PATH')
if (jump_path) loginJump()
}, () => {
$store.commit('loadingDone')
})
}
const setUserAccount = () => {
if (!user_password.value) return uni.$lu.toast('请输入密码');
if (user_password.value.length < 6 || user_password.value.length > 40) return uni.$lu.toast('密码长度应在6-20字符之间');
if (user_password.value !== check_password.value) return uni.$lu.toast('两次输入的密码不一致');
let data = {}
if (user_info.value.account) {
data.old_password = old_password.value
data.password = user_password.value
} else {
if (!user_account.value) return uni.$lu.toast('请输入账号');
if (user_account.value.length < 2 || user_account.value.length > 20) return uni.$lu.toast(
'账号长度应在2-20字符之间');
data.account = user_account.value
data.password = user_password.value
}
$store.commit('loadingStart')
setUserAccountAction(data, () => {
$store.commit('loadingDone')
uni.$lu.toast('设置成功');
old_password.value = ''
user_password.value = ''
check_password.value = ''
getUserInfo()
}, () => {
$store.commit('loadingDone')
})
}
</script>
<template>
<Loading></Loading>
<view v-if="user_info">
<view class="info_line_wrapper user_avatar_wrapper">
<view class="info_title_wrapper">头像</view>
<view class="user_info_avatar_wrapper">
<u-image :src="user_info.info.avatar" width="140rpx" height="140rpx">
</u-image>
<button class="opentype_button_wrapper" open-type="chooseAvatar"
@chooseavatar="onChooseAvatar">获取头像</button>
</view>
</view>
<view class="info_line_wrapper user_nickname_wrapper">
<view class="info_title_wrapper">昵称</view>
<view class="info_content_wrapper">
<view v-if="!edit_nickname" @click="edit_nickname = true">
{{ user_info.info.nickname?user_info.info.nickname:'未设置' }}
</view>
<view v-else>
<input :focus="edit_nickname" @blur="editNicknameDone()" type="nickname"
v-model="user_info.info.nickname" placeholder="请输入昵称" />
</view>
</view>
</view>
<view>
<view class="primary_button_wrapper get_wx_info_wrapper">
<button class="opentype_button_wrapper" @tap="updateUserInfo" withCredentials="true">获取信息</button>
授权获取微信头像和昵称
</view>
</view>
<view class="info_line_wrapper user_nickname_wrapper">
<button class="opentype_button_wrapper" open-type="getPhoneNumber" @getphonenumber="phoneLoginButtonClick"
withCredentials="true">获取手机号</button>
<view class="info_title_wrapper">手机号</view>
<view class="info_content_wrapper">
<view>
{{ user_info.phone?user_info.phone.account:'未设置,点击此处设置' }}
</view>
</view>
</view>
<view class="info_line_wrapper user_nickname_wrapper">
<view class="info_title_wrapper">账号</view>
<view class="info_content_wrapper">
<view v-if="!edit_account" @click="editAccountClick()">
{{ user_account?user_account:'未设置' }}
</view>
<view v-else>
<input :focus="edit_account" @blur="edit_account = false" v-model="user_account"
placeholder="请输入账号" />
</view>
</view>
</view>
<view v-if="user_info.account" class="info_line_wrapper user_nickname_wrapper">
<view class="info_title_wrapper">旧密码</view>
<view class="info_content_wrapper">
<input v-model="old_password" placeholder="请输入旧密码" />
</view>
</view>
<view class="info_line_wrapper user_nickname_wrapper">
<view class="info_title_wrapper">{{ user_info.account?'新密码':'密码' }}</view>
<view class="info_content_wrapper">
<input v-model="user_password" placeholder="请输入密码" />
</view>
</view>
<view class="info_line_wrapper user_nickname_wrapper">
<view class="info_title_wrapper">确认密码</view>
<view class="info_content_wrapper">
<input v-model="check_password" placeholder="请确认密码" />
</view>
</view>
<view>
<view @click="setUserAccount()" class="primary_button_wrapper get_wx_info_wrapper">
{{ user_info.account?'修改密码':'创建账号' }}
</view>
</view>
</view>
<view class="info_line_wrapper user_phone_wrapper"></view>
</template>
<style scoped>
.get_wx_info_wrapper {
margin: 50rpx auto;
}
.info_content_wrapper {
text-align: right;
}
.user_info_avatar_wrapper {
width: 140rpx;
height: 140rpx;
position: relative;
}
.info_title_wrapper {
font-weight: bold;
}
.info_line_wrapper {
position: relative;
padding: 30rpx;
display: flex;
min-height: 110rpx;
align-items: center;
justify-content: space-between;
}
</style>

@ -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: {}

@ -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'
})
}
}
Loading…
Cancel
Save