17 changed files with 1073 additions and 26 deletions
@ -0,0 +1,217 @@ |
|||||
|
<template> |
||||
|
<div style="padding-top: 88rpx;"> |
||||
|
<div class="login-tip">大美非遗 申请获得</div> |
||||
|
<div class="login-tip2">以下权限</div> |
||||
|
<div class="login-tip-box"> |
||||
|
<text>获得你的公开信息(昵称、头像、地区及性别)</text> |
||||
|
</div> |
||||
|
<div class="btn-box"> |
||||
|
<button bindtap="cancel" type="default" @click="redirectIndex">取消</button> |
||||
|
<button type="primary" @click="getUserInfo">同意</button> |
||||
|
</div> |
||||
|
<div class="flex-center article-box"> |
||||
|
<radio-group @change="toggleAgreement"> |
||||
|
<radio value="1" :checked="isAgreed" style="transform:scale(0.7)"></radio> |
||||
|
</radio-group> |
||||
|
<div>同意<text @click="gotoInfo">《用户服务协议》、《隐私政策》</text></div> |
||||
|
</div> |
||||
|
<uni-popup ref="popup" type="bottom" background-color="#fff"> |
||||
|
<button type="default" open-type="getPhoneNumber" @getphonenumber="handlePhoneNumber" style="width: 100%;height: 12vh;line-height: 12vh;">点击授权手机号</button> |
||||
|
</uni-popup> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
name: "login", |
||||
|
data() { |
||||
|
return { |
||||
|
isAgreed: false, |
||||
|
}; |
||||
|
}, |
||||
|
onLoad(options) { |
||||
|
// 只需授权手机号 |
||||
|
if (options.needAuth === '1') { |
||||
|
setTimeout(() => { |
||||
|
this.$refs.popup.open('bottom'); |
||||
|
}, 400); |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
// 处理手机号授权 |
||||
|
handlePhoneNumber(e) { |
||||
|
if (e.detail.errMsg === "getPhoneNumber:ok") { // 成功 |
||||
|
this.$refs.popup.close(); |
||||
|
this.Post({ |
||||
|
code: e.detail.code, |
||||
|
encryptedData: e.detail.encryptedData, |
||||
|
iv: e.detail.iv, |
||||
|
token: uni.getStorageSync('token1') |
||||
|
}, '/api/mini_program/bindPhoneNumber') |
||||
|
.then(res => { |
||||
|
this.$store.commit('changeUserInfo', res.data.userinfo); |
||||
|
this.navigateBasedOnPath(); |
||||
|
}) |
||||
|
.catch(error => { |
||||
|
console.error('绑定手机号失败:', error); |
||||
|
uni.showToast({ |
||||
|
title: '绑定手机号失败,请稍后重试', |
||||
|
icon: 'none' |
||||
|
}); |
||||
|
}); |
||||
|
} else { |
||||
|
console.error('获取手机号失败:', e.detail.errMsg); |
||||
|
uni.showToast({ |
||||
|
title: '获取手机号失败,请稍后重试', |
||||
|
icon: 'none' |
||||
|
}); |
||||
|
} |
||||
|
}, |
||||
|
// 跳转到协议页面 |
||||
|
gotoInfo() { |
||||
|
uni.navigateTo({ |
||||
|
url: '/subPackages/user/privacy' |
||||
|
}); |
||||
|
}, |
||||
|
// 切换协议同意状态 |
||||
|
toggleAgreement() { |
||||
|
this.isAgreed = !this.isAgreed; |
||||
|
}, |
||||
|
// 重定向到首页 |
||||
|
redirectIndex() { |
||||
|
uni.switchTab({ |
||||
|
url: '/pages/index/index', |
||||
|
}); |
||||
|
}, |
||||
|
// 获取用户信息 |
||||
|
getUserInfo() { |
||||
|
if (!this.isAgreed) { |
||||
|
uni.showToast({ |
||||
|
title: '请先勾选同意《用户服务协议》、《隐私政策》', |
||||
|
icon: 'none' |
||||
|
}); |
||||
|
return; |
||||
|
} |
||||
|
uni.login({ |
||||
|
provider: 'weixin', |
||||
|
success: (loginRes) => { |
||||
|
uni.getUserInfo({ |
||||
|
withCredentials: true, |
||||
|
success: (res) => { |
||||
|
this.Post({ |
||||
|
code: loginRes.code, |
||||
|
userInfo: res.userInfo, |
||||
|
encryptedData: res.encryptedData, |
||||
|
iv: res.iv, |
||||
|
wechat_qrcode: uni.getStorageSync('wechat_qrcode') || '' |
||||
|
}, '/api/mini_program/login') |
||||
|
.then(resTwo => { |
||||
|
this.$store.commit('changeUserInfo', resTwo.data.userinfo); |
||||
|
if (resTwo.data.userinfo.mobile) { |
||||
|
this.navigateBasedOnPath(); |
||||
|
} else { |
||||
|
uni.setStorageSync('token1', resTwo.data.userinfo.token); |
||||
|
this.$refs.popup.open('bottom'); |
||||
|
} |
||||
|
}) |
||||
|
.catch(error => { |
||||
|
console.error('登录失败:', error); |
||||
|
uni.showToast({ |
||||
|
title: '登录失败,请稍后重试', |
||||
|
icon: 'none' |
||||
|
}); |
||||
|
}); |
||||
|
}, |
||||
|
fail: (err) => { |
||||
|
console.error('获取用户信息失败:', err); |
||||
|
uni.showToast({ |
||||
|
title: '获取用户信息失败,请稍后重试', |
||||
|
icon: 'none' |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
}, |
||||
|
fail: (err) => { |
||||
|
console.error('微信登录失败:', err); |
||||
|
uni.showToast({ |
||||
|
title: '微信登录失败,请稍后重试', |
||||
|
icon: 'none' |
||||
|
}); |
||||
|
} |
||||
|
}); |
||||
|
}, |
||||
|
// 根据路径进行导航 |
||||
|
navigateBasedOnPath() { |
||||
|
if (this.$store.state.user.toPath.includes('user/user')) { |
||||
|
uni.switchTab({ |
||||
|
url: this.$store.state.user.toPath |
||||
|
}); |
||||
|
} else { |
||||
|
uni.navigateBack({}); |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style> |
||||
|
.login-tip { |
||||
|
font-size: 28rpx; |
||||
|
margin: 0 60rpx; |
||||
|
margin-top: 40rpx; |
||||
|
} |
||||
|
|
||||
|
.login-tip2 { |
||||
|
font-size: 44rpx; |
||||
|
margin: 0rpx 60rpx; |
||||
|
margin-top: 20rpx; |
||||
|
font-weight: 400; |
||||
|
} |
||||
|
|
||||
|
.login-tip-box { |
||||
|
display: flex; |
||||
|
align-items: flex-start; |
||||
|
margin: 0 60rpx; |
||||
|
font-size: 28rpx; |
||||
|
margin-top: 40rpx; |
||||
|
line-height: 40rpx; |
||||
|
} |
||||
|
|
||||
|
.login-tip-box .icon-gou1 { |
||||
|
line-height: 80rpx; |
||||
|
margin-top: -20rpx; |
||||
|
margin-right: 30rpx; |
||||
|
color: #666; |
||||
|
} |
||||
|
|
||||
|
.btn-box { |
||||
|
display: flex; |
||||
|
position: absolute; |
||||
|
bottom: 100rpx; |
||||
|
left: 0; |
||||
|
right: 0; |
||||
|
} |
||||
|
|
||||
|
.btn-box button { |
||||
|
width: 400rpx; |
||||
|
} |
||||
|
|
||||
|
.article-box { |
||||
|
position: absolute; |
||||
|
left: 0; |
||||
|
right: 0; |
||||
|
justify-content: center; |
||||
|
font-size: 24rpx; |
||||
|
color: #1aad19; |
||||
|
bottom: 40rpx; |
||||
|
} |
||||
|
|
||||
|
.article-box .iconfont { |
||||
|
margin-right: 10rpx; |
||||
|
font-size: 26rpx; |
||||
|
} |
||||
|
|
||||
|
.article-box text { |
||||
|
border-bottom: 1px solid; |
||||
|
} |
||||
|
</style> |
Before Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 10 KiB |
@ -0,0 +1,196 @@ |
|||||
|
function getLocalFilePath(path) { |
||||
|
if (path.indexOf('_www') === 0 || path.indexOf('_doc') === 0 || path.indexOf('_documents') === 0 || path.indexOf('_downloads') === 0) { |
||||
|
return path |
||||
|
} |
||||
|
if (path.indexOf('file://') === 0) { |
||||
|
return path |
||||
|
} |
||||
|
if (path.indexOf('/storage/emulated/0/') === 0) { |
||||
|
return path |
||||
|
} |
||||
|
if (path.indexOf('/') === 0) { |
||||
|
var localFilePath = plus.io.convertAbsoluteFileSystem(path) |
||||
|
if (localFilePath !== path) { |
||||
|
return localFilePath |
||||
|
} else { |
||||
|
path = path.substr(1) |
||||
|
} |
||||
|
} |
||||
|
return '_www/' + path |
||||
|
} |
||||
|
|
||||
|
function dataUrlToBase64(str) { |
||||
|
var array = str.split(',') |
||||
|
return array[array.length - 1] |
||||
|
} |
||||
|
|
||||
|
var index = 0 |
||||
|
function getNewFileId() { |
||||
|
return Date.now() + String(index++) |
||||
|
} |
||||
|
|
||||
|
function biggerThan(v1, v2) { |
||||
|
var v1Array = v1.split('.') |
||||
|
var v2Array = v2.split('.') |
||||
|
var update = false |
||||
|
for (var index = 0; index < v2Array.length; index++) { |
||||
|
var diff = v1Array[index] - v2Array[index] |
||||
|
if (diff !== 0) { |
||||
|
update = diff > 0 |
||||
|
break |
||||
|
} |
||||
|
} |
||||
|
return update |
||||
|
} |
||||
|
|
||||
|
export function pathToBase64(path) { |
||||
|
return new Promise(function(resolve, reject) { |
||||
|
if (typeof window === 'object' && 'document' in window) { |
||||
|
if (typeof FileReader === 'function') { |
||||
|
var xhr = new XMLHttpRequest() |
||||
|
xhr.open('GET', path, true) |
||||
|
xhr.responseType = 'blob' |
||||
|
xhr.onload = function() { |
||||
|
if (this.status === 200) { |
||||
|
let fileReader = new FileReader() |
||||
|
fileReader.onload = function(e) { |
||||
|
resolve(e.target.result) |
||||
|
} |
||||
|
fileReader.onerror = reject |
||||
|
fileReader.readAsDataURL(this.response) |
||||
|
} |
||||
|
} |
||||
|
xhr.onerror = reject |
||||
|
xhr.send() |
||||
|
return |
||||
|
} |
||||
|
var canvas = document.createElement('canvas') |
||||
|
var c2x = canvas.getContext('2d') |
||||
|
var img = new Image |
||||
|
img.onload = function() { |
||||
|
canvas.width = img.width |
||||
|
canvas.height = img.height |
||||
|
c2x.drawImage(img, 0, 0) |
||||
|
resolve(canvas.toDataURL()) |
||||
|
canvas.height = canvas.width = 0 |
||||
|
} |
||||
|
img.onerror = reject |
||||
|
img.src = path |
||||
|
return |
||||
|
} |
||||
|
if (typeof plus === 'object') { |
||||
|
plus.io.resolveLocalFileSystemURL(getLocalFilePath(path), function(entry) { |
||||
|
entry.file(function(file) { |
||||
|
var fileReader = new plus.io.FileReader() |
||||
|
fileReader.onload = function(data) { |
||||
|
resolve(data.target.result) |
||||
|
} |
||||
|
fileReader.onerror = function(error) { |
||||
|
reject(error) |
||||
|
} |
||||
|
fileReader.readAsDataURL(file) |
||||
|
}, function(error) { |
||||
|
reject(error) |
||||
|
}) |
||||
|
}, function(error) { |
||||
|
reject(error) |
||||
|
}) |
||||
|
return |
||||
|
} |
||||
|
if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) { |
||||
|
wx.getFileSystemManager().readFile({ |
||||
|
filePath: path, |
||||
|
encoding: 'base64', |
||||
|
success: function(res) { |
||||
|
resolve('data:image/png;base64,' + res.data) |
||||
|
}, |
||||
|
fail: function(error) { |
||||
|
reject(error) |
||||
|
} |
||||
|
}) |
||||
|
return |
||||
|
} |
||||
|
reject(new Error('not support')) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
export function base64ToPath(base64) { |
||||
|
return new Promise(function(resolve, reject) { |
||||
|
if (typeof window === 'object' && 'document' in window) { |
||||
|
base64 = base64.split(',') |
||||
|
var type = base64[0].match(/:(.*?);/)[1] |
||||
|
var str = atob(base64[1]) |
||||
|
var n = str.length |
||||
|
var array = new Uint8Array(n) |
||||
|
while (n--) { |
||||
|
array[n] = str.charCodeAt(n) |
||||
|
} |
||||
|
return resolve((window.URL || window.webkitURL).createObjectURL(new Blob([array], { type: type }))) |
||||
|
} |
||||
|
var extName = base64.split(',')[0].match(/data\:\S+\/(\S+);/) |
||||
|
if (extName) { |
||||
|
extName = extName[1] |
||||
|
} else { |
||||
|
reject(new Error('base64 error')) |
||||
|
} |
||||
|
var fileName = getNewFileId() + '.' + extName |
||||
|
if (typeof plus === 'object') { |
||||
|
var basePath = '_doc' |
||||
|
var dirPath = 'uniapp_temp' |
||||
|
var filePath = basePath + '/' + dirPath + '/' + fileName |
||||
|
if (!biggerThan(plus.os.name === 'Android' ? '1.9.9.80627' : '1.9.9.80472', plus.runtime.innerVersion)) { |
||||
|
plus.io.resolveLocalFileSystemURL(basePath, function(entry) { |
||||
|
entry.getDirectory(dirPath, { |
||||
|
create: true, |
||||
|
exclusive: false, |
||||
|
}, function(entry) { |
||||
|
entry.getFile(fileName, { |
||||
|
create: true, |
||||
|
exclusive: false, |
||||
|
}, function(entry) { |
||||
|
entry.createWriter(function(writer) { |
||||
|
writer.onwrite = function() { |
||||
|
resolve(filePath) |
||||
|
} |
||||
|
writer.onerror = reject |
||||
|
writer.seek(0) |
||||
|
writer.writeAsBinary(dataUrlToBase64(base64)) |
||||
|
}, reject) |
||||
|
}, reject) |
||||
|
}, reject) |
||||
|
}, reject) |
||||
|
return |
||||
|
} |
||||
|
var bitmap = new plus.nativeObj.Bitmap(fileName) |
||||
|
bitmap.loadBase64Data(base64, function() { |
||||
|
bitmap.save(filePath, {}, function() { |
||||
|
bitmap.clear() |
||||
|
resolve(filePath) |
||||
|
}, function(error) { |
||||
|
bitmap.clear() |
||||
|
reject(error) |
||||
|
}) |
||||
|
}, function(error) { |
||||
|
bitmap.clear() |
||||
|
reject(error) |
||||
|
}) |
||||
|
return |
||||
|
} |
||||
|
if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) { |
||||
|
var filePath = wx.env.USER_DATA_PATH + '/' + fileName |
||||
|
wx.getFileSystemManager().writeFile({ |
||||
|
filePath: filePath, |
||||
|
data: dataUrlToBase64(base64), |
||||
|
encoding: 'base64', |
||||
|
success: function() { |
||||
|
resolve(filePath) |
||||
|
}, |
||||
|
fail: function(error) { |
||||
|
reject(error) |
||||
|
} |
||||
|
}) |
||||
|
return |
||||
|
} |
||||
|
reject(new Error('not support')) |
||||
|
}) |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
{ |
||||
|
"id": "mmmm-image-tools", |
||||
|
"name": "image-tools", |
||||
|
"version": "1.4.0", |
||||
|
"description": "图像转换工具,可用于图像和base64的转换", |
||||
|
"keywords": [ |
||||
|
"base64", |
||||
|
"保存", |
||||
|
"图像" |
||||
|
] |
||||
|
} |
@ -0,0 +1,102 @@ |
|||||
|
<template> |
||||
|
<view class="bg"> |
||||
|
<image src="https://static.ticket.sz-trip.com/cgc/images/index/shiguang.png" mode="aspectFill" class="topImg"></image> |
||||
|
|
||||
|
<view class="box"> |
||||
|
<view v-for="(item,index) in list" :key="index" class="item"> |
||||
|
<view style="display: flex;align-items: center;"> |
||||
|
<image :src="showImg(item.head_img)" mode="aspectFill" class="profile"></image> |
||||
|
<view class="name">君到苏州</view> |
||||
|
</view> |
||||
|
<view class="title"> |
||||
|
视频标题视频标题视频标题视频标题视频标题视频标题视频标题视频标题视频标题 |
||||
|
</view> |
||||
|
<view class="video-box" :style="{backgroundImage: 'url('+showImg(item.head_img)+')'}"> |
||||
|
<image src="https://static.ticket.sz-trip.com/cgc/images/index/plays.png" mode="" class="play"></image> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
data() { |
||||
|
return { |
||||
|
list: [ |
||||
|
{ |
||||
|
head_img: 'https://static.ticket.sz-trip.com/uploads/20230920/7cdb05709d09cc2c86ea5671bd657c85.jpg' |
||||
|
}, |
||||
|
{ |
||||
|
head_img: 'https://changshu.js-dyyj.com/uploads/20250418/8a7631a1955ca05e619c0a25ad5ac1d1.jpg' |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.bg { |
||||
|
min-height: 100vh; |
||||
|
background: #FFFFFF; |
||||
|
padding-bottom: 100rpx; |
||||
|
} |
||||
|
|
||||
|
.topImg { |
||||
|
width: 750rpx; |
||||
|
height: 380rpx; |
||||
|
} |
||||
|
|
||||
|
.box { |
||||
|
margin-top: -24rpx; |
||||
|
border-radius: 24rpx 24rpx 0 0; |
||||
|
padding: 0 32rpx; |
||||
|
|
||||
|
.item { |
||||
|
padding: 32rpx 0; |
||||
|
|
||||
|
.profile { |
||||
|
width: 48rpx; |
||||
|
height: 48rpx; |
||||
|
border-radius: 50%; |
||||
|
margin-right: 16rpx; |
||||
|
} |
||||
|
.name { |
||||
|
font-weight: 500; |
||||
|
font-size: 28rpx; |
||||
|
color: #000000; |
||||
|
} |
||||
|
|
||||
|
.title { |
||||
|
font-weight: 400; |
||||
|
font-size: 28rpx; |
||||
|
color: #000000; |
||||
|
margin-top: 24rpx; |
||||
|
} |
||||
|
|
||||
|
.video-box { |
||||
|
width: 686rpx; |
||||
|
height: 372rpx; |
||||
|
border-radius: 32rpx; |
||||
|
margin-top: 20rpx; |
||||
|
background-size: 100% 100%; |
||||
|
position: relative; |
||||
|
|
||||
|
.play { |
||||
|
position: absolute; |
||||
|
top: 0; |
||||
|
bottom: 0; |
||||
|
left: 0; |
||||
|
right: 0; |
||||
|
margin: auto; |
||||
|
width: 56rpx; |
||||
|
height: 56rpx; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
.item:nth-child(n+2) { |
||||
|
border-top: 2rpx solid rgba(0,0,0,0.05); |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -1,19 +0,0 @@ |
|||||
<template> |
|
||||
<view class="bg"> |
|
||||
|
|
||||
</view> |
|
||||
</template> |
|
||||
|
|
||||
<script> |
|
||||
export default { |
|
||||
data() { |
|
||||
return { |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
</script> |
|
||||
|
|
||||
<style lang="scss" scoped> |
|
||||
|
|
||||
</style> |
|
@ -0,0 +1,89 @@ |
|||||
|
<template> |
||||
|
<view class="bg"> |
||||
|
<view class="nickname-box"> |
||||
|
<input v-model="nickname" type="text" placeholder="请输入内容" /> |
||||
|
</view> |
||||
|
<view class="btn" @click="save">保存</view> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
name: "changeNickname", |
||||
|
data: function() { |
||||
|
return { |
||||
|
nickname: "" |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
save: function() { |
||||
|
if (!this.nickname) { |
||||
|
uni.showToast({ |
||||
|
title: '请输入昵称', |
||||
|
icon: 'none' |
||||
|
}) |
||||
|
return; |
||||
|
} |
||||
|
this.Post({ |
||||
|
nickname: this.nickname |
||||
|
}, '/api/user/profile').then(res => { |
||||
|
console.log(res) |
||||
|
if (res.code == 1) { |
||||
|
uni.showModal({ |
||||
|
title: '提示', |
||||
|
content: '保存成功!', |
||||
|
success: res => { |
||||
|
if (res.confirm) { |
||||
|
this.goBack() |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style scoped> |
||||
|
.bg { |
||||
|
min-height: 100vh; |
||||
|
padding-top: 50rpx; |
||||
|
} |
||||
|
|
||||
|
.nickname-box { |
||||
|
display: flex; |
||||
|
padding: 10rpx 0 30rpx; |
||||
|
margin: 0 30rpx; |
||||
|
align-items: center; |
||||
|
background: white; |
||||
|
margin-bottom: 100rpx; |
||||
|
font-size: 30rpx; |
||||
|
height: 70rpx; |
||||
|
border-bottom: 1rpx solid #D8D8D8; |
||||
|
} |
||||
|
|
||||
|
.nickname-box span { |
||||
|
flex-shrink: 0; |
||||
|
} |
||||
|
|
||||
|
.nickname-box input { |
||||
|
flex: 1; |
||||
|
font-size: 30rpx; |
||||
|
display: block; |
||||
|
} |
||||
|
|
||||
|
.btn { |
||||
|
color: black; |
||||
|
margin: 0 auto; |
||||
|
line-height: 80rpx; |
||||
|
position: relative; |
||||
|
font-size: 34rpx; |
||||
|
text-align: center; |
||||
|
width: 333rpx; |
||||
|
height: 80rpx; |
||||
|
background: #C3282E; |
||||
|
border-radius: 40rpx; |
||||
|
color: #FFFFFF; |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,407 @@ |
|||||
|
<template> |
||||
|
<view v-if="info"> |
||||
|
<view class="user-other-info"> |
||||
|
<div class="info-avatar-top"> |
||||
|
<span>头像</span> |
||||
|
<view @click="uploadImg()"> |
||||
|
<image :src="showImg(info.avatar)" mode="aspectFill" |
||||
|
style="width: 80rpx;height: 80rpx;border-radius: 50%;"></image> |
||||
|
</view> |
||||
|
</div> |
||||
|
<navigator url="/subPackages/user/changeNickname" tag="view" class="userinfo-item"> |
||||
|
<span>昵称</span> |
||||
|
<view>{{nickname}}</view> |
||||
|
</navigator> |
||||
|
<!-- <view class="userinfo-item" @click="showSexSelect = true"> |
||||
|
<span>性别</span> |
||||
|
<view @click="$refs.popup.open()">{{gender == 1 ? '男' : (gender == 2 ? '女' : '保密')}}</view> |
||||
|
</view> --> |
||||
|
<view class="userinfo-item"> |
||||
|
<span>手机号</span> |
||||
|
<view>{{info.mobile}}</view> |
||||
|
</view> |
||||
|
<!-- <view class="userinfo-item"> |
||||
|
<span>生日</span> |
||||
|
<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange"> |
||||
|
<view class="uni-input">{{birthday}}</view> |
||||
|
</picker> |
||||
|
</view> |
||||
|
<navigator url="/subPackages/user/logout" tag="view" class="userinfo-item"> |
||||
|
<span>注销账号</span> |
||||
|
<i>注销后账号无法恢复,请谨慎操作</i> |
||||
|
</navigator> --> |
||||
|
<!-- <view class="btn-tao" @click="submit">保存</view> --> |
||||
|
</view> |
||||
|
|
||||
|
<!-- 性别弹框 --> |
||||
|
<uni-popup ref="popup" type="bottom"> |
||||
|
<view class="popup-box"> |
||||
|
<view class="popup-item flex-center" v-for="(item,index) in sexes" :key="index" @click="changesex(index)">{{item.text}}</view> |
||||
|
<view class="popup-items flex-center" @click="$refs.popup.close()">取消</view> |
||||
|
</view> |
||||
|
</uni-popup> |
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import {pathToBase64} from "@/static/js/mmmm-image-tools/index.js" |
||||
|
export default { |
||||
|
name: "Profile", |
||||
|
data() { |
||||
|
const currentDate = this.getDate({ |
||||
|
format: true |
||||
|
}) |
||||
|
return { |
||||
|
date: currentDate, |
||||
|
info: null, |
||||
|
showSexSelect: false, |
||||
|
sexes: [{ |
||||
|
value: '1', |
||||
|
text: '男' |
||||
|
}, |
||||
|
{ |
||||
|
value: '2', |
||||
|
text: '女' |
||||
|
}, |
||||
|
{ |
||||
|
value: '0', |
||||
|
text: '保密' |
||||
|
} |
||||
|
], |
||||
|
today: null, |
||||
|
showCropper: false, |
||||
|
nickname: '', |
||||
|
gender: '', |
||||
|
birthday: '', |
||||
|
email: '', |
||||
|
fileList1: [], |
||||
|
startDate: '1900-1-1', |
||||
|
endDate: '2050-1-1' |
||||
|
} |
||||
|
}, |
||||
|
onShow() { |
||||
|
console.log(this.$store.state.user.userInfo,uni.getStorageSync('userInfo')) |
||||
|
this.getList() |
||||
|
}, |
||||
|
computed: { |
||||
|
// startDate() { |
||||
|
// return this.getDate('start'); |
||||
|
// }, |
||||
|
// endDate() { |
||||
|
// return this.getDate('end'); |
||||
|
// } |
||||
|
}, |
||||
|
methods: { |
||||
|
getFile(e) { |
||||
|
console.log(e) |
||||
|
}, |
||||
|
getList() { |
||||
|
let today = new Date(); |
||||
|
today = today.getFullYear() + "/" + (today.getMonth() + 1) + "/" + today.getDate(); |
||||
|
this.today = today; |
||||
|
this.Post({}, "/api/user/userInfo").then(res => { |
||||
|
if (!res.data.birthday) { |
||||
|
let date = new Date(); |
||||
|
res.data.birthday = date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date |
||||
|
.getDate(); |
||||
|
} |
||||
|
this.info = res.data; |
||||
|
this.nickname = this.info.nickname |
||||
|
this.email = this.info.email |
||||
|
this.birthday = this.info.birthday |
||||
|
this.gender = this.info.gender |
||||
|
this.info.token = JSON.parse(uni.getStorageSync('userInfo')).token || this.$store.state.user.userInfo.token |
||||
|
console.log(this.info) |
||||
|
this.$store.commit('changeUserInfo', this.info) |
||||
|
}) |
||||
|
}, |
||||
|
uploadImg() { |
||||
|
uni.chooseImage({ |
||||
|
success: (chooseImageRes) => { |
||||
|
const tempFilePaths = chooseImageRes.tempFilePaths; |
||||
|
// // #ifdef MP-WEIXIN |
||||
|
// uni.getFileSystemManager().readFile({ |
||||
|
// filePath: tempFilePaths[0], |
||||
|
// encoding: 'base64', |
||||
|
// success: res => { |
||||
|
// this.Post({ |
||||
|
// method: 'POST', |
||||
|
// base64: 'data:image/png;base64,' + res.data |
||||
|
// }, '/api/common/base64').then(res => { |
||||
|
// if (res.data) { |
||||
|
// this.Post({ |
||||
|
// avatar: res.data |
||||
|
// }, '/api/user/profile').then(res => { |
||||
|
// uni.showModal({ |
||||
|
// title: '提示', |
||||
|
// content: res.msg, |
||||
|
// showCancel: false, |
||||
|
// success: res => { |
||||
|
// if (res.confirm) { |
||||
|
// this.getList() |
||||
|
// } |
||||
|
// } |
||||
|
// }) |
||||
|
// }) |
||||
|
// } |
||||
|
// }) |
||||
|
// } |
||||
|
// }) |
||||
|
// // #endif |
||||
|
|
||||
|
pathToBase64(tempFilePaths[0]).then(base64 => { |
||||
|
this.Post({ |
||||
|
method: 'POST', |
||||
|
base64: base64 |
||||
|
}, '/api/common/base64').then(res => { |
||||
|
if (res.data) { |
||||
|
this.Post({ |
||||
|
avatar: res.data |
||||
|
}, '/api/user/profile').then(res => { |
||||
|
uni.showModal({ |
||||
|
title: '提示', |
||||
|
content: res.msg, |
||||
|
showCancel: false, |
||||
|
success: res => { |
||||
|
if (res.confirm) { |
||||
|
this.getList() |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
}); |
||||
|
}, |
||||
|
//生日 |
||||
|
bindDateChange: function(e) { |
||||
|
this.birthday = e.detail.value |
||||
|
}, |
||||
|
getDate(type) { |
||||
|
const date = new Date(); |
||||
|
let year = date.getFullYear(); |
||||
|
let month = date.getMonth() + 1; |
||||
|
let day = date.getDate(); |
||||
|
|
||||
|
if (type === 'start') { |
||||
|
year = year - 60; |
||||
|
} else if (type === 'end') { |
||||
|
year = year + 2; |
||||
|
} |
||||
|
month = month > 9 ? month : '0' + month; |
||||
|
day = day > 9 ? day : '0' + day; |
||||
|
return `${year}/${month}/${day}`; |
||||
|
}, |
||||
|
changesex(index) { |
||||
|
this.gender = this.sexes[index].value |
||||
|
this.$refs.popup.close() |
||||
|
}, |
||||
|
submit() { |
||||
|
uni.showModal({ |
||||
|
title: '提示', |
||||
|
content: '确认修改您的信息?', |
||||
|
success: res => { |
||||
|
if (res.confirm) { |
||||
|
this.Post({ |
||||
|
nickname: this.nickname, |
||||
|
gender: this.gender, |
||||
|
birthday: this.birthday |
||||
|
}, '/api/user/profile').then(res => { |
||||
|
console.log(res) |
||||
|
if (res.code == 1) { |
||||
|
uni.showModal({ |
||||
|
title: '提示', |
||||
|
content: res.msg, |
||||
|
showCancel: false, |
||||
|
success: res => { |
||||
|
if (res.confirm) { |
||||
|
this.getList() |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style scoped lang="scss"> |
||||
|
view { |
||||
|
box-sizing: content-box; |
||||
|
} |
||||
|
.info-avatar-top { |
||||
|
display: flex; |
||||
|
justify-content: space-between; |
||||
|
font-size: 30rpx; |
||||
|
border-bottom: 1rpx solid #D8D8D8; |
||||
|
padding: 40rpx 0; |
||||
|
height: 48rpx; |
||||
|
color: #333; |
||||
|
align-items: center; |
||||
|
} |
||||
|
.info-avatar-top view{ |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
} |
||||
|
.info-avatar-top view:after{ |
||||
|
content: ""; |
||||
|
width: 20rpx; |
||||
|
height: 20rpx; |
||||
|
margin-left: 6rpx; |
||||
|
background-image: url('https://static.ticket.sz-trip.com/tongli/images/user/rightIcon-gray.png'); |
||||
|
background-size: 100% 100%; |
||||
|
} |
||||
|
.info-avatar-top img { |
||||
|
width: 80rpx; |
||||
|
height: 80rpx; |
||||
|
border-radius: 50%; |
||||
|
margin-right: 10rpx; |
||||
|
} |
||||
|
|
||||
|
.change-avatar-btn { |
||||
|
color: #FFF; |
||||
|
width: 220rpx; |
||||
|
margin: 0 auto; |
||||
|
line-height: 70rpx; |
||||
|
border-radius: 20rpx; |
||||
|
background: #4C93FF; |
||||
|
position: relative; |
||||
|
font-size: 34rpx; |
||||
|
} |
||||
|
|
||||
|
.change-avatar-btn input { |
||||
|
position: absolute; |
||||
|
left: 0; |
||||
|
right: 0; |
||||
|
top: 0; |
||||
|
bottom: 0; |
||||
|
opacity: 0; |
||||
|
} |
||||
|
|
||||
|
.user-other-info { |
||||
|
margin: 30rpx; |
||||
|
} |
||||
|
|
||||
|
.userinfo-item { |
||||
|
display: flex; |
||||
|
justify-content: space-between; |
||||
|
align-items: center; |
||||
|
font-size: 30rpx; |
||||
|
border-bottom: 1rpx solid #D8D8D8; |
||||
|
padding: 40rpx 30rpx 40rpx 0; |
||||
|
height: 48rpx; |
||||
|
color: #333; |
||||
|
position: relative; |
||||
|
} |
||||
|
|
||||
|
.info-avatar-top span { |
||||
|
font-weight: 500; |
||||
|
font-size: 31rpx; |
||||
|
flex-shrink: 0; |
||||
|
} |
||||
|
|
||||
|
.userinfo-item span { |
||||
|
font-weight: 500; |
||||
|
font-size: 31rpx; |
||||
|
flex-shrink: 0; |
||||
|
color: #000; |
||||
|
} |
||||
|
|
||||
|
.userinfo-item i { |
||||
|
font-weight: 500; |
||||
|
font-size: 24rpx; |
||||
|
color: #999999; |
||||
|
} |
||||
|
|
||||
|
.userinfo-item { |
||||
|
& view::after { |
||||
|
content: ""; |
||||
|
width: 20rpx; |
||||
|
height: 20rpx; |
||||
|
margin-left: 6rpx; |
||||
|
background-image: url('https://static.ticket.sz-trip.com/tongli/images/user/rightIcon-gray.png'); |
||||
|
background-size: 100% 100%; |
||||
|
position: absolute; |
||||
|
right: 0; |
||||
|
margin: auto; |
||||
|
top: 0; |
||||
|
bottom: 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.birthday-box { |
||||
|
text-align: right; |
||||
|
} |
||||
|
|
||||
|
.cropper { |
||||
|
width: auto; |
||||
|
height: 100%; |
||||
|
} |
||||
|
|
||||
|
.cropper-content { |
||||
|
position: fixed; |
||||
|
left: 0; |
||||
|
right: 0; |
||||
|
top: 0; |
||||
|
bottom: 0; |
||||
|
z-index: 1000; |
||||
|
} |
||||
|
|
||||
|
.dialog-footer .change-avatar-btn { |
||||
|
position: fixed; |
||||
|
text-align: center; |
||||
|
bottom: 80rpx; |
||||
|
left: 50%; |
||||
|
margin-left: -110rpx; |
||||
|
} |
||||
|
|
||||
|
.btn-tao { |
||||
|
text-align: center; |
||||
|
font-size: 30rpx; |
||||
|
width: 697rpx; |
||||
|
height: 80rpx; |
||||
|
background: #C3282E; |
||||
|
border-radius: 40rpx; |
||||
|
line-height: 80rpx; |
||||
|
color: #FFFFFF; |
||||
|
position: fixed; |
||||
|
left: 26rpx; |
||||
|
bottom: 100rpx; |
||||
|
} |
||||
|
|
||||
|
.popup-box { |
||||
|
border-radius: 20rpx 20rpx 0rpx 0rpx; |
||||
|
background: #fff; |
||||
|
overflow: hidden; |
||||
|
|
||||
|
.popup-item { |
||||
|
width: 697rpx; |
||||
|
height: 99rpx; |
||||
|
font-weight: 500; |
||||
|
font-size: 31rpx; |
||||
|
color: #12293C; |
||||
|
margin: auto; |
||||
|
} |
||||
|
.popup-item:nth-child(2) { |
||||
|
border: none; |
||||
|
border-bottom: 1rpx solid #D8D8D8; |
||||
|
border-top: 1rpx solid #D8D8D8; |
||||
|
} |
||||
|
|
||||
|
.popup-items { |
||||
|
width: 100%; |
||||
|
height: 99rpx; |
||||
|
font-weight: 500; |
||||
|
font-size: 31rpx; |
||||
|
color: #12293C; |
||||
|
border-top: 13rpx solid #F2F2F2; |
||||
|
} |
||||
|
} |
||||
|
</style> |
Loading…
Reference in new issue