Compare commits

..

3 Commits
applet ... main

Author SHA1 Message Date
qsh 657f237b9f sc 2 weeks ago
qsh 4c65fb9bce sc 2 weeks ago
qsh 67cca9687e sc 3 weeks ago
  1. 9
      .env.development
  2. 4
      .env.production
  3. 2
      project.config.json
  4. 12
      src/jtools/store/user.js
  5. 12
      src/manifest.json
  6. 63
      src/pages.json
  7. 33
      src/pages/choseCity/choseCity.vue
  8. 92
      src/pages/course/chapter.vue
  9. 121
      src/pages/course/detail.vue
  10. 80
      src/pages/course/index.vue
  11. 23
      src/pages/index/index.vue
  12. 82
      src/pages/me/good.vue
  13. 96
      src/pages/me/index.vue
  14. 86
      src/pages/me/like.vue
  15. 49
      src/pages/me/login.vue
  16. 15
      src/pages/me/look.vue
  17. 122
      src/pages/me/userInfo.vue

@ -5,13 +5,8 @@ VITE_APP_TITLE = 耕读社
VITE_APP_ENV = 'development' VITE_APP_ENV = 'development'
# 耕读社/开发环境 # 耕读社/开发环境
VITE_APP_BASE_API = 'https://cloud.cloud.com/' VITE_APP_BASE_API = 'https://cloud.ahfkbg.com/'
# VITE_APP_BASE_API = 'https://xj.ahduima.com/' # VITE_APP_BASE_API = 'https://xj.ahduima.com/'
# 资源地址 # 资源地址
VITE_UPLOAD_URL = 'https://cloud.ahduima.com/' VITE_UPLOAD_URL = 'https://cloud.ahfkbg.com/'
# 静态资源地址
VITE_STATIC_URL = 'https://cloud.ahduima.com/gds'
#

@ -11,6 +11,4 @@ VITE_APP_BASE_API = 'https://cloud.ahduima.com/'
VITE_WEB_BASE_URL = 'https://cloud.ahduima.com' VITE_WEB_BASE_URL = 'https://cloud.ahduima.com'
# 资源地址 # 资源地址
VITE_UPLOAD_URL = 'http://cloud.ahduima.com' VITE_UPLOAD_URL = 'https://cloud.ahduima.com'
VITE_STATIC_URL = 'https://cloud.ahduima.com/gds'

