[新增体验官]
This commit is contained in:
@@ -1,239 +1,250 @@
|
||||
/*
|
||||
* 手太欠
|
||||
* 愿这世界都如故事里一样 美好而动人~
|
||||
*/
|
||||
|
||||
Page({
|
||||
data: {
|
||||
barHeight : getApp().globalData.barHeight, // 状态栏高度
|
||||
openId : '',
|
||||
nameValue : '', // 姓名
|
||||
testTitle : '',
|
||||
nameStatus: false, // 姓名填写弹框
|
||||
Analyze : '', // 是否交钱
|
||||
disabled : false, // 支付按钮
|
||||
payStatus : false, // 支付弹框
|
||||
payPrice : '', // 支付金额
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
openId: options.code
|
||||
})
|
||||
if(options) {
|
||||
wx.login({
|
||||
success: res => {
|
||||
// 获取openid
|
||||
this.openInfo(res.code)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 判断是否可检测
|
||||
this.ifAnalyze();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* openid
|
||||
*/
|
||||
openInfo(code) {
|
||||
wx.$api.auth.codeOpenid({code: code}).then(res => {
|
||||
this.setData({
|
||||
openId: res.data
|
||||
})
|
||||
}).catch(err => {})
|
||||
},
|
||||
|
||||
/**
|
||||
* 是否可检测
|
||||
*/
|
||||
ifAnalyze() {
|
||||
wx.$api.index.analyze().then(res => {
|
||||
if(res.data.is_first) {
|
||||
this.setData({
|
||||
testTitle: '首次免费,开始测肤'
|
||||
})
|
||||
} else if (res.data.is_first == false && res.data.analyze == false) {
|
||||
this.setData({
|
||||
testTitle: '支付' + res.data.price + '元,进行测肤'
|
||||
})
|
||||
} else if (res.data.is_first == false && res.data.analyze == true) {
|
||||
this.setData({
|
||||
testTitle: '您已付费,进行检测'
|
||||
})
|
||||
}
|
||||
|
||||
this.setData({
|
||||
Analyze : res.data
|
||||
})
|
||||
if(!res.data.is_update) {
|
||||
this.setData({
|
||||
nameStatus: true
|
||||
})
|
||||
}
|
||||
}).catch(err => {})
|
||||
},
|
||||
|
||||
/*
|
||||
姓名截取
|
||||
*/
|
||||
bindinput(e) {
|
||||
this.setData({
|
||||
nameValue: e.detail.value.substr(0,5)
|
||||
})
|
||||
},
|
||||
|
||||
/*
|
||||
提交信息
|
||||
*/
|
||||
issueForm() {
|
||||
wx.showLoading({
|
||||
title: '信息提交中...',
|
||||
mask : true
|
||||
})
|
||||
let data = {
|
||||
name : this.data.nameValue
|
||||
}
|
||||
wx.$api.auth.userAdd(data).then(() => {
|
||||
wx.hideLoading()
|
||||
this.setData({
|
||||
nameStatus: false
|
||||
})
|
||||
}).catch(err => {})
|
||||
},
|
||||
|
||||
/**
|
||||
* 开始皮肤检测
|
||||
*/
|
||||
goAnalyze() {
|
||||
if(this.data.Analyze.is_first == false && this.data.Analyze.analyze == false) {
|
||||
this.setData({
|
||||
payStatus: true
|
||||
})
|
||||
} else {
|
||||
this.uploadPhoto()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 上传图片信息
|
||||
*/
|
||||
uploadPhoto() {
|
||||
wx.chooseMedia({
|
||||
count : 1,
|
||||
sourceType: ['camera'],
|
||||
camera : 'front',
|
||||
success : path => {
|
||||
// 获取皮肤检测接口
|
||||
if(wx.cropImage){
|
||||
wx.cropImage({
|
||||
src: path.tempFiles[0].tempFilePath, // 图片路径
|
||||
cropScale: '3:4', // 裁剪比例
|
||||
success: res=> {
|
||||
// 获取皮肤检测接口
|
||||
this.checkEnter(res.tempFilePath);
|
||||
},
|
||||
complete: err => {}
|
||||
})
|
||||
return
|
||||
}
|
||||
this.checkEnter(path.tempFiles[0].tempFilePath);
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 皮肤检测接口
|
||||
*/
|
||||
checkEnter(img) {
|
||||
wx.$api.index.skinEnter({}, img).then(res => {
|
||||
wx.redirectTo({
|
||||
url: "/pages/report/detail/detail?image_id=" + res.image_id
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 关闭支付弹窗
|
||||
*/
|
||||
cancelAnalyze() {
|
||||
this.setData({
|
||||
payStatus: false
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
*/
|
||||
payFound() {
|
||||
wx.$api.index.skinOrder().then(res => {
|
||||
this.setData({
|
||||
disabled : true
|
||||
})
|
||||
this.payBtn(res.data.order_id)
|
||||
}).catch(err => {})
|
||||
},
|
||||
|
||||
/**
|
||||
* 确认支付1元
|
||||
*/
|
||||
payBtn(orderid) {
|
||||
wx.showLoading({
|
||||
title: '支付中...',
|
||||
mask : true
|
||||
})
|
||||
wx.$api.index.skinPay(orderid,{type: 'miniapp', openid: this.data.openId}).then(res=>{
|
||||
wx.hideLoading()
|
||||
let payInfo = JSON.parse(res.data.wechat)
|
||||
wx.requestPayment({
|
||||
timeStamp: payInfo.timeStamp,
|
||||
nonceStr : payInfo.nonceStr,
|
||||
package : payInfo.package,
|
||||
paySign : payInfo.paySign,
|
||||
signType : payInfo.signType,
|
||||
success : res=>{
|
||||
if(res.errMsg == "requestPayment:ok"){
|
||||
wx.showToast({
|
||||
title: '支付成功',
|
||||
icon : 'success'
|
||||
})
|
||||
}
|
||||
this.setData({
|
||||
payStatus: false
|
||||
})
|
||||
this.setData({
|
||||
Analyze: false
|
||||
})
|
||||
this.uploadPhoto()
|
||||
},
|
||||
fail : err=>{
|
||||
wx.showToast({
|
||||
title: '支付失败',
|
||||
icon : 'error'
|
||||
})
|
||||
this.setData({
|
||||
disabled : false,
|
||||
payStatus: false
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(err => {
|
||||
this.setData({
|
||||
disabled : false,
|
||||
payStatus: false
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 返回上一页
|
||||
*/
|
||||
returnGo() {
|
||||
wx.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
},
|
||||
})
|
||||
/*
|
||||
* 手太欠
|
||||
* 愿这世界都如故事里一样 美好而动人~
|
||||
*/
|
||||
|
||||
Page({
|
||||
data: {
|
||||
barHeight : getApp().globalData.barHeight, // 状态栏高度
|
||||
openId : '',
|
||||
nameValue : '', // 姓名
|
||||
testTitle : '',
|
||||
nameStatus : false, // 姓名填写弹框
|
||||
Analyze : '', // 是否交钱
|
||||
disabled : false, // 支付按钮
|
||||
payStatus : false, // 支付弹框
|
||||
payPrice : '', // 支付金额
|
||||
refertoType: 0,
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
// 体验官 type=1或者type=2 直接面检,不用交钱
|
||||
this.setData({
|
||||
refertoType: options.type
|
||||
})
|
||||
this.setData({
|
||||
openId: options.code
|
||||
})
|
||||
if(options) {
|
||||
wx.login({
|
||||
success: res => {
|
||||
// 获取openid
|
||||
this.openInfo(res.code)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if(this.data.refertoType == '1' || this.data.refertoType == '2') {
|
||||
this.setData({
|
||||
testTitle: '请您开始测肤'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 判断是否可检测
|
||||
this.ifAnalyze();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* openid
|
||||
*/
|
||||
openInfo(code) {
|
||||
wx.$api.auth.codeOpenid({code: code}).then(res => {
|
||||
this.setData({
|
||||
openId: res.data
|
||||
})
|
||||
}).catch(err => {})
|
||||
},
|
||||
|
||||
/**
|
||||
* 是否可检测
|
||||
*/
|
||||
ifAnalyze() {
|
||||
wx.$api.index.analyze().then(res => {
|
||||
if(res.data.is_first) {
|
||||
this.setData({
|
||||
testTitle: '首次免费,开始测肤'
|
||||
})
|
||||
} else if (res.data.is_first == false && res.data.analyze == false) {
|
||||
this.setData({
|
||||
testTitle: '支付' + res.data.price + '元,进行测肤'
|
||||
})
|
||||
} else if (res.data.is_first == false && res.data.analyze == true) {
|
||||
this.setData({
|
||||
testTitle: '您已付费,进行检测'
|
||||
})
|
||||
}
|
||||
|
||||
this.setData({
|
||||
Analyze : res.data
|
||||
})
|
||||
if(!res.data.is_update) {
|
||||
this.setData({
|
||||
nameStatus: true
|
||||
})
|
||||
}
|
||||
}).catch(err => {})
|
||||
},
|
||||
|
||||
/*
|
||||
姓名截取
|
||||
*/
|
||||
bindinput(e) {
|
||||
this.setData({
|
||||
nameValue: e.detail.value.substr(0,5)
|
||||
})
|
||||
},
|
||||
|
||||
/*
|
||||
提交信息
|
||||
*/
|
||||
issueForm() {
|
||||
wx.showLoading({
|
||||
title: '信息提交中...',
|
||||
mask : true
|
||||
})
|
||||
let data = {
|
||||
name : this.data.nameValue
|
||||
}
|
||||
wx.$api.auth.userAdd(data).then(() => {
|
||||
wx.hideLoading()
|
||||
this.setData({
|
||||
nameStatus: false
|
||||
})
|
||||
}).catch(err => {})
|
||||
},
|
||||
|
||||
/**
|
||||
* 开始皮肤检测
|
||||
*/
|
||||
goAnalyze() {
|
||||
if(this.data.Analyze.is_first == false && this.data.Analyze.analyze == false) {
|
||||
this.setData({
|
||||
payStatus: true
|
||||
})
|
||||
} else {
|
||||
this.uploadPhoto()
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 上传图片信息
|
||||
*/
|
||||
uploadPhoto() {
|
||||
wx.chooseMedia({
|
||||
count : 1,
|
||||
sourceType: ['camera'],
|
||||
camera : 'front',
|
||||
success : path => {
|
||||
// 获取皮肤检测接口
|
||||
if(wx.cropImage){
|
||||
wx.cropImage({
|
||||
src: path.tempFiles[0].tempFilePath, // 图片路径
|
||||
cropScale: '3:4', // 裁剪比例
|
||||
success: res=> {
|
||||
// 获取皮肤检测接口
|
||||
this.checkEnter(res.tempFilePath);
|
||||
},
|
||||
complete: err => {}
|
||||
})
|
||||
return
|
||||
}
|
||||
this.checkEnter(path.tempFiles[0].tempFilePath);
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 皮肤检测接口
|
||||
*/
|
||||
checkEnter(img) {
|
||||
wx.$api.index.skinEnter({type: this.data.refertoType}, img).then(res => {
|
||||
wx.redirectTo({
|
||||
url: "/pages/report/detail/detail?image_id=" + res.image_id + "&type=" + this.data.refertoType
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 关闭支付弹窗
|
||||
*/
|
||||
cancelAnalyze() {
|
||||
this.setData({
|
||||
payStatus: false
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
*/
|
||||
payFound() {
|
||||
wx.$api.index.skinOrder().then(res => {
|
||||
this.setData({
|
||||
disabled : true
|
||||
})
|
||||
this.payBtn(res.data.order_id)
|
||||
}).catch(err => {})
|
||||
},
|
||||
|
||||
/**
|
||||
* 确认支付1元
|
||||
*/
|
||||
payBtn(orderid) {
|
||||
wx.showLoading({
|
||||
title: '支付中...',
|
||||
mask : true
|
||||
})
|
||||
wx.$api.index.skinPay(orderid,{type: 'miniapp', openid: this.data.openId}).then(res=>{
|
||||
wx.hideLoading()
|
||||
let payInfo = JSON.parse(res.data.wechat)
|
||||
wx.requestPayment({
|
||||
timeStamp: payInfo.timeStamp,
|
||||
nonceStr : payInfo.nonceStr,
|
||||
package : payInfo.package,
|
||||
paySign : payInfo.paySign,
|
||||
signType : payInfo.signType,
|
||||
success : res=>{
|
||||
if(res.errMsg == "requestPayment:ok"){
|
||||
wx.showToast({
|
||||
title: '支付成功',
|
||||
icon : 'success'
|
||||
})
|
||||
}
|
||||
this.setData({
|
||||
payStatus: false
|
||||
})
|
||||
this.setData({
|
||||
Analyze: false
|
||||
})
|
||||
this.uploadPhoto()
|
||||
},
|
||||
fail : err=>{
|
||||
wx.showToast({
|
||||
title: '支付失败',
|
||||
icon : 'error'
|
||||
})
|
||||
this.setData({
|
||||
disabled : false,
|
||||
payStatus: false
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(err => {
|
||||
this.setData({
|
||||
disabled : false,
|
||||
payStatus: false
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 返回上一页
|
||||
*/
|
||||
returnGo() {
|
||||
wx.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
<!-- 第一屏幕 -->
|
||||
<!-- bindtap="assessGo" -->
|
||||
<view class="indexBack">
|
||||
<image class="indexBack-img" src="https://cdn.shuiganying.com/images/2023/05/17/d8be509c6ce2bd268967388621bc095a.png"></image>
|
||||
<view class="indexText">
|
||||
<view class="indexText-name">下滑了解详情</view>
|
||||
<image class="indexText-arrow" src="https://cdn.shuiganying.com/images/2023/05/16/d323c1a5d97c0c566126e3a2ff7f1827.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 漂浮窗 -->
|
||||
<view class="wander" bindtap="assessGo">
|
||||
<view class="wander-cont">
|
||||
<image class="wander-icon" src="https://cdn.shuiganying.com/images/2023/05/16/e69134d810039f1c9bfe9111036d92fb.png" mode="widthFix"></image>
|
||||
<view class="wander-name">检测</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 单图 -->
|
||||
<view class="indexSingle">
|
||||
<image class="indexSingle-img" mode="widthFix" src="https://cdn.shuiganying.com/images/2023/05/18/ac3182087d2607104409f3fc988514c6.gif"></image>
|
||||
<image class="indexSingle-img" style="margin-top: -280rpx;" mode="widthFix" src="https://cdn.shuiganying.com/images/2023/05/18/a6dee6dbb61b03ffe0ca55896a77a4d4.png"></image>
|
||||
<image class="indexSingle-img" mode="widthFix" src="https://cdn.shuiganying.com/images/2023/07/01/142307c731c974a66f7d802087b361f8.png"></image>
|
||||
<image class="indexSingle-img" mode="widthFix" src="https://cdn.shuiganying.com/images/2023/05/17/88be57f403db19a0413b93045bd406d8.png"></image>
|
||||
</view>
|
||||
|
||||
<view class="testBtn">
|
||||
<image class="indexText-arrow" src="https://cdn.shuiganying.com/images/2023/05/16/a72e053db51bc68bed00168047d2cb3e.png"></image>
|
||||
<view class="testBtn-go" bindtap="assessGo">{{userLogin ? testTitle : '立即开启皮肤检测'}}</view>
|
||||
</view>
|
||||
<!-- 第一屏幕 -->
|
||||
<!-- bindtap="assessGo" -->
|
||||
<view class="indexBack">
|
||||
<image class="indexBack-img" src="https://cdn.shuiganying.com/images/2023/05/17/d8be509c6ce2bd268967388621bc095a.png"></image>
|
||||
<view class="indexText">
|
||||
<view class="indexText-name">下滑了解详情</view>
|
||||
<image class="indexText-arrow" src="https://cdn.shuiganying.com/images/2023/05/16/d323c1a5d97c0c566126e3a2ff7f1827.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 漂浮窗 -->
|
||||
<view class="wander" bindtap="assessGo">
|
||||
<view class="wander-cont">
|
||||
<image class="wander-icon" src="https://cdn.shuiganying.com/images/2023/05/16/e69134d810039f1c9bfe9111036d92fb.png" mode="widthFix"></image>
|
||||
<view class="wander-name">检测</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 单图 -->
|
||||
<view class="indexSingle">
|
||||
<image class="indexSingle-img" mode="widthFix" src="https://cdn.shuiganying.com/images/2023/05/18/ac3182087d2607104409f3fc988514c6.gif"></image>
|
||||
<image class="indexSingle-img" style="margin-top: -280rpx;" mode="widthFix" src="https://cdn.shuiganying.com/images/2023/05/18/a6dee6dbb61b03ffe0ca55896a77a4d4.png"></image>
|
||||
<image class="indexSingle-img" mode="widthFix" src="https://cdn.shuiganying.com/images/2023/07/01/142307c731c974a66f7d802087b361f8.png"></image>
|
||||
<image class="indexSingle-img" mode="widthFix" src="https://cdn.shuiganying.com/images/2023/05/17/88be57f403db19a0413b93045bd406d8.png"></image>
|
||||
</view>
|
||||
|
||||
<view class="testBtn">
|
||||
<image class="indexText-arrow" src="https://cdn.shuiganying.com/images/2023/05/16/a72e053db51bc68bed00168047d2cb3e.png"></image>
|
||||
<view class="testBtn-go" bindtap="assessGo">{{userLogin ? testTitle : '立即开启皮肤检测'}}</view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user