添加公众号配置
This commit is contained in:
4
env/.env
vendored
4
env/.env
vendored
@ -10,12 +10,12 @@ VITE_APP_PUBLIC_BASE = '/h5'
|
||||
# 登录页面
|
||||
VITE_LOGIN_URL = '/pages/login/login'
|
||||
# 第一个请求地址
|
||||
VITE_SERVER_BASEURL = 'https://cz.stnav.com/gzhapi'
|
||||
VITE_SERVER_BASEURL = 'https://cz.stnav.com'
|
||||
|
||||
VITE_UPLOAD_BASEURL = 'https://cz.stnav.com/upload'
|
||||
|
||||
# h5是否需要配置代理
|
||||
VITE_APP_PROXY=false
|
||||
VITE_APP_PROXY=true
|
||||
VITE_APP_PROXY_PREFIX = '/api'
|
||||
|
||||
# 第二个请求地址 (目前alova中可以使用)
|
||||
|
||||
2
env/.env.production
vendored
2
env/.env.production
vendored
@ -1,6 +1,6 @@
|
||||
# 变量必须以 VITE_ 为前缀才能暴露给外部读取
|
||||
NODE_ENV = 'development'
|
||||
# 是否去除console 和 debugger
|
||||
VITE_DELETE_CONSOLE = false
|
||||
VITE_DELETE_CONSOLE = false
|
||||
# 是否开启sourcemap
|
||||
VITE_SHOW_SOURCEMAP = false
|
||||
|
||||
@ -101,6 +101,8 @@
|
||||
"dayjs": "1.11.10",
|
||||
"echarts": "^6.0.0",
|
||||
"js-cookie": "^3.0.5",
|
||||
"jweixin-1.6.0": "^1.0.0",
|
||||
"jweixin-module": "^1.6.0",
|
||||
"pinia": "2.0.36",
|
||||
"pinia-plugin-persistedstate": "3.2.1",
|
||||
"vue": "3.4.21",
|
||||
|
||||
40
pnpm-lock.yaml
generated
40
pnpm-lock.yaml
generated
@ -91,6 +91,12 @@ importers:
|
||||
js-cookie:
|
||||
specifier: ^3.0.5
|
||||
version: 3.0.5
|
||||
jweixin-1.6.0:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
jweixin-module:
|
||||
specifier: ^1.6.0
|
||||
version: 1.6.0
|
||||
pinia:
|
||||
specifier: 2.0.36
|
||||
version: 2.0.36(typescript@5.9.2)(vue@3.4.21(typescript@5.9.2))
|
||||
@ -240,15 +246,6 @@ importers:
|
||||
specifier: ^2.2.10
|
||||
version: 2.2.12(typescript@5.9.2)
|
||||
|
||||
src/uni_modules/lime-echart:
|
||||
dependencies:
|
||||
echarts:
|
||||
specifier: ^5.4.1
|
||||
version: 5.6.0
|
||||
zrender:
|
||||
specifier: ^5.4.3
|
||||
version: 5.6.1
|
||||
|
||||
src/uni_modules/mescroll-uni: {}
|
||||
|
||||
src/uni_modules/uni-icons: {}
|
||||
@ -3442,9 +3439,6 @@ packages:
|
||||
eastasianwidth@0.2.0:
|
||||
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
||||
|
||||
echarts@5.6.0:
|
||||
resolution: {integrity: sha512-oTbVTsXfKuEhxftHqL5xprgLoc0k7uScAwtryCgWF6hPYFLRwOUHiFmHGCBKP5NPFNkDVopOieyUqYGH8Fa3kA==}
|
||||
|
||||
echarts@6.0.0:
|
||||
resolution: {integrity: sha512-Tte/grDQRiETQP4xz3iZWSvoHrkCQtwqd6hs+mifXcjrCuo2iKWbajFObuLJVBlDIJlOzgQPd1hsaKt/3+OMkQ==}
|
||||
|
||||
@ -4560,6 +4554,12 @@ packages:
|
||||
resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==}
|
||||
engines: {'0': node >= 0.2.0}
|
||||
|
||||
jweixin-1.6.0@1.0.0:
|
||||
resolution: {integrity: sha512-QH69Y/j4h8p9dy6wqIplXmhjLy67AGJswvrjwWUD84HUdB22QyHaX1PmV7oJFbsYL+Vn9Qe1uIx/2NFKkD51Bg==}
|
||||
|
||||
jweixin-module@1.6.0:
|
||||
resolution: {integrity: sha512-dGk9cf+ipipHmtzYmKZs5B2toX+p4hLyllGLF6xuC8t+B05oYxd8fYoaRz0T30U2n3RUv8a4iwvjhA+OcYz52w==}
|
||||
|
||||
keyv@4.5.4:
|
||||
resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==}
|
||||
|
||||
@ -6459,9 +6459,6 @@ packages:
|
||||
resolution: {integrity: sha512-RcDeKFoCQB51dmrrTb1PMIazjTqGuAbFmjPS0/N5hdUNTCRvxGOOBTBFolvIxUcsWhrocI9C0mYDgUwXT6Dwcg==}
|
||||
engines: {HBuilderX: ^3.0.7}
|
||||
|
||||
zrender@5.6.1:
|
||||
resolution: {integrity: sha512-OFXkDJKcrlx5su2XbzJvj/34Q3m6PvyCZkVPHGYpcCJ52ek4U/ymZyfuV1nKE23AyBJ51E/6Yr0mhZ7xGTO4ag==}
|
||||
|
||||
zrender@6.0.0:
|
||||
resolution: {integrity: sha512-41dFXEEXuJpNecuUQq6JlbybmnHaqqpGlbH1yxnA5V9MMP4SbohSVZsJIwz+zdjQXSSlR1Vc34EgH1zxyTDvhg==}
|
||||
|
||||
@ -10585,11 +10582,6 @@ snapshots:
|
||||
|
||||
eastasianwidth@0.2.0: {}
|
||||
|
||||
echarts@5.6.0:
|
||||
dependencies:
|
||||
tslib: 2.3.0
|
||||
zrender: 5.6.1
|
||||
|
||||
echarts@6.0.0:
|
||||
dependencies:
|
||||
tslib: 2.3.0
|
||||
@ -12109,6 +12101,10 @@ snapshots:
|
||||
|
||||
jsonparse@1.3.1: {}
|
||||
|
||||
jweixin-1.6.0@1.0.0: {}
|
||||
|
||||
jweixin-module@1.6.0: {}
|
||||
|
||||
keyv@4.5.4:
|
||||
dependencies:
|
||||
json-buffer: 3.0.1
|
||||
@ -14175,10 +14171,6 @@ snapshots:
|
||||
|
||||
z-paging@2.8.7: {}
|
||||
|
||||
zrender@5.6.1:
|
||||
dependencies:
|
||||
tslib: 2.3.0
|
||||
|
||||
zrender@6.0.0:
|
||||
dependencies:
|
||||
tslib: 2.3.0
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
import { navigateToInterceptor } from '@/router/interceptor'
|
||||
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
|
||||
import {snsapiBaseAuthorize} from '@/hooks/useWeiXin'
|
||||
import {initJweixinSDK} from '@/utils/jwexin'
|
||||
|
||||
onLaunch((options) => {
|
||||
// 处理直接进入页面路由的情况:如h5直接输入路由、微信小程序分享后进入等
|
||||
@ -16,7 +17,8 @@
|
||||
}
|
||||
|
||||
// 微信静默授权
|
||||
snsapiBaseAuthorize()
|
||||
// snsapiBaseAuthorize()
|
||||
initJweixinSDK()
|
||||
})
|
||||
onShow((options) => {
|
||||
console.log('App Show', options)
|
||||
|
||||
13
src/api/jwexin.ts
Normal file
13
src/api/jwexin.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { http } from '@/http/alova'
|
||||
import type { IJweiXin } from '@/api/types/jwexin'
|
||||
|
||||
/**
|
||||
* 获取微信JSSDK签名
|
||||
*/
|
||||
export interface IJweiXinSignature {
|
||||
url: string
|
||||
}
|
||||
|
||||
export function wxSignature(data: IJweiXinSignature) {
|
||||
return http.Get<IJweiXin>('/api/wechat/jsConfig', { params: data })
|
||||
}
|
||||
@ -4,19 +4,28 @@ import { API_DOMAINS, http } from '@/http/alova'
|
||||
|
||||
|
||||
/**
|
||||
* 微信静默授权登录参数
|
||||
* 微信静默授权登录
|
||||
*/
|
||||
export interface IWxSnsapiBaseLoginForm {
|
||||
code: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信静默授权登录
|
||||
*/
|
||||
export function wxSnsapiBaseLogin(loginForm: IWxSnsapiBaseLoginForm) {
|
||||
return http.Get<IUserLogin>('/login/oaLogin', {params: loginForm})
|
||||
export function wxSnsapiBaseLogin(data: IWxSnsapiBaseLoginForm) {
|
||||
return http.Post<IUserInfoVo>('/api/login/oaLogin', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机验证码登录
|
||||
*/
|
||||
export interface IPhoneLoginForm {
|
||||
account: number,
|
||||
scene: number,
|
||||
terminal: number
|
||||
}
|
||||
|
||||
export function phoneLogin(data: IPhoneLoginForm) {
|
||||
return http.Post<IUserLogin>('/api/login/oaLogin', {params: data})
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录表单
|
||||
@ -33,7 +42,7 @@ export interface ILoginForm {
|
||||
* @returns ICaptcha 验证码
|
||||
*/
|
||||
export function getCode() {
|
||||
return http.Get<ICaptcha>('/user/getCode')
|
||||
return http.Get<ICaptcha>('/api/user/getCode')
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,35 +50,35 @@ export function getCode() {
|
||||
* @param loginForm 登录表单
|
||||
*/
|
||||
export function login(loginForm: ILoginForm) {
|
||||
return http.Post<IUserLogin>('/user/login', loginForm)
|
||||
return http.Post<IUserLogin>('/api/user/login', loginForm)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
export function getUserInfo() {
|
||||
return http.Get<IUserInfoVo>('/user/info')
|
||||
return http.Get<IUserInfoVo>('/api/user/info')
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
export function logout() {
|
||||
return http.Get<void>('/user/logout')
|
||||
return http.Get<void>('/api/user/logout')
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*/
|
||||
export function updateInfo(data: IUpdateInfo) {
|
||||
return http.Get('/user/updateInfo', data)
|
||||
return http.Get('/api/user/updateInfo', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户密码
|
||||
*/
|
||||
export function updateUserPassword(data: IUpdatePassword) {
|
||||
return http.Post('/user/updatePassword', data)
|
||||
return http.Post('/api/user/updatePassword', data)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,5 +105,5 @@ export function getWxCode() {
|
||||
* @returns Promise 包含登录结果
|
||||
*/
|
||||
export function wxLogin(data: { code: string }) {
|
||||
return http.Post<IUserLogin>('/user/wxLogin', data)
|
||||
return http.Post<IUserLogin>('/api/user/wxLogin', data)
|
||||
}
|
||||
|
||||
13
src/api/types/jwexin.ts
Normal file
13
src/api/types/jwexin.ts
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* JSSDK返回的签名参数
|
||||
*/
|
||||
export interface IJweiXin {
|
||||
appId: string
|
||||
debug: boolean
|
||||
jsApiList: string[]
|
||||
nonceStr: string
|
||||
openTagList: string[]
|
||||
signature: string
|
||||
timestamp: number
|
||||
url: string
|
||||
}
|
||||
@ -3,9 +3,14 @@
|
||||
*/
|
||||
export interface IUserInfoVo {
|
||||
id: number
|
||||
username: string
|
||||
nickname: string
|
||||
avatar: string
|
||||
token: string
|
||||
sn: string
|
||||
account: string
|
||||
channel: number
|
||||
is_new_user: number
|
||||
mobile: string
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
import {wxSnsapiBaseLogin} from '@/api/login'
|
||||
// import {setUserInfo, getUserInfo} from '@/store/user'
|
||||
import { useUserStore } from '@/store'
|
||||
import type { IUserInfoVo } from '@/api/types/login'
|
||||
|
||||
/**
|
||||
* 微信静默授权
|
||||
*/
|
||||
@ -22,6 +24,22 @@ const getUrlCode = (): { [key: string]: string | undefined } => {
|
||||
* 微信静默授权登录
|
||||
*/
|
||||
export function snsapiBaseAuthorize() {
|
||||
// TODO 测试代码
|
||||
const res = {
|
||||
account: "u39317465",
|
||||
avatar: "https://cz.stnav.com/uploads/user/avatar/c2b3c5f94e3f20c8a989bd302519b4c7.jpeg",
|
||||
channel:2,
|
||||
is_new_user: 1,
|
||||
id: 1,
|
||||
sn:"39317465",
|
||||
token: "14a11310d926121e352afec2ef1d2f7f",
|
||||
nickname: '微信用户',
|
||||
mobile: '15005837859'
|
||||
}
|
||||
useUserStore().setUserInfo(res)
|
||||
console.log(useUserStore().userInfo)
|
||||
return
|
||||
|
||||
let local = window.location.href // 获取页面url
|
||||
let appid = import.meta.env.VITE_WX_SERVICE_ACCOUNT_APPID // 公众号的APPID
|
||||
console.log("🚀 ~ snsapiBaseAuthorize ~ appid:", appid)
|
||||
@ -38,19 +56,18 @@ export function snsapiBaseAuthorize() {
|
||||
window.location.href =
|
||||
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${uri}&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect`
|
||||
} else {
|
||||
console.log('存在code,使用code换取用户信息')
|
||||
// 保存最新code
|
||||
uni.setStorageSync('wechatCode',code)
|
||||
console.log("🚀 ~ snsapiBaseAuthorize ~ code:", code)
|
||||
|
||||
// 使用code换取用户信息
|
||||
wxSnsapiBaseLogin({code}).then(res=>{
|
||||
console.log("🚀 ~ snsapiBaseAuthorize ~ res:", res)
|
||||
|
||||
}).catch(err=>{
|
||||
// 失败就重新授权
|
||||
uni.setStorageSync('wechatCode',0)
|
||||
console.log('请求失败', err)
|
||||
wxSnsapiBaseLogin({code}).then((res: IUserInfoVo) => {
|
||||
console.log("登录成功 ~ snsapiBaseAuthorize ~ res:", res)
|
||||
// 映射 IUserLogin 到 IUserInfoVo
|
||||
useUserStore().setUserInfo(res)
|
||||
console.log('登录成功 ~ ' + useUserStore().userInfo)
|
||||
}).catch(err => {
|
||||
// 失败就重新授权
|
||||
uni.setStorageSync('wechatCode', 0)
|
||||
console.log('请求失败', err)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ import { createServerTokenAuthentication } from 'alova/client'
|
||||
import VueHook from 'alova/vue'
|
||||
import { toast } from '@/utils/toast'
|
||||
import { ContentTypeEnum, ResultEnum, ShowMessage } from './tools/enum'
|
||||
import { useUserStore } from '@/store'
|
||||
|
||||
// 配置动态Tag
|
||||
export const API_DOMAINS = {
|
||||
@ -87,6 +88,11 @@ const alovaInstance = createAlova({
|
||||
return response
|
||||
}
|
||||
|
||||
if (statusCode === ResultEnum.Unauthorized) {
|
||||
useUserStore().removeUserInfo()
|
||||
uni.navigateTo({ url: '/pages/login/mobile' })
|
||||
}
|
||||
|
||||
// 处理 HTTP 状态码错误
|
||||
// if (statusCode !== 200) {
|
||||
// const errorMessage = ShowMessage(statusCode) || `HTTP请求错误[${statusCode}]`
|
||||
@ -97,12 +103,12 @@ const alovaInstance = createAlova({
|
||||
|
||||
// 处理业务逻辑错误
|
||||
const { code, message, data } = rawData as IResponse
|
||||
// if (code !== ResultEnum.Success) {
|
||||
// if (config.meta?.toast !== false) {
|
||||
// toast.warning(message)
|
||||
// }
|
||||
// throw new Error(`请求错误[${code}]:${message}`)
|
||||
// }
|
||||
if (code !== ResultEnum.Success) {
|
||||
if (config.meta?.toast !== false) {
|
||||
toast.warning(message)
|
||||
}
|
||||
throw new Error(`请求错误[${code}]:${message}`)
|
||||
}
|
||||
// 处理成功响应,返回业务数据
|
||||
return data
|
||||
}),
|
||||
|
||||
@ -21,6 +21,7 @@ const httpInterceptor = {
|
||||
options.url += `?${queryStr}`
|
||||
}
|
||||
}
|
||||
|
||||
// 非 http 开头需拼接地址
|
||||
if (!options.url.startsWith('http')) {
|
||||
// #ifdef H5
|
||||
@ -32,6 +33,7 @@ const httpInterceptor = {
|
||||
else {
|
||||
options.url = baseUrl + options.url
|
||||
}
|
||||
|
||||
// #endif
|
||||
// 非H5正常拼接
|
||||
// #ifndef H5
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
export enum ResultEnum {
|
||||
Success = 0, // 成功
|
||||
Error = 400, // 错误
|
||||
Success = 1, // 成功
|
||||
Error = 0, // 错误
|
||||
Unauthorized = 401, // 未授权
|
||||
Forbidden = 403, // 禁止访问(原为forbidden)
|
||||
NotFound = 404, // 未找到(原为notFound)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "",
|
||||
"appid": "",
|
||||
"name": "茶址",
|
||||
"appid": "__UNI__D1E5001",
|
||||
"description": "",
|
||||
"versionName": "1.0.0",
|
||||
"versionCode": "100",
|
||||
@ -18,22 +18,85 @@
|
||||
"modules": {},
|
||||
"distribute": {
|
||||
"android": {
|
||||
"permissions": []
|
||||
"permissions": [
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
||||
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
|
||||
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||
],
|
||||
"minSdkVersion": 30,
|
||||
"targetSdkVersion": 30,
|
||||
"abiFilters": [
|
||||
"armeabi-v7a",
|
||||
"arm64-v8a"
|
||||
]
|
||||
},
|
||||
"ios": {},
|
||||
"sdkConfigs": {}
|
||||
"sdkConfigs": {},
|
||||
"icons": {
|
||||
"android": {
|
||||
"hdpi": "static/app/icons/72x72.png",
|
||||
"xhdpi": "static/app/icons/96x96.png",
|
||||
"xxhdpi": "static/app/icons/144x144.png",
|
||||
"xxxhdpi": "static/app/icons/192x192.png"
|
||||
},
|
||||
"ios": {
|
||||
"appstore": "static/app/icons/1024x1024.png",
|
||||
"ipad": {
|
||||
"app": "static/app/icons/76x76.png",
|
||||
"app@2x": "static/app/icons/152x152.png",
|
||||
"notification": "static/app/icons/20x20.png",
|
||||
"notification@2x": "static/app/icons/40x40.png",
|
||||
"proapp@2x": "static/app/icons/167x167.png",
|
||||
"settings": "static/app/icons/29x29.png",
|
||||
"settings@2x": "static/app/icons/58x58.png",
|
||||
"spotlight": "static/app/icons/40x40.png",
|
||||
"spotlight@2x": "static/app/icons/80x80.png"
|
||||
},
|
||||
"iphone": {
|
||||
"app@2x": "static/app/icons/120x120.png",
|
||||
"app@3x": "static/app/icons/180x180.png",
|
||||
"notification@2x": "static/app/icons/40x40.png",
|
||||
"notification@3x": "static/app/icons/60x60.png",
|
||||
"settings@2x": "static/app/icons/58x58.png",
|
||||
"settings@3x": "static/app/icons/87x87.png",
|
||||
"spotlight@2x": "static/app/icons/80x80.png",
|
||||
"spotlight@3x": "static/app/icons/120x120.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"compatible": {
|
||||
"ignoreVersion": true
|
||||
}
|
||||
},
|
||||
"quickapp": {},
|
||||
"mp-weixin": {
|
||||
"appid": "",
|
||||
"appid": "wxa2abb91f64032a2b",
|
||||
"setting": {
|
||||
"urlCheck": false
|
||||
"urlCheck": false,
|
||||
"es6": true,
|
||||
"minified": true
|
||||
},
|
||||
"usingComponents": true
|
||||
"usingComponents": true,
|
||||
"optimization": {
|
||||
"subPackages": true
|
||||
}
|
||||
},
|
||||
"mp-alipay": {
|
||||
"usingComponents": true
|
||||
"usingComponents": true,
|
||||
"styleIsolation": "shared"
|
||||
},
|
||||
"mp-baidu": {
|
||||
"usingComponents": true
|
||||
@ -45,118 +108,7 @@
|
||||
"enable": false
|
||||
},
|
||||
"vueVersion": "3",
|
||||
"default": {
|
||||
"name": "茶址",
|
||||
"appid": "__UNI__D1E5001",
|
||||
"description": "",
|
||||
"versionName": "1.0.0",
|
||||
"versionCode": "100",
|
||||
"transformPx": false,
|
||||
"h5": {
|
||||
"router": {}
|
||||
},
|
||||
"app-plus": {
|
||||
"usingComponents": true,
|
||||
"nvueStyleCompiler": "uni-app",
|
||||
"compilerVersion": 3,
|
||||
"compatible": {
|
||||
"ignoreVersion": true
|
||||
},
|
||||
"splashscreen": {
|
||||
"alwaysShowBeforeRender": true,
|
||||
"waiting": true,
|
||||
"autoclose": true,
|
||||
"delay": 0
|
||||
},
|
||||
"modules": {},
|
||||
"distribute": {
|
||||
"android": {
|
||||
"minSdkVersion": 30,
|
||||
"targetSdkVersion": 30,
|
||||
"abiFilters": [
|
||||
"armeabi-v7a",
|
||||
"arm64-v8a"
|
||||
],
|
||||
"permissions": [
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
||||
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
|
||||
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||
]
|
||||
},
|
||||
"ios": {},
|
||||
"sdkConfigs": {},
|
||||
"icons": {
|
||||
"android": {
|
||||
"hdpi": "static/app/icons/72x72.png",
|
||||
"xhdpi": "static/app/icons/96x96.png",
|
||||
"xxhdpi": "static/app/icons/144x144.png",
|
||||
"xxxhdpi": "static/app/icons/192x192.png"
|
||||
},
|
||||
"ios": {
|
||||
"appstore": "static/app/icons/1024x1024.png",
|
||||
"ipad": {
|
||||
"app": "static/app/icons/76x76.png",
|
||||
"app@2x": "static/app/icons/152x152.png",
|
||||
"notification": "static/app/icons/20x20.png",
|
||||
"notification@2x": "static/app/icons/40x40.png",
|
||||
"proapp@2x": "static/app/icons/167x167.png",
|
||||
"settings": "static/app/icons/29x29.png",
|
||||
"settings@2x": "static/app/icons/58x58.png",
|
||||
"spotlight": "static/app/icons/40x40.png",
|
||||
"spotlight@2x": "static/app/icons/80x80.png"
|
||||
},
|
||||
"iphone": {
|
||||
"app@2x": "static/app/icons/120x120.png",
|
||||
"app@3x": "static/app/icons/180x180.png",
|
||||
"notification@2x": "static/app/icons/40x40.png",
|
||||
"notification@3x": "static/app/icons/60x60.png",
|
||||
"settings@2x": "static/app/icons/58x58.png",
|
||||
"settings@3x": "static/app/icons/87x87.png",
|
||||
"spotlight@2x": "static/app/icons/80x80.png",
|
||||
"spotlight@3x": "static/app/icons/120x120.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"quickapp": {},
|
||||
"mp-weixin": {
|
||||
"appid": "wxa2abb91f64032a2b",
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"es6": true,
|
||||
"minified": true
|
||||
},
|
||||
"optimization": {
|
||||
"subPackages": true
|
||||
},
|
||||
"usingComponents": true
|
||||
},
|
||||
"mp-alipay": {
|
||||
"usingComponents": true,
|
||||
"styleIsolation": "shared"
|
||||
},
|
||||
"mp-baidu": {
|
||||
"usingComponents": true
|
||||
},
|
||||
"mp-toutiao": {
|
||||
"usingComponents": true
|
||||
},
|
||||
"uniStatistics": {
|
||||
"enable": false
|
||||
},
|
||||
"vueVersion": "3"
|
||||
"h5": {
|
||||
"router": {}
|
||||
}
|
||||
}
|
||||
@ -133,6 +133,7 @@
|
||||
{
|
||||
"path": "pages/my/my",
|
||||
"type": "page",
|
||||
"needLogin": true,
|
||||
"layout": "tabbar",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
|
||||
@ -149,6 +149,7 @@
|
||||
import {TeaSpecialistLevels} from '@/utils/teaSpecialist'
|
||||
import TeaSpecialistLevel from '@/components/TeaSpecialistLevel.vue'
|
||||
import { OrderSource, OrderStatus } from '@/utils/order'
|
||||
import {getlocation} from '@/utils/jwexin'
|
||||
|
||||
const OSS = inject('OSS')
|
||||
|
||||
@ -159,6 +160,9 @@
|
||||
const { mescrollInit, downCallback } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
|
||||
|
||||
onLoad(() => {
|
||||
getlocation((res) => {
|
||||
console.log('经纬度:' + res.latitude + ',' + res.longitude)
|
||||
})
|
||||
})
|
||||
|
||||
const Index = {
|
||||
@ -231,7 +235,7 @@
|
||||
// 跳转到团体预约页面
|
||||
handleToGroupReserve: () => {
|
||||
uni.navigateTo({
|
||||
url: '/pages/reservve/group-tea-specialist'
|
||||
url: '/pages/reserve/group-tea-specialist'
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -246,9 +250,9 @@
|
||||
.tea-level-scrollbar {
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
-ms-overflow-style: none;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
-ms-overflow-style: none;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.home-bg {
|
||||
|
||||
@ -94,7 +94,7 @@
|
||||
|
||||
/** 页面 **/
|
||||
let pageType = 'login' // 页面类型 login:登录 edit:修改手机号
|
||||
const page = ref<{title: string, desc: string}>({title: '其他手机号登录', desc: '请输入你要登录的手机号'})
|
||||
const page = ref<{title: string, desc: string}>({title: '绑定手机号', desc: '请输入你要绑定的手机号'})
|
||||
const showEditSuccessPopup = ref<boolean>(false) // 显示手机号修改成功弹窗
|
||||
const userId = ref<number>(0) // 用户ID,修改手机号时需要传
|
||||
|
||||
@ -218,7 +218,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
<style lang="scss" scoped>
|
||||
page {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<route lang="jsonc" type="page">
|
||||
{
|
||||
"needLogin": true,
|
||||
"layout": "tabbar",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
@ -25,13 +26,13 @@
|
||||
<view>
|
||||
<wd-img width="120rpx" height="120rpx" :src="`${OSS}icon/icon_avatar.png`" mode="aspectFill" round />
|
||||
</view>
|
||||
<view class="flex-1 ml-22rpx flex justify-between items-center">
|
||||
<view @click="My.handleToProfile">
|
||||
<view class="text-[#303133] text-36rpx leading-50rpx ml-8rpx">{{ isLogin ? '王大帅' : '立即登录' }}</view>
|
||||
<view v-if="isLogin" class="flex justify-center items-center vip-bg mt-10rpx">
|
||||
<view class="flex-1 ml-22rpx flex justify-between items-center" @click="My.handleToProfile">
|
||||
<view>
|
||||
<view class="text-[#303133] text-36rpx leading-50rpx ml-8rpx">{{ isLogin ? userInfo.nickname : '立即登录' }}</view>
|
||||
<view v-if="isLogin" class="flex justify-center items-center vip-bg mt-10rpx" >
|
||||
<!-- 会员显示图标 -->
|
||||
<view v-if="isVip" class="flex items-center mr-12rpx">
|
||||
<wd-img width="36rpx" height="36rpx" mode="aspectFill" :src="`${OSS}icon/icon_crown.png`" round></wd-img>
|
||||
<wd-img width="36rpx" height="36rpx" mode="aspectFill" :src="userInfo.avatar" round></wd-img>
|
||||
</view>
|
||||
<!-- 这里要根据用户身份显示不同的文字 -->
|
||||
<view class="text-24rpx text-[#675649] leading-34rpx flex items-center">茶址会员</view>
|
||||
@ -180,6 +181,7 @@
|
||||
<script lang="ts" setup>
|
||||
import {OrderStatus} from '@/utils/order'
|
||||
import {toast} from '@/utils/toast'
|
||||
import { useUserStore } from '@/store'
|
||||
|
||||
const OSS = inject('OSS')
|
||||
const navbarHeight = inject('navbarHeight')
|
||||
@ -187,7 +189,7 @@
|
||||
|
||||
// 登录信息相关
|
||||
const userInfo = ref<any>(null)
|
||||
const isLogin = ref<boolean>(true)
|
||||
const isLogin = ref<boolean>(false)
|
||||
const isVip = ref<boolean>(true)
|
||||
|
||||
// 茶艺师订单
|
||||
@ -209,18 +211,19 @@
|
||||
// 领取优惠券
|
||||
const isClaimCoupon = ref<boolean>(false)
|
||||
|
||||
onShow(() => {
|
||||
const userStore = useUserStore()
|
||||
if (userStore.userInfo.mobile) {
|
||||
userInfo.value = userStore.userInfo
|
||||
isLogin.value = true
|
||||
}
|
||||
})
|
||||
|
||||
onLoad(() => {
|
||||
|
||||
})
|
||||
|
||||
const My = {
|
||||
// 跳转到个人信息
|
||||
handleToProfile: () => {
|
||||
uni.navigateTo({
|
||||
url: '/bundle/profile/profile'
|
||||
})
|
||||
},
|
||||
|
||||
// 点击显示客服电话
|
||||
handleShowService: () => {
|
||||
showServiceMobile.value = true
|
||||
@ -250,6 +253,19 @@
|
||||
}
|
||||
},
|
||||
|
||||
// 跳转到个人信息
|
||||
handleToProfile: () => {
|
||||
if (isLogin.value) {
|
||||
uni.navigateTo({
|
||||
url: '/bundle/profile/profile'
|
||||
})
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/mobile'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 跳转到会员权益
|
||||
handleToVipBenefits: () => {
|
||||
uni.navigateTo({
|
||||
@ -280,8 +296,8 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page, home-bg{
|
||||
<style lang="scss" scoped>
|
||||
page, home-bg {
|
||||
background: $cz-page-background url(#{$OSS}images/my/my_image1.png) 0 0 no-repeat;
|
||||
background-size: 100%;
|
||||
}
|
||||
|
||||
@ -13,7 +13,8 @@ const loginRoute = import.meta.env.VITE_LOGIN_URL
|
||||
|
||||
function isLogined() {
|
||||
const userStore = useUserStore()
|
||||
return !!userStore.userInfo.username
|
||||
// 如果没有手机号或者token,就认为没有登录(需要绑定手机号)
|
||||
return !!userStore.userInfo.mobile && !!userStore.userInfo.token
|
||||
}
|
||||
|
||||
const isDev = import.meta.env.DEV
|
||||
|
||||
@ -10,12 +10,19 @@ import {
|
||||
} from '@/api/login'
|
||||
import { toast } from '@/utils/toast'
|
||||
|
||||
const defaultAvatar = 'https://shchazhi.oss-cn-hangzhou.aliyuncs.com/fronted/icon/icon_avatar.png'
|
||||
|
||||
// 初始化状态
|
||||
const userInfoState: IUserInfoVo = {
|
||||
id: 0,
|
||||
username: '',
|
||||
avatar: '/static/images/default-avatar.png',
|
||||
nickname: '',
|
||||
avatar: defaultAvatar,
|
||||
token: '',
|
||||
sn: '',
|
||||
account: '',
|
||||
channel: 0,
|
||||
is_new_user: 1,
|
||||
mobile: ''
|
||||
}
|
||||
|
||||
export const useUserStore = defineStore(
|
||||
@ -31,7 +38,7 @@ export const useUserStore = defineStore(
|
||||
val.avatar = userInfoState.avatar
|
||||
}
|
||||
else {
|
||||
val.avatar = 'https://oss.laf.run/ukw0y1-site/avatar.jpg?feige'
|
||||
val.avatar = defaultAvatar
|
||||
}
|
||||
userInfo.value = val
|
||||
}
|
||||
@ -103,6 +110,8 @@ export const useUserStore = defineStore(
|
||||
getUserInfo,
|
||||
setUserAvatar,
|
||||
logout,
|
||||
setUserInfo,
|
||||
removeUserInfo
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
76
src/utils/jwexin.ts
Normal file
76
src/utils/jwexin.ts
Normal file
@ -0,0 +1,76 @@
|
||||
import wx from 'jweixin-1.6.0'
|
||||
import {wxSignature} from '@/api/jwexin'
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
entryUrl?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export function isWechat() {
|
||||
const ua = window.navigator.userAgent.toLowerCase();
|
||||
if (ua.match(/micromessenger/i) !== null) {
|
||||
//console.log('是微信客户端')
|
||||
return true;
|
||||
} else {
|
||||
//console.log('不是微信客户端')
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function initJweixinSDK(callback: (res?: any) => void = () => {}) {
|
||||
if (typeof window.entryUrl === 'undefined' || window.entryUrl === '') {
|
||||
window.entryUrl = location.href.split('#')[0]
|
||||
console.log("🚀 ~ initJweixin ~ window.entryUrl:", window.entryUrl)
|
||||
}
|
||||
|
||||
let isiOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
|
||||
// 进行签名的时候 Android 不用使用之前的链接, ios 需要
|
||||
let signLink = isiOS ? window.entryUrl : location.href.split('#')[0];
|
||||
console.log('-----------当前签名url--------------')
|
||||
console.log(signLink)
|
||||
// var uri = encodeURIComponent(location.href.split('#')[0]); //获取当前url然后传递给后台获取授权和签名信息
|
||||
let url = encodeURIComponent(signLink); //获取当前url然后传递给后台获取授权和签名信息
|
||||
wxSignature({ url }).then((res) => {
|
||||
console.log("🚀 ~ initJweixin ~ res:", res)
|
||||
wx.config({
|
||||
debug: false,
|
||||
appId: res.appId,
|
||||
timestamp: res.timestamp,
|
||||
nonceStr: res.nonceStr,
|
||||
signature: res.signature,
|
||||
jsApiList: res.jsApiList
|
||||
});
|
||||
wx.ready(function() {
|
||||
console.log('config注入成功')
|
||||
if (callback) {
|
||||
callback(res)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function getlocation(callback: (res: any) => void ) {
|
||||
if (!isWechat()) {
|
||||
//console.log('不是微信客户端')
|
||||
return
|
||||
}
|
||||
|
||||
initJweixinSDK(function(res) {
|
||||
wx.ready(function() {
|
||||
wx.getLocation({
|
||||
type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
|
||||
success: function(res) {
|
||||
// console.log(res);
|
||||
callback(res)
|
||||
},
|
||||
fail: function(res) {
|
||||
console.log('经纬度:' + res)
|
||||
},
|
||||
// complete:function(res){
|
||||
// console.log(res)
|
||||
// }
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user