@ -1,5 +1,5 @@
{ {
"appid": "wxc170fcbfd0c96f88", "appid": "wx0668c6fabb1a9c44",
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "3.3.3", "libVersion": "3.3.3",
"packOptions": { "packOptions": {

@ -1,7 +1,6 @@
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { login, getInfo } from '@/jtools/api/login'; import { login, getInfo } from '@/jtools/api/login';
import storage from '@/jtools/storage'; import storage from '@/jtools/storage';
import { queryUserMember } from '@/jtools/api/user';
const useUserStore = defineStore({ const useUserStore = defineStore({
id: 'user', id: 'user',
@ -26,7 +25,6 @@ const useUserStore = defineStore({
this.isLogin = true; this.isLogin = true;
this.token = resp.data.token; this.token = resp.data.token;
this.userInfo = resp.data; this.userInfo = resp.data;
this.searchVip()
storage.set('isLogin', true); storage.set('isLogin', true);
storage.set('token', resp.data.token); storage.set('token', resp.data.token);
storage.set('userInfo', resp.data); storage.set('userInfo', resp.data);
@ -62,20 +60,10 @@ const useUserStore = defineStore({
getInfo().then(resp => { getInfo().then(resp => {
if (resp.code == '0000') { if (resp.code == '0000') {
this.userInfo = resp.data; this.userInfo = resp.data;
this.searchVip()
storage.set('userInfo', resp.data); storage.set('userInfo', resp.data);
} }
}); });
}, },
searchVip() {
queryUserMember({ userId: this.userInfo.userId }).then(resp => {
if (resp.code == '0000') {
// this.vipInfo = resp.data;
console.log(resp);
}
});
},
setUserInfo(info) { setUserInfo(info) {
this.userInfo = info; this.userInfo = info;
}, },

@ -2,7 +2,7 @@
"name": "耕读社", "name": "耕读社",
"appid": "__UNI__59447F7", "appid": "__UNI__59447F7",
"description": "", "description": "",
"versionName": "1.0.2", "versionName": "1.0.1",
"versionCode": "100", "versionCode": "100",
"transformPx": false, "transformPx": false,
"app-plus": { "app-plus": {
@ -41,8 +41,16 @@
} }
}, },
"quickapp": {}, "quickapp": {},
"h5": {
"title": "耕读社",
"base": "/gds/",
"router": {
"mode": "history",
"base": "/gds/"
}
},
"mp-weixin": { "mp-weixin": {
"appid": "wxc170fcbfd0c96f88", "appid": "wx0668c6fabb1a9c44",
"setting": { "setting": {
"urlCheck": true, "urlCheck": true,
"minified": true, "minified": true,

@ -4,10 +4,52 @@
}, },
"pages": [ "pages": [
{ {
"path": "pages/index/index", "path": "pages/course/index",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
} }
},
{
"path": "pages/me/index",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/course/chapter",
"style": {
"navigationBarTitleText": "章节"
}
},
{
"path": "pages/course/detail",
"style": {
"navigationBarTitleText": "课程详情"
}
},
{
"path": "pages/me/userInfo",
"style": {
"navigationBarTitleText": "个人信息"
}
},
{
"path": "pages/me/good",
"style": {
"navigationBarTitleText": "我的点赞"
}
},
{
"path": "pages/me/like",
"style": {
"navigationBarTitleText": "我的收藏"
}
},
{
"path": "pages/me/login",
"style": {
"navigationBarTitleText": "登录"
}
} }
], ],
"globalStyle": { "globalStyle": {
@ -15,5 +57,24 @@
"navigationBarTitleText": "耕读社", "navigationBarTitleText": "耕读社",
"navigationBarBackgroundColor": "#FFF", "navigationBarBackgroundColor": "#FFF",
"backgroundColor": "#FFF" "backgroundColor": "#FFF"
},
"tabBar": {
"color": "#333",
"selectedColor": "#18AFFF",
"backgroundColor": "#FFF",
"list": [
{
"pagePath": "pages/course/index",
"text": "课程",
"iconPath": "static/image/tabbar/tab-book.png",
"selectedIconPath": "static/image/tabbar/tab-book-selected.png"
},
{
"pagePath": "pages/me/index",
"text": "我的",
"iconPath": "static/image/tabbar/tab-mine.png",
"selectedIconPath": "static/image/tabbar/tab-mine-selected.png"
}
]
} }
} }

@ -0,0 +1,33 @@
<template>
<view>
<chose-city @selectCity="selectCity" v-if="showCity" @closeModal="closeModal"></chose-city>
</view>
</template>
<script>
import choseCity from "@/components/chose-city/chose-city"
export default {
components: {
choseCity
},
data() {
return {
showCity:true
}
},
methods: {
selectCity(item) {
uni.setStorageSync('city', item.name)
uni.navigateBack()
// this.showCity = false
},
closeModal() {
this.showCity = false
},
}
}
</script>
<style>
</style>

@ -0,0 +1,92 @@
<template>
<view class="p15">
<view class="chapter_item" v-for="(item, index) of chapterList" :key="index" @tap="toDetail(item)">
<view style="line-height: 20px;">
<text class="j-tag" style="background: #DDEEFF;color: #1A8CFE">{{ item.chapterIndex }}</text>
<text class="fs14 ml5 ">{{ item.chapterName }}</text>
</view>
<view class="mt10 flex ai-c jc-sb fs12 mt8 cor-999">
<view class="flex ai-c">
<u-icon name="eye" color="#999" size="14" :label="item.browseCount" label-color="#999" label-size="12"></u-icon>
<u-icon class="ml20" name="thumb-up" color="#999" size="14" :label="item.goodCount" label-color="#999" label-size="12"></u-icon>
</view>
<text>{{ item.author }}</text>
<text>{{ item.publicTime }}</text>
</view>
</view>
</view>
</template>
<script>
import { getCourseChapter } from '@/jtools/api/index'
import { mapState } from 'pinia'; //
import useUserStore from '@/jtools/store/user'; //store
export default {
computed: {
...mapState(useUserStore, ['isLogin'])
},
data() {
return {
chapterList: [],
lessonId: undefined
}
},
onLoad(op){
this.lessonId = op.id
this.getChapterList(op.id)
},
onShow() {
if(this.lessonId) {
this.getChapterList(this.lessonId)
}
},
methods:{
getChapterList(lessonId){
getCourseChapter({lessonId}).then(resp=>{
if(resp.code==='0000'){
this.chapterList=resp.data
}
})
},
toDetail(chapter){
if(!this.isLogin){
uni.showToast({
title: '请先登录',
icon: 'none'
});
setTimeout(() => {
uni.navigateTo({
url: '/pages/me/login'
});
}, 1500);
return
} else {
uni.navigateTo({
url: `/pages/course/detail?id=${chapter.chapterId}`
});
}
},
}
}
</script>
<style lang="scss" scoped>
.chapter_item {
padding: 10px;
margin-bottom: 10px;
border-radius: 5px;
background-color: #fff;
}
.chapter_item:hover {
background-color: rgb(210, 209, 214);
}
.j-tag {
padding: 1px 3px;
border-radius: 3px;
font-size: 12px;
line-height: 14px;
color: #fff;
}
</style>

@ -0,0 +1,121 @@
<template>
<view class="bc-fff p10 relative">
<u-parse :content="chapterInfo.content"></u-parse>
<u-overlay :show="showMask" opacity="0.75">
<view class="p20 flex ai-c jc-c fld-c hp100" @tap="toMe" @scroll0.stop>
<u-icon name="lock" size="60" color="#999"></u-icon>
<view class="fs18 cor-999 mt20">请开通会员后继续学习</view>
<view class="fs14 cor-999 mt10">前往我的联系客服开通会员</view>
</view>
</u-overlay>
<!-- 右下角点赞收藏 -->
<view class="btns">
<view class="btn">
<u-icon name="thumb-up-fill" color="#999" size="28" :label="chapterInfo.goodCount" label-pos="bottom" label-size="12" @tap="good"></u-icon>
</view>
<view class="btn">
<u-icon name="heart-fill" color="#999" size="28" :label="chapterInfo.collectCount" label-pos="bottom" label-size="12" @tap="like"></u-icon>
</view>
</view>
</view>
</template>
<script>
import { getChapterDetail } from '@/jtools/api/index';
import { userGood, userLike } from '@/jtools/api/user';
import { mapState } from 'pinia'; //
import useUserStore from '@/jtools/store/user'; //store
export default {
computed: {
...mapState(useUserStore, ['userInfo'])
},
data() {
return {
chapterInfo: {
content: "",
goodCount: 0,
collectCount: 0,
},
showMask: false
}
},
onLoad(op) {
this.getInfo(op.id);
},
methods: {
getInfo(chapterId) {
try {
const _this = this;
getChapterDetail({ chapterId }).then(res => {
if (res.code === '0000') {
_this.chapterInfo = res.data;
uni.setNavigationBarTitle({
title: res.data.chapterIndex
});
if(!_this.userInfo.memberInfo && !_this.showMask && !res.data.isFree) {
_this.showMask = true;
}
}
});
} catch (error) {
console.log(error);
}
},
like() {
const _this = this;
userLike({ chapterId: this.chapterInfo.chapterId,userId:this.userInfo.userId }).then(res => {
if (res.code === '0000') {
_this.chapterInfo.collectCount += 1;
uni.showToast({
title: '收藏成功',
icon: 'none'
});
}
});
},
good() {
const _this = this;
userGood({ chapterId: this.chapterInfo.chapterId,userId: this.userInfo.userId }).then(res => {
if (res.code === '0000') {
_this.chapterInfo.goodCount += 1;
uni.showToast({
title: '点赞成功',
icon: 'none'
});
}
});
},
toMe() {
uni.switchTab({
url: '/pages/me/index'
});
this.showMask = false;
}
}
}
</script>
<style lang="scss" scoped>
.btns {
position: fixed;
right: 20px;
bottom: 80px;
display: flex;
flex-direction: column;
gap: 20px;
.btn {
width: 60px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
background-color: #fff;
border-radius: 50%;
padding: 5px;
border: 1px solid #333;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
opacity: 0.7;
}
}
</style>

@ -0,0 +1,80 @@
<template>
<view class="wp100 hp100">
<view class="p5" style="background-color: #fff;">
<u-search v-model="queryParams.searchValue" placeholder="搜索标题/作者" :showAction="false"
@search="handleSearch">搜索</u-search>
</view>
<u-list v-if="pageList.length > 0" @scrolltolower="scrolltolower" class="course-list">
<u-list-item v-for="(item, index) in pageList" :key="index">
<view class="flex ai-c jc-sb p10lr p5tb bc-fff" @click="handleClick(item)">
<view class="flex ai-c">
<image :src="item.image" mode="aspectFill" style="width: 160px;height: 100px;border-radius: 6px;" />
</view>
<view class="fl1 ml10 overflow-h">
<view class="fs14">{{ item.lessonName }}</view>
<view class="fs13 mt8 cor-999 text-ellipsis">{{ item.introduction }}</view>
<view class="flex ai-c jc-sb fs12 mt8 cor-999">
<u-icon name="eye" color="#999" size="14" :label="item.browseCount" label-color="#999" label-size="12"></u-icon>
<u-icon name="thumb-up" color="#999" size="14" :label="item.goodCount" label-color="#999" label-size="12"></u-icon>
<text>{{ item.author }}</text>
</view>
</view>
</view>
</u-list-item>
</u-list>
<u-empty v-else mode="list" text="暂无数据"></u-empty>
</view>
</template>
<script>
import { getCourseList } from '@/jtools/api/index'
export default {
data() {
return {
pageList: [],
total: 0,
queryParams: {
searchValue: '',
pageNo: 1,
pageSize: 20
}
}
},
mounted() {
this.handleSearch()
},
methods: {
scrolltolower() {
if (this.pageList.length < this.total) {
this.queryParams.pageNo++
this.getPageList()
}
},
handleSearch() {
this.pageList = []
this.queryParams.pageNo = 1
this.getPageList()
},
getPageList() {
const _this = this
const params = { ...this.queryParams }
getCourseList(params).then(res => {
_this.pageList = [..._this.pageList, ...res.data.records]
_this.total = res.data.total
});
},
handleClick(item) {
uni.navigateTo({
url: `/pages/course/chapter?id=${item.lessonId}`
});
}
}
}
</script>
<style lang="scss" scoped>
.course-list {
background-color: #fff;
}
</style>

@ -1,23 +0,0 @@
<template>
<view>
<web-view :webview-styles="webviewStyles" :src="webUrl"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
webviewStyles: {
top: '0px',
bottom: '0px'
},
webUrl: import.meta.env.VITE_STATIC_URL
};
}
}
</script>
<style lang="scss" scoped>
</style>

@ -0,0 +1,82 @@
<template>
<view>
<u-list v-if="pageList.length > 0" @scrolltolower="scrolltolower" class="course-list">
<u-list-item v-for="(item, index) in pageList" :key="index">
<view class="flex ai-c jc-sb p10lr p5tb bc-fff" @click="handleClick(item)">
<view class="flex ai-c">
<image :src="item.image" mode="aspectFill" style="width: 150px;height: 100px;border-radius: 6px;" />
</view>
<view class="fl1 ml10">
<view class="fs14">{{ item.lessonName }}</view>
<view class="fs13 mt8 cor-999">
<text class="j-tag" style="background: #DDEEFF;color: #1A8CFE">{{ item.chapterIndex }}</text>
<text>{{ item.chapterName }}</text>
</view>
</view>
</view>
</u-list-item>
</u-list>
<u-empty v-else mode="list" text="暂无数据"></u-empty>
</view>
</template>
<script>
import { getUserGoodList } from '@/jtools/api/user'
import { mapState } from 'pinia'; //
import useUserStore from '@/jtools/store/user'; //store
export default {
computed: {
...mapState(useUserStore, ['userInfo'])
},
data() {
return {
pageList: [],
total: 0,
queryParams: {
pageNo: 1,
pageSize: 20
}
}
},
mounted() {
this.handleSearch()
},
methods: {
scrolltolower() {
if (this.pageList.length < this.total) {
this.queryParams.pageNo++
this.getPageList()
}
},
handleSearch() {
this.pageList = []
this.queryParams.pageNo = 1
this.getPageList()
},
getPageList() {
const _this = this
const params = { ...this.queryParams, userId: this.userInfo.userId }
getUserGoodList(params).then(res => {
_this.pageList = [..._this.pageList, ...res.data.records]
_this.total = res.data.total
});
},
handleClick(chapter) {
uni.navigateTo({
url: `/pages/course/detail?id=${chapter.chapterId}`
});
}
}
}
</script>
<style lang="scss" scoped>
.j-tag {
padding: 1px 3px;
border-radius: 3px;
font-size: 12px;
line-height: 14px;
color: #fff;
}
</style>

@ -0,0 +1,96 @@
<template>
<view class="container">
<view class="p15">
<!-- 用户信息 -->
<view class="user-info" @tap="next('/pages/me/userInfo')">
<view class="fl1 flex ai-c">
<u-avatar size="48" :src="userInfo?.avatar"></u-avatar>
<view class="ml10 fs16 fw600">
<view>{{ isLogin ? userInfo?.userName : '点击登陆' }}</view>
<view class="fs12 cor-999">{{ isLogin ? userInfo?.phone : '未登录' }}</view>
</view>
</view>
<u-icon name="arrow-right" size="16"></u-icon>
</view>
<!-- cells 列表 -->
<u-cell-group :customStyle="{ 'background-color': '#fff', 'margin-top': '10px', 'border-radius': '8px' }">
<u-cell icon="thumb-up" size="large" title="我的点赞" isLink @tap="next('/pages/me/good')"></u-cell>
<u-cell icon="heart" size="large" title="我的收藏" isLink @tap="next('/pages/me/like')"></u-cell>
<u-cell icon="level" size="large" title="当前版本" :value="version"></u-cell>
<u-cell icon="phone" size="large" title="联系我们" :value="contactInfo.configDesc" isLink @tap="makePhone"></u-cell>
</u-cell-group>
<!-- 退出登陆 -->
<u-button v-if="isLogin" plain :customStyle="{ 'margin-top': '20px' }" @tap="logout">退出登录</u-button>
</view>
</view>
</template>
<script>
import { getSysConfig } from '@/jtools/api/index';
import { mapState, mapActions } from 'pinia'; //
import useUserStore from '@/jtools/store/user'; //store
export default {
computed: {
...mapState(useUserStore, ['userInfo', 'isLogin'])
},
data() {
return {
version: uni.getAppBaseInfo().appVersion,
contactInfo: {
configValue: '18056811878',
configDesc: '周老师'
}
};
},
onLoad() {
getSysConfig({ configKey: 'AppletContact', driverTypeId: -1 }).then(res => {
this.contactInfo = res.data;
});
},
methods: {
...mapActions(useUserStore, ['logout']),
next(url) {
if (this.isLogin) {
uni.navigateTo({
url: url
});
} else {
uni.navigateTo({
url: '/pages/me/login'
});
}
},
makePhone() {
uni.makePhoneCall({
phoneNumber: this.contactInfo.configValue
});
},
}
};
</script>
<style lang="scss" scoped>
.container {
width: 100vw;
height: 100vh;
background: linear-gradient(180deg, rgb(242, 242, 242), #fff); // 线
.user-info {
display: flex;
align-items: center;
justify-content: space-between;
background-color: #fff;
border-radius: 8px;
padding: 15px;
}
.share {
background-color: #fff;
width: 100%;
padding: 0;
text-align: left;
border: 0;
}
}
</style>

@ -0,0 +1,86 @@
<template>
<view>
<u-list v-if="pageList.length > 0" @scrolltolower="scrolltolower" class="course-list">
<u-list-item v-for="(item, index) in pageList" :key="index">
<view class="flex ai-c jc-sb p10lr p5tb bc-fff" @click="handleClick(item)">
<view class="flex ai-c">
<image :src="item.image" mode="aspectFill" style="width: 150px;height: 100px;border-radius: 6px;" />
</view>
<view class="fl1 ml10">
<view class="fs14">{{ item.lessonName }}</view>
<view class="fs13 mt8 cor-999">
<text class="j-tag" style="background: #DDEEFF;color: #1A8CFE">{{ item.chapterIndex }}</text>
<text>{{ item.chapterName }}</text>
</view>
<view class="mt5 flex ai-c jc-sb fs13 cor-999">
<text>{{ item.author }}</text>
<text>{{ item.publicTime }}</text>
</view>
</view>
</view>
</u-list-item>
</u-list>
<u-empty v-else mode="list" text="暂无数据"></u-empty>
</view>
</template>
<script>
import { getUserLikeList } from '@/jtools/api/user'
import { mapState } from 'pinia'; //
import useUserStore from '@/jtools/store/user'; //store
export default {
computed: {
...mapState(useUserStore, ['userInfo'])
},
data() {
return {
pageList: [],
total: 0,
queryParams: {
pageNo: 1,
pageSize: 20
}
}
},
mounted() {
this.handleSearch()
},
methods: {
scrolltolower() {
if (this.pageList.length < this.total) {
this.queryParams.pageNo++
this.getPageList()
}
},
handleSearch() {
this.pageList = []
this.queryParams.pageNo = 1
this.getPageList()
},
getPageList() {
const _this = this
const params = { ...this.queryParams, userId: this.userInfo.userId }
getUserLikeList(params).then(res => {
_this.pageList = [..._this.pageList, ...res.data.records]
_this.total = res.data.total
});
},
handleClick(chapter) {
uni.navigateTo({
url: `/pages/course/detail?id=${chapter.chapterId}`
});
}
}
}
</script>
<style lang="scss" scoped>
.j-tag {
padding: 1px 3px;
border-radius: 3px;
font-size: 12px;
line-height: 14px;
color: #fff;
}
</style>

@ -0,0 +1,49 @@
<template>
<view class="content">
<view class="mb40" style="border-bottom: 1px solid #eee;margin-top: 100px;">
<u-input border="none" v-model="loginForm.phone" type="number" maxlength="11"
placeholder="输入手机号" />
</view>
<u-button shape="circle" type="primary" @click="bindLogin()">授权登录</u-button>
</view>
</template>
<script>
import useUserStore from '@/jtools/store/user'
import storage from '@/jtools/storage';
export default {
data() {
return {
loginForm: {
phone: '',
code: '000000'
},
countDown: 0,
js: undefined
};
},
methods: {
bindLogin() {
let params = { ...this.loginForm }
if (storage.get('companyId')) {
params.id = storage.get('companyId')
}
useUserStore().login(params).then(resp => {
if (resp.userId) {
useUserStore().getUserInfo()
uni.navigateBack()
}
})
},
}
}
</script>
<style>
.content {
width: 100vw;
height: 100vh;
padding: 20px;
background-color: #fff;
}
</style>

@ -0,0 +1,15 @@
<template>
<div>
</div>
</template>
<script>
export default {
}
</script>
<style lang="scss" scoped>
</style>

@ -0,0 +1,122 @@
<template>
<view class="container">
<view class="flex ai-c jc-sb p15lr p5tb bb1">
<view class="fs14 fl1">头像</view>
<u-avatar size="56" :src="form.avatar" @tap="chooseAvatar" />
</view>
<view class="flex ai-c jc-sb p15 bb1">
<view class="fs14">
<text style="color: red;">*</text>
<text class="ml2">昵称</text>
</view>
<input
type="text"
v-model="form.userName"
placeholder="请输入昵称"
style="width: 100px;text-align: right; flex: 1;"
/>
</view>
<view class="flex ai-c jc-sb p15 bb1">
<view class="fs14">性别</view>
<view class="flex" @tap="showSexPicker">
<text class="cor-666">{{ ['男', '女'][form.sex] || '请选择性别' }}</text>
<u-icon name="arrow-right" size="16" class="ml10"></u-icon>
</view>
</view>
<view class="flex ai-c jc-sb p15 bb1">
<view class="fs14">生日</view>
<view class="flex" @tap="showDate = true">
<text class="cor-666">{{ form.birthday || '请选择出生日期' }}</text>
<u-icon name="arrow-right" size="16" class="ml10"></u-icon>
</view>
</view>
<view class="flex ai-c jc-sb p15 bb1">
<view class="fs14 fl1">手机号码</view>
<text class="cor-999">{{ form.phone }}</text>
</view>
<!-- 保存 -->
<view class="p15 mt20">
<u-button type="primary" @tap="submit">保存</u-button>
</view>
<u-datetime-picker :show="showDate" mode="date" closeOnClickOverlay v-model="form.birthday" :minDate="Number(new Date('1900-01-01'))" @confirm="confirmDate" @cancel="showDate=false"></u-datetime-picker>
</view>
</template>
<script>
import { updateUserInfo } from '@/jtools/api/user'
import useUserStore from '@/jtools/store/user' //store
export default {
name: 'UserInfo',
data() {
return {
form: {...useUserStore().userInfo, sex: useUserStore().userInfo.sex || 0},
saving: false,
showDate: false
}
},
methods: {
async submit() {
const res = await updateUserInfo(this.form)
if (res.code == '0000') {
uni.showToast({
title: '修改成功',
icon: 'none'
})
useUserStore().setUserInfo(this.form)
uni.navigateBack()
}
},
chooseAvatar() {
const _this = this
uni.chooseImage({
count: 1,
success: (res) => {
_this.form.avatar = res.tempFilePaths[0]
_this.saving = true
_this.uploadAvatar(res.tempFilePaths[0])
}
})
},
uploadAvatar(url) {
const _this = this
uni.uploadFile({
url: import.meta.env.VITE_UPLOAD_URL + 'sinology-api/system/file/upload', //
filePath: url,
name: 'file',
success: (res) => {
console.log(JSON.parse(res.data).data);
_this.form.avatar = JSON.parse(res.data).data
this.saving = false;
},
fail: () => {
uni.showToast({ title: '上传失败', icon: 'none' });
this.saving = false;
}
});
},
showSexPicker() {
uni.showActionSheet({
itemList: ['男', '女'],
success: (res) => {
this.form.sex = res.tapIndex
}
})
},
confirmDate(e) {
this.showDate = false;
this.form.birthday = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
},
}
}
</script>
<style lang="scss" scoped>
.container {
width: 100vw;
height: 100vh;
background-color: #fff;
}
</style>
Loading…
Cancel
Save