10.18前的开发
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<script setup>
|
||||
// 引入依赖
|
||||
import uniDatetimePicker from '@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue'
|
||||
import uniEasyinput from '@/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue'
|
||||
import { onLoad } from "@dcloudio/uni-app"
|
||||
import mySwiper from "@/components/mySwiper.vue"
|
||||
import {ref,onMounted,nextTick} from "vue"
|
||||
@@ -8,11 +10,11 @@
|
||||
const store = useStore()
|
||||
onLoad((e) => {
|
||||
if(!store.userInfo?.has_operation) { // 未填写手术信息
|
||||
// operation_flag.value = true
|
||||
// setTimeout(()=>{
|
||||
// console.log(inputDialog.value)
|
||||
// inputDialog.value.open()
|
||||
// },0)
|
||||
operation_flag.value = true
|
||||
setTimeout(()=>{
|
||||
console.log(inputDialog.value)
|
||||
inputDialog.value.open()
|
||||
},0)
|
||||
}
|
||||
})
|
||||
// 变量
|
||||
@@ -42,6 +44,21 @@
|
||||
weigh: 6,
|
||||
}
|
||||
])
|
||||
function toClose() {
|
||||
inputDialog.value.close()
|
||||
}
|
||||
function radioChange(e) {
|
||||
console.log(e)
|
||||
}
|
||||
const single = ref('')
|
||||
function maskClick(e){
|
||||
console.log('maskClick事件:', e);
|
||||
}
|
||||
const hValue = ref('') // 医院
|
||||
const hValueId = ref('') // 医院id
|
||||
function onClickH(e) {
|
||||
console.log(hValue.value)
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<view class="content page-box">
|
||||
@@ -78,9 +95,33 @@
|
||||
</view>
|
||||
<uni-popup ref="inputDialog" :is-mask-click='false'>
|
||||
<view class="pop-box">
|
||||
<view class="pb-title">手术信息</view>
|
||||
<view class="pb-title">完善手术信息</view>
|
||||
<view class="pb-content">
|
||||
<view class="pb-item">
|
||||
<view class="pb-item-left">已经手术</view>
|
||||
<view class="pb-item-right">
|
||||
<radio-group @change="radioChange">
|
||||
<label class="radio"><radio value="1" />是</label>
|
||||
<label class="radio"><radio value="0" />否</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
</view>
|
||||
<view class="pb-item">
|
||||
<view class="pb-item-left">手术时间</view>
|
||||
<view class="pb-item-right">
|
||||
<!-- <uni-datetime-picker type="date" :clear-icon="false" v-model="single" @maskClick="maskClick" /> -->
|
||||
<uniDatetimePicker type="date" :clear-icon="false" v-model="single" @maskClick="maskClick" ></uniDatetimePicker>
|
||||
</view>
|
||||
</view>
|
||||
<view class="pb-item">
|
||||
<view class="pb-item-left">医院名称</view>
|
||||
<view class="pb-item-right">
|
||||
<uniEasyinput suffixIcon="search" v-model="hValue" focus placeholder="请输入内容" @iconClick="onClickH"></uniEasyinput>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="pop-close">
|
||||
<view class="pop-close" @tap="toClose">
|
||||
关闭
|
||||
</view>
|
||||
<!-- <uni-popup-dialog ref="inputClose" mode="input" title="输入内容" value="对话框预置提示内容!"
|
||||
@@ -89,6 +130,27 @@
|
||||
</view>
|
||||
</template>
|
||||
<style scoped lang="scss">
|
||||
.radio{
|
||||
margin-right:20rpx;
|
||||
}
|
||||
.pb-item{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 40rpx;
|
||||
// justify-content: space-between;
|
||||
.pb-item-left{
|
||||
width: 30%;
|
||||
}
|
||||
.pb-item-right{
|
||||
margin-left: 10rpx;
|
||||
width: 75%;
|
||||
}
|
||||
}
|
||||
:deep(){
|
||||
.uni-popup__wrapper{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.part-title{
|
||||
border-left: 10rpx solid #fe915d;
|
||||
padding-left: 20rpx;
|
||||
@@ -148,8 +210,20 @@
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.pop-box{
|
||||
.pb-title{
|
||||
text-align: center;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
background-color: white;
|
||||
padding: 20rpx;
|
||||
width: 80%;
|
||||
margin: 0 auto;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
.pop-close{
|
||||
text-align: center;
|
||||
color: white;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.page-box{
|
||||
padding: 20rpx;
|
||||
|
173
pages/login/login.vue
Normal file
173
pages/login/login.vue
Normal file
@@ -0,0 +1,173 @@
|
||||
<script setup>
|
||||
// 引入依赖
|
||||
import { onLoad } from "@dcloudio/uni-app"
|
||||
// import mySwiper from "@/components/mySwiper.vue"
|
||||
import {ref,onMounted,nextTick,watch} from "vue"
|
||||
import {useStore} from '@/store/index.js'
|
||||
const store = useStore()
|
||||
import api from "@/api/index"
|
||||
import custom from "@/utils/index.js"
|
||||
onLoad(() => {
|
||||
// is_login.value = custom.checkLogin()
|
||||
// console.log(is_login.value)
|
||||
})
|
||||
|
||||
// 变量
|
||||
const avatarUrl = ref(null)
|
||||
const nickname = ref('')
|
||||
const res_form = ref(null)
|
||||
watch(nickname,(v1,v2)=> {
|
||||
console.log("watch",v1)
|
||||
})
|
||||
// 函数
|
||||
function onChooseAvatar(e) {
|
||||
// const { avatarUrl } = e.detail
|
||||
// console.log(avatarUrl)
|
||||
avatarUrl.value = e.detail.avatarUrl
|
||||
|
||||
}
|
||||
function getPhoneNumber (e) {
|
||||
// tel_code.value = e.detail.code
|
||||
// console.log(e)
|
||||
getAccess_token({code:e.detail.code})
|
||||
// console.log(e.detail.code) // 动态令牌
|
||||
// console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
|
||||
// console.log(e.detail.errno) // 错误码(失败时返回)
|
||||
}
|
||||
async function getAccess_token(params={}){//获取token 获取手机号
|
||||
//清除token缓存
|
||||
// wx.clearStorageSync();
|
||||
//访问接口
|
||||
const data={
|
||||
username:params.code,//手机号按钮获取的code
|
||||
type:'wechat_mini_app',
|
||||
identity:'user',
|
||||
password:'111',
|
||||
avatarUrl:avatarUrl.value,
|
||||
nickName:nickname.value
|
||||
}
|
||||
// console.log('登录参数:',data);return;
|
||||
const res = await api.getToken(data)
|
||||
if(res.code === 200) {
|
||||
uni.setStorageSync('avatarUrl', avatarUrl.value);//avatarUrl
|
||||
res_form.value = res.data
|
||||
res_form.value.access_token = 'Bearer '+res.data.access_token
|
||||
let userId = res.data.userId
|
||||
uni.setStorageSync('access_token',res_form.value.access_token);// token单独缓存一次
|
||||
wx_login(userId)
|
||||
}
|
||||
}
|
||||
async function wx_login(userId){
|
||||
let res=await new Promise(resolve=>{
|
||||
uni.login({
|
||||
provider: 'weixin', //使用微信登录
|
||||
success: function (loginRes) {
|
||||
resolve(loginRes);
|
||||
console.log(loginRes,'微信登录返回信息');
|
||||
}
|
||||
});
|
||||
});
|
||||
let res2=await api.wx_login({code:res.code},userId);
|
||||
if(res2.code === 0) {
|
||||
// for(let prop in res_form.value) {
|
||||
// uni.setStorageSync(prop,res_form.value[prop])
|
||||
// }
|
||||
uni.setStorageSync('userInfo',JSON.stringify(res_form.value))
|
||||
custom.uploadImage(avatarUrl.value,async (file)=>{
|
||||
avatarUrl.value = file.data.file.url
|
||||
uni.setStorageSync('avatarUrl', file.data.file.url);//头像链接
|
||||
const up_res = await updateFunc() // 更新用户信息
|
||||
uni.switchTab({
|
||||
url:"/pages/user/index"
|
||||
})
|
||||
})
|
||||
}
|
||||
else{
|
||||
uni.clearStorage();
|
||||
}
|
||||
}
|
||||
async function updateFunc(){ // 更新用户信息,通过此接口获取用户是否填写手术信息
|
||||
let user_info = JSON.parse(uni.getStorageSync('userInfo'))
|
||||
user_info.avatar = avatarUrl.value
|
||||
user_info.id =user_info.userId
|
||||
// console.log(user_info)
|
||||
return await api.userinfoUpdae(user_info)
|
||||
}
|
||||
function nameInput(e) {
|
||||
nickname.value = e.detail.value
|
||||
// console.log('拿到的值:',e)
|
||||
// console.log('nickname:',nickname.value)
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<view class="loginBox page-box img-part card-part" style="text-align:center">
|
||||
<view class="base-info">
|
||||
<button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar" style="border-radius: 50%;">
|
||||
<image class="avatar" v-if="avatarUrl" mode="aspectFill" :src="avatarUrl"></image>
|
||||
<uni-icons type="person-filled" color="white" v-else size="60"></uni-icons>
|
||||
</button>
|
||||
<input type="nickname" @blur="nameInput" class="weui-input" placeholder="请输入昵称" v-model="nickname" />
|
||||
</view>
|
||||
<view class="btn-part">
|
||||
<button class="buy-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">立即登录</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<style scoped lang="scss">
|
||||
.base-info{
|
||||
padding: 50rpx 0;
|
||||
}
|
||||
.loginBox{
|
||||
|
||||
}
|
||||
/* pages/login/login.wxss */
|
||||
page{
|
||||
height: 100%;
|
||||
}
|
||||
.container{
|
||||
align-items: center;
|
||||
}
|
||||
.title{
|
||||
font-weight: bolder;
|
||||
font-size: 40rpx;
|
||||
}
|
||||
.more-info{
|
||||
color: gray;
|
||||
font-size: 24rpx;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
.buy-btn{
|
||||
display: inline-block;
|
||||
margin-top:1rem;
|
||||
background-color: #26758d;
|
||||
color: white;
|
||||
border-radius: 50rpx;
|
||||
font-weight: 200;
|
||||
font-size: 24rpx;
|
||||
width: 50%;
|
||||
padding: 10rpx 0;
|
||||
}
|
||||
.title-part{
|
||||
text-align: center;
|
||||
}
|
||||
.avatar-wrapper{
|
||||
width: 160rpx !important;
|
||||
height: 160rpx;
|
||||
padding: 0px;
|
||||
margin: 0 auto;
|
||||
overflow: hidden;
|
||||
margin-bottom: 40rpx;
|
||||
// border: 1px solid #26758d;
|
||||
background: #ececec;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.avatar{
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
}
|
||||
.weui-input{
|
||||
|
||||
}
|
||||
</style>
|
@@ -1,15 +1,31 @@
|
||||
<script setup>
|
||||
// 引入依赖
|
||||
import { onLoad } from "@dcloudio/uni-app"
|
||||
import { onLoad,onShow } from "@dcloudio/uni-app"
|
||||
import mySwiper from "@/components/mySwiper.vue"
|
||||
import {ref,onMounted,nextTick} from "vue"
|
||||
import {useStore} from '@/store/index.js'
|
||||
const store = useStore()
|
||||
import api from "@/api/index"
|
||||
import custom from "@/utils/index.js"
|
||||
onShow(() => {
|
||||
is_login.value = custom.checkLogin()
|
||||
// console.log(is_login.value)
|
||||
if(is_login.value) {
|
||||
userinfo.value = uni.getStorageSync('userInfo')
|
||||
avatar.value = uni.getStorageSync('avatarUrl')
|
||||
userinfo.value = JSON.parse(userinfo.value)
|
||||
// console.log(userinfo.value)
|
||||
}
|
||||
})
|
||||
// 变量
|
||||
const avatar = ref('')
|
||||
const res_form = ref(null)
|
||||
const is_login = ref(null)
|
||||
const userinfo = ref(null)
|
||||
// 函数
|
||||
function getPhoneNumber (e) {
|
||||
// tel_code.value = e.detail.code
|
||||
console.log(e)
|
||||
// console.log(e)
|
||||
getAccess_token({code:e.detail.code})
|
||||
// console.log(e.detail.code) // 动态令牌
|
||||
// console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
|
||||
@@ -27,10 +43,15 @@
|
||||
}
|
||||
// console.log('登录参数:',data)
|
||||
const res = await api.getToken(data)
|
||||
wx_login()
|
||||
|
||||
if(res.code === 200) {
|
||||
res_form.value = res.data
|
||||
res_form.value.access_token = 'Bearer '+res.data.access_token
|
||||
let userId = res.data.userId
|
||||
uni.setStorageSync('access_token',res_form.value.access_token);// token单独缓存一次
|
||||
wx_login(userId)
|
||||
}
|
||||
}
|
||||
async function wx_login(token_res){
|
||||
async function wx_login(userId){
|
||||
let res=await new Promise(resolve=>{
|
||||
uni.login({
|
||||
provider: 'weixin', //使用微信登录
|
||||
@@ -40,18 +61,61 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
let userId = ''
|
||||
// const res = await api.wx_login(data)
|
||||
let res2=await api.wx_login({code:res.code},userId);
|
||||
}
|
||||
if(res2.code === 0) {
|
||||
// for(let prop in res_form.value) {
|
||||
// uni.setStorageSync(prop,res_form.value[prop])
|
||||
// }
|
||||
uni.setStorageSync(userInfo,JSON.stringify(res_form.value))
|
||||
}
|
||||
else{
|
||||
uni.clearStorage();
|
||||
}
|
||||
}
|
||||
function toLogin() {
|
||||
uni.navigateTo({
|
||||
url:"/pages/login/login"
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<view class="user-box page-box">
|
||||
<button class="submit-btn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
|
||||
<!-- <image class="wx_loin_img" :src="wx_login" mode=""></image> -->
|
||||
<text>登录</text>
|
||||
</button>
|
||||
<view class="userinfo-box">
|
||||
<image :src="is_login?avatar:'../../static/avatar.png'" mode=""></image>
|
||||
<view class="">
|
||||
{{is_login?userinfo.nickname:'未登录'}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="btn-box" @tap="toLogin" v-if="!is_login">
|
||||
<view class="btn">登录</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<style>
|
||||
<style scoped lang="scss">
|
||||
.btn-box{
|
||||
text-align: center;
|
||||
margin-top: 40rpx;
|
||||
.btn{
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
background: #e2e2e2;
|
||||
color: #26758d;
|
||||
border-radius: 10px;
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
.userinfo-box{
|
||||
image{
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 50%;
|
||||
background: white;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
color: white;
|
||||
background-color: #26758d;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 40rpx 20rpx;
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user