用工小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

146 lines
3.6 KiB

<template>
<view>
<view class="se-pt-200 se-flex se-flex-h-c se-flex-ff-cw">
<image class="se-w-150 se-h-150" src="@/static/image/logo.png" mode=""></image>
<view class="se-flex se-flex-h-c se-fs-34 se-fw-6 se-c-black se-mt-40">
用工平台小程序
</view>
<view class="se-mt-20 se-fs-26 se-c-black se-flex se-flex-h-c">
申请获取您的头像昵称
</view>
</view>
<view class="se-mx-40 se-py-100">
<view class="se-b-t se-b-b se-flex se-h-140 se-lh-140 se-flex-h-sb">
<text>头像</text>
<button class="se-w-100 se-h-100 se-p-0 se-m-0" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
<image v-if="imagUrl" class="se-w-100 se-h-100" :src="imagUrl"></image>
<image v-else class="se-w-100 se-h-100" src="@/static/image/header.png" mode=""></image>
</button>
</view>
<view class=" se-b-b se-flex se-h-140 se-lh-140 se-flex-h-sb">
<text>昵称</text>
<input type="nickname" placeholder="请输入昵称" v-model="nameUser" @blur="bindblur"
class="se-h-80 se-lh-80 se-w-320 se-fs-24 se-ta-r" placeholder-class="se-fs-24 se-ta-r" />
</view>
</view>
<view class="se-mx-40">
<view @click="onUpdateInfo"
class="se-br-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-32 se-c-white se-bgc-green">
确认
</view>
</view>
</view>
</template>
<script>
import {
appletLogin
} from "@/common/api.js"
export default {
name: 'Login',
data() {
return {
nameUser: "",
imagUrl: "",
phone: "",
back: 0
}
},
onLoad(options) {
if (options.back == 1) {
this.imagUrl = uni.getStorageSync('userInfo').headImage
this.nameUser = uni.getStorageSync('userInfo').nickName
this.phone = uni.getStorageSync('userInfo').phone
this.back = options.back
}
},
methods: {
bindblur(event) {
this.nameUser = event.target.value
},
onChooseAvatar(res) {
console.log("获取头像消息", res)
// let self = this
// self.$Oss.ossUpload(res.target.avatarUrl).then(url => {
// self.imagUrl = url
// })
},
onPhonenumber(event) {
let that = this
var detail = event.detail;
if (detail.errMsg == 'getPhoneNumber:ok') {
let params = {
code: detail.code,
encryptedData: detail.encryptedData,
iv: detail.iv,
sessionKey: uni.getStorageSync('sessionKey'),
openid: uni.getStorageSync('userInfo').appletOpenid
}
bindPhone(params).then((response) => {
console.info(response)
that.phone = response.result
}).catch(error => {
})
}
},
onUpdateInfo() {
let that = this
uni.showLoading({
title: '保存中...'
})
uni.login({
success(res) {
console.info(res.code)
if (res.errMsg != "login:ok") {
return
}
let params = {
code: res.code,
headimgurl: that.imagUrl,
nickName: that.nameUser,
openid: uni.getStorageSync('userInfo').appletOpenid
// phone:that.phone
}
// &&that.phone
if (that.imagUrl && that.nameUser) {
appletLogin(params).then((response) => {
if (this.back == 1) {
uni.navigateBack({
delta: 1
})
} else {
uni.navigateTo({
url: "/pages/identity/index"
})
}
}).catch((error) => {
})
} else {
return uni.showToast({
icon: "none",
title: "头像和昵称不能为空!"
})
}
}
})
}
}
}
</script>
<style scoped lang="scss">
.default-btn {
background-color: #fff;
}
.default-btn::after {
content: "";
border: none;
}
</style>