Commit 70513471 authored by jyx's avatar jyx

联调微信人脸识别

parent c01b56ca
......@@ -127,7 +127,7 @@
auth: false, // 三要素实名认证
userInfo: null,
cardInfo: null,
pkgName: 'com.mingshu.scandemon'
pkgName: 'com.duben.loveplayletd'
}
};
</script>
......
......@@ -25,6 +25,27 @@ module.exports = {
return post('roseApi/user/sendMobileCode', params)
},
/**
* 基础资料
*/
initInfo(params) {
return post('roseApi/user/initInfo', params)
},
/**
* 是否已经绑定分享码
*/
getRuserShareCode() {
return post('roseApi/user/getRuserShareCode')
},
/**
* 修改邀请我的分享码
*/
updateRuserShareCode() {
return post('roseApi/user/updateRuserShareCode', params)
},
/**
* 获得人脸核验url
*/
......@@ -36,6 +57,6 @@ module.exports = {
* 返回人脸核验url,跳转后录制视频
*/
faceResult(params) {
return post('roseApi/face/faceResult', params)
return post('roseApi/face/faceResultWxh5', params)
},
}
\ No newline at end of file
const baseUrl = {
isDebug: process.env.NODE_ENV === 'development',
devUrl: '/camera-api/',
prodUrl: 'https://api.mints-tech.cn/camera-api/'
}
const appName = "爱短剧"
const appVersion = "1.0.0"
const pkgName = "com.duben.loveplayletd"
const endPkgName = "loveplayletd"
module.exports = {
baseUrl,
appName,
appVersion,
pkgName,
endPkgName
}
\ No newline at end of file
import {
baseUrl,
endPkgName
} from '@/common/cofig/baseCofig.js'
const REGISTER_URL =
baseUrl.prodUrl + "agreements/" + endPkgName + "/yhxy.html" //注册协议
const PRIVACY_URL =
baseUrl.prodUrl + "agreements/" + endPkgName + "/syzc.html" //隐私协议
const MEMBERS_URL =
baseUrl.prodUrl + "agreements/" + endPkgName + "/gmxy.html" //会员付费服务协议
module.exports = {
REGISTER_URL,
PRIVACY_URL,
MEMBERS_URL
}
\ No newline at end of file
......@@ -2,28 +2,27 @@ import {
encrypt,
decrypt
} from '../encry/aesUtil.js'
import {
baseUrl,
appVersion,
pkgName
} from '@/common/cofig/baseCofig.js'
import md5 from 'js-md5'
import {
encode,
decode
} from 'js-base64';
import {
removeUserInfo
removeUserInfo,
TOKEN
} from '../store/user.js';
const optionsUrl = {
isDebug: process.env.NODE_ENV === 'development',
devUrl: "",
prodUrl: "https://api.mints-tech.cn/camera-api/"
}
const API_ROOT = optionsUrl.isDebug ? optionsUrl.devUrl : optionsUrl.prodUrl
const API_ROOT = baseUrl.isDebug ? baseUrl.devUrl : baseUrl.prodUrl
const headers = {
'token': '',
'version': '1.0.0',
'pkgName': 'com.duben.loveplayletd',
'version': appVersion,
'pkgName': pkgName,
'channel': 'h5',
'Content-Type': 'application/json',
}
......@@ -31,9 +30,9 @@ const headers = {
function getAuth() {
return new Promise((resolve, reject) => {
uni.getStorage({
key: 'TOKEN_ID',
key: TOKEN,
success: function(data) {
headers.token = data
headers.token = data.data
resolve(true)
},
fail: function(data, code) {
......@@ -73,19 +72,18 @@ function realFetch(url, data = null, method = 'get') {
let option = {}; // 请求参数
option.url = API_ROOT + url
option.method = method
option.data = encrypt(jsonData)
option.data = params
headers['last-session'] = encode(time) // base64 编码
headers['new-session'] = md5(time) // md5 加密
option.header = {
...headers
}
}
return new Promise((resolve, reject) => {
uni.request({
...option,
success: (data) => {
console.log(data)
var result = {}
if (typeof data.data === 'object') {
result = data.data
......@@ -108,7 +106,7 @@ function realFetch(url, data = null, method = 'get') {
if (result.status == 200) {
if (result.data != undefined) {
resolve(decrypt(result.data))
resolve(JSON.parse(decrypt(result.data)))
} else {
resolve(result.message ?? '')
}
......@@ -127,7 +125,7 @@ function realFetch(url, data = null, method = 'get') {
})
}
function withAuth(url, data = null, method = 'get', canSkip = false) {
function withAuth(url, data = null, method = 'get', canSkip = true) {
return getAuth().then((auth) => {
if (auth || canSkip) {
return realFetch(url, data, method)
......
const TOKEN = 'token'
const MOBILE = 'mobile'
const PK_ID = 'pk_id'
const ID_CODE = 'idcode'
const NICK_NAME = 'nickName'
const REWARD_COIN = 'rewardCoin'
const BEANS = 'beans'
const IDCARD_STAUTS = 'idcardStatus'
const SEX = 'sex'
const SHARE_CODE = 'shareCode'
const HAS_BASE = 'hasBase'
const HEADER_URL = 'headerUrl'
const CAN_UPDATE_RUID_CODE = 'canUpdateRuidCode'
const CAN_HAVE_RUID_CODE = 'canHaveRuidCode'
const RUID_CODE = 'ruidCode'
const ACTIVITY_FLAG = 'activiteFlag'
const ALIPAY_SET = 'alipaySet'
const BIRTHDAY = 'birthday'
const CITY = 'city'
const AGE = 'age'
const EXPIRE_TIME = 'expireTime'
const IS_FOREVER = 'isForever'
const VIP_FLAG = 'vipFlag'
export function setUserInfo(obj) {
uni.setStorageSync('TOKEN_ID', obj.token)
uni.setStorageSync('MOBILE', obj.mobile)
uni.setStorageSync('USER_ID', obj.pk_id)
uni.setStorageSync('CODE_ID', obj.idcode)
uni.setStorageSync('NICK_NAME', obj.nickName)
uni.setStorageSync('HEAD', obj.head)
uni.setStorageSync('OPENID', obj.openId)
uni.setStorageSync('ACTIVITE_FLAG', obj.activiteFlag == 1)
uni.setStorageSync('USER_GET_ONE_HOUR_VIP', obj.userGetOneHourVip)
uni.setStorageSync('IS_FOREVER', obj.isForever)
uni.setStorageSync('EXPIRE_TIME', obj.expireTime)
console.log(obj)
uni.setStorageSync(TOKEN, obj.token)
uni.setStorageSync(MOBILE, obj.mobile)
uni.setStorageSync(PK_ID, obj.pk_id)
uni.setStorageSync(ID_CODE, obj.idcode)
uni.setStorageSync(NICK_NAME, obj.nickName)
uni.setStorageSync(REWARD_COIN, obj.rewardCoin)
uni.setStorageSync(BEANS, obj.beans)
uni.setStorageSync(IDCARD_STAUTS, obj.idcardStatus)
uni.setStorageSync(SEX, obj.sex)
uni.setStorageSync(SHARE_CODE, obj.shareCode)
uni.setStorageSync(HAS_BASE, obj.hasBase)
uni.setStorageSync(HEADER_URL, obj.headerUrl)
uni.setStorageSync(CAN_UPDATE_RUID_CODE, obj.canUpdateRuidCode)
uni.setStorageSync(CAN_HAVE_RUID_CODE, obj.canHaveRuidCode)
uni.setStorageSync(RUID_CODE, obj.ruidCode)
uni.setStorageSync(ACTIVITY_FLAG, obj.activiteFlag == 1)
uni.setStorageSync(BIRTHDAY, obj.birthday)
uni.setStorageSync(CITY, obj.city)
uni.setStorageSync(AGE, obj.age)
uni.setStorageSync(EXPIRE_TIME, obj.expireTime)
uni.setStorageSync(IS_FOREVER, obj.isForever)
if (obj.expireTime > 0) {
uni.setStorageSync('VIP_FLAG', true)
uni.setStorageSync(VIP_FLAG, true)
} else {
uni.setStorageSync('VIP_FLAG', false)
}
// uni.setStorageSync('CREATE_TIME', obj.createTime)
if (obj.mobile != null || obj.mobile != '' || obj.openId != null || obj.openId != '') {
uni.setStorageSync('IS_TEMP_USER', false)
} else {
uni.setStorageSync('IS_TEMP_USER', true)
uni.setStorageSync(VIP_FLAG, false)
}
}
export function setBaseMsg(obj) {
uni.setStorageSync('MOBILE', obj.mobile)
uni.setStorageSync('USER_ID', obj.pk_id)
uni.setStorageSync('CODE_ID', obj.idcode)
uni.setStorageSync('NICK_NAME', obj.nickName)
uni.setStorageSync('HEAD', obj.head)
uni.setStorageSync('OPENID', obj.openId)
uni.setStorageSync('ACTIVITE_FLAG', obj.activiteFlag == 1)
uni.setStorageSync('USER_GET_ONE_HOUR_VIP', obj.userGetOneHourVip)
uni.setStorageSync('IS_FOREVER', obj.isForever)
uni.setStorageSync('EXPIRE_TIME', obj.expireTime)
function setBaseMsg(obj) {
uni.setStorageSync(TOKEN, obj.token)
uni.setStorageSync(MOBILE, obj.mobile)
uni.setStorageSync(PK_ID, obj.pk_id)
uni.setStorageSync(ID_CODE, obj.idcode)
uni.setStorageSync(NICK_NAME, obj.nickName)
uni.setStorageSync(REWARD_COIN, obj.rewardCoin)
uni.setStorageSync(BEANS, obj.beans)
uni.setStorageSync(IDCARD_STAUTS, obj.idcardStatus)
uni.setStorageSync(SEX, obj.sex)
uni.setStorageSync(SHARE_CODE, obj.shareCode)
uni.setStorageSync(HAS_BASE, obj.hasBase)
uni.setStorageSync(HEADER_URL, obj.headerUrl)
uni.setStorageSync(CAN_UPDATE_RUID_CODE, obj.canUpdateRuidCode)
uni.setStorageSync(CAN_HAVE_RUID_CODE, obj.canHaveRuidCode)
uni.setStorageSync(RUID_CODE, obj.ruidCode)
uni.setStorageSync(ACTIVITY_FLAG, obj.activiteFlag == 1)
uni.setStorageSync(BIRTHDAY, obj.birthday)
uni.setStorageSync(CITY, obj.city)
uni.setStorageSync(AGE, obj.age)
uni.setStorageSync(EXPIRE_TIME, obj.expireTime)
uni.setStorageSync(IS_FOREVER, obj.isForever)
if (obj.expireTime > 0) {
uni.setStorageSync('VIP_FLAG', 1)
uni.setStorageSync(VIP_FLAG, true)
} else {
uni.setStorageSync('VIP_FLAG', 0)
uni.setStorageSync(VIP_FLAG, false)
}
// uni.setStorageSync('CREATE_TIME', obj.createTime)
if (obj.mobile != null || obj.mobile != '' || obj.openId != null || obj.openId != '') {
uni.setStorageSync('IS_TEMP_USER', false)
} else {
uni.setStorageSync('IS_TEMP_USER', true)
}
}
export function removeUserInfo() {
function removeUserInfo() {
// 清空
uni.clearStorage()
}
export function setMobile(obj) {
uni.setStorageSync('MOBILE', obj.mobile)
}
export function initUser() {
uni.getStorage('TOKEN_ID')
.then((data) => {
user.token = data
})
.catch((err) => {
user.token = ''
})
uni.getStorage('MOBILE')
.then((data) => {
user.mobile = data
})
.catch((err) => {
user.mobile = ''
})
uni.getStorage('USER_ID')
.then((data) => {
user.uid = data
})
.catch((err) => {
user.uid = ''
})
uni.getStorage('IS_TEMP_USER')
.then((data) => {
user.isTempUser = data
})
.catch((err) => {
user.isTempUser = ''
})
uni.getStorage('CODE_ID')
.then((data) => {
user.codeId = data
})
.catch((err) => {
user.codeId = ''
})
uni.getStorage('ACTIVITE_FLAG')
.then((data) => {
user.activiteFlag = data
})
.catch((err) => {
user.activiteFlag = false
})
uni.getStorage('USER_GET_ONE_HOUR_VIP')
.then((data) => {
user.userGetOneHourVip = data
})
.catch((err) => {
user.userGetOneHourVip = ''
})
uni.getStorage('IS_FOREVER')
.then((data) => {
user.isForever = data
})
.catch((err) => {
user.isForever = ''
})
uni.getStorage('NICK_NAME')
.then((data) => {
user.nickName = data
})
.catch((err) => {
user.nickName = ''
})
uni.getStorage('HEAD')
.then((data) => {
user.head = data
})
.catch((err) => {
user.head = ''
})
uni.getStorage('OPENID')
.then((data) => {
user.openId = data
})
.catch((err) => {
user.openId = ''
})
uni.getStorage('VIP_FLAG')
.then((data) => {
user.vipFlag = data
})
.catch((err) => {
user.vipFlag = 0
})
uni.getStorage('EXPIRE_TIME')
.then((data) => {
user.expireTime = data
})
.catch((err) => {
user.expireTime = 0
})
return user
}
export var user = {
token: '', // Token
mobile: '', // 手机号
uid: '', // 用户id
isTempUser: '', // 游客或登录用户
codeId: '', // 用户code
nickName: '', // 昵称
head: '', // 头像
openId: '', // 微信openId
activiteFlag: '', // 匹配用户
userGetOneHourVip: '', // 应用市场弹窗
isForever: '', // 永久会员
expireTime: '', // 会员到期时间
vipFlag: '', // 会员
module.exports = {
TOKEN,
setUserInfo,
setBaseMsg,
removeUserInfo
}
\ No newline at end of file
......@@ -180,26 +180,18 @@
},
"title": "爱短剧",
"router": {
"base": "./"
"mode": "history" //去掉#号
},
"uniStatistics": {
"enable": true
},
"devServer": {
"port": 8080,
"proxy": {
"/roseApi": {
"target": "https://api.mints-tech.cn/camera-api",
"/camera-api": {
"target": "https://api.mints-tech.cn/camera-api/",
"changeOrgin": true, //是否跨域
"pathRewrite": {
"^/roseApi": ""
}
},
"/api": {
"target": "https://api.mints-tech.cn/camera-api",
"changeOrgin": true, //是否跨域
"pathRewrite": {
"^/api": ""
"^/camera-api": ""
}
}
}
......
......@@ -55,6 +55,14 @@
}, {
"root": "pagesB",
"pages": [{
"path": "base/base",
"style": {
"navigationStyle": "default",
"navigationBarTitleText": "完善资料",
"navigationBarBackgroundColor": "#000000",
"navigationBarTextStyle": "white"
}
}, {
"path": "auth/auth",
"style": {
"navigationStyle": "default",
......@@ -62,6 +70,14 @@
"navigationBarBackgroundColor": "#000000",
"navigationBarTextStyle": "white"
}
}, {
"path": "faceResult/faceResult",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "校验认证结果",
"navigationBarBackgroundColor": "#000000",
"navigationBarTextStyle": "white"
}
}, {
"path": "label/label",
"style": {
......@@ -90,7 +106,7 @@
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},{
}, {
"path": "cashBag/cashBag",
"style": {
"navigationStyle": "default",
......@@ -98,7 +114,7 @@
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},{
}, {
"path": "feedback/feedback",
"style": {
"navigationStyle": "default",
......@@ -106,7 +122,7 @@
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},{
}, {
"path": "friends/friends",
"style": {
"navigationStyle": "default",
......@@ -114,7 +130,7 @@
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},{
}, {
"path": "iLikeRecord/iLikeRecord",
"style": {
"navigationStyle": "default",
......@@ -122,7 +138,7 @@
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},{
}, {
"path": "likeMeRecord/likeMeRecord",
"style": {
"navigationStyle": "default",
......@@ -130,7 +146,7 @@
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},{
}, {
"path": "lookMeRecord/lookMeRecord",
"style": {
"navigationStyle": "default",
......@@ -138,7 +154,7 @@
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},{
}, {
"path": "userDetail/userDetail",
"style": {
"navigationStyle": "default",
......@@ -146,7 +162,7 @@
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},{
}, {
"path": "income/income",
"style": {
"navigationStyle": "default",
......@@ -154,7 +170,7 @@
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},{
}, {
"path": "bindalipay/bindalipay",
"style": {
"navigationStyle": "default",
......
......@@ -2,19 +2,24 @@
<view class="container">
<view class="title">短信验证码登录/注册</view>
<view class="input-group">
<input class="input" type="number" placeholder="+86 输入手机号" v-model="phoneNumber" />
<view class="area">+86</view>
<input class="input" type="number" placeholder="请输入您的手机号" v-model="phoneNumber"
style="margin-left: 80rpx;" />
</view>
<view class="input-group">
<input class="input" type="number" placeholder="输入验证码" v-model="verificationCode" />
<view class="get-code-btn" @click="getVerificationCode">获取验证码</view>
<input class="input" type="number" placeholder="输入手机验证码" v-model="verificationCode" />
<view v-if="!isSending" class="get-code-btn" @click="getVerificationCode">获取验证码</view>
<view v-else class="get-code-count">{{sendingCount}} s</view>
</view>
<button class="login-btn" @click="login">登录</button>
<view class="login-btn" @click="login">登录</view>
<view class="agreement">
<checkbox-group @change="agreeToTerms">
<label>
<checkbox value="agree" /> 已阅读并同意用户协议和隐私政策
<checkbox value="agree" />已阅读并同意
<text class="agree-text" @click="openUserAgree">《用户注册协议》</text>
<text class="agree-text" @click="openPrivacyAgree">《用户隐私协议》</text>
</label>
</checkbox-group>
</view>
......@@ -27,11 +32,29 @@
sendMobileCode
} from '@/common/api/user.js'
import {
REGISTER_URL,
PRIVACY_URL
} from '@/common/constant/constant.js'
import {
setUserInfo
} from '@/common/store/user.js'
import {
encrypt,
decrypt
} from '@/common/encry/aesUtil.js'
import {
redirectTo,
message,
} from '@/utils/fun.js';
import {
openUrl
} from '@/utils/app+.js';
const app = getApp();
export default {
......@@ -39,16 +62,78 @@
data() {
return {
phoneNumber: '',
isSending: false,
sendingCount: 60,
verificationCode: '',
agreed: false
agreed: false,
};
},
methods: {
getVerificationCode() {},
login() {},
switchToPasswordLogin() {},
getVerificationCode() {
if (this.isSending) return
var reg = /^1[3456789]\d{9}$/
if (!reg.test(this.phoneNumber)) {
message.notify("请输入您的手机号")
return
}
sendMobileCode({
mobile: this.phoneNumber,
type: 1
}).then(data => {
message.notify("验证码发送成功")
this.startCount()
})
.catch((err) => {
message.notify(err)
})
},
login() {
var reg = /^1[3456789]\d{9}$/
if (!reg.test(this.phoneNumber)) {
message.notify("请输入您的手机号")
return
}
if (this.verificationCode == '' || this.verificationCode.length != 4) {
message.notify("请输入您的验证码")
return
}
if (!this.agreed) {
message.notify("请勾选同意后再进行登录")
return
}
mobileLogin({
mobile: this.phoneNumber,
smsCode: this.verificationCode
}).then(data => {
setUserInfo(data)
redirectTo(`/pagesB/base/base`)
})
.catch((err) => {
message.notify(err)
})
},
startCount() {
this.isSending = true;
const timer = setInterval(() => {
this.sendingCount--
if (this.sendingCount <= 0) {
clearInterval(timer)
this.isSending = false
this.sendingCount = 60
}
}, 1000)
},
agreeToTerms(e) {
this.agreed = e.detail.value.includes('agree');
},
openUserAgree() {
openUrl(REGISTER_URL)
},
openPrivacyAgree() {
openUrl(PRIVACY_URL)
}
}
};
......@@ -65,38 +150,60 @@
.title {
margin-top: 150rpx;
margin-left: 50rpx;
font-size: 40rpx;
margin-bottom: 20rpx;
color: white;
}
.input-group {
margin: 0 50rpx;
position: relative;
margin-top: 50rpx;
border-bottom: solid 2rpx #555555;
}
.input {
width: 90%;
border-radius: 0;
color: white;
border-bottom: solid 1rpx #555555;
background-color: transparent;
height: 80rpx;
height: 70rpx;
padding: 15rpx;
}
.area {
left: 10rpx;
top: 30rpx;
position: absolute;
color: white;
}
.get-code-btn {
right: 10%;
top: 40rpx;
right: 30rpx;
top: 35rpx;
position: absolute;
color: white;
}
.get-code-count {
right: 30rpx;
top: 35rpx;
position: absolute;
color: #E8CF83;
}
.login-btn {
width: 90%;
width: 80%;
height: 80rpx;
margin: 0 auto;
margin-top: 200rpx;
line-height: 80rpx;
text-align: center;
font-size: 30rpx;
background-color: #E8CF83;
color: black;
border: none;
margin-top: 100rpx;
border-radius: 50rpx;
}
......@@ -110,4 +217,8 @@
color: white;
text-align: center;
}
.agree-text {
color: #E8CF83;
}
</style>
\ No newline at end of file
......@@ -14,8 +14,8 @@
<view class="step-section">
<text class="step-title">上传头像</text>
<image v-if="!croppedImageUrl" mode="aspectFill" src="/static/auth/upload_avatar.png"
@click="uploadImage" style="width: 216px;height: 131px;margin: 0 auto;"></image>
<image v-else mode="aspectFill" :src="croppedImageUrl" @click="uploadImage"
@click="chooseImage" style="width: 216px;height: 131px;margin: 0 auto;"></image>
<image v-else mode="aspectFill" :src="croppedImageUrl" @click="chooseImage"
style="width: 150px;height: 150px;margin: 0 auto;"></image>
</view>
......@@ -110,7 +110,15 @@
import common from '@/mixins/common';
import {
mobileLogin
TOKEN
} from '@/common/store/user.js'
import {
openUrl
} from '@/utils/app+.js';
import {
getWxFaceParam
} from '@/common/api/user.js'
import Cropper from 'cropperjs';
......@@ -138,10 +146,9 @@
},
data() {
return {
step: 3,
step: 1,
avatarUrl: '',
tempPath: '',
imageType: '',
cropper: null,
croppedImageUrl: '',
heightRange: UserProfile.PROFILE_SG.arr,
......@@ -164,16 +171,6 @@
},
onLoad(option) {
this.getIsWxBrower()
mobileLogin({
mobile: 18311400069,
smsCode: 1234
}).then(data => {
})
.catch((err) => {
})
},
onShow() {
if (this.trace_source != undefined) {
......@@ -200,6 +197,17 @@
},
doNext() {
if (this.step == 1) {
getWxFaceParam({
imgUrl: 'https://mints-sh.oss-cn-shanghai.aliyuncs.com/pkg_roseplaylet/img/20250208/2503917403801500001/photo_1739011744899.jpeg'
}).then(data => {
openUrl(data.url)
})
.catch((err) => {
message.notify(err)
})
return
if (this.croppedImageUrl == undefined || this.croppedImageUrl == null || this.croppedImageUrl == '') {
message.notify('请先上传头像')
return
......@@ -250,7 +258,7 @@
}
}
},
uploadImage() {
chooseImage() {
uni.chooseImage({
count: 1,
sizeType: ['compressed'],
......@@ -263,28 +271,29 @@
}
});
},
uploadImg(tempFilePath) {
uploadImage(path) {
if (this.step == 1) {
} else if (this.step == 4) {
}
let baseUrl = '/camera-api/'
let that = this;
let tempUrl = '/ai/image/upload';
let tempUrl = 'roseApi/user/uploadImg';
uni.uploadFile({
url: `${app.globalData.baseUrl}${tempUrl}`,
filePath: tempFilePath,
url: `${baseUrl}${tempUrl}`,
filePath: path,
header: {
'content-type': 'multipart/form-data',
// 'content-type': 'multipart/form-data',
pkgname: app.globalData.pkgName,
token: uni.getStorageSync('token')
token: uni.getStorageSync(TOKEN)
},
name: 'file',
formData: {
"type": this.imageType
},
// formData: {},
success: (uploadFileRes) => {
console.log(uploadFileRes)
let data = JSON.parse(uploadFileRes.data)
if (this.step == 1) {
that.avatarUrl = data.data.url
......@@ -320,6 +329,8 @@
// 销毁 Cropper 实例
this.cropper.destroy();
this.cropper = null;
this.uploadImage(this.croppedImageUrl)
}
},
// step-3
......@@ -399,9 +410,9 @@
.steps-item-s {
text-align: center;
line-height: 50rpx;
width: 50rpx;
height: 50rpx;
line-height: 50rpx;
border-radius: 50rpx;
background: #E8C265;
color: black;
......@@ -409,9 +420,9 @@
.steps-item {
text-align: center;
line-height: 50rpx;
width: 50rpx;
height: 50rpx;
line-height: 50rpx;
border-radius: 50rpx;
background: #999999;
color: white;
......
<template>
<view class="container">
<view class="header">
<view class="avatar" @click="uploadPhoto">
<image v-if="!croppedImageUrl" src="/static/ic_avatar.png" @click="uploadPhoto"
style="width: 85px;height: 85px;"></image>
<image v-else :src="croppedImageUrl" @click="uploadPhoto"
style="width: 85px;height: 85px;border-radius: 85px;"></image>
<image class="take-photo" mode="aspectFill" src="/static/ic_take_photo.png"></image>
</view>
<text>上传本人真实清晰近照,能大大提高约会成功率哟~</text>
</view>
<view class="form">
<view class="input-group">
<input v-model="baseForm.nickName" type="text" placeholder="请输入您的昵称" placeholder-class="input-co" />
</view>
<view class="input-group">
<picker mode="selector" :range="ages" @change="onAgeChange">
<view class="picker">
<text v-if="baseForm.birthday">{{ baseForm.birthday ? baseForm.birthday : '请选择您的年龄' }}</text>
<text v-else style="color: #61616E;">请选择您的年龄</text>
</view>
</picker>
</view>
<view class="gender-group">
<text>请选择您的性别</text>
<view class="gender-options">
<view class="gender-option" :class="{ active: baseForm.sex == 2 }" @click="selectGender(2)">
</view>
<view style="width: 60rpx;"></view>
<view class="gender-option" :class="{ active: baseForm.sex == 1 }" @click="selectGender(1)">
</view>
</view>
</view>
</view>
<view class="notice">
<text>注册完成后,您的性别将无法更改</text>
</view>
<view class="save-btn" @click="submit">保存</view>
<!-- 用于显示原始图片和裁剪框 -->
<view class="crop-container" v-if="tempPath">
<div class="image-container">
<img class="crop-img" ref="imageRef" :src="tempPath" alt="原始图片" />
<!-- 裁剪操作按钮 -->
<button class="crop-button" @click="cropImage" v-if="cropper">裁剪</button>
</div>
</view>
</view>
</template>
<script>
import Cropper from 'cropperjs';
import 'cropperjs/dist/cropper.css';
import {
TOKEN
} from '@/common/store/user.js'
import {
initInfo,
updateRuserShareCode,
getRuserShareCode,
} from '@/common/api/user.js'
import {
UserProfile
} from '@/common/constant/userProfile.js'
import {
redirectTo,
message,
loading
} from '@/utils/fun.js';
const app = getApp();
export default {
name: 'index',
data() {
return {
ages: UserProfile.PROFILE_NL.arr,
baseForm: {
birthday: '',
nickName: '',
sex: -1,
headerUrl: ''
},
tempPath: '',
cropper: null,
croppedImageUrl: '',
avatarUrl: '',
showShareCode: false
};
},
onLoad(options) {
// getRuserShareCode().then(data => {
// if (data.ruserShareCode != undefined || data.ruserShareCode != null ||
// data.ruserShareCode != '') {
// this.showShareCode = false
// } else {
// this.showShareCode = true
// }
// })
// .catch((err) => {
// message.notify(err)
// })
},
methods: {
selectGender(sex) {
this.baseForm.sex = sex
},
onAgeChange(e) {
console.log(e)
this.baseForm.birthday = this.ages[e.detail.value];
},
uploadPhoto() {
uni.chooseImage({
count: 1,
sizeType: ['compressed'],
success: (res) => {
this.tempPath = res.tempFilePaths;
// 裁剪图片
this.$nextTick(() => {
this.initCropper();
});
}
});
},
// 执行裁剪操作的方法
cropImage() {
if (this.cropper) {
const canvas = this.cropper.getCroppedCanvas();
this.croppedImageUrl = canvas.toDataURL('image/jpeg');
this.tempPath = ''
// 销毁 Cropper 实例
this.cropper.destroy();
this.cropper = null;
}
},
uploadImg(tempFilePath) {
let that = this;
let tempUrl = '/user/uploadImg';
uni.uploadFile({
url: `${app.globalData.baseUrl}${tempUrl}`,
filePath: tempFilePath,
header: {
// 'content-type': 'multipart/form-data',
pkgname: app.globalData.pkgName,
token: uni.getStorageSync(TOKEN)
},
name: 'file',
formData: {},
success: (uploadFileRes) => {
let data = JSON.parse(uploadFileRes.data)
if (this.step == 1) {
that.avatarUrl = data.data.url
} else if (this.step == 4) {
that.wxCodeUrl = data.data.url
}
},
fail: (res) => {
loading.hide()
uni.hideLoading()
}
});
},
submit() {
if (this.baseForm.nickName == '') {
message.notify("请输入昵称!")
return
}
if (this.baseForm.birthday == '') {
message.notify("请输入年龄!")
return
}
if (this.baseForm.sex == -1) {
message.notify("请输入年龄!")
return
}
initInfo(this.baseForm).then(data => {
message.notify("完善资料成功!")
redirectTo(`/pagesB/auth/auth`)
})
.catch((err) => {
message.notify(err)
})
},
// 初始化 Cropper 实例的方法
initCropper() {
const image = this.$refs.imageRef;
this.cropper = new Cropper(image, {
aspectRatio: 1, // 裁剪框的宽高比,这里设置为 1:1
viewMode: 1, // 裁剪框的显示模式
autoCropArea: 0.8, // 初始裁剪区域占图片的比例
movable: true, // 裁剪框是否可移动
zoomable: true, // 图片是否可缩放
rotatable: false, // 图片是否可旋转
scalable: true // 裁剪框是否可缩放
});
},
// 执行裁剪操作的方法
cropImage() {
if (this.cropper) {
const canvas = this.cropper.getCroppedCanvas();
this.croppedImageUrl = canvas.toDataURL('image/jpeg');
this.tempPath = ''
// 销毁 Cropper 实例
this.cropper.destroy();
this.cropper = null;
}
},
}
};
</script>
<style lang="scss">
.container {
height: 100vh;
background-color: black;
padding: 20rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.header {
width: 80%;
margin-top: 150rpx;
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 20rpx;
color: #61616E;
}
.avatar {
width: 85px;
height: 85px;
position: relative;
margin-bottom: 20px;
.take-photo {
right: 0;
bottom: 0;
width: 22px;
height: 22px;
position: absolute;
}
}
.form {
display: flex;
width: 80%;
margin-top: 80rpx;
flex-direction: column;
}
.input-group {
background-color: #252429;
border-radius: 50rpx;
margin-bottom: 30rpx;
height: 80rpx;
}
.input-co {
color: #61616E;
}
.input-group input,
.picker {
font-size: 30rpx;
width: 100%;
height: 80rpx;
line-height: 80rpx;
margin-left: 50rpx;
color: white;
}
.gender-group {
height: 60rpx;
line-height: 60rpx;
margin-bottom: 15rpx;
}
.gender-options {
display: flex;
}
.gender-option {
flex: 1;
color: white;
padding: 10rpx;
color: #61616E;
background-color: #252429;
text-align: center;
border-radius: 50rpx;
}
.gender-option.active {
background-color: #E8CF83;
color: black;
}
.notice {
margin-top: 100rpx;
font-size: 26rpx;
color: #E8CF83;
}
.save-btn {
width: 80%;
height: 80rpx;
margin-top: 200rpx;
line-height: 80rpx;
text-align: center;
font-size: 30rpx;
background-color: #E8CF83;
color: black;
border: none;
border-radius: 50rpx;
}
.crop-container {
position: absolute;
z-index: 999;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
}
.image-container {
position: absolute;
max-width: 100%;
max-height: 60%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.crop-button {
margin-top: 10px;
width: 120px;
color: black;
background: white;
}
</style>
\ No newline at end of file
<template>
<view>{{ }}</view>
</template>
<script>
import {
faceResult
} from '@/common/api/user.js'
import {
redirectTo,
message,
loading
} from '@/utils/fun.js';
export default {
name: 'index',
data() {
return {
BizToken: ''
};
},
onLoad(options) {
this.BizToken = options.BizToken
this.getFaceResult()
},
methods: {
getFaceResult() {
loading.show()
if (this.BizToken == undefined || this.BizToken == null || this.BizToken == '') {
message.notify("人脸识别失败!")
setTimeout(() => {
redirectTo(`/pagesB/auth/auth`)
}, 1000)
return
}
setTimeout(() => {
faceResult({
bizToken: this.BizToken
}).then(data => {
loading.hide()
message.notify("人脸识别成功!")
setTimeout(() => {
redirectTo(`/pagesB/auth/auth`)
}, 1000)
})
.catch((err) => {
loading.hide()
message.notify(err)
setTimeout(() => {
redirectTo(`/pagesB/auth/auth`)
}, 1000)
})
}, 1000)
}
}
};
</script>
<style>
</style>
\ No newline at end of file
friends/static/ic_take_photo.png

1.2 KB | W: | H:

friends/static/ic_take_photo.png

853 Bytes | W: | H:

friends/static/ic_take_photo.png
friends/static/ic_take_photo.png
friends/static/ic_take_photo.png
friends/static/ic_take_photo.png
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment