first commit
This commit is contained in:
107
components/share/share.vue
Normal file
107
components/share/share.vue
Normal file
@@ -0,0 +1,107 @@
|
||||
<template>
|
||||
<view style="width: 345px;height:336px;background-color: #ffffff;border-radius: 10rpx;">
|
||||
<canvas style="width: 100%;height: 100%;" canvas-id="canvas" id="canvas"></canvas>
|
||||
<view>
|
||||
<u-button @click="save" type="primary">保存海报</u-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
let self;
|
||||
export default {
|
||||
props: {
|
||||
qrcode: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
screenWidth: 345,
|
||||
screenHeight: 336
|
||||
}
|
||||
},
|
||||
created() {
|
||||
self = this;
|
||||
|
||||
// uni.getSystemInfo({
|
||||
// success: (res) => {
|
||||
// self.screenWidth = res.windowWidth - 30; // 屏幕宽度,单位为px
|
||||
// self.screenHeight = res.windowHeight; // 屏幕高度,单位为px
|
||||
// },
|
||||
// });
|
||||
|
||||
self.draw();
|
||||
},
|
||||
|
||||
methods: {
|
||||
getImageInfo(src) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.getImageInfo({
|
||||
src,
|
||||
success: res => {
|
||||
resolve(res)
|
||||
},
|
||||
fail: err => {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
async draw() {
|
||||
|
||||
const ctx = uni.createCanvasContext('canvas');
|
||||
|
||||
// 绘制图片1
|
||||
const image1 = await this.getImageInfo('https://xingdong-app.oss-cn-beijing.aliyuncs.com/share.png')
|
||||
let x = image1.width / 2;
|
||||
let y = image1.height / 2;
|
||||
ctx.drawImage(image1.path, 0, 0, x, y);
|
||||
|
||||
// 绘制图片2
|
||||
const image2 = await this.getImageInfo(
|
||||
self.$store.state.auth.user.qrcode
|
||||
);
|
||||
|
||||
ctx.drawImage(image2.path, x / 2 - 96, 90, 190, 190);
|
||||
|
||||
ctx.font = '16px Regular'; // 字体大小
|
||||
ctx.fillStyle = '#1449AE'; // 字体填充颜色
|
||||
let invite_code = '邀请码:' + self.$store.state.auth.user.invite_code;
|
||||
ctx.fillText(invite_code, x / 2 - 90, 36);
|
||||
|
||||
ctx.font = '14px Regular'; // 字体大小
|
||||
ctx.fillStyle = '#999999'; // 字体填充颜色
|
||||
ctx.fillText('欢迎加入羿充电', x / 2 - 70, 60);
|
||||
|
||||
ctx.font = '14px Regular'; // 字体大小
|
||||
ctx.fillStyle = '#999999'; // 字体填充颜色
|
||||
ctx.fillText('长按保存或转发', x / 2 - 48, y - 28);
|
||||
|
||||
setTimeout(function() { // uni-app必须加上延迟,不然显示不出来, 亲测
|
||||
ctx.stroke();
|
||||
ctx.draw() //必须加上 uniapp 没这儿玩意儿 显示不出来不比原生 不加可以显示
|
||||
}, 300);
|
||||
|
||||
},
|
||||
save() {
|
||||
// uni.canvasToTempFilePath({
|
||||
// canvasId: 'canvas',
|
||||
// success: res => {
|
||||
// uni.saveImageToPhotosAlbum({
|
||||
// filePath: res.tempFilePath,
|
||||
// success(res) {
|
||||
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
</style>
|
||||
96
components/tabbar.vue
Normal file
96
components/tabbar.vue
Normal file
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<view class="tabbar">
|
||||
<view class="tabbar_view" @click="changeTabbar(0)">
|
||||
<image style="width: 50rpx;height: 50rpx;" mode="widthFix"
|
||||
:src="`/static/tabbar/tabbar${tabbarCuur == 0 ? '1s' : '1'}.png`"></image>
|
||||
<view :style="{color:tabbarCuur != 0 ?'#333' : '#1F70B7'}">我的</view>
|
||||
</view>
|
||||
<view class="tabbar_view tabbar_active" :style="{backgroundColor:tabbarCuur == 1 ?'#1F70B7' : '#CCC'}"
|
||||
@click="changeTabbar(1)">
|
||||
<image style="width: 60rpx;height: 66rpx;" src="../static/tabbar/tabbar2.png"></image>
|
||||
<view>首页</view>
|
||||
</view>
|
||||
<view class="tabbar_view" @click="changeTabbar(2)">
|
||||
<image style="width: 50rpx;height: 50rpx;" mode="widthFix"
|
||||
:src="`/static/tabbar/tabbar${tabbarCuur == 2 ? '2s' : '3'}.png`"></image>
|
||||
<view :style="{color:tabbarCuur != 2 ?'#333' : '#1F70B7'}">公告</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "tabbar",
|
||||
props: {
|
||||
tabbarCuurent: {
|
||||
type: Number,
|
||||
default: 1
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
tabbarCuurent(e) {
|
||||
this.tabbarCuur = e
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tabbarCuur: 1
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
changeTabbar(e) {
|
||||
this.tabbarCuur = e
|
||||
this.$emit('change', e)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
page {
|
||||
padding-bottom: 120rpx;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
view {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.tabbar {
|
||||
width: 750rpx;
|
||||
height: 136rpx;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 120rpx;
|
||||
box-shadow: 0px 2rpx 11rpx 2rpx rgba(190, 190, 190, 0.35);
|
||||
|
||||
&_view {
|
||||
// width: 140rpx;
|
||||
// height: 140rpx;
|
||||
// margin-top: -35rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 28rpx;
|
||||
|
||||
image {
|
||||
margin-bottom: 5rpx;
|
||||
}
|
||||
}
|
||||
|
||||
&_active {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
background-color: #1F70B7;
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
margin-top: -35rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
142
components/userinfo-popup/userinfo-popup.vue
Normal file
142
components/userinfo-popup/userinfo-popup.vue
Normal file
@@ -0,0 +1,142 @@
|
||||
<template>
|
||||
<u-popup :show="showUserinfo" mode="center" @close="sendshow" closeable round="20rpx">
|
||||
<view style="padding: 30rpx;">
|
||||
<view style="font-size: 30rpx;font-weight: 700;">设置头像昵称</view>
|
||||
<view style="background-color: #ffffff;border-radius: 16rpx; padding: 30rpx;">
|
||||
<view class="u-flex u-flex-y-center">
|
||||
<view style="font-size: 30rpx;">头像</view>
|
||||
<view style="width: 20rpx;"></view>
|
||||
<button class="xkl-clear-btn" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
|
||||
<u--image width="120rpx" height="120rpx" :src="userinfo.avatar_url" shape="circle">
|
||||
</u--image>
|
||||
<view style="width: 10rpx;"></view>
|
||||
</button>
|
||||
</view>
|
||||
<view style="height: 30rpx;"></view>
|
||||
<view class="u-flex u-flex-y-center">
|
||||
<view style="font-size: 30rpx;">昵称</view>
|
||||
<view style="width: 20rpx;"></view>
|
||||
<!-- <u-input type="nickname" v-model="userInfo.nickname" placeholder="请输入昵称" /> -->
|
||||
<input type="nickname" @blur="onNicknameBlur" v-model="userinfo.nickname" placeholder="请输入昵称"
|
||||
style="border-bottom: 1px solid #cccccc;height: 60rpx;font-size: 30rpx;" />
|
||||
</view>
|
||||
</view>
|
||||
<view style="height: 20rpx;"></view>
|
||||
<u-button @click="setUserinfo" color="#71d5a1">确认</u-button>
|
||||
</view>
|
||||
</u-popup>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
let self;
|
||||
export default {
|
||||
props: {
|
||||
showUserinfo: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
userinfo: {
|
||||
nickname: '',
|
||||
avatar_url: ''
|
||||
},
|
||||
avatar_url: '',
|
||||
ossdata: {}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
self = this;
|
||||
self.getOssData();
|
||||
self.userinfo = self.$store.state.auth.user;
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
sendshow() {
|
||||
this.$emit('update:showUserinfo', false);
|
||||
},
|
||||
getOssData() {
|
||||
self.$http.get('/com/oss/uptoken').then(({
|
||||
data
|
||||
}) => {
|
||||
self.ossdata = data;
|
||||
})
|
||||
},
|
||||
onChooseAvatar(e) {
|
||||
const {
|
||||
avatarUrl
|
||||
} = e.detail;
|
||||
self.userinfo.avatar_url = avatarUrl;
|
||||
self.avatar_url = avatarUrl;
|
||||
|
||||
let ext = self.avatar_url.split('.').pop();
|
||||
let key = self.ossdata.dir + Math.random() + '.' + ext;
|
||||
|
||||
uni.uploadFile({
|
||||
url: self.ossdata.host, //仅为示例,非真实的接口地址
|
||||
filePath: self.avatar_url,
|
||||
name: 'file',
|
||||
formData: {
|
||||
key: key,
|
||||
OSSAccessKeyId: self.ossdata.accessid,
|
||||
policy: self.ossdata.policy,
|
||||
'success_action_status': '200',
|
||||
Signature: self.ossdata.signature,
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.statusCode == 200) {
|
||||
self.avatar_url = key;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
setUserinfo() {
|
||||
if (self.userinfo.nickname.length < 1) {
|
||||
uni.showToast({
|
||||
title: '请填写昵称',
|
||||
icon: 'none'
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.userinfo.nickname.length > 8) {
|
||||
uni.showToast({
|
||||
title: '最多8个字符',
|
||||
icon: 'none'
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
self.$http.post('/shop/v10/user/update', {
|
||||
avatar_url: self.avatar_url,
|
||||
nickname: self.userinfo.nickname
|
||||
}).then(({
|
||||
data,
|
||||
success,
|
||||
msg
|
||||
}) => {
|
||||
if (success) {
|
||||
self.$store.commit('auth/setUser', data);
|
||||
uni.showToast({
|
||||
title: msg,
|
||||
icon: 'none'
|
||||
})
|
||||
self.sendshow();
|
||||
}
|
||||
})
|
||||
},
|
||||
onNicknameBlur(e) {
|
||||
const nickname = e.detail.value;
|
||||
|
||||
self.userinfo.nickname = nickname;
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user