Commit 4ef5bba2 authored by 李超鹏's avatar 李超鹏

Merge remote-tracking branch 'origin/dev-photo-v2' into dev-photo-v2

parents 2972153b 8784c284
<style lang="scss">
@import '@/common/index.scss';
@import 'uview-ui/index.scss';
@import '@/common/index.scss';
@import 'uview-ui/index.scss';
</style>
<script>
import {
AnalysysAgent
} from '@/utils/analysys_paas.js'
import util from '@/utils/util.js'
export default {
globalData: {
//https://system.banshouhui.com
//https://system.dev.banshouhui.com
//正式环境
//domain_Name: 'https://system.banshouhui.com',
//测试环境
domain_Name: 'https://system.banshouhui.com',
//http://192.168.0.208:8192
//小青本地环境
//domain_Name: 'http://192.168.0.208:37080',
token:'',
//RTOKEN45f41a3053238cb72b3b72fe14df8d7040c9f502
//定位 图标
icon_location:'https://qn-static.banshouhui.com/take_order/icon/location.png',
//首页提示 图标
icon_index_notice:'https://qn-static.banshouhui.com/index_notice.png',
//授权提示 图标
icon_auth_notice:'https://qn-static.banshouhui.com/auth_notice.png',
//勾选确认 图标
icon_agree_yes:'https://qn-static.banshouhui.com/agree_yes.png',
//勾选取消 图标
icon_agrss_no:'https://qn-static.banshouhui.com/agree_no.png',
//无数据 图标
icon_noData:'https://qn-static.banshouhui.com/empty.png',
//抢单 图标
icon_rob:'https://qn-static.banshouhui.com/take_order/icon/rob.png',
//右箭头 图标
icon_arrow_right:'https://qn-static.banshouhui.com/arrow_right.png',
//照片添加 图标
icon_photo_add:'https://qn-static.banshouhui.com/take_order/icon/photo_add.png',
//关闭 图标
icon_close:'https://qn-static.banshouhui.com/close.png',
//顶部 图标
icon_top:'https://qn-static.banshouhui.com/topIcon.png',
//我的 图标
icon_mine:'https://qn-static.banshouhui.com/mine.png',
//三角形向下 图标
icon_trangle_down:'https://qn-static.banshouhui.com/trangle_down.png',
//i 图标
icon_i:'https://qn-static.banshouhui.com/i.png',
//客服 图片
icon_customer_service:'https://qn-static.banshouhui.com/customer-service.png',
//三角形向上 图标
icon_trangle_up:'https://qn-static.banshouhui.com/trangle_up.png',
//勾选 图标
icon_selected:'https://qn-static.banshouhui.com/selected.png',
//关闭新 图标
icon_close_new:'https://qn-static.banshouhui.com/close_new.png',
//授权提示新 图标
icon_auth_notice_new:'https://qn-static.banshouhui.com/auth_notice_new.png',
//登录注册页--
//通过code获取用户信息(登录)
getUsersByCode:'/wxh-support-rest/rest/ssoinfo/v3/getUsersByCode',
//通过手机号获取用户信息(注册并登录)
findByMobile:'/wxh-support-rest/rest/ssoinfo/v3/findByMobile',
//下单模块--
//立即下单
createAppletsOrder:'',
//下单列表
createOrderList:'',
//接单模块--
//抢单广场
grabbing:'',
//检查抢单用户状态
checkRobStatus:'',
///wxh-worker-rest/rest/order/revision/applets/{token}/order/check
//工单列表
workOrderList:'',
//工单详情
workOrderDetail:'',
//预约 V2
orderReserve:'',
//工单完工
configCompletion:'',
protocolContent:'',
signUrl:'',
jumpLoginStatus:true,
settleRecommend:'',
navHeight:0, //导航栏高度
rpxScreenHeight:0,// 照相视框高度
//拍照相关数据
photo:{
product:{
brandId:'', // 品牌id
brandName:'', // 品牌名称
classifyId:'', // 分类id
systemId:'', // 系统id
},
currentItemLength:0,//已拍摄照片张数
productList:[],
currentItem:null, // 选择的某一项
setting:null, //自定义设置
waterSetting:null, // 水印设置
tempPath:{
origin:'', // 缓存拍照图片
mixWater:'' // 缓存水印拍照图片
}
import {
AnalysysAgent
} from '@/utils/analysys_paas.js'
import util from '@/utils/util.js'
export default {
globalData: {
//https://system.banshouhui.com
//https://system.dev.banshouhui.com
//正式环境
//domain_Name: 'https://system.banshouhui.com',
//测试环境
domain_Name: 'https://system.banshouhui.com',
//http://192.168.0.208:8192
//小青本地环境
//domain_Name: 'http://192.168.0.208:37080',
token: '',
//RTOKEN45f41a3053238cb72b3b72fe14df8d7040c9f502
//定位 图标
icon_location: 'https://qn-static.banshouhui.com/take_order/icon/location.png',
//首页提示 图标
icon_index_notice: 'https://qn-static.banshouhui.com/index_notice.png',
//授权提示 图标
icon_auth_notice: 'https://qn-static.banshouhui.com/auth_notice.png',
//勾选确认 图标
icon_agree_yes: 'https://qn-static.banshouhui.com/agree_yes.png',
//勾选取消 图标
icon_agrss_no: 'https://qn-static.banshouhui.com/agree_no.png',
//无数据 图标
icon_noData: 'https://qn-static.banshouhui.com/empty.png',
//抢单 图标
icon_rob: 'https://qn-static.banshouhui.com/take_order/icon/rob.png',
//右箭头 图标
icon_arrow_right: 'https://qn-static.banshouhui.com/arrow_right.png',
//照片添加 图标
icon_photo_add: 'https://qn-static.banshouhui.com/take_order/icon/photo_add.png',
//关闭 图标
icon_close: 'https://qn-static.banshouhui.com/close.png',
//顶部 图标
icon_top: 'https://qn-static.banshouhui.com/topIcon.png',
//我的 图标
icon_mine: 'https://qn-static.banshouhui.com/mine.png',
//三角形向下 图标
icon_trangle_down: 'https://qn-static.banshouhui.com/trangle_down.png',
//i 图标
icon_i: 'https://qn-static.banshouhui.com/i.png',
//客服 图片
icon_customer_service: 'https://qn-static.banshouhui.com/customer-service.png',
//三角形向上 图标
icon_trangle_up: 'https://qn-static.banshouhui.com/trangle_up.png',
//勾选 图标
icon_selected: 'https://qn-static.banshouhui.com/selected.png',
//关闭新 图标
icon_close_new: 'https://qn-static.banshouhui.com/close_new.png',
//授权提示新 图标
icon_auth_notice_new: 'https://qn-static.banshouhui.com/auth_notice_new.png',
//登录注册页--
//通过code获取用户信息(登录)
getUsersByCode: '/wxh-support-rest/rest/ssoinfo/v3/getUsersByCode',
//通过手机号获取用户信息(注册并登录)
findByMobile: '/wxh-support-rest/rest/ssoinfo/v3/findByMobile',
//下单模块--
//立即下单
createAppletsOrder: '',
//下单列表
createOrderList: '',
//接单模块--
//抢单广场
grabbing: '',
//检查抢单用户状态
checkRobStatus: '',
///wxh-worker-rest/rest/order/revision/applets/{token}/order/check
//工单列表
workOrderList: '',
//工单详情
workOrderDetail: '',
//预约 V2
orderReserve: '',
//工单完工
configCompletion: '',
protocolContent: '',
signUrl: '',
jumpLoginStatus: true,
settleRecommend: '',
navHeight: 0, //导航栏高度
rpxScreenHeight: 0,// 照相视框高度
//拍照相关数据
photo: {
product: {
brandId: '', // 品牌id
brandName: '', // 品牌名称
classifyId: '', // 分类id
systemId: '', // 系统id
},
// 用户信息
tempUserInfo: '', // 临时用户选项
userInfo: '', // 用户信息
authLoading: false,
},
onLaunch: function() {
this.getSystemInfo()
this.checkUpdate()
var that=this
uni.getStorage({
key: 'token',
success: function (res) {
that.globalData.token = res.data
that.initAPIneedToken()
}
})
this.getProtocolContent()
AnalysysAgent.registerSuperProperty("platform","take-order");
currentItemLength: 0,//已拍摄照片张数
productList: [],
currentItem: null, // 选择的某一项
setting: null, //自定义设置
waterSetting: null, // 水印设置
tempPath: {
origin: '', // 缓存拍照图片
mixWater: '' // 缓存水印拍照图片
}
},
onShow: function() {
if (this.globalData.token) {
this.globalData.authLoading = false
} else {
this.autoLogin()
// 用户信息
tempUserInfo: '', // 临时用户选项
},
onLaunch: function () {
this.getSystemInfo()
this.checkUpdate()
var that = this
that.globalData.token = util.getToken()
console.log(that.globalData.token, 'that.globalData.token')
that.initAPIneedToken()
// uni.getStorage({
// key: 'token',
// success: function (res) {
// that.globalData.token = res.data
// that.initAPIneedToken()
// }
// })
this.getProtocolContent()
AnalysysAgent.registerSuperProperty("platform", "take-order");
},
onShow: function () {
if (!this.globalData.token) {
this.autoLogin()
}
},
methods: {
getSystemInfo() {
try {
let a = wx.getSystemInfoSync();
// this.globalData.platform = systemInfo.platform, this.globalData.pixelRatio = a.pixelRatio,
// this.globalData.statusBarHeight = a.statusBarHeight, this.globalData.navHeight = a.statusBarHeight / a.screenWidth * 750 + 90,
// this.globalData.rpxScreenHeight = a.screenHeight / a.screenWidth * 750, this.globalData.screenWidth = a.screenWidth,
// this.globalData.screenHeight = a.screenHeight;
this.globalData.navHeight = a.statusBarHeight / a.screenWidth * 750 + 90
this.globalData.rpxScreenHeight = a.screenHeight / a.screenWidth * 750
this.globalData.screenHeight = a.screenHeight
} catch (a) {
}
},
methods: {
getSystemInfo(){
try {
let a = wx.getSystemInfoSync();
// this.globalData.platform = systemInfo.platform, this.globalData.pixelRatio = a.pixelRatio,
// this.globalData.statusBarHeight = a.statusBarHeight, this.globalData.navHeight = a.statusBarHeight / a.screenWidth * 750 + 90,
// this.globalData.rpxScreenHeight = a.screenHeight / a.screenWidth * 750, this.globalData.screenWidth = a.screenWidth,
// this.globalData.screenHeight = a.screenHeight;
this.globalData.navHeight = a.statusBarHeight / a.screenWidth * 750 + 90
this.globalData.rpxScreenHeight = a.screenHeight / a.screenWidth * 750
this.globalData.screenHeight = a.screenHeight
} catch (a) {}
},
//检查更新
checkUpdate: function () {
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
console.log(res.hasUpdate)
})
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(function () {
// 新版本下载失败
//检查更新
checkUpdate: function () {
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
console.log(res.hasUpdate)
})
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
}
})
},
async getBaseInfo(vm,callBack){
uni.showLoading({
title:'加载中……'
})
const res = await vm.$u.api.getSettleBaseInfo()
if (!res || !res.status) {
if(res && res.message){
})
updateManager.onUpdateFailed(function () {
// 新版本下载失败
})
},
async getBaseInfo(vm, callBack) {
uni.showLoading({
title: '加载中……'
})
const res = await vm.$u.api.getSettleBaseInfo()
if (!res || !res.status) {
if (res && res.message) {
uni.showToast({
title: res && res.message || '获取基本信息错误',
icon: 'none'
title: res && res.message || '获取基本信息错误',
icon: 'none'
});
}
return false;
}
this.globalData.settledInfo = res.data
if(!res.data){
return
}
callBack(vm,res.data)
uni.hideLoading()
return res.data
},
initAPIneedToken: function() {
//RTOKEN45f41a3053238cb72b3b72fe14df8d7040c9f502
///*
if(this.globalData.token){
//console.log('initAPIneedToken')
//下单模块--
//立即下单
this.globalData.createAppletsOrder = '/wxh-worker-rest/rest/order/revision/applets/'
+this.globalData.token+'/order/createAppletsOrder',
return false;
}
this.globalData.settledInfo = res.data
if (!res.data) {
return
}
callBack(vm, res.data)
uni.hideLoading()
return res.data
},
initAPIneedToken: function () {
//RTOKEN45f41a3053238cb72b3b72fe14df8d7040c9f502
///*
if (this.globalData.token) {
//console.log('initAPIneedToken')
//下单模块--
//立即下单
this.globalData.createAppletsOrder = '/wxh-worker-rest/rest/order/revision/applets/'
+ this.globalData.token + '/order/createAppletsOrder',
//console.log('立即下单'+this.globalData.createAppletsOrder)
//下单列表
this.globalData.createOrderList = '/wxh-worker-rest/rest/order/revision/applets/'
+this.globalData.token+'/order/customer'
//console.log('下单列表'+this.globalData.createOrderList)
//接单模块--
//抢单广场
this.globalData.grabbing = '/wxh-worker-rest/rest/order/revision/applets/'
+this.globalData.token+'/order/grabbing'
//console.log('抢单广场'+this.globalData.grabbing)
//检查抢单用户状态
this.globalData.checkRobStatus = '/wxh-worker-rest/rest/order/revision/applets/'
+this.globalData.token+'/order/check',
+ this.globalData.token + '/order/customer'
//console.log('下单列表'+this.globalData.createOrderList)
//接单模块--
//抢单广场
this.globalData.grabbing = '/wxh-worker-rest/rest/order/revision/applets/'
+ this.globalData.token + '/order/grabbing'
//console.log('抢单广场'+this.globalData.grabbing)
//检查抢单用户状态
this.globalData.checkRobStatus = '/wxh-worker-rest/rest/order/revision/applets/'
+ this.globalData.token + '/order/check',
//console.log('检查抢单用户状态'+this.globalData.checkRobStatus)
//工单列表
this.globalData.workOrderList = '/wxh-worker-rest/rest/order/revision/applets/'
+this.globalData.token+'/order/worker',
+ this.globalData.token + '/order/worker',
//console.log('工单列表'+this.globalData.workOrderList)
//工单详情
this.globalData.workOrderDetail = '/wxh-worker-rest/rest/order/revision/applets/'
+this.globalData.token+'/order/detail',
+ this.globalData.token + '/order/detail',
//console.log('工单详情'+this.globalData.workOrderDetail)
//预约 V2
this.globalData.orderReserve = '/wxh-worker-rest/rest/project/order/reserve/'
+ this.globalData.token,
+ this.globalData.token,
//console.log('预约 V2'+this.globalData.orderReserve)
//工单完工
this.globalData.configCompletion = ''
///wxh-worker-rest/rest/config/RTOKEN222bdab78b0d2a74f159b640df53180772813250/completion/11885887?inGuaranteePeriod=true
}
//*/
},
getProtocolContent: function() {
this.protocolContent
},
/* ------------------------- 数据埋点begin ------------------------------ */
track(event, properties) {
if (AnalysysAgent) {
// 易观添加事件
let AnalysysAgent = wx.AnalysysAgent;
AnalysysAgent.track("take_order_" + event, properties);
}
},
identify(userInfo, openid, unionid = null) {
// 设备身份表示
if (AnalysysAgent) {
let setProfile = {
'openid': openid,
'unionid': unionid,
}
setProfile = Object.assign(setProfile, userInfo)
AnalysysAgent.profileSet(setProfile);
}
},
setUserId(userId) {
// 用户id设置
if (AnalysysAgent) {
AnalysysAgent.alias(userId + '')
}
},
setUser(user) {
// 用户附加属性
if (AnalysysAgent) {
let userInfo = {
'mobile':user.mobile,
'userfrom_id':user.uid,
'userfrom':'家维广场',
'avatar':user.avatar,
'nickname':user.nickname,
'username':user.username,
'wxhuid':user.wxhuid,
'id':user.id,
'money': user.money,
'score':user.score
};
Object.keys(userInfo).map(key=>{
if(key && userInfo[key]){
AnalysysAgent.profileAppend(key,userInfo[key])
}
})
}
},
share(toShareProperties, trackProperties) {
if (AnalysysAgent) {
AnalysysAgent.share(toShareProperties, trackProperties);
}
},
trackPage(pageName, properties){
if (AnalysysAgent) {
AnalysysAgent.pageView(pageName, properties);
///wxh-worker-rest/rest/config/RTOKEN222bdab78b0d2a74f159b640df53180772813250/completion/11885887?inGuaranteePeriod=true
}
//*/
},
getProtocolContent: function () {
this.protocolContent
},
/* ------------------------- 数据埋点begin ------------------------------ */
track(event, properties) {
if (AnalysysAgent) {
// 易观添加事件
let AnalysysAgent = wx.AnalysysAgent;
AnalysysAgent.track("take_order_" + event, properties);
}
},
identify(userInfo, openid, unionid = null) {
// 设备身份表示
if (AnalysysAgent) {
let setProfile = {
'openid': openid,
'unionid': unionid,
}
},
initShare(option){
console.log(option,'option-initShare')
option = option || {}
if (AnalysysAgent && option.user_id) {
let shareUserInfo = {
'share_from_id':option.user_id || '',
'share_from_nickname':option.user_name || '',
setProfile = Object.assign(setProfile, userInfo)
AnalysysAgent.profileSet(setProfile);
}
},
setUserId(userId) {
// 用户id设置
if (AnalysysAgent) {
AnalysysAgent.alias(userId + '')
}
},
setUser(user) {
// 用户附加属性
if (AnalysysAgent) {
let userInfo = {
'mobile': user.mobile,
'userfrom_id': user.uid,
'userfrom': '家维广场',
'avatar': user.avatar,
'nickname': user.nickname,
'username': user.username,
'wxhuid': user.wxhuid,
'id': user.id,
'money': user.money,
'score': user.score
};
Object.keys(userInfo).map(key => {
if (key && userInfo[key]) {
AnalysysAgent.profileAppend(key, userInfo[key])
}
AnalysysAgent.registerSuperProperties(shareUserInfo);
})
}
},
share(toShareProperties, trackProperties) {
if (AnalysysAgent) {
AnalysysAgent.share(toShareProperties, trackProperties);
}
},
trackPage(pageName, properties) {
if (AnalysysAgent) {
AnalysysAgent.pageView(pageName, properties);
}
},
initShare(option) {
console.log(option, 'option-initShare')
option = option || {}
if (AnalysysAgent && option.user_id) {
let shareUserInfo = {
'share_from_id': option.user_id || '',
'share_from_nickname': option.user_name || '',
}
},
/* ------------------------- 数据埋点end ------------------------------ */
/**
* 用户自动登录
*/
autoLogin() {
let that = this;
that.globalData.authLoading = true
uni.login({
success(res) {
if (res.code) {
let params = {code: res.code};
that.authorization(params)
AnalysysAgent.registerSuperProperties(shareUserInfo);
}
},
/* ------------------------- 数据埋点end ------------------------------ */
/**
* 用户自动登录
*/
autoLogin() {
let that = this
uni.login({
async success(res) {
if (res.code) {
let result = await that.$u.api.loginWechatAuth({code: res.code})
if (result) {
if (result.code == 200 && result.data) {
that.setUserData(result.data)
}
} else {
uni.showModal({
title: '登录失败',
content: '未获取到code',
title: '请求失败',
content: result.message,
showCancel: false
});
}
},
fail() {
wx.showModal({
uni.hideLoading()
} else {
uni.showModal({
title: '登录失败',
content: '接口调用失败',
content: '未获取到code',
});
}
});
},
async authorization(params) {
let that = this
const res = await that.$u.api.loginWechatAuth(params)
if(!res || !res.code || !res.data){
uni.hideLoading()
return
} else if (res.code == 200) {
that.setUserData(res.data)
if (typeof callback == "function") {
callback();
}
} else {
wx.showModal({
title: '请求失败',
showCancel: false
});
}
that.globalData.authLoading = false
uni.hideLoading()
},
setUserData(userInfo) {
if(userInfo && userInfo.token) {
// 如果已经登录则直接获取相关信息
util.setOpenid(userInfo.wxopenid)
util.setToken(userInfo.token)
this.globalData.userInfo = userInfo;
uni.setStorageSync('user-info', userInfo);
uni.setStorageSync('isNewUser', false);
} else {
uni.setStorageSync('isNewUser', true);
},
fail() {
}
},
});
},
onHide: function() {
console.log('App Hide')
setUserData(userInfo) {
if (userInfo && userInfo.token) {
// 如果已经登录则直接获取相关信息
util.setOpenid(userInfo.wxopenid)
util.setToken(userInfo.token)
uni.setStorageSync('user-info', userInfo);
} else {
util.setToken('')
}
},
}
},
onHide: function () {
console.log('App Hide')
},
}
</script>
<style>
/*每个页面公共css */
/*每个页面公共css */
</style>
......@@ -50,13 +50,7 @@
}, {
name: '之约'
}],
swiperList:[{
title:'记录的距离大家零点九零杰拉德杰拉德建立的连接就111111111111',
},{
title:'记录的距离大家零点九零杰拉德杰拉德建立的连接就222222',
},{
title:'记录的距离大家零点九零杰拉德杰拉德建立的连接就333333',
},],
swiperList:[],
// 因为内部的滑动机制限制,请将tabs组件和swiper组件的current用不同变量赋值
current: 0, // tabs组件的current值,表示当前活动的tab选项
swiperCurrent: 0, // swiper组件的current值,表示当前那个swiper-item是活动的
......
......@@ -124,8 +124,8 @@
{
"path": "pages/photo/setting",
"style": {
"navigationBarTitleText": "水印设置",
"navigationBarBackgroundColor":"#FFFFFF",
"navigationBarTitleText": "水印设置",
"navigationBarBackgroundColor":"#FFFFFF",
"backgroundColor":"#F4F5F7"
// "navigationBarBackgroundColor": "#333333",
// "navigationBarTextStyle": "#FFFFFF",
......@@ -288,6 +288,10 @@
"name": "照片预览", //模式名称
"path": "pages/photo/preview", //启动页面,必选
"query": "standardId=1&img=https://papers.co/wallpaper/papers.co-bk57-art-illust-girl-pink-tomboy-red-6-wallpaper.jpg" //启动参数,在页面的onLoad函数里面得到
},{
"name": "授权登录",
"path": "pages/login/wxlogin",
"query": ""
}]
}
}
......@@ -5,15 +5,19 @@
<image class="noticeImage" :src="icon_auth_notice_new" mode=""></image>
</view>
<view class="noticeTitleView">
<text class="noticeTitle">{{noticeTitle}}</text>
<text class="noticeTitle">{{ noticeTitle }}</text>
</view>
<button class="loginBtn" v-if="!isNewUser" lang="zh_CN" catchtap="getUserProfile">
<text class="u-font-32 white">立即登录</text>
</button>
<!-- <button class="loginBtn" v-if="!isNewUser" open-type="getUserInfo" lang="zh_CN" @getuserinfo="getUserInfo">
<text class="u-font-32 white">立即登录</text>
</button> -->
<button class="loginBtn" v-if="needAuth" lang="zh_CN" @tap="getUserProfile">
<text class="u-font-32 white">立即登录</text>
</button>
<!-- <button class="loginBtn" v-if="isNewUser" open-type="getPhoneNumber" throttle-time="1000" @getphonenumber="getPhoneNumber">
<text class="u-font-32 white">授权登录</text>
</button> -->
<button class="loginBtn" v-if="isNewUser" open-type="getPhoneNumber" throttle-time="1000" @getphonenumber="getPhoneNumber">
<button class="loginBtn" v-else open-type="getPhoneNumber" throttle-time="1000"
@getphonenumber="signupLogin">
<text class="u-font-32 white">授权登录</text>
</button>
<view class="cancelView">
......@@ -24,464 +28,408 @@
</template>
<script>
import util from '@/utils/util.js'
export default {
data() {
return {
domain_name: 'http://192.168.0.208:8192',
isNewUser: false,
unionID: '',
openID: '',
icon_notice: '',
TimeID: -1,
icon_auth_notice_new: '',
noticeTitle:'申请获得您的公开信息(昵称,头像等)以便于为您提供更好的服务',
}
},
onLoad() {
getApp().trackPage('授权登录页')
this.icon_notice = getApp().globalData.icon_auth_notice
this.icon_auth_notice_new = getApp().globalData.icon_auth_notice_new
},
onShow(){
const app = getApp()
app.globalData.jumpLoginStatus = true
},
methods: {
// 授权用户信息
getUserProfile() {
var self = this
const app = getApp()
if (self.isNewUser) {
uni.getUserProfile({
desc: '用于授权登录',
success: function (res) {
const userInfo = res.userInfo;
if (!userInfo) {
uni.showModal({
title: '授权失败',
content: '获取用户信息的授权失败',
showCancel: false
});
return
}
app.globalData.tempUserInfo = userInfo;
uni.showLoading({
title: '授权中..',
mask: true
});
self.authLogin()
},
fail:function(res){
uni.showModal({
title: '授权失败',
content: '请允许获取用户信息的授权',
showCancel: false
});
return;
}
})
}
},
async authLogin() {
var that = this
const app = getApp()
const res = await that.$u.api.loginWechatAuth(params)
if(!res || !res.code || !res.data){
uni.hideLoading()
return
} else if (res.code == 200) {
app.setUserData(res.data)
} else {
}
uni.hideLoading()
},
async signLogin() {
var that = this
const app = getApp()
const res = await that.$u.api.loginWechatAuth(params)
if(!res || !res.code || !res.data){
uni.hideLoading()
return
} else if (res.code == 200) {
app.setUserData(res.data)
} else {
}
uni.hideLoading()
},
//用户授权得到用户的信息
getUserInfo: async function(e) {
clearTimeout(this.TimeID);
this.TimeID = setTimeout(() => {
//console.log('获取用户信息')
//console.log(e.detail.userInfo)
if (e.detail.errMsg == 'getUserInfo:fail auth deny') {
import util from '@/utils/util.js'
import login from '@/utils/login.js'
const app = getApp()
export default {
data() {
return {
isNewUser: false,
needAuth: true,
unionID: '',
openID: '',
icon_notice: '',
TimeID: -1,
icon_auth_notice_new: '',
noticeTitle: '申请获得您的公开信息(昵称,头像等)以便于为您提供更好的服务',
}
},
onLoad() {
getApp().trackPage('授权登录页')
this.icon_notice = getApp().globalData.icon_auth_notice
this.icon_auth_notice_new = getApp().globalData.icon_auth_notice_new
},
onShow() {
app.globalData.jumpLoginStatus = true
// 微信授权过用户信息,则无需重复授权
if (app.globalData.tempUserInfo) {
this.needAuth = false
}
},
methods: {
// 授权用户信息
getUserProfile() {
var that = this
const app = getApp()
uni.getUserProfile({
desc: '用于授权登录',
success: function (res) {
const userInfo = res.userInfo;
if (userInfo) {
app.globalData.tempUserInfo = userInfo;
uni.showLoading({
title: '授权中..',
mask: true
});
that.authLogin()
} else {
uni.showModal({
title: '授权失败',
content: '请允许获取用户信息的授权',
content: '获取用户信息的授权失败',
showCancel: false
});
} else {
this.getCode()
}
}, 1000);
},
//小程序获取code
getCode: async function() {
let that = this
uni.showLoading({
title: '加载中',
})
return new Promise((resolve, reject) => {
console.log(uni.login,'uni.login(')
uni.login({
// #ifdef MP-ALIPAY
scopes: 'auth_user',
// #endif
success: function(res) {
if (res.code) {
that.getUsersByCode(res.code)
//that.getUnionID(res.code)
//resolve(res.code);
} else {
//login成功,但是没有取到code
reject('未取得code');
}
},
fail: function(res) {
reject('用户授权失败wx.login');
},
complete(res) {
reject('code获取失败');
console.log('code获取失败',res)
uni.hideLoading()
}
},
fail: function (res) {
uni.showModal({
title: '授权失败',
content: '请允许获取用户信息的授权',
showCancel: false
});
});
},
//通过code获取用户信息(新接口)
getUsersByCode: async function(code) {
uni.showLoading({
title: '加载中'
})
const params = {
code: code,
}
const res = await this.$u.api.loginWxByUser(params)
if (res.code == 200) {
this.unionID = res.data.user.unionid
this.openID = res.data.user.wxopenid
util.setOpenid(res.data.user.wxopenid)
if (res.data.token) {
uni.showToast({
icon: 'none',
title: '登陆成功'
})
this.saveUserInfo(res)
} else {
uni.showToast({
icon: 'none',
title: '新用户请授权登录'
})
this.isNewUser = true
}
})
},
authLogin() {
var that = this
let params = {
nickname: app.globalData.tempUserInfo.nickName,
avatar: app.globalData.tempUserInfo.avatarUrl
}
login.appLogin().then(res => {
params.code = res.code
return login.authorization(params);
}).then(res => {
uni.hideLoading();
if (res && util.getToken()) {
that.goBackPage()
} else {
uni.showToast({
icon: 'none',
title: res.data.message
})
title: '授权失败,请重新授权',
icon: 'none'
});
this.setLoginStatus()
}
}).catch(res => {
uni.hideLoading()
},
//用户信息存本地
saveUserInfo: async function(res) {
//console.log('用户信息存本地 token:' +res.data.data.token);
// this.$u.vuex('vuex_token', res.data.data.token)
console.log('token','token')
util.setToken(res.data.token)
// uni.setStorage({
// key: 'token',
// data: res.data.token,
// success: function(e) {
// //console.log('保存token 成功'+e);
// }
// });
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2]; //上一个页面
// if (prevPage.route == 'pages/index/index') {
// prevPage.$vm.isRefresh = true;
// }
if(prevPage && prevPage.$vm){
prevPage.$vm.isRefresh = true;
uni.showToast({
title: res.message,
icon: 'none'
});
this.setLoginStatus()
})
},
signupLogin(e) {
var that = this
if (!e || !e.detail || e.detail.errMsg.indexOf('user deny') > -1) {
wx.showModal({
title: '提示',
showCancel: false,
content: '用户未授权不能完成注册'
});
} else {
let params = {
nickname: app.globalData.tempUserInfo.nickName,
avatar: app.globalData.tempUserInfo.avatarUrl,
encryptedData: e.detail.encryptedData,
iv: e.detail.iv
}
uni.navigateBack({
delta:2
login.appLogin().then(res => {
params.code = res.code
return login.signup(params);
}).then(res => {
uni.hideLoading()
if (util.getToken()) {
that.goBackPage()
} else {
this.setLoginStatus(false)
}
}).catch(res => {
uni.hideLoading()
uni.showToast({
title: res.message,
icon: 'none'
});
this.setLoginStatus(false)
})
}
},
},
goBackPage() {
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2]; //上一个页面
if (prevPage && prevPage.$vm) {
prevPage.$vm.isRefresh = true;
}
uni.navigateBack({
delta: 2
})
},
//获取用户手机号
getPhoneNumber: async function(e) {
setLoginStatus(authed = true) {
if (authed) {
this.needAuth = false
uni.setNavigationBarTitle({
title: '登录页'
});
} else {
this.needAuth = true
uni.setNavigationBarTitle({
title: '授权页'
});
}
},
clearTimeout(this.TimeID);
this.TimeID = setTimeout(() => {
//用户授权得到用户的信息
getUserInfo: async function (e) {
//console.log('获取用户手机号')
//console.log(e.detail)
clearTimeout(this.TimeID);
this.TimeID = setTimeout(() => {
//console.log('获取用户信息')
//console.log(e.detail.userInfo)
if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
//this.$u.toast('未授权');
uni.showModal({
title: '授权失败',
content: '请允许获取用户信息的授权',
showCancel: false
});
} else {
this.findByMobile(e)
}
if (e.detail.errMsg == 'getUserInfo:fail auth deny') {
}, 1000);
uni.showModal({
title: '授权失败',
content: '请允许获取用户信息的授权',
showCancel: false
});
} else {
this.getCode()
}
}, 1000);
},
},
//通过手机号获取用户信息
findByMobile: async function(e) {
uni.showLoading({
title: '加载中'
})
const params = {
wxopenid: this.openID,
unionid: this.unionID,
encryptedData: e.detail.encryptedData,
iv: e.detail.iv
}
const res = await this.$u.api.loginWxByPhone(params)
if (res.code == 200) {
//小程序获取code
getCode: async function () {
let that = this
uni.showLoading({
title: '加载中',
})
return new Promise((resolve, reject) => {
console.log(uni.login, 'uni.login(')
uni.login({
// #ifdef MP-ALIPAY
scopes: 'auth_user',
// #endif
success: function (res) {
if (res.code) {
that.getUsersByCode(res.code)
//that.getUnionID(res.code)
//resolve(res.code);
} else {
//login成功,但是没有取到code
reject('未取得code');
}
},
fail: function (res) {
reject('用户授权失败wx.login');
},
complete(res) {
reject('code获取失败');
console.log('code获取失败', res)
uni.hideLoading()
}
});
});
},
//通过code获取用户信息(新接口)
getUsersByCode: async function (code) {
uni.showLoading({
title: '加载中'
})
const params = {
code: code,
}
const res = await this.$u.api.loginWxByUser(params)
if (res.code == 200) {
this.unionID = res.data.user.unionid
this.openID = res.data.user.wxopenid
util.setOpenid(res.data.user.wxopenid)
if (res.data.token) {
uni.showToast({
icon: 'none',
title: '登录成功'
title: '登陆成功'
})
this.saveUserInfo(res)
} else {
uni.showToast({
icon: 'none',
title: res.message
title: '新用户请授权登录'
})
this.isNewUser = true
}
} else {
uni.showToast({
icon: 'none',
title: res.data.message
})
}
uni.hideLoading()
},
//用户信息存本地
saveUserInfo: async function (res) {
//console.log('用户信息存本地 token:' +res.data.data.token);
// this.$u.vuex('vuex_token', res.data.data.token)
console.log('token', 'token')
util.setToken(res.data.token)
// uni.setStorage({
// key: 'token',
// data: res.data.token,
// success: function(e) {
// //console.log('保存token 成功'+e);
// }
// });
let pages = getCurrentPages();
let prevPage = pages[pages.length - 2]; //上一个页面
// if (prevPage.route == 'pages/index/index') {
// prevPage.$vm.isRefresh = true;
// }
if (prevPage && prevPage.$vm) {
prevPage.$vm.isRefresh = true;
}
uni.navigateBack({
delta: 2
})
},
//获取用户手机号
getPhoneNumber: async function (e) {
clearTimeout(this.TimeID);
this.TimeID = setTimeout(() => {
//console.log('获取用户手机号')
//console.log(e.detail)
if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
//this.$u.toast('未授权');
uni.showModal({
title: '授权失败',
content: '请允许获取用户信息的授权',
showCancel: false
});
} else {
this.findByMobile(e)
}
},
//取消点击
cancelClick: function() {
uni.navigateBack({
}, 1000);
},
//通过手机号获取用户信息
findByMobile: async function (e) {
uni.showLoading({
title: '加载中'
})
const params = {
wxopenid: this.openID,
unionid: this.unionID,
encryptedData: e.detail.encryptedData,
iv: e.detail.iv
}
const res = await this.$u.api.loginWxByPhone(params)
if (res.code == 200) {
uni.showToast({
icon: 'none',
title: '登录成功'
})
},
/*
//微信授权
toLogin: async function(data) {
uni.showLoading({
title:'授权中……'
})
let res = await this.$u.api.gowxLogin(data);
console.log('微信授权')
console.log(res)
uni.hideLoading()
if (res.code!==1) {
this.$u.toast(res.msg);
return;
}
if (res.data) {
//this.setLoginStatus()
// this.success(res.data.user.id);
}
},
//获取unionID
getUnionID: async function(code) {
uni.request({
url: getApp().globalData.domain_Name
+'/wxh-support-rest/rest/ssoinfo/getUsersByCode',
method: 'GET',
data: {
code: code,
},
success: (res) => {
console.log('获取unionID 成功')
console.log(res)
if(res.data.code==200){
this.getSSOID(res.data.data.unionid)
}
},
fail: (e) => {
console.log('获取unionID 失败')
console.log(e)
}
})
},
//获取SSOID
getSSOID: async function(unionID) {
uni.request({
url: getApp().globalData.domain_Name
+ '/wxh-support-rest/rest/ssoinfo/v2/findByUnionId',
method: 'GET',
data: {
unionid: unionID,
},
success: (res) => {
console.log('获取SSOID 成功')
console.log(res)
},
fail: (e) => {
console.log('获取SSOID 失败')
console.log(e)
}
})
},
//获取loginCode
getLoginCode: async function() {
uni.request({
url: getApp().globalData.domain_Name
+ '/wxh-support-rest/rest/ssoinfo/v2/getLoginCode',
method: 'GET',
data: {
ssoId: '93140',
},
success: (res) => {
console.log('获取loginCode 成功')
console.log(res)
if(res.data.code==200){
this.getToken(res.data.data.loginCode)
}
},
fail: (e) => {
console.log('获取loginCode 失败')
console.log(e)
}
})
},
//获取token
getToken: async function(loginCode) {
uni.request({
url: getApp().globalData.domain_Name
+ '/wxh-support-rest/rest/worker/login/applets/'
+loginCode,
method: 'GET',
data: {
},
success: (res) => {
console.log('获取token 成功')
console.log(res)
},
fail: (e) => {
console.log('获取token 失败')
console.log(e)
}
})
},
*/
}
this.saveUserInfo(res)
} else {
uni.showToast({
icon: 'none',
title: res.message
})
}
},
//取消点击
cancelClick: function () {
uni.navigateBack({})
},
}
}
</script>
<style>
.backView {
background-color: #FFFFFF;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.backView {
background-color: #FFFFFF;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.noticeView {
background-color: #FFFFFF;
width: 100%;
height: 470rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.noticeView {
background-color: #FFFFFF;
width: 100%;
height: 470rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.noticeImage {
background-color: #FFFFFF;
width: 386rpx;
height: 270rpx;
margin-top: 180rpx;
}
.noticeTitleView{
margin-top: 80rpx;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.noticeTitle{
width: 60%;
font-size: 24rpx;
color: #999999;
text-align: center;
line-height: 40rpx;
}
.noticeImage {
background-color: #FFFFFF;
width: 386rpx;
height: 270rpx;
margin-top: 180rpx;
}
.loginBtn {
background-color: #2272FF;
width: 390rpx;
height: 80rpx;
border-radius: 40rpx;
margin-top: 334rpx;
display: flex;
align-items: center;
justify-content: center;
}
.noticeTitleView {
margin-top: 80rpx;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.cancelView {
width: 100%;
margin-top: 30rpx;
display: flex;
align-items: center;
justify-content: center;
}
.noticeTitle {
width: 60%;
font-size: 24rpx;
color: #999999;
text-align: center;
line-height: 40rpx;
}
.cancelText {
color: #666666;
font-size: 32rpx;
}
.loginBtn {
background-color: #2272FF;
width: 390rpx;
height: 80rpx;
border-radius: 40rpx;
margin-top: 334rpx;
display: flex;
align-items: center;
justify-content: center;
}
.white {
color: #FFFFFF;
}
.cancelView {
width: 100%;
margin-top: 30rpx;
display: flex;
align-items: center;
justify-content: center;
}
.cancelText {
color: #666666;
font-size: 32rpx;
}
.white {
color: #FFFFFF;
}
</style>
......@@ -74,8 +74,6 @@
methods: {
getRelationDictionaryV2: function() {
this.$u.cloudApi.getRelationDictionaryV2().then(res => {
console.log('V2:')
console.log(res)
if (res && res.result) {
this.classifyList = res.result
this.param.classifyId = res.result[0].id
......@@ -123,6 +121,12 @@
handleClick() {
// 点击下一步设置全局拍照品牌品类
const globalData = getApp().globalData
if (!globalData.token) {
uni.navigateTo({
url:'/pages/login/wxlogin'
})
return
}
let keys = ['brandId', 'brandName', 'classifyId', 'systemId']
keys.map(key => {
globalData.photo.product[key] = this[key] || this.param[key]
......
<template>
<view class="backView">
<view class="backView">
<u-loading style="position: absolute;top: 50%;" :show="loading" size="36" mode="flower"></u-loading>
<view class="topView">
<view :class="['topItemView', {'active':activeTop===ikey}]" @click="handleTopItemChange(ikey,item)" v-for="(item,ikey) in dataList" :key="ikey">
<text
......@@ -11,14 +12,14 @@
<view class="right-view-title">拍照项有:</view>
<template v-for="(item,ikey) in rightList">
<view class="rightItemView" @click="rightItemClick(item,ikey)" :key="ikey">
<view :class="['rightContentView', {'active':item.images.length > 0}]">
<view :class="['rightContentView', {'active':item.imageList.length > 0 || item.images.length > 0}]">
<text class="ph-lst-item-index">{{ ikey + 1 }}</text>
<text class="">{{item.name}} ({{item.image_count}}张)</text>
<text class="">{{item.name}}</text>
<image class="ph-list-item-arrow" src="/static/photo/arrow.png"></image>
<!-- <text class="rightContent u-m-t-14 u-m-l-30 u-p-b-30">{{item.describe}}</text> -->
</view>
<view class="rightImageView" v-if="item.images">
<image class="rightImage" v-for="(image, index) in item.images" :src="image" :key="image"
<view class="rightImageView" v-if="item.imageList.length > 0 || item.images.length > 0">
<image class="rightImage" v-for="(image, index) in (item.imageList.length > 0 ? item.imageList : item.images)" :src="image" :key="image"
@click.stop="handleClickImage(item, index)" mode=""></image>
</view>
</view>
......@@ -41,7 +42,7 @@
brand: '',
brandId: '',
dataList: [],
loading: true
}
},
onLoad(e) {
......@@ -70,25 +71,17 @@
},
onShow() {
console.log('onShow 里的rightList:')
console.log(this.rightList)
},
methods: {
getListData: function() {
getListData: function() {
this.loading = true
let that = this
this.$u.cloudApi.getGroupStandardV2({
'token': getApp().globalData.token,
'classify_id': this.classifyId,
'system_id': this.systemId,
'brand_id': this.brandId
}).then(res => {
console.log('获取规范标准数据:')
console.log(res)
}).then(res => {
this.loading = false
if (res && res.result) {
that.handleData(res.result)
}
......@@ -120,14 +113,13 @@
// 点击图片
handleClickImage(item, index) {
uni.previewImage({
urls: item.images,
urls: item.imageList.length > 0 ? item.imageList : item.images,
current:index
})
},
//右侧点击
rightItemClick: function(item, ikey) {
console.log(item,'item')
const photo = getApp().globalData.photo
photo.currentItem = item
uni.navigateTo({
......
<template>
<view>
<view class="contentView">
<image class="pic" :src="files[0]" mode="aspectFill" @click="showPreviewFn"></image>
<image class="pic" :src="files[0]" mode="aspectFit" @click="showPreviewFn"></image>
</view>
<view class="bottomView">
<image class="btn" :src="btn_remake" @click="remakePhoto"></image>
......@@ -137,15 +137,17 @@
// photo.currentItem.
// 当前项的图片显示
// 拍照项张数目增加 等于10张
if(photo.currentItemLength<10){
uni.navigateBack({
delta:1
})
}else{
uni.redirectTo({
url:"pages/photo/list"
})
}
let timer = setTimeout(()=>{
if(photo.currentItemLength<10){
uni.navigateBack({
delta:1
})
}else{
uni.redirectTo({
url:"pages/photo/list"
})
}
},2000)
} else {
uni.showToast({
title:'图片上传失败'
......
<template>
<view class="backView">
<u-loading style="position: absolute;top: 50%;" :show="loading" size="36" mode="flower"></u-loading>
<view class="itemView firstItem">
<view class="itemTitleView">
<text class="itemTitle">保存原图</text>
......@@ -12,33 +13,34 @@
<text class="itemTitle">水印标题</text>
<text class="itemNotice">{{result['lower_right']['title_text'] || '点击可编辑更改'}}</text>
</view>
<switch class="itemSwitch" disabled :checked="result['lower_right']['title_text']"
@change="itemChange({},-1)" color="#007AFF" />
<switch class="itemSwitch" disabled :checked="result['lower_right']['title_text'] != ''"
@click="handleClickTitleSwitch" color="#007AFF" />
</view>
<view class="itemView" v-for="(item,ikey) in itemList" :key="ikey">
<view class="itemTitleView" @click="itemClick(item,ikey)">
<text class="itemTitle">{{item['watemark_text'] || '自定义' + (ikey + 1)}}</text>
<text class="itemNotice">{{item['watemark_value'] || '点击可编辑更改'}}</text>
</view>
<switch class="itemSwitch" :disabled="!item['enable']" :checked="item['enable']"
@change="itemChange(item, ikey)" color="#007AFF" />
<switch class="itemSwitch" :checked="item['enable']" @change="itemChange(item, ikey)" color="#007AFF" />
</view>
<view class="shadowBackView" v-if="isPopShow">
<u-popup border-radius="10" v-model="isPopShow" safe-area-inset-bottom :mask-close-able="false" mode="center"
width="690rp" height="600rpx">
<view class="popCenterView">
<text class="popTitle">设置自定义项</text>
<view class="inputBackView">
<view class="ph-pop-left-view">
<view class="leftInputView">
<input class="leftInput" type="text" v-model="currenItem['watemark_text']" @input="leftInput()"
:disabled="currenItem.type === 'title_text'" placeholder="请输入" maxlength="10" />
<input class="leftInput" type="text" v-model="currenItem['watemark_text']"
@input="leftInput()" :disabled="currenItem.type === 'title_text'" placeholder="请输入"
maxlength="10" />
</view>
<view class="ph-pop-tip-view" v-if="showTipLeft">*必填项</view>
</view>
<view class="ph-pop-mid-view">:</view>
<view>
<view class="rightInputView">
<input class="rightInput" type="text" v-model="currenItem['watemark_value']" @input="rightInput()"
placeholder="请输入内容" maxlength="30" />
<input class="rightInput" type="text" v-model="currenItem['watemark_value']"
@input="rightInput()" placeholder="请输入内容" maxlength="30" />
</view>
<view class="ph-pop-tip-view" v-if="showTipRight">*必填项</view>
</view>
......@@ -54,7 +56,7 @@
</view>
</view>
</view>
</view>
</u-popup>
</view>
</template>
......@@ -76,9 +78,10 @@
'watemark_text': '',
'watemark_value': ''
},
editingItem: {},
showTipLeft: false,
showTipRight: false
editingItem: {},
showTipLeft: false,
showTipRight: false,
loading: true
}
},
computed: {
......@@ -108,66 +111,58 @@
getItemList: function() {
// this.systemId = '79550af260555cc20afb34156c94b32c' // 测试数据
uni.showLoading();
this.$u.cloudApi.getUserWatermark({
this.loading = true
this.$u.cloudApi.getUserWatermark({
'token': getApp().globalData.token,
'system_id': this.systemId
}).then(res => {
console.log(res)
if (res && res.result) {
this.result = res.result
}
this.$nextTick(function() {
uni.hideLoading();
})
this.loading = false
})
},
saveUserWatermark: function() {
uni.showLoading();
this.loading = true
this.$u.cloudApi.saveUserWatermark({
'token': getApp().globalData.token,
'watermark': this.result
}).then(res => {
console.log(res)
if (res.result == true) {
const photo = getApp().globalData.photo
photo.waterSetting = this.result
}
this.$nextTick(function() {
uni.hideLoading();
})
if (res.result == true) {
const photo = getApp().globalData.photo
photo.waterSetting = this.result
}
this.loading = false
})
},
//保存原图 开关
handleOrigineChange: function(e) {
this.result['has_origin'] = !this.result['has_origin']
this.result['has_origin'] = !this.result['has_origin']
this.saveUserWatermark()
},
handleClickTitleSwitch: function(e) {
var string = this.result['lower_right']['title_text'] ? '水印标题不可关闭' : '请先编辑该自定义项'
uni.showToast({
icon: 'none',
title: string
})
},
//自定义 开关
itemChange: function(item, ikey) {
if (ikey === -1) { // 水印标题
// if (this.result['lower_right']['title_text']) {
// 修改
this.saveUserWatermark()
// } else {
// // 弹出修改框
// this.itemClick(item, ikey)
// }
} else { // 其他自定义
// if (item['watemark_value']) {
if (item['watemark_value']) {
// 修改
item['enable'] = !item['enable']
this.saveUserWatermark()
// } else {
// // 弹出修改框
// this.itemClick(item, ikey)
// }
} else {
uni.showToast({
icon: 'none',
title: '请先编辑该自定义项'
})
}
},
......@@ -191,26 +186,26 @@
//左侧输入框
leftInput: function(e) {
if (this.currenItem['watemark_text']) {
this.showTipLeft = false
}
if (this.currenItem['watemark_text']) {
this.showTipLeft = false
}
},
//右侧输入框
rightInput: function(e) {
if (this.currenItem['watemark_value']) {
this.showTipRight = false
if (this.currenItem['watemark_value']) {
this.showTipRight = false
}
},
//自定义弹窗 关闭
popCancelClick: function() {
this.currenItem = {
'watemark_text': '',
'watemark_value': ''
this.isPopShow = false
this.currenItem = {
'watemark_text': '',
'watemark_value': ''
}
this.isPopShow = false
},
//自定义弹窗 保存
......@@ -226,12 +221,12 @@
}
this.saveUserWatermark()
} else {
// 提示
if (!this.currenItem['watemark_text']) {
this.showTipLeft = true
}
if (!this.currenItem['watemark_value']) {
this.showTipRight = true
// 提示
if (!this.currenItem['watemark_text']) {
this.showTipLeft = true
}
if (!this.currenItem['watemark_value']) {
this.showTipRight = true
}
}
......@@ -323,10 +318,6 @@
.popCenterView {
background-color: #FFFFFF;
width: 690rpx;
height: 600rpx;
margin-top: 300rpx;
border-radius: 12rpx;
display: flex;
flex-direction: column;
......@@ -341,13 +332,13 @@
.inputBackView {
margin-top: 52rpx;
width: 100%;
width: 100%;
height: 90rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
display: flex;
justify-content: space-between;
display: flex;
align-items: flex-start;
}
......@@ -355,7 +346,7 @@
width: 220rpx;
height: 72rpx;
border: 2rpx solid #666666;
display: flex;
align-items: center;
justify-content: center;
......@@ -364,17 +355,18 @@
.leftInput {
width: 180rpx;
height: 32rpx;
}
.ph-pop-left-view {
margin-left: 30rpx;
}
.ph-pop-tip-view {
color:#F56C6C;
}
.ph-pop-mid-view {
margin-top: 20rpx;
}
.ph-pop-left-view {
margin-left: 30rpx;
}
.ph-pop-tip-view {
color: #F56C6C;
}
.ph-pop-mid-view {
margin-top: 20rpx;
}
.rightInputView {
......
......@@ -13,10 +13,11 @@
<camera class="camera-box" v-if="cameraChange&&!standardShow" :device-position="cameraInfo.devicePosition"
:flash="cameraInfo.flash" :style="{'height':cameraHeight + 'rpx'}" @error="cameraError">
<cover-view class="mark-box">
<cover-view class="txt u-m-t-30">经度:{{waterInfo.longitude || '正在获取中...'}}</cover-view>
<cover-view class="txt u-m-t-10">维度:{{waterInfo.latitude || '正在获取中...'}}</cover-view>
<cover-view class="txt big" >{{titleTxt}}</cover-view>
<cover-view class="txt" v-for="(txt,index) in settingTxtArr" :key="index">{{txt || '获取中'}}</cover-view>
<!-- <cover-view class="txt u-m-t-10">维度:{{waterInfo.latitude || '正在获取中...'}}</cover-view>
<cover-view class="txt u-m-t-10">地址:{{waterInfo.address || '正在获取中...'}}</cover-view>
<cover-view class="txt u-m-t-10">时间:{{waterInfo.date || '正在获取中...'}}</cover-view>
<cover-view class="txt u-m-t-10">时间:{{waterInfo.date || '正在获取中...'}}</cover-view> -->
</cover-view>
<cover-image class="mark-water" mode="aspectFit" :src="waterInfo.markImage"></cover-image>
</camera>
......@@ -83,6 +84,7 @@
cameraHeight: 1000, // (4 / 3 * 750) 图片比例4:3
ratio: 0,
cameraChange: true,
waterSetting:null,
}
},
onLoad(e) {
......@@ -95,13 +97,45 @@
this.getMarkPath()
this.currentItem = photo.currentItem
},
compute: {
waterSetting() {
// photo.waterSetting
const photo = getApp().globalData.photo
console.log(photo.waterSetting,'photo.waterSetting')
return photo.waterSetting || null
computed: {
titleTxt(){
const waterSetting = this.waterSetting
let txt = ''
if(!waterSetting || !waterSetting.lower_right){
return ''
}
txt = waterSetting.lower_right && waterSetting.lower_right.title_text || ''
console.log(txt,'title_text','waterSetting',waterSetting)
return txt
},
settingTxtArr(){
let arr = []
// 包含经纬度
const waterInfo = this.waterInfo
arr = ['经度嘟嘟嘟激励大家了杰拉德杰拉德了大量聚集的决定立即登录: ' + waterInfo.longitude, '纬度: ' + waterInfo.latitude, '地址: ' + waterInfo.address, '时间: ' +
waterInfo.date
]
let settingTxtArr = []
const typeArr = ['经度', '纬度', '地址', '时间']
const waterSetting = this.waterSetting
if (!waterSetting || !waterSetting.lower_right || !waterSetting.lower_right.body) {
return arr
}
const settingArr = waterSetting.lower_right.body
settingArr.map(item => {
const idx = typeArr.indexOf(item.watemark_type)
if (item.enable && (idx > -1 || (item.watemark_value && item.watemark_text))) {
if (idx > -1) {
settingTxtArr.push(arr[idx])
} else {
settingTxtArr.push(item.watemark_text + ': ' + item.watemark_value)
}
}
})
console.log(settingTxtArr,'settingTxtArr')
return settingTxtArr
}
},
watch: {
'authSetting.camera'(val) {
......@@ -126,7 +160,7 @@
methods: {
goBack() {
uni.navigateBack({
delta:2
delta: 1
})
// uni.redirectTo({
// url: '/pages/photo/list'
......@@ -141,10 +175,10 @@
},
updateTime() {
this.waterInfo.date = this.getTime()
let timer = setTimeout(() => {
clearTimeout(timer);
this.updateTime()
}, 1000)
// let timer = setTimeout(() => {
// clearTimeout(timer);
// this.updateTime()
// }, 1000)
},
setCameraInfo(type) {
// 设置相机前置后置、闪关灯等
......@@ -168,6 +202,7 @@
const globalData = getApp().globalData
this.navHeight = globalData.navHeight
this.ratio = globalData.screenHeight / globalData.rpxScreenHeight
this.waterSetting = getApp().globalData.photo.waterSetting
// this.cameraHeight = globalData.rpxScreenHeight
},
baiduLocation() {
......@@ -291,16 +326,6 @@
})
},
getDrawTxtArr() {
// 获取绘制数组
let arr = []
// 包含经纬度
const waterInfo = this.waterInfo
arr = ['经度: ' + waterInfo.longitude, '维度: ' + waterInfo.latitude, '地址: ' + waterInfo.address, '时间: ' +
waterInfo.date
]
return arr
},
/* ---------------------- 拍照流程 ---------------------- */
// 第一步:拍照
takePhoto() {
......@@ -317,34 +342,48 @@
title: '数据处理中...',
icon: 'loading'
})
const waterSetting = this.waterSetting
const globalTempPath = getApp().globalData.photo.tempPath
const ratio = this.ratio
let canvasWidth = this.cameraWidth * ratio
let canvasHeight = this.cameraHeight * ratio
const waterInfo = this.waterInfo
this.showImage = true
const drawTxtArr = this.getDrawTxtArr()
const settingTxtArr = this.settingTxtArr
//将原图画到canvas上面
let canvas = uni.createCanvasContext("canvas", this)
canvas.rect(0, 0, canvasWidth, canvasHeight)
canvas.drawImage(tempPath, 0, 0, canvasWidth, canvasHeight)
// this.canvas.draw()
//加入 水印文字
canvas.setFontSize(14)
canvas.setFillStyle('#f2f2f2')
let h = 1
let txtHeight = 18
for (let i = 0; i < drawTxtArr.length; i++) {
const txt = drawTxtArr[i]
canvas.fillText(txt, 10, canvasHeight - txtHeight * h++);
let h = 1
//加入 水印文字
for (let i = settingTxtArr.length-1; i >=0; i--) {
txtHeight = 18
canvas.setFontSize(14)
canvas.setFillStyle('#f2f2f2')
let txt = settingTxtArr[i]
if(txt.length>14){
canvas.fillText(txt.substr(0,14), 10, canvasHeight - txtHeight * h++);
canvas.fillText(txt.substr(14,14), 10, canvasHeight - txtHeight * h++);
}else{
canvas.fillText(txt, 10, canvasHeight - txtHeight * h++);
}
// canvas.fillText(txt, 10, canvasHeight - txtHeight * h++);
}
const title = this.titleTxt
if(title){
txtHeight = 20
canvas.setFontSize(20)
canvas.setFillStyle('#f2f2f2')
canvas.fillText(title, 10, canvasHeight - txtHeight * h++);
}
// canvas.fillText('经度: ' + waterInfo.longitude, 10, canvasHeight - txtHeight * h++);
// canvas.fillText('维度: ' + waterInfo.latitude, 10, canvasHeight - txtHeight * h++);
// canvas.fillText('地址: ' + waterInfo.address, 10, canvasHeight - txtHeight * h++);
// canvas.fillText('时间: ' + waterInfo.date, 10, canvasHeight - txtHeight * h++);
//加入 水印图片
canvas.drawImage(this.tempImgs.markImage, canvasWidth / 2 - 100, canvasHeight / 2 - 25, 200, 50)
if(this.waterSetting && this.waterSetting.mid_text){
//加入 水印图片
canvas.drawImage(this.tempImgs.markImage, canvasWidth / 2 - 100, canvasHeight / 2 - 25, 200, 50)
}
// canvas.drawImage(this.tempImgs.markImage, canvasWidth / 2 - 100, canvasHeight / 2 - 25, 200, 50)
canvas.draw(false,
setTimeout(() => {
uni.canvasToTempFilePath({
......@@ -455,11 +494,18 @@
.mark-box {
position: absolute;
left: 0;
bottom: 20rpx;
bottom: 0;
padding: 20rpx;
.txt {
margin-top:5rpx;
line-height: 40rpx;
white-space: normal;
font-size: 28rpx;
color: #fff;
.big{
font-size: 32rpx;
}
}
}
......
......@@ -4,7 +4,7 @@ const app = getApp();
function appLogin() {
return new Promise(function (resolve, reject) {
uni.login({
success: res => {
success(res) {
if (!res.code) {
uni.hideLoading();
uni.showModal({
......@@ -17,7 +17,7 @@ function appLogin() {
fail() {
uni.hideLoading();
uni.showModal({
content: '登录失败',
content: '小程序登录失败',
showCancel: false
});
reject();
......@@ -28,51 +28,51 @@ function appLogin() {
// 小程序授权
function authorization(data) {
return new Promise(function (resolve, reject) {
data = data || {}
const res = await app.$u.api.loginWechatAuth(data)
if (res && res.status) {
let data = res.data
app.setUserData(data)
uni.hideLoading();
resolve(res);
} else () {
uni.hideLoading();
uni.showModal({
title: '请求失败',
content: err.message,
showCancel: false
});
reject();
},
return new Promise(async function (resolve, reject) {
const res = await app.$vm.$u.api.loginWechatAuth(data)
if (res) {
if (res.code == 200 && res.data) {
app.setUserData(res.data)
resolve(res);
} else {
uni.showModal({
title: '用户登录失败',
content: res.message,
showCancel: false
});
reject(res);
}
} else {
uni.showModal({
title: '请求失败',
content: res.message
});
}
});
}
// 小程序注册
function signup(data) {
return new Promise(function (resolve, reject) {
const res = await app.$u.api.loginWechatAuth(data)
api.request('login/signup-login', {
method: "post",
data: {
code: data.code,
encryptedData: data.encryptedData,
iv: data.iv
},
success: function (res) {
if (res && res.status) {
let data = res.data
app.setUserData(data)
resolve(res);
}else{
if(!res.status && res.message==='用户授权信息失效,请重新授权'){
api.setAuthToken('')
}
resolve(res);
}
return new Promise(async function (resolve, reject) {
const res = await app.$vm.$u.api.loginWechatAuth(data)
if (res) {
if (res.code == 200 && res.data) {
app.setUserData(res.data)
resolve(res);
} else {
uni.showModal({
title: '用户授权失败',
content: res.message,
showCancel: false
});
reject(res);
}
});
} else {
uni.showModal({
title: '请求失败',
content: res.message
});
}
});
}
......
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