添加绑定手机号
This commit is contained in:
parent
c62e30f847
commit
4a3c488019
@ -24,6 +24,7 @@ export default defineManifestConfig({
|
||||
locale: VITE_FALLBACK_LOCALE, // 'zh-Hans'
|
||||
h5: {
|
||||
router: {
|
||||
mode: 'history',
|
||||
base: VITE_APP_PUBLIC_BASE,
|
||||
},
|
||||
sdkConfigs: {
|
||||
|
@ -96,3 +96,7 @@ export function wxLogin(data: { code: string }) {
|
||||
export function phoneLogin(data) {
|
||||
return http.post('/api/auth/phoneLogin', data)
|
||||
}
|
||||
|
||||
export function mpLoginApi(data: { code: string }) {
|
||||
return http.post('/api/auth/mpLogin', data)
|
||||
}
|
||||
|
@ -115,7 +115,8 @@
|
||||
"vueVersion": "3",
|
||||
"h5": {
|
||||
"router": {
|
||||
"base": "/"
|
||||
"mode": "history",
|
||||
"base": ""
|
||||
},
|
||||
"sdkConfigs": {
|
||||
"maps": {
|
||||
|
@ -102,6 +102,14 @@
|
||||
"navigationBarTitleText": "登录"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/login/mpLogin",
|
||||
"type": "page",
|
||||
"layout": "tabbar",
|
||||
"style": {
|
||||
"navigationBarTitleText": "登录"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/my/index",
|
||||
"type": "page",
|
||||
@ -110,6 +118,13 @@
|
||||
"navigationBarTitleText": "我的"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/my/phone",
|
||||
"type": "page",
|
||||
"style": {
|
||||
"navigationBarTitleText": "修改手机号"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/my/setting",
|
||||
"type": "page",
|
||||
|
136
src/pages/login/mpLogin.vue
Normal file
136
src/pages/login/mpLogin.vue
Normal file
@ -0,0 +1,136 @@
|
||||
<route lang="json5">
|
||||
{
|
||||
layout: 'tabbar',
|
||||
style: {
|
||||
navigationBarTitleText: '登录',
|
||||
},
|
||||
}
|
||||
</route>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { mpLoginApi } from '@/api/login'
|
||||
import { useUserStore } from '@/store'
|
||||
import { toast } from '@/utils/toast'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const lastPage = ref('')
|
||||
|
||||
onLoad((options) => {
|
||||
console.log(options)
|
||||
uni.hideTabBar()
|
||||
if (options.code && options.state) {
|
||||
mpLoginApi({ code: options.code }).then((res) => {
|
||||
if (res.code === 1) {
|
||||
const userInfo = res.data
|
||||
userStore.setUserInfo(userInfo)
|
||||
uni.setStorageSync('userInfo', userInfo)
|
||||
uni.setStorageSync('token', userInfo.token)
|
||||
toast.success('登录成功')
|
||||
setTimeout(() => {
|
||||
if (options.target) {
|
||||
let method
|
||||
const indexPat = [
|
||||
'/pages/index/index',
|
||||
'/pages/about/index',
|
||||
'/pages/service/index',
|
||||
'/pages/my/index',
|
||||
]
|
||||
if (options.target === '/pages/login/login') {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index',
|
||||
})
|
||||
return
|
||||
}
|
||||
if (indexPat.includes(options.target)) {
|
||||
uni.switchTab({
|
||||
url: options.target,
|
||||
})
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: options.target,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.navigateBack({
|
||||
delta: 2,
|
||||
})
|
||||
}
|
||||
}, 1500)
|
||||
} else {
|
||||
toast.error(res.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
const pages = getCurrentPages()
|
||||
if (pages[pages.length - 2]) {
|
||||
const route = pages[pages.length - 2].route
|
||||
lastPage.value = `/${route}`
|
||||
}
|
||||
})
|
||||
|
||||
function onClose() {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
})
|
||||
}
|
||||
async function login() {
|
||||
const targetUrl = encodeURIComponent(lastPage.value)
|
||||
const redirectUri = encodeURIComponent(
|
||||
`${location.origin}/pages/login/mpLogin?target=${targetUrl}`,
|
||||
)
|
||||
// const redirectUri = encodeURIComponent(`https://test.shop.lihaink.cn/pages/index/index`)
|
||||
const state = encodeURIComponent(`${`${Math.random()}`.split('.')[1]}authorizestate`)
|
||||
const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxe2428e8fe6767e45&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base&state=${state}#wechat_redirect`
|
||||
window.location.replace(url)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="fly-login">
|
||||
<view class="fly-login-mask" />
|
||||
<view class="fly-login-content px-4">
|
||||
<view class="m-10 text-center">
|
||||
<button type="primary" custom-class="font-bold font-size-5" block @click="login">
|
||||
<text class="font-size-5 color-white font-bold text-shadow">微信登录</text>
|
||||
</button>
|
||||
</view>
|
||||
<view class="text-center">
|
||||
<text class="font-size-5 color-white font-bold text-shadow" @click="onClose">暂不登录</text>
|
||||
</view>
|
||||
<view />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.fly-login {
|
||||
background: url(https://imgs.design006.com/201812/Design006_Nh8kwSNRfZ.jpg);
|
||||
background-size: cover; /* 保持图片宽高比的同时覆盖整个背景区域 */
|
||||
background-position: center; /* 将背景图片居中 */
|
||||
background-repeat: no-repeat; /* 防止背景图片重复 */
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
bottom: 0;
|
||||
z-index: 999;
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
|
||||
.fly-login-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background-color: rgb(0 0 0 / 30%);
|
||||
}
|
||||
|
||||
.fly-login-content {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
bottom: var(--window-bottom);
|
||||
left: 0;
|
||||
top: 50vh;
|
||||
// background-color: #fff;
|
||||
border-top-left-radius: 16px;
|
||||
border-top-right-radius: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
@ -4,6 +4,53 @@
|
||||
}
|
||||
</route>
|
||||
|
||||
<script lang="ts" setup name="WxLogin">
|
||||
import { defineComponent } from 'vue'
|
||||
import { useUserStore } from '@/store'
|
||||
import { getShopWebUrl, getUrl, getWebUrl, hasLogin } from '@/utils'
|
||||
|
||||
const userStore = useUserStore()
|
||||
console.log('userStore', userStore)
|
||||
|
||||
async function more(item) {
|
||||
const islogin = await hasLogin()
|
||||
if (islogin === true) {
|
||||
if (item.type == 1) {
|
||||
getUrl(item.url)
|
||||
} else if (item.type == 2) {
|
||||
getWebUrl(item.url)
|
||||
} else if (item.type == 3) {
|
||||
getShopWebUrl(item.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
const show = ref(false)
|
||||
|
||||
function toLogin() {
|
||||
// #ifdef H5
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/mpLogin',
|
||||
})
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login',
|
||||
})
|
||||
// #endif
|
||||
}
|
||||
|
||||
// const logout = () => {
|
||||
// uni.showModal({
|
||||
// title: '确认退出当前账号?',
|
||||
// success: (res) => {
|
||||
// if (res.confirm) {
|
||||
// userStore.logout()
|
||||
// }
|
||||
// },
|
||||
// })
|
||||
// }
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="background_home">
|
||||
<view class=" " style="">
|
||||
@ -15,14 +62,14 @@
|
||||
src="https://img.shetu66.com/2023/06/14/1686734441937414.png"
|
||||
/> -->
|
||||
<view
|
||||
class="m-4 absolute bottom-0 text-left left-0 right-0 text-white bg-black bg-opacity-0"
|
||||
class="absolute bottom-0 left-0 right-0 m-4 bg-black bg-opacity-0 text-left text-white"
|
||||
style="backdrop-filter: blur(2rpx); border-radius: 10rpx"
|
||||
>
|
||||
<view class="p-4">
|
||||
<view class="flex items-center leading-6" v-if="userStore.userInfo?.id">
|
||||
<image class="w-18 h-18 rounded-full" :src="userStore.userInfo?.avatar"></image>
|
||||
<view v-if="userStore.userInfo?.id" class="flex items-center leading-6">
|
||||
<image class="h-18 w-18 rounded-full" :src="userStore.userInfo?.avatar" />
|
||||
|
||||
<view class="ml-2 flex-content-column">
|
||||
<view class="flex-content-column ml-2">
|
||||
<view class="ps-1 font-size-5 font-bold">
|
||||
{{ userStore.userInfo?.nickname }}
|
||||
</view>
|
||||
@ -31,8 +78,8 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex items-center leading-6" v-else @click="toLogin">
|
||||
<image class="w-18 h-18 rounded-full" :src="userStore.userInfo?.avatar"></image>
|
||||
<view v-else class="flex items-center leading-6" @click="toLogin">
|
||||
<image class="h-18 w-18 rounded-full" :src="userStore.userInfo?.avatar" />
|
||||
<view class="ml-2 font-size-5">去登录</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -44,7 +91,6 @@
|
||||
<wd-card>
|
||||
<wd-grid :gutter="2" :column="4">
|
||||
<view
|
||||
@click="more(item)"
|
||||
v-for="item in [
|
||||
{
|
||||
name: '我的钱包',
|
||||
@ -104,11 +150,12 @@
|
||||
// color: 'red',
|
||||
// },
|
||||
]"
|
||||
@click="more(item)"
|
||||
>
|
||||
<wd-grid-item use-slot>
|
||||
<view class="p-2">
|
||||
<wd-img radius="20rpx" :width="'60rpx'" :height="'60rpx'" :src="item.icon" />
|
||||
<view class="p-2 text-center color-black font-size-4">
|
||||
<wd-img radius="20rpx" width="60rpx" height="60rpx" :src="item.icon" />
|
||||
<view class="p-2 text-center font-size-4 color-black">
|
||||
{{ item.name }}
|
||||
</view>
|
||||
</view>
|
||||
@ -121,42 +168,3 @@
|
||||
<fly-login v-model="show" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="WxLogin">
|
||||
import { useUserStore } from '@/store'
|
||||
import { getUrl, getWebUrl, getShopWebUrl, hasLogin } from '@/utils'
|
||||
const userStore = useUserStore()
|
||||
console.log('userStore', userStore)
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
async function more(item) {
|
||||
const islogin = await hasLogin()
|
||||
if (islogin === true) {
|
||||
if (item.type == 1) {
|
||||
getUrl(item.url)
|
||||
} else if (item.type == 2) {
|
||||
getWebUrl(item.url)
|
||||
} else if (item.type == 3) {
|
||||
getShopWebUrl(item.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
const show = ref(false)
|
||||
|
||||
function toLogin() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login',
|
||||
})
|
||||
}
|
||||
|
||||
// const logout = () => {
|
||||
// uni.showModal({
|
||||
// title: '确认退出当前账号?',
|
||||
// success: (res) => {
|
||||
// if (res.confirm) {
|
||||
// userStore.logout()
|
||||
// }
|
||||
// },
|
||||
// })
|
||||
// }
|
||||
</script>
|
||||
|
@ -3,16 +3,12 @@
|
||||
style: { navigationStyle: 'custom', navigationBarTitleText: '我的' },
|
||||
}
|
||||
</route>
|
||||
<template>
|
||||
<view>
|
||||
<wx-login />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useUserStore } from '@/store'
|
||||
import { http } from '@/utils/http'
|
||||
import WxLogin from './components/wx-login.vue'
|
||||
|
||||
// const userStore = useUserStore()
|
||||
// const hasLogin = computed(() => userStore.userInfo?.nickname)
|
||||
|
||||
@ -35,3 +31,9 @@ import WxLogin from './components/wx-login.vue'
|
||||
// },
|
||||
// })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view>
|
||||
<wx-login />
|
||||
</view>
|
||||
</template>
|
||||
|
116
src/pages/my/phone.vue
Normal file
116
src/pages/my/phone.vue
Normal file
@ -0,0 +1,116 @@
|
||||
<route lang="json5">
|
||||
{
|
||||
style: { navigationBarTitleText: '修改手机号' },
|
||||
}
|
||||
</route>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import { bindPhoneApi, getCodeAPI, setPhoneAPI } from '@/service/crmeb/product.ts'
|
||||
import { useUserStore } from '@/store'
|
||||
|
||||
export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
phone: '',
|
||||
code: '',
|
||||
}
|
||||
},
|
||||
async onLoad(option) {},
|
||||
methods: {
|
||||
async onSubmitPhone() {
|
||||
if (!this.phone) {
|
||||
uni.showToast({
|
||||
title: '请填写手机号',
|
||||
icon: 'none',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const phoneRegex = /^1[3-9]\d{9}$/
|
||||
if (!phoneRegex.test(this.phone)) {
|
||||
uni.showToast({
|
||||
title: '手机号格式不正确',
|
||||
icon: 'none',
|
||||
})
|
||||
return
|
||||
}
|
||||
const res = await setPhoneAPI(this.phone)
|
||||
},
|
||||
getCode() {
|
||||
const phoneRegex = /^1[3-9]\d{9}$/
|
||||
if (!phoneRegex.test(this.phone)) {
|
||||
uni.showToast({
|
||||
title: '手机号格式不正确',
|
||||
icon: 'none',
|
||||
})
|
||||
return
|
||||
}
|
||||
getCodeAPI({ phone: this.phone }).then((res) => {
|
||||
if (res.code == 1) {
|
||||
uni.showToast({
|
||||
title: '获取验证码成功',
|
||||
icon: 'none',
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
submit() {
|
||||
bindPhoneApi({
|
||||
phone: this.phone,
|
||||
code: this.code,
|
||||
}).then((res) => {
|
||||
if (res.code == 1) {
|
||||
uni.showToast({
|
||||
title: '绑定成功',
|
||||
icon: 'none',
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 返回上一级
|
||||
goBack() {
|
||||
uni.navigateBack({
|
||||
delta: 1, // delta 表示返回的页面数,1 表示返回上一级
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="p-2">
|
||||
<view class="detail-box bg-white p-4">
|
||||
<view class="flex items-center justify-around">
|
||||
<view class="w-[130px]">手机号</view>
|
||||
<view>
|
||||
<wd-input v-model="phone" placeholder="请输入手机号" size="large" class="w-[220px]" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex items-center justify-around">
|
||||
<view class="w-[130px]">验证码</view>
|
||||
<view>
|
||||
<wd-input v-model="code" placeholder="请输入验证码" size="large" class="w-[220px]">
|
||||
<template #suffix>
|
||||
<wd-button type="primary" size="small" @click="getCode">获取验证码</wd-button>
|
||||
</template>
|
||||
</wd-input>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mt-2 flex justify-center">
|
||||
<wd-button type="primary" size="large" @click="submit">提交</wd-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
@ -3,211 +3,29 @@
|
||||
style: { navigationBarTitleText: '设置' },
|
||||
}
|
||||
</route>
|
||||
<template>
|
||||
<view class="p-2">
|
||||
<view class="p-2 detail-box bg-white">
|
||||
<wd-card>
|
||||
<wd-cell-group>
|
||||
<wd-cell title="头像" center custom-style="padding:20rpx;font-size:28rpx">
|
||||
<view class="custom-value" style="height: 120rpx" @click="showImage = true">
|
||||
<wd-img
|
||||
round
|
||||
:width="'120rpx'"
|
||||
:height="'120rpx'"
|
||||
:src="userInfo.avatar"
|
||||
custom-class="profile-img"
|
||||
/>
|
||||
</view>
|
||||
</wd-cell>
|
||||
|
||||
<wd-cell
|
||||
icon=""
|
||||
title="昵称"
|
||||
right-icon="lock"
|
||||
:value="userInfo.nickname"
|
||||
:border="false"
|
||||
size="large"
|
||||
is-link
|
||||
custom-style="padding:20rpx;font-size:28rpx"
|
||||
@click="showName = true"
|
||||
/>
|
||||
<wd-cell
|
||||
icon=""
|
||||
title="角色"
|
||||
right-icon="lock"
|
||||
:value="userInfo.group_name"
|
||||
:border="false"
|
||||
size="large"
|
||||
custom-style="padding:20rpx;font-size:28rpx"
|
||||
/>
|
||||
<wd-cell
|
||||
icon=""
|
||||
title="手机号"
|
||||
right-icon="lock"
|
||||
:value="userInfo.phone"
|
||||
:border="false"
|
||||
size="large"
|
||||
custom-style="padding:20rpx;font-size:28rpx"
|
||||
/>
|
||||
|
||||
<wd-cell
|
||||
icon=""
|
||||
title="地址"
|
||||
is-link
|
||||
right-icon="lock"
|
||||
:value="address_string"
|
||||
:border="false"
|
||||
size="large"
|
||||
custom-style="padding:20rpx;font-size:28rpx"
|
||||
@click="show = true"
|
||||
/>
|
||||
</wd-cell-group>
|
||||
<wd-popup
|
||||
v-model="showImage"
|
||||
position="bottom"
|
||||
custom-style="height: 480rpx;padding:20rpx;font-size:28rpx"
|
||||
>
|
||||
<view class="flex items-center">
|
||||
<view class="w-[33%] text-[14px] px-2">修改头像</view>
|
||||
<wd-upload
|
||||
v-model="image"
|
||||
image-mode="aspectFill"
|
||||
:action="action"
|
||||
:limit="1"
|
||||
@success="uploadSuccess"
|
||||
/>
|
||||
</view>
|
||||
<view class="text-center m-10">
|
||||
<wd-button
|
||||
type="primary"
|
||||
custom-class="font-bold font-size-5 "
|
||||
block
|
||||
size="large"
|
||||
@click="onSubmitImage"
|
||||
>
|
||||
<text class="color-white font-bold font-size-5 text-shadow">提交修改</text>
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
<wd-popup
|
||||
v-model="showName"
|
||||
position="bottom"
|
||||
custom-style="height: 480rpx;padding:20rpx;font-size:28rpx"
|
||||
>
|
||||
<wd-input
|
||||
label="修改昵称"
|
||||
type="text"
|
||||
prop="nickname"
|
||||
no-border
|
||||
center
|
||||
size="large"
|
||||
clearable
|
||||
v-model="nickname"
|
||||
placeholder="请填写昵称"
|
||||
/>
|
||||
|
||||
<view class="text-center m-10">
|
||||
<wd-button
|
||||
type="primary"
|
||||
custom-class="font-bold font-size-5 "
|
||||
block
|
||||
size="large"
|
||||
@click="onSubmitInfo"
|
||||
>
|
||||
<text class="color-white font-bold font-size-5 text-shadow">提交修改</text>
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-popup>
|
||||
<wd-popup
|
||||
v-model="showPhone"
|
||||
position="bottom"
|
||||
custom-style="height: 480rpx;padding:20rpx;font-size:28rpx"
|
||||
>
|
||||
<wd-input
|
||||
label="修改手机号"
|
||||
type="number"
|
||||
prop="phone"
|
||||
no-border
|
||||
center
|
||||
size="large"
|
||||
clearable
|
||||
v-model="phone"
|
||||
placeholder="请填写联系电话"
|
||||
:rules="[{ required: false, pattern: /^1[3-9]\d{9}$/, message: '请输入有效手机号码' }]"
|
||||
/>
|
||||
|
||||
<view class="text-center m-10">
|
||||
<wd-button
|
||||
type="primary"
|
||||
custom-class="font-bold font-size-5 "
|
||||
block
|
||||
size="large"
|
||||
@click="onSubmitPhone"
|
||||
>
|
||||
<text class="color-white font-bold font-size-5 text-shadow">提交修改</text>
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
<wd-popup
|
||||
v-model="show"
|
||||
position="bottom"
|
||||
custom-style="height: 480rpx;padding:20rpx;font-size:28rpx"
|
||||
>
|
||||
<wd-col-picker
|
||||
label="修改地址"
|
||||
v-model="address"
|
||||
prop="address"
|
||||
:columns="area"
|
||||
:column-change="columnChange"
|
||||
placeholder="请填写地址"
|
||||
@confirm="handleConfirm"
|
||||
:border="false"
|
||||
size="large"
|
||||
custom-style="padding:20rpx;font-size:28rpx"
|
||||
:rules="[
|
||||
{
|
||||
required: false,
|
||||
validator: (value: string) => {
|
||||
if (value.length > 0) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
message: '地址不能为空,请填写',
|
||||
},
|
||||
]"
|
||||
></wd-col-picker>
|
||||
</wd-popup>
|
||||
</wd-card>
|
||||
</view>
|
||||
<button v-if="hasLogin" class="mt-2" @click="logout">退出登录</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
const switchValue = ref('')
|
||||
|
||||
import { useUserStore } from '@/store'
|
||||
const userStore = useUserStore()
|
||||
import { getEnvBaseUploadUrl } from '@/utils'
|
||||
import { useColPickerData, useModal } from '@/hooks'
|
||||
|
||||
const { colPickerData, findChildrenByCode } = useColPickerData()
|
||||
import { defineComponent } from 'vue'
|
||||
import { useColPickerData, useModal } from '@/hooks'
|
||||
import {
|
||||
getInfoAPI,
|
||||
getCityAPI,
|
||||
getDistrictAPI,
|
||||
getInfoAPI,
|
||||
getStreetAPI,
|
||||
getVillageAPI,
|
||||
setGroupAPI,
|
||||
setPhoneAPI,
|
||||
setInfoPI,
|
||||
setBaseAPI,
|
||||
getUplaodImageAPI,
|
||||
getVillageAPI,
|
||||
setBaseAPI,
|
||||
setGroupAPI,
|
||||
setInfoPI,
|
||||
setPhoneAPI,
|
||||
} from '@/service/crmeb/product.ts'
|
||||
import { useUserStore } from '@/store'
|
||||
import { getEnvBaseUploadUrl } from '@/utils'
|
||||
|
||||
const switchValue = ref('')
|
||||
const userStore = useUserStore()
|
||||
|
||||
const { colPickerData, findChildrenByCode } = useColPickerData()
|
||||
const formData = reactive({
|
||||
image: [],
|
||||
})
|
||||
@ -260,13 +78,13 @@ export default defineComponent({
|
||||
this.getArea()
|
||||
this.getUserInfo()
|
||||
console.log(option)
|
||||
this.type = parseInt(option.type) || 0
|
||||
this.type = Number.parseInt(option.type) || 0
|
||||
console.log('type值', this.type)
|
||||
if (this.type === 1) {
|
||||
//跳转登录
|
||||
// 跳转登录
|
||||
this.show = true
|
||||
} else {
|
||||
//点击进入
|
||||
// 点击进入
|
||||
this.show = false
|
||||
}
|
||||
console.log('type值', this.show)
|
||||
@ -308,16 +126,20 @@ export default defineComponent({
|
||||
this.addressinfo.phone = res.data.phone
|
||||
this.address_string = res.data.district_name + res.data.street_name + res.data.village_name
|
||||
|
||||
this.nickname = this.userInfo['nickname']
|
||||
this.phone = this.userInfo['phone']
|
||||
this.nickname = this.userInfo.nickname
|
||||
this.phone = this.userInfo.phone
|
||||
if (this.userInfo.phone == '' || this.userInfo.phone == null) {
|
||||
this.userInfo.phone = '去绑定'
|
||||
this.phone = '去绑定'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//获取地址--直接到泸州市区级
|
||||
// 获取地址--直接到泸州市区级
|
||||
getArea() {
|
||||
this.getDistrict()
|
||||
},
|
||||
//选择地址后--记录地址字符串
|
||||
// 选择地址后--记录地址字符串
|
||||
handleConfirm(value) {
|
||||
// console.log(value.value.length)
|
||||
// this.addressNumber = value.value.length
|
||||
@ -330,7 +152,7 @@ export default defineComponent({
|
||||
// console.log(this.addressinfo)
|
||||
this.submitGroup()
|
||||
},
|
||||
//图片上传
|
||||
// 图片上传
|
||||
uploadSuccess(res) {
|
||||
const response = JSON.parse(res.file.response)
|
||||
if (response.code === 1) {
|
||||
@ -354,15 +176,15 @@ export default defineComponent({
|
||||
return
|
||||
}
|
||||
const data = {
|
||||
nickname: this.userInfo['nickname'],
|
||||
nickname: this.userInfo.nickname,
|
||||
avatar: this.imgSrc,
|
||||
}
|
||||
const res = await setBaseAPI(data)
|
||||
console.log(res)
|
||||
|
||||
if (res.code === 1) {
|
||||
//重新调用
|
||||
this.userInfo['avatar'] = this.imgSrc
|
||||
// 重新调用
|
||||
this.userInfo.avatar = this.imgSrc
|
||||
userStore.getUserInfo()
|
||||
}
|
||||
this.showImage = false
|
||||
@ -379,12 +201,12 @@ export default defineComponent({
|
||||
this.userInfo.nickname = this.nickname
|
||||
const data = {
|
||||
nickname: this.nickname,
|
||||
avatar: this.userInfo['avatar'],
|
||||
avatar: this.userInfo.avatar,
|
||||
}
|
||||
const res = await setBaseAPI(data)
|
||||
console.log(res)
|
||||
if (res.code === 1) {
|
||||
//重新调用
|
||||
// 重新调用
|
||||
userStore.getUserInfo()
|
||||
}
|
||||
this.showName = false
|
||||
@ -415,15 +237,15 @@ export default defineComponent({
|
||||
const res = await setGroupAPI(this.addressinfo)
|
||||
// console.log(res)
|
||||
this.show = false
|
||||
//重新获取地址信息
|
||||
// 重新获取地址信息
|
||||
userStore.getUserInfo()
|
||||
//跳转页面,设置后返回
|
||||
// 跳转页面,设置后返回
|
||||
if (this.type === 1) {
|
||||
this.goBack()
|
||||
}
|
||||
},
|
||||
|
||||
//地址改版事件
|
||||
// 地址改版事件
|
||||
async columnChange({ selectedItem, resolve, finish }) {
|
||||
try {
|
||||
if (selectedItem.grade === 1) {
|
||||
@ -477,6 +299,196 @@ export default defineComponent({
|
||||
delta: 1, // delta 表示返回的页面数,1 表示返回上一级
|
||||
})
|
||||
},
|
||||
goTo() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/my/phone',
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="p-2">
|
||||
<view class="detail-box bg-white p-2">
|
||||
<wd-card>
|
||||
<wd-cell-group>
|
||||
<wd-cell title="头像" center custom-style="padding:20rpx;font-size:28rpx">
|
||||
<view class="custom-value" style="height: 120rpx" @click="showImage = true">
|
||||
<wd-img
|
||||
round
|
||||
width="120rpx"
|
||||
height="120rpx"
|
||||
:src="userInfo.avatar"
|
||||
custom-class="profile-img"
|
||||
/>
|
||||
</view>
|
||||
</wd-cell>
|
||||
|
||||
<wd-cell
|
||||
icon=""
|
||||
title="昵称"
|
||||
right-icon="lock"
|
||||
:value="userInfo.nickname"
|
||||
:border="false"
|
||||
size="large"
|
||||
is-link
|
||||
custom-style="padding:20rpx;font-size:28rpx"
|
||||
@click="showName = true"
|
||||
/>
|
||||
<wd-cell
|
||||
icon=""
|
||||
title="角色"
|
||||
right-icon="lock"
|
||||
:value="userInfo.group_name"
|
||||
:border="false"
|
||||
size="large"
|
||||
custom-style="padding:20rpx;font-size:28rpx"
|
||||
/>
|
||||
<wd-cell
|
||||
icon=""
|
||||
title="手机号"
|
||||
right-icon="lock"
|
||||
:value="userInfo.phone"
|
||||
:border="false"
|
||||
size="large"
|
||||
clickable
|
||||
custom-style="padding:20rpx;font-size:28rpx"
|
||||
@click="goTo"
|
||||
/>
|
||||
|
||||
<wd-cell
|
||||
icon=""
|
||||
title="地址"
|
||||
is-link
|
||||
right-icon="lock"
|
||||
:value="address_string"
|
||||
:border="false"
|
||||
size="large"
|
||||
custom-style="padding:20rpx;font-size:28rpx"
|
||||
@click="show = true"
|
||||
/>
|
||||
</wd-cell-group>
|
||||
<wd-popup
|
||||
v-model="showImage"
|
||||
position="bottom"
|
||||
custom-style="height: 480rpx;padding:20rpx;font-size:28rpx"
|
||||
>
|
||||
<view class="flex items-center">
|
||||
<view class="w-[33%] px-2 text-[14px]">修改头像</view>
|
||||
<wd-upload
|
||||
v-model="image"
|
||||
image-mode="aspectFill"
|
||||
:action="action"
|
||||
:limit="1"
|
||||
@success="uploadSuccess"
|
||||
/>
|
||||
</view>
|
||||
<view class="m-10 text-center">
|
||||
<wd-button
|
||||
type="primary"
|
||||
custom-class="font-bold font-size-5 "
|
||||
block
|
||||
size="large"
|
||||
@click="onSubmitImage"
|
||||
>
|
||||
<text class="font-size-5 color-white font-bold text-shadow">提交修改</text>
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
<wd-popup
|
||||
v-model="showName"
|
||||
position="bottom"
|
||||
custom-style="height: 480rpx;padding:20rpx;font-size:28rpx"
|
||||
>
|
||||
<wd-input
|
||||
v-model="nickname"
|
||||
label="修改昵称"
|
||||
type="text"
|
||||
prop="nickname"
|
||||
size="large"
|
||||
no-border
|
||||
clearable
|
||||
center
|
||||
placeholder="请填写昵称"
|
||||
/>
|
||||
|
||||
<view class="m-10 text-center">
|
||||
<wd-button
|
||||
type="primary"
|
||||
custom-class="font-bold font-size-5 "
|
||||
block
|
||||
size="large"
|
||||
@click="onSubmitInfo"
|
||||
>
|
||||
<text class="font-size-5 color-white font-bold text-shadow">提交修改</text>
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-popup>
|
||||
<wd-popup
|
||||
v-model="showPhone"
|
||||
position="bottom"
|
||||
custom-style="height: 480rpx;padding:20rpx;font-size:28rpx"
|
||||
>
|
||||
<wd-input
|
||||
v-model="phone"
|
||||
label="修改手机号"
|
||||
type="number"
|
||||
prop="phone"
|
||||
size="large"
|
||||
no-border
|
||||
clearable
|
||||
center
|
||||
placeholder="请填写联系电话"
|
||||
:rules="[{ required: false, pattern: /^1[3-9]\d{9}$/, message: '请输入有效手机号码' }]"
|
||||
/>
|
||||
|
||||
<view class="m-10 text-center">
|
||||
<wd-button
|
||||
type="primary"
|
||||
custom-class="font-bold font-size-5 "
|
||||
block
|
||||
size="large"
|
||||
@click="onSubmitPhone"
|
||||
>
|
||||
<text class="font-size-5 color-white font-bold text-shadow">提交修改</text>
|
||||
</wd-button>
|
||||
</view>
|
||||
</wd-popup>
|
||||
|
||||
<wd-popup
|
||||
v-model="show"
|
||||
position="bottom"
|
||||
custom-style="height: 480rpx;padding:20rpx;font-size:28rpx"
|
||||
>
|
||||
<wd-col-picker
|
||||
v-model="address"
|
||||
label="修改地址"
|
||||
prop="address"
|
||||
:columns="area"
|
||||
:column-change="columnChange"
|
||||
placeholder="请填写地址"
|
||||
:border="false"
|
||||
size="large"
|
||||
custom-style="padding:20rpx;font-size:28rpx"
|
||||
:rules="[
|
||||
{
|
||||
required: false,
|
||||
validator: (value: string) => {
|
||||
if (value.length > 0) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
message: '地址不能为空,请填写',
|
||||
},
|
||||
]"
|
||||
@confirm="handleConfirm"
|
||||
/>
|
||||
</wd-popup>
|
||||
</wd-card>
|
||||
</view>
|
||||
<button v-if="hasLogin" class="mt-2" @click="logout">退出登录</button>
|
||||
</view>
|
||||
</template>
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { http } from '@/utils/http'
|
||||
import { getEnvBaseUrl, getUrlCrmeb, getUrlCrmebProxy } from '@/utils'
|
||||
import { http } from '@/utils/http'
|
||||
|
||||
export interface IFooItem {
|
||||
cate_pid: string
|
||||
// name: string
|
||||
@ -26,8 +27,8 @@ export interface IFooItem {
|
||||
/** GET 请求 */
|
||||
export function getProductAPI(labels: string) {
|
||||
// return http.get<IFooItem>(getUrlCrmebProxy() + '/api/product/spu/lst', { cate_pid })
|
||||
//根据标签获取产品
|
||||
return http.get<IFooItem>(getUrlCrmebProxy() + '/api/product/spu/labels', { labels: labels })
|
||||
// 根据标签获取产品
|
||||
return http.get<IFooItem>(`${getUrlCrmebProxy()}/api/product/spu/labels`, { labels })
|
||||
}
|
||||
// 用户中心
|
||||
export function getInfoAPI() {
|
||||
@ -39,14 +40,14 @@ export function setInfoPI(data: any) {
|
||||
}
|
||||
|
||||
export function setPhoneAPI(phone: any) {
|
||||
return http.post('/api/user/setPhone', { phone: phone })
|
||||
return http.post('/api/user/setPhone', { phone })
|
||||
}
|
||||
|
||||
export function setGroupAPI(data: any) {
|
||||
return http.post('/api/user/setGroup', data)
|
||||
}
|
||||
|
||||
//基础修改
|
||||
// 基础修改
|
||||
export function setBaseAPI(data: any) {
|
||||
return http.post('/api/user/setBase', data)
|
||||
}
|
||||
@ -60,11 +61,11 @@ export function getDistrictAPI() {
|
||||
}
|
||||
|
||||
export function getStreetAPI(code: string) {
|
||||
return http.get('/api/location/getStreet', { code: code })
|
||||
return http.get('/api/location/getStreet', { code })
|
||||
}
|
||||
|
||||
export function getVillageAPI(code: string) {
|
||||
return http.get('/api/location/getVillage', { code: code })
|
||||
return http.get('/api/location/getVillage', { code })
|
||||
}
|
||||
|
||||
// 首页
|
||||
@ -83,14 +84,14 @@ export function getArticleDetailAPI(data: any) {
|
||||
return http.get('/api/article/detail', data)
|
||||
}
|
||||
|
||||
//图片上传
|
||||
// 图片上传
|
||||
export function getUplaodImageAPI(data: any) {
|
||||
return http.post('/api/upload/image', data)
|
||||
}
|
||||
|
||||
/** GET 请求 */
|
||||
export function getMerchantAPI(data: any) {
|
||||
return http.get<IFooItem>(getUrlCrmebProxy() + '/api/store/merchant/lst', data)
|
||||
return http.get<IFooItem>(`${getUrlCrmebProxy()}/api/store/merchant/lst`, data)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,3 +118,11 @@ export function openLocation(
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getCodeAPI(data: any) {
|
||||
return http.post('/api/auth/getCode', data)
|
||||
}
|
||||
|
||||
export function bindPhoneApi(data: any) {
|
||||
return http.post('/api/user/checkPhone', data)
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import type { CustomRequestOptions } from '@/interceptors/request'
|
||||
import { useUserStore } from '@/store'
|
||||
|
||||
export function http<T>(options: CustomRequestOptions) {
|
||||
// 1. 返回 Promise 对象
|
||||
return new Promise<IResData<T>>((resolve, reject) => {
|
||||
@ -24,7 +25,12 @@ export function http<T>(options: CustomRequestOptions) {
|
||||
title: (res.data as IResData<T>).msg || '请登录',
|
||||
})
|
||||
setTimeout(() => {
|
||||
// #ifdef H5
|
||||
uni.navigateTo({ url: '/pages/login/mpLogin' })
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.navigateTo({ url: '/pages/login/login' })
|
||||
// #endif
|
||||
}, 1500)
|
||||
// reject(res)
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user