Lufaneng 10 months ago
parent 33a9adfbef
commit 26be228f0a

@ -129,12 +129,12 @@
"selectedIconPath": "static/tabbar/order_HL.png",
"text": "订单"
},
{
"pagePath": "pages/consumption/consumption",
"iconPath": "static/tabbar/xiaofei.png",
"selectedIconPath": "static/tabbar/xiaofei_HL.png",
"text": "消费"
},
// {
// "pagePath": "pages/consumption/consumption",
// "iconPath": "static/tabbar/xiaofei.png",
// "selectedIconPath": "static/tabbar/xiaofei_HL.png",
// "text": "消费"
// },
{
"pagePath": "pages/mine/mine",
"iconPath": "static/tabbar/mine.png",

@ -1,7 +1,7 @@
<template>
<view class="container">
<!-- 顶部筛选标签 -->
<uv-sticky bgColor="#fff" offsetTop="0">
<uv-sticky bgColor="#fff" :offsetTop="isWeChatH5 ? -50 : 0">
<div class="tabBox">
<div class="tabItem" :class="{selected:active==='全部'}" @click="switchTab('全部')"></div>
<div class="tabItem" :class="{selected:active==='生成'}" @click="switchTab('生成')"></div>
@ -81,6 +81,13 @@
import RPC from "@/utils/request";
import dayjs from "dayjs";
const isWeChatH5 = ref(false)
// #ifdef H5
if (navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1) {
isWeChatH5.value = true
}
// #endif
const authStore = useAuthStore();
const userStore = useUserStore();

@ -19,7 +19,7 @@
手机号
</div>
<uv-input v-model="userInfo.phone" color="#000" border="bottom"
:placeholderStyle="{ color: '#666778' }" placeholder="请输入用户名"></uv-input>
:placeholderStyle="{ color: '#666778' }" placeholder="请输入手机号"></uv-input>
</uv-form-item>
<uv-form-item prop="password">
<div class="formLabel">
@ -29,7 +29,7 @@
<uv-input v-model="userInfo.password" color="#000" border="bottom"
:placeholderStyle="{ color: '#666778' }" placeholder="请输入验证码">
<template v-slot:suffix>
<uv-code ref="codeRef" @change="codeChange" seconds="20" changeText="X秒重新获取"></uv-code>
<uv-code ref="codeRef" @change="codeChange" seconds="60" changeText="X秒重新获取"></uv-code>
<text style="color: #4d82fd" @click="getCode">{{ tips }}</text>
</template>
</uv-input>
@ -85,9 +85,10 @@
</view>
</view>
</uv-popup>
<a style="display: none;" ref="ToLoginRef" href="weixin://dl/business/?appid=wxc504638e03981812&path=pages/login/login?from=h5ToWechat">
<!-- <a style="display: none;" ref="ToLoginRef"
href="weixin://dl/business/?appid=wxc504638e03981812&path=pages/login/login?from=h5ToWechat">
打开小程序并登录
</a>
</a> -->
</view>
</template>
@ -156,9 +157,17 @@
};
const codeRef = ref(null);
const getCode = () => {
if (!userInfo.phone) {
if (!userInfo.value.phone) {
uni.showToast({
title: "请填写手机号",
title: "请输入手机号",
icon: "none",
});
return;
}
if (!/^1[3-9]\d{9}$/.test(userInfo.value.phone)) {
uni.showToast({
title: "请输入正确的手机号",
icon: "none",
});
return;
@ -168,16 +177,22 @@
uni.showLoading({
title: "正在获取验证码",
});
setTimeout(() => {
uni.hideLoading();
// this.start()
RPC.post('/login/phone/send_code', {
phone: userInfo.value.phone,
}).then(() => {
uni.hideLoading()
uni.showToast({
title: "验证码已发送",
icon: "none",
});
//
codeRef.value.start();
}, 2000);
title: '验证码已发送',
icon: 'success'
})
codeRef.value.start()
}).catch(() => {
uni.hideLoading()
uni.showToast({
title: '发送失败,请重试',
icon: 'none'
})
})
} else {
uni.showToast({
title: "倒计时结束后再发送",
@ -212,6 +227,7 @@
let redirect = HOME_PATH;
onLoad((options) => {
if (options.redirect && removeQueryString(options.redirect) !== LOGIN_PATH) {
if(decodeURIComponent(options.redirect) && decodeURIComponent(options.redirect) != 'undefined')
redirect = decodeURIComponent(options.redirect);
}
if (options.from && options.from === 'h5ToWechat') {
@ -228,9 +244,9 @@
// #ifdef H5
// H5
const ua = navigator.userAgent.toLowerCase();
const isWechat = ua.indexOf("micromessenger") !== -1;
showWechatLogin.value = isWechat;
// const ua = navigator.userAgent.toLowerCase();
// const isWechat = ua.indexOf("micromessenger") !== -1;
// showWechatLogin.value = isWechat;
// #endif
// #ifdef APP-PLUS
@ -250,18 +266,22 @@
js_code: loginRes.code
}).then(res => {
console.log('phonelogin', res)
if (res.user.phone) {
authStore.setAccessToken(res.token)
userStore.setUserInfo(res.user)
if(!res.user.phone) {
uni.showToast({
title: "登录成功",
icon: "success",
});
uni.$uv.route({
type: isTabBarPath(redirect) ? "switchTab" : "redirectTo",
url: redirect,
type: isTabBarPath(redirect || HOME_PATH) ? "switchTab" :
"redirectTo",
url: redirect || HOME_PATH,
});
} else {
accessToken.value = res.token
accessUserInfo.value = res.user
uni.hideLoading()
popup.value.open()
}
}).catch(() => {
@ -324,35 +344,28 @@
uni.showLoading({
title: "正在获取验证码",
});
// API
// RPC.post('/api/sms/send', {
// phone: bindPhoneInfo.value.phone,
// type: 'bind'
// }).then(() => {
// uni.hideLoading()
// uni.showToast({
// title: '',
// icon: 'success'
// })
// bindCodeRef.value.start()
// }).catch(() => {
// uni.hideLoading()
// uni.showToast({
// title: '',
// icon: 'none'
// })
// })
//
setTimeout(() => {
uni.hideLoading();
RPC.post('/user/bind_phone/send_code', {
phone: bindPhoneInfo.value.phone,
token: accessToken.value
}, {
custom: {
customToken: accessToken.value
}
}).then(() => {
uni.hideLoading()
uni.showToast({
title: "验证码已发送",
icon: "success",
});
bindCodeRef.value.start();
}, 1500);
title: '验证码已发送',
icon: 'success'
})
bindCodeRef.value.start()
}).catch(() => {
uni.hideLoading()
uni.showToast({
title: '发送失败,请重试',
icon: 'none'
})
})
} else {
uni.showToast({
title: "倒计时结束后再发送",
@ -399,6 +412,9 @@
// #endif
};
const accessToken = ref('')
const accessUserInfo = ref({})
// H5
const handleWechatH5Callback = async (code) => {
// #ifdef H5
@ -415,18 +431,20 @@
js_code: loginRes.code
}).then(res => {
console.log('phonelogin', res)
if (res.user.phone) {
authStore.setAccessToken(res.token)
userStore.setUserInfo(res.user)
if(!res.user.phone) {
uni.showToast({
title: "登录成功",
icon: "success",
});
uni.$uv.route({
type: isTabBarPath(redirect) ? "switchTab" : "redirectTo",
url: redirect,
type: isTabBarPath(redirect || HOME_PATH) ? "switchTab" : "redirectTo",
url: redirect || HOME_PATH,
});
} else {
accessToken.value = res.token
accessUserInfo.value = res.user
popup.value.open()
}
}).catch(() => {
@ -507,35 +525,32 @@
bindingPhone.value = true;
// API
// const result = await RPC.post('/api/wechat/bind-phone', {
// phone: bindPhoneInfo.value.phone,
// code: bindPhoneInfo.value.code,
// wechatCode: wechatLoginCode // code
// })
//
setTimeout(() => {
RPC.post('/user/bind_phone', {
phone: bindPhoneInfo.value.phone,
code: bindPhoneInfo.value.code,
token: accessToken.value
},{
custom: {
customToken: accessToken.value
}
}).then((res) => {
console.log('bind_phone', res)
bindingPhone.value = false;
authStore.setAccessToken(accessToken.value)
userStore.setUserInfo(accessUserInfo.value)
uni.showToast({
title: "绑定成功",
icon: "success",
});
//
authStore.setAccessToken("wechat_access_token");
// userStore.setUserInfo(result.userInfo)
closeBindPhoneModal();
//
setTimeout(() => {
closeBindPhoneModal()
uni.$uv.route({
type: isTabBarPath(redirect) ? "switchTab" : "redirectTo",
url: redirect,
type: isTabBarPath(redirect || HOME_PATH) ? "switchTab" :
"redirectTo",
url: redirect || HOME_PATH,
});
}, 1000);
}, 2000);
}, 500);
})
} catch (error) {
console.error("绑定手机号失败:", error);
bindingPhone.value = false;
@ -571,9 +586,9 @@
// url: redirect,
// });
// })
RPC.post('/login', {
username: userInfo.value.phone,
password: userInfo.value.password,
RPC.post('/login/phone', {
phone: userInfo.value.phone,
code: userInfo.value.password,
}, {
custom: {
loading: true,
@ -588,8 +603,8 @@
.then((res) => {
userStore.setUserInfo(res)
uni.$uv.route({
type: isTabBarPath(redirect) ? "switchTab" : "redirectTo",
url: redirect,
type: isTabBarPath(redirect || HOME_PATH) ? "switchTab" : "redirectTo",
url: redirect || HOME_PATH,
});
})
.finally(() => {

@ -546,6 +546,7 @@
getPlanList()
// getBalance()
getMemberInfo()
uni.stopPullDownRefresh();
});
</script>

@ -1,8 +1,9 @@
<template>
<view class="container">
<uv-sticky bgColor="#fff" offsetTop="0">
<uv-sticky bgColor="#fff" :offsetTop="isWeChatH5 ? -50 : 0">
<div class="tabBox">
<div class="tabItem" :class="{selected:active==='全部'}" @click="switchTab('全部')"></div>
<div class="tabItem" :class="{selected:active==='图纸生成'}" @click="switchTab('图纸生成')"></div>
<div class="tabItem" :class="{selected:active==='会员购买'}" @click="switchTab('会员购买')"></div>
<div class="tabItem" :class="{selected:active==='钱包充值'}" @click="switchTab('钱包充值')"></div>
</div>
@ -63,7 +64,8 @@
</view> -->
<view class="detail-row">
<text class="label">创建时间</text>
<text class="value">{{ order.created_at ? dayjs(order.created_at * 1000).format('YYYY-MM-DD HH:mm:ss') :'' }}</text>
<text
class="value">{{ order.created_at ? dayjs(order.created_at * 1000).format('YYYY-MM-DD HH:mm:ss') :'' }}</text>
</view>
</view>
@ -123,6 +125,13 @@
import RPC from "@/utils/request";
import dayjs from "dayjs";
const isWeChatH5 = ref(false)
// #ifdef H5
if (navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1) {
isWeChatH5.value = true
}
// #endif
const active = ref('全部')
const authStore = useAuthStore()
@ -217,7 +226,9 @@
if (res.confirm) {
try {
// API
await RPC.post('/membership/order/cancel', { order_no: order.order_no })
await RPC.post('/membership/order/cancel', {
order_no: order.order_no
})
//
const index = list.value.findIndex(item => item.id === order.id)
@ -413,7 +424,9 @@
console.log('paymentResult', paymentResult)
} else if (res.cancel) {
console.log('用户点击了取消');
paymentResult = { success: false }
paymentResult = {
success: false
}
}
}
@ -543,6 +556,7 @@
}
}
}
.order-list {
padding: 16px;

@ -34,10 +34,11 @@
</view>
<!-- 电话 -->
<view class="profile-item">
<view class="profile-item" @click="changePhone">
<view class="item-label">手机号</view>
<view class="item-content">
<text class="item-value">{{ userStore.userInfo.phone }}</text>
<uv-icon name="arrow-right" size="16" color="#ccc"></uv-icon>
</view>
</view>
</view>
@ -73,12 +74,7 @@
<!-- 退出登录按钮 -->
<view class="logout-section">
<uv-button
type="primary"
size="large"
@click="logout"
:loading="logoutLoading"
>
<uv-button type="primary" size="large" @click="logout" :loading="logoutLoading">
退出登录
</uv-button>
</view>
@ -97,19 +93,13 @@
: ""
}}
</view>
<uv-input
v-model="editValue"
:placeholder="getPlaceholder()"
:type="
<uv-input v-model="editValue" :placeholder="getPlaceholder()" :type="
editType === 'phone'
? 'number'
: editType === 'email'
? 'email'
: 'text'
"
border="bottom"
clearable
></uv-input>
" border="bottom" clearable></uv-input>
<view class="modal-actions">
<uv-button type="default" @click="closeEditModal"></uv-button>
<uv-button type="primary" @click="saveEdit"></uv-button>
@ -118,12 +108,7 @@
</uv-popup>
<!-- 头像选择弹窗 -->
<uv-popup
ref="avatarSheet"
mode="bottom"
@close="closeAvatarSheet"
:round="10"
>
<uv-popup ref="avatarSheet" mode="bottom" @close="closeAvatarSheet" :round="10">
<view class="avatar-sheet">
<view class="sheet-header">
<view class="sheet-title">选择头像</view>
@ -145,13 +130,59 @@
</view>
</view>
</uv-popup>
<uv-popup ref="popup" mode="center" :closeOnClickOverlay="false" :round="10">
<view class="bind-phone-modal">
<view class="modal-header">
<view class="modal-title">换绑手机号</view>
<view class="modal-subtitle">请输入换绑手机号信息</view>
</view>
<view class="modal-form">
<uv-form :model="bindPhoneInfo" :rules="bindPhoneRules" ref="bindPhoneForm">
<uv-form-item prop="phone">
<uv-input v-model="bindPhoneInfo.phone" placeholder="请输入手机号" type="number" maxlength="11"
border="surround"></uv-input>
</uv-form-item>
<uv-form-item prop="code">
<uv-input v-model="bindPhoneInfo.code" placeholder="请输入验证码" border="surround">
<template v-slot:suffix>
<uv-code ref="bindCodeRef" @change="bindCodeChange" seconds="60"
changeText="X秒重新获取"></uv-code>
<text style="color: #4d82fd; font-size: 12px" @click="getBindCode">
{{ bindCodeTips }}
</text>
</template>
</uv-input>
</uv-form-item>
</uv-form>
</view>
<view class="modal-actions">
<uv-button type="default" @click="closeBindPhoneModal" customStyle="margin-right: 12px;">
取消
</uv-button>
<uv-button type="primary" @click="confirmBindPhone" :loading="bindingPhone">
确认绑定
</uv-button>
</view>
</view>
</uv-popup>
</view>
</template>
<script setup>
import { ref, onMounted } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { useAuthStore, useUserStore } from "@/store";
import {
ref,
onMounted
} from "vue";
import {
onShow
} from "@dcloudio/uni-app";
import {
useAuthStore,
useUserStore
} from "@/store";
import RPC from "@/utils/request";
const authStore = useAuthStore();
@ -269,22 +300,34 @@ const saveEdit = async () => {
return;
}
if (editType.value === 'username') {
RPC.post('/user/update',{id:userStore.userInfo.id,username:editValue.value}).then(() => {
RPC.post('/user/update', {
id: userStore.userInfo.id,
username: editValue.value
}).then(() => {
uni.showToast({
title: "保存成功",
icon: "success",
});
userStore.setUserInfo({...userStore.userInfo,username:editValue.value})
userStore.setUserInfo({
...userStore.userInfo,
username: editValue.value
})
closeEditModal()
})
}
if (editType.value === 'email') {
RPC.post('/user/update',{id:userStore.userInfo.id,email:editValue.value}).then(() => {
RPC.post('/user/update', {
id: userStore.userInfo.id,
email: editValue.value
}).then(() => {
uni.showToast({
title: "保存成功",
icon: "success",
});
userStore.setUserInfo({...userStore.userInfo,email:editValue.value})
userStore.setUserInfo({
...userStore.userInfo,
email: editValue.value
})
closeEditModal()
})
}
@ -411,6 +454,134 @@ onShow(() => {
//
loadUserInfo();
});
const popup = ref(null);
const bindingPhone = ref(false);
const bindCodeTips = ref("获取验证码");
const bindCodeRef = ref(null);
const bindPhoneForm = ref(null);
const bindPhoneInfo = ref({
phone: "",
code: "",
});
const changePhone = () => {
bindPhoneInfo.value = {
phone: "",
code: "",
}
popup.value.open()
}
const bindPhoneRules = ref({
phone: [{
required: true,
message: "请输入手机号",
trigger: ["blur", "change"],
},
{
pattern: /^1[3-9]\d{9}$/,
message: "请输入正确的手机号",
trigger: ["blur", "change"],
},
],
code: {
required: true,
message: "请输入验证码",
trigger: ["blur", "change"],
},
});
const bindCodeChange = (text) => {
bindCodeTips.value = text;
};
const closeBindPhoneModal = () => {
popup.value.close();
bindPhoneInfo.value = {
phone: "",
code: "",
};
bindCodeTips.value = "获取验证码";
};
const confirmBindPhone = async () => {
try {
await bindPhoneForm.value.validate();
bindingPhone.value = true;
// API
RPC.post('/user/bind_phone', {
phone: bindPhoneInfo.value.phone,
code: bindPhoneInfo.value.code,
token: authStore.accessToken
}).then((res) => {
console.log('bind_phone', res)
bindingPhone.value = false;
uni.showToast({
title: "换绑成功",
icon: "success",
});
popup.value.close()
RPC.post('/user/info', {
token: authStore.accessToken,
})
.then((res) => {
userStore.setUserInfo(res)
})
})
} catch (error) {
console.error("换绑手机号失败:", error);
bindingPhone.value = false;
}
};
const getBindCode = () => {
if (!bindPhoneInfo.value.phone) {
uni.showToast({
title: "请输入手机号",
icon: "none",
});
return;
}
if (!/^1[3-9]\d{9}$/.test(bindPhoneInfo.value.phone)) {
uni.showToast({
title: "请输入正确的手机号",
icon: "none",
});
return;
}
if (bindCodeRef.value.canGetCode) {
uni.showLoading({
title: "正在获取验证码",
});
// API
RPC.post('/user/bind_phone/send_code', {
phone: bindPhoneInfo.value.phone,
token: authStore.accessToken
}).then(() => {
uni.hideLoading()
uni.showToast({
title: '验证码已发送',
icon: 'success'
})
bindCodeRef.value.start()
}).catch(() => {
uni.hideLoading()
uni.showToast({
title: '发送失败,请重试',
icon: 'none'
})
})
} else {
uni.showToast({
title: "倒计时结束后再发送",
icon: "none",
});
}
};
</script>
<style lang="scss" scoped>
@ -537,4 +708,42 @@ onShow(() => {
margin-top: 10px;
}
}
.bind-phone-modal {
width: 320px;
padding: 24px;
.modal-header {
text-align: center;
margin-bottom: 24px;
.modal-title {
font-size: 18px;
font-weight: bold;
color: #333;
margin-bottom: 8px;
}
.modal-subtitle {
font-size: 14px;
color: #666;
}
}
.modal-form {
margin-bottom: 24px;
.uv-form-item {
margin-bottom: 16px;
}
}
.modal-actions {
display: flex;
gap: 12px;
.uv-button {
flex: 1;
}
}
}
</style>

@ -130,13 +130,14 @@ $uv.http.interceptors.request.use(
// #endif
// config.url = useUserStore().adressIp + '/jsonrpc'
const params = config.data
console.log('config',config)
const customToken = config.custom.customToken
config.data = {
id: guid(),
jsonrpc: '2.0',
method,
params,
session: useAuthStore().accessToken,
// session:'8ef0a67e75d4ebbcbc5bc897024ea160',
session:customToken || useAuthStore().accessToken,
timestampin: Date.now().toString()
}

Loading…
Cancel
Save