Commit 1ed284c2 authored by Facius's avatar Facius

水印设置页面交互和接口调试

parent 2b1099d2
......@@ -127,10 +127,12 @@
{
"path": "pages/photo/setting",
"style": {
"navigationBarTitleText": "水印设置",
"navigationBarBackgroundColor": "#333333",
"navigationBarTextStyle": "#FFFFFF",
"disableScroll": true
"navigationBarTitleText": "水印设置",
"navigationBarBackgroundColor":"#FFFFFF",
"backgroundColor":"#F4F5F7"
// "navigationBarBackgroundColor": "#333333",
// "navigationBarTextStyle": "#FFFFFF",
// "disableScroll": true
}
},
{
......
<template>
<view class="backView">
<view class="firstItemView">
<view class="itemTitleView ">
<text class="itemTitle">保存原图</text>
<text class="itemNotice">拍照后另保存一张无水印的图片</text>
</view>
<switch class="itemSwitch" :checked="isSaveOrigine" @change="saveOrigineChange" color="#007AFF" style="transform:scale(0.8)"/>
</view>
<view class="itemView" v-for="(item,ikey) in itemList":key="ikey">
<view class="itemTitleView" @click="itemClick(item,ikey)">
<text class="itemTitle">{{item.title}}</text>
<text class="itemNotice">{{item.notice}}</text>
</view>
<switch class="itemSwitch" :checked="item.isSelect" @change="itemChange" color="#007AFF" style="transform:scale(0.8)"/>
</view>
<view class="shadowBackView" v-if="isPopShow">
<view class="popCenterView">
<text class="popTitle">设置自定义项</text>
<view class="inputBackView">
<view class="leftInputView">
<input class="leftInput" type="text" value="" placeholder="请输入" @input="leftInput"/>
</view>
:
<view class="rightInputView">
<input class="rightInput" type="text" value="" placeholder="请输入内容" @input="rightInput"/>
</view>
</view>
<text class="popNoticeText u-m-t-40">示例:</text>
<text class="popNoticeText">工程队名称:蓝天工程队</text>
<view class="popBtnView">
<view class="popCancelBtn" @click="popCancelClick()">
<text class="popBtnText">取消</text>
</view>
<view class="popSaveBtn" @click="popSaveClick()">
<text class="popBtnText">保存</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
isSaveOrigine:true,
itemList:[],
isPopShow:false,
icon_close_new:''
}
},
onLoad(e) {
getApp().trackPage('水印设置页')
this.icon_close_new = getApp().globalData.icon_close_new
if(e && e.product_code){
this.product_code = e.product_code
}
this.getItemList()
},
methods: {
getItemList: function () {
this.itemList = [
{
title:'自定义1',
notice:'点击可编辑更改',
isSelect:false
},
{
title:'自定义2',
notice:'点击可编辑更改',
isSelect:true
},
{
title:'自定义3',
notice:'点击可编辑更改',
isSelect:false
},
{
title:'自定义4',
notice:'点击可编辑更改',
isSelect:false
},
{
title:'自定义5',
notice:'点击可编辑更改',
isSelect:false
}
]
},
//保存原图 开关
saveOrigineChange: function(e) {
console.log('保存原图 开关 发生 change 事件,携带值为', e.target.value)
},
//自定义 开关
itemChange: function(e) {
console.log('自定义 开关 发生 change 事件,携带值为', e.target.value)
},
//自定义 点击
itemClick: function (item,ikey) {
console.log('自定义 开关 发生 click 事件,携带值为', item,ikey)
this.isPopShow = true
},
//左侧输入框
leftInput: function (e){
console.log('左侧输入框 发生 input 事件,携带值为', e.detail.value)
},
//右侧输入框
rightInput: function (e){
console.log('右侧输入框 发生 input 事件,携带值为', e.detail.value)
},
//自定义弹窗 关闭
popCancelClick: function () {
this.isPopShow = false
},
//自定义弹窗 保存
popSaveClick: function () {
this.isPopShow = false
}
}
}
</script>
<style>
.backView{
background-color: #FAFAFA;
position: absolute;
top: 0;
left: 0;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.firstItemView{
background-color: #FFFFFF;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding-top: 80rpx;
padding-bottom: 80rpx;
border-bottom: 2rpx solid #F4F5F7;
}
.itemView{
background-color: #FFFFFF;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding-top: 54rpx;
padding-bottom: 54rpx;
}
.itemTitleView{
background-color: #FFFFFF;
width: 80%;
display: flex;
flex-direction: column;
padding-left: 30rpx;
}
.itemTitle{
font-size: 32rpx;
font-weight: bold;
color: #333333;
}
.itemNotice{
font-size: 26rpx;
font-weight: bold;
color: #666666;
margin-top: 4rpx;
}
.itemSwitch{
margin-right: 30rpx;
}
.shadowBackView{
background-color: rgba(0,0,0,0.5);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.popCenterView{
background-color: #FFFFFF;
width: 690rpx;
height: 600rpx;
margin-top: 300rpx;
border-radius: 12rpx;
display: flex;
flex-direction: column;
}
.popTitle{
font-size: 36rpx;
font-weight: bold;
margin-top: 50rpx;
padding-left: 30rpx;
}
.inputBackView{
margin-top: 52rpx;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.leftInputView{
width: 220rpx;
height: 72rpx;
border: 2rpx solid #666666;
margin-left: 30rpx;
display: flex;
align-items: center;
justify-content: center;
}
.leftInput{
width: 180rpx;
height: 32rpx;
}
.rightInputView{
width: 360rpx;
height: 72rpx;
border: 2rpx solid #666666;
margin-right: 30rpx;
display: flex;
align-items: center;
justify-content: center;
}
.rightInput{
width: 320rpx;
height: 32rpx;
}
.popNoticeText{
font-size: 26rpx;
color: #666666;
padding-left: 30rpx;
}
.popBtnView{
margin-top: 110rpx;
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.popCancelBtn{
background-color: #D1D4D4;
width: 280rpx;
height: 96rpx;
border-radius: 48rpx;
margin-left: 40rpx;
display: flex;
align-items: center;
justify-content: center;
}
.popSaveBtn{
background-color: #2272FF;
width: 280rpx;
height: 96rpx;
border-radius: 48rpx;
margin-right: 40rpx;
display: flex;
align-items: center;
justify-content: center;
}
.popBtnText{
font-size: 32rpx;
color: #FFFFFF;
font-weight: 600;
}
<template>
<view class="backView">
<view class="itemView firstItem">
<view class="itemTitleView">
<text class="itemTitle">保存原图</text>
<text class="itemNotice">拍照后另保存一张无水印的图片</text>
</view>
<switch class="itemSwitch" :checked="result['has_origin']" @change="handleOrigineChange" color="#007AFF"
style="transform:scale(0.8)" />
</view>
<view class="itemView" v-if="showTitleSwitch">
<view class="itemTitleView" @click="itemClick({},-1)">
<text class="itemTitle">水印标题</text>
<text class="itemNotice">{{result['lower_right']['title_text'] || '点击可编辑更改'}}</text>
</view>
<switch class="itemSwitch" :checked="result['lower_right']['title_text']" @change="itemChange({},-1)"
color="#007AFF" style="transform:scale(0.8)" />
</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" :checked="item['watemark_value']" @change="itemChange(item, ikey)"
color="#007AFF" style="transform:scale(0.8)" />
</view>
<view class="shadowBackView" v-if="isPopShow">
<view class="popCenterView">
<text class="popTitle">设置自定义项</text>
<view class="inputBackView">
<view class="leftInputView">
<input class="leftInput" type="text" v-model="currenItem['watemark_text']"
:disabled="currenItem.type === 'title_text'" placeholder="请输入" maxlength="10" />
</view>
:
<view class="rightInputView">
<input class="rightInput" type="text" v-model="currenItem['watemark_value']" placeholder="请输入内容"
maxlength="30" />
</view>
</view>
<text class="popNoticeText u-m-t-40">示例:</text>
<text class="popNoticeText">工程队名称:蓝天工程队</text>
<view class="popBtnView">
<view class="popCancelBtn" @click="popCancelClick()">
<text class="popBtnText">取消</text>
</view>
<view class="popSaveBtn" @click="popSaveClick()">
<text class="popBtnText">保存</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
systemId: '',
isSaveOrigine: true,
isPopShow: false,
icon_close_new: '',
result: {
has_origin: true,
lower_right: {
body: []
}
},
currenItem: {
'watemark_text': '',
'watemark_value': ''
},
editingItem: {}
}
},
computed: {
itemList() {
if (this.result['lower_right']) {
var arr = this.result['lower_right']['body']
return arr.filter((item) => {
return item.watemark_type === '备注'
})
} else {
return []
}
},
showTitleSwitch() {
return this.result['lower_right'].hasOwnProperty('title_text')
}
},
onLoad(e) {
getApp().trackPage('水印设置页')
this.icon_close_new = getApp().globalData.icon_close_new
if (e && e.systemId) {
this.systemId = e.systemId
}
this.getItemList()
},
methods: {
getItemList: function() {
this.systemId = '79550af260555cc20afb34156c94b32c' // 测试数据
uni.showLoading();
this.$u.cloudApi.getUserWatermark({
'system_id': this.systemId
}).then(res => {
console.log(res)
if (res && res.result) {
this.result = res.result
}
this.$nextTick(function() {
uni.hideLoading();
})
})
},
saveUserWatermark: function() {
uni.showLoading();
this.$u.cloudApi.saveUserWatermark({
'token': getApp().globalData.token,
'watermark': this.result
}).then(res => {
console.log(res)
this.$nextTick(function() {
uni.hideLoading();
})
})
},
//保存原图 开关
handleOrigineChange: function(e) {
this.result['has_origin'] = !this.result['has_origin']
console.log('保存原图 开关 发生 change 事件,携带值为', this.result['has_origin'])
},
//自定义 开关
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']) {
// 修改
this.saveUserWatermark()
} else {
// 弹出修改框
this.itemClick(item, ikey)
}
}
},
//自定义 点击
itemClick: function(item, ikey) {
if (ikey === -1) {
this.currenItem = {
'watemark_text': '水印标题',
'watemark_value': this.result['lower_right']['title_text'],
'type': 'title_text'
}
} else {
this.editingItem = item
this.currenItem = {
...item
}
}
this.isPopShow = true
},
//左侧输入框
leftInput: function(e) {
console.log('左侧输入框 发生 input 事件,携带值为', e.detail.value)
},
//右侧输入框
rightInput: function(e) {
console.log('右侧输入框 发生 input 事件,携带值为', e.detail.value)
},
//自定义弹窗 关闭
popCancelClick: function() {
this.currenItem = {
'watemark_text': '',
'watemark_value': ''
}
this.isPopShow = false
},
//自定义弹窗 保存
popSaveClick: function() {
this.isPopShow = false
debugger
if (this.currenItem.type === 'title_text') {
this.result['lower_right']['title_text'] = this.currenItem['watemark_value']
} else {
this.editingItem['watemark_text'] = this.currenItem['watemark_text']
this.editingItem['watemark_value'] = this.currenItem['watemark_value']
}
this.saveUserWatermark()
}
}
}
</script>
<style>
.backView {
background-color: #FAFAFA;
position: absolute;
top: 0;
left: 0;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
/*
.firstItemView{
background-color: #FFFFFF;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding-top: 80rpx;
padding-bottom: 80rpx;
border-bottom: 2rpx solid #F4F5F7;
} */
.itemView {
background-color: #FFFFFF;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding-top: 54rpx;
padding-bottom: 54rpx;
}
.itemView.firstItem {
border-bottom: 2rpx solid #F4F5F7;
}
.itemTitleView {
background-color: #FFFFFF;
width: 80%;
display: flex;
flex-direction: column;
padding-left: 30rpx;
}
.itemTitle {
font-size: 32rpx;
font-weight: bold;
color: #333333;
}
.itemNotice {
font-size: 26rpx;
font-weight: bold;
color: #666666;
margin-top: 4rpx;
}
.itemSwitch {
margin-right: 30rpx;
}
.shadowBackView {
background-color: rgba(0, 0, 0, 0.5);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.popCenterView {
background-color: #FFFFFF;
width: 690rpx;
height: 600rpx;
margin-top: 300rpx;
border-radius: 12rpx;
display: flex;
flex-direction: column;
}
.popTitle {
font-size: 36rpx;
font-weight: bold;
margin-top: 50rpx;
padding-left: 30rpx;
}
.inputBackView {
margin-top: 52rpx;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.leftInputView {
width: 220rpx;
height: 72rpx;
border: 2rpx solid #666666;
margin-left: 30rpx;
display: flex;
align-items: center;
justify-content: center;
}
.leftInput {
width: 180rpx;
height: 32rpx;
}
.rightInputView {
width: 360rpx;
height: 72rpx;
border: 2rpx solid #666666;
margin-right: 30rpx;
display: flex;
align-items: center;
justify-content: center;
}
.rightInput {
width: 320rpx;
height: 32rpx;
}
.popNoticeText {
font-size: 26rpx;
color: #666666;
padding-left: 30rpx;
}
.popBtnView {
margin-top: 110rpx;
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
.popCancelBtn {
background-color: #D1D4D4;
width: 280rpx;
height: 96rpx;
border-radius: 48rpx;
margin-left: 40rpx;
display: flex;
align-items: center;
justify-content: center;
}
.popSaveBtn {
background-color: #2272FF;
width: 280rpx;
height: 96rpx;
border-radius: 48rpx;
margin-right: 40rpx;
display: flex;
align-items: center;
justify-content: center;
}
.popBtnText {
font-size: 32rpx;
color: #FFFFFF;
font-weight: 600;
}
</style>
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