平板端快衣店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

269 lines
8.2 KiB

<template>
<view>
<view class="type-popup" style="margin-bottom: 0;border-radius: 0;padding: 15rpx;">
<view style="height: 80rpx;font-size: 36rpx;font-weight: bold;line-height: 80rpx;text-align: center;">
<uni-easyinput v-model="printName" placeholder="请输入模板名称"></uni-easyinput>
</view>
<view v-for="(item,index) in shippList" :key="index" style="display: flex;flex-direction: column;margin-top: 20rpx;background: #fff;border-radius: 10px;padding: 10px;">
<view style='display: flex;'>
<view style="color: #333;width: 40%;">
<uni-easyinput trim='none' v-model="item.name" placeholder="请输入标签名称"></uni-easyinput>
</view>
<view style="height: 60rpx;width: 5%;text-align: center;line-height: 60rpx;">:</view>
<view style="color: #333;width: 50%;margin: 0 auto 20rpx;">
<uni-easyinput v-model="item.value" placeholder="请输入标签值"></uni-easyinput>
</view>
<view @tap="delItem(index)" style="width:12%;margin-left: 20rpx;margin-top: 10rpx;">
<uni-icons color="red" type="minus" size="26"></uni-icons>
</view>
</view>
<view style="display: flex;">
<view @tap="addIcon(index,'left')" style="margin-top: 5px;width: 30%;height: 60rpx;line-height: 60rpx;background: #088FEB;text-align: center;color: #fff;border-radius: 5px;">
左侧添加图标
</view>
<view @longpress="delIcon(index,index1,'left')" v-for="(item1,index1) in item.leftIcon" :key="index1">
<img :src="item1" alt="" style="width: 60rpx;height: 60rpx;margin:10rpx 0 0 10rpx;"/>
</view>
</view>
<view style="display: flex;">
<view @tap="addIcon(index,'right')" style="margin-top: 5px;width: 30%;height: 60rpx;line-height: 60rpx;background: #088FEB;text-align: center;color: #fff;border-radius: 5px;">
右侧添加图标
</view>
<view @longpress="delIcon(index,index1,'right')" v-for="(item1,index1) in item.rightIcon" :key="index1" style="">
<img :src="item1" alt="" style="width: 60rpx;height: 60rpx;margin:10rpx 0 0 10rpx;"/>
</view>
</view>
<view style='display: flex;margin-top: 20rpx;'>
<radio-group @change="discountChange(index,$event)" style="display: flex;width:41%;">
<label class="uni-list-cell uni-list-cell-pd" v-for="(item1, index1) in items"
:key="item1.value" style="margin-right:0">
<view>
<radio :value="item1.value" :checked="item.modelLeft == item1.value" />
</view>
<view style="width: 100rpx;">{{item1.name}}</view>
</label>
</radio-group>
<radio-group @change="discountChange1(index,$event)" style="display: flex;">
<label class="uni-list-cell uni-list-cell-pd" v-for="(item2, index2) in items2"
:key="item2.value" style="margin-right:0">
<view>
<radio :value="item2.value" :checked="item.modelBlod == item2.value" />
</view>
<view style="width: 100rpx;">{{item2.name}}</view>
</label>
</radio-group>
</view>
</view>
<view @tap="addShippList" style="text-align: right;height: 80rpx;line-height: 80rpx;padding-right: 20rpx;color: #088FEB;font-size: 30rpx;">新增一条</view>
<view @tap="goAddClass"
style="width: 100%;height: 70rpx;line-height: 70rpx;text-align: center;border-radius: 0;background: linear-gradient(90deg, #60F3FF, #088FEB);color: #fff;">
<view>确认</view>
</view>
</view>
<!-- 洗涤图标展示框 -->
<uni-popup ref="showIconPopup" background-color="#fff">
<view class="popup-pay-content">
<view class="popup-pay-title">
<text>选择洗涤图标</text>
<uni-icons @tap='$refs.showIconPopup.close()' type="closeempty" color='red' size="16"
style="height:40rpx;line-height: 40rpx;position: absolute !important;bottom:0;right: 30rpx;"></uni-icons>
</view>
<view style="height:900rpx;overflow: scroll;">
<view @tap="checkIcon(item)" v-for="(item,index) in iconList" :key="index" style="display: flex;flex-direction: column;text-align: center;width: 30%;float: left;margin-right: 3%;height: 180rpx;padding-top: 40rpx;">
<img :src="item.value" alt="" style="width: 60rpx;height: 60rpx;background-size: 100%;margin-top: 20rpx;display: inline-block;margin: 0 auto;"/>
<text>{{item.text}}</text>
</view>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
import {
washingInstructions
} from '@/utils/global.js'
export default {
data() {
return {
shippList:[],
categoryId:'',
printName:'',
shipId:'',
discountCurrent:'left',
items: [{
value: 'left',
name: '靠左'
},
{
value: 'right',
name: '居中'
}
],
discountCurrent2:'blod',
items2: [{
value: 'blod',
name: '加粗'
},
{
value: 'notblod',
name: '不加粗'
}
],
iconList:[]
}
},
onLoad(option) {
this.iconList = washingInstructions()
if(option){
try{
let item = JSON.parse(option.item)
this.shipId = item.id
this.printName = item.printName
this.shippList = JSON.parse(item.content)
for(let i=0;i<this.shippList.length;i++){
if(this.shippList[i].leftIcon == undefined){
this.shippList[i].leftIcon = []
}
if(this.shippList[i].rightIcon == undefined){
this.shippList[i].rightIcon = []
}
}
this.$forceUpdate()
}catch(e){
}
}
},
methods: {
delIcon(index,index1,type){
var that = this;
uni.showModal({
title: "提示",
content: "确定删除此图标吗?",
success: function(res) {
if (res.confirm) {
if(type == 'left'){
that.shippList[index].leftIcon.splice(index1, 1);
}else{
that.shippList[index].rightIcon.splice(index1, 1);
}
}
that.$forceUpdate()
}
})
},
checkIcon(item){
if(this.listType == 'left'){
this.shippList[this.listIndex].leftIcon.push(item.value)
}else{
this.shippList[this.listIndex].rightIcon.push(item.value)
}
console.log(this.shippList)
this.$forceUpdate()
this.$refs.showIconPopup.close()
},
addIcon(index,type){
this.listIndex = index;
this.listType = type
this.$refs.showIconPopup.open('bottom')
},
delItem(index) {
let that = this;
uni.showModal({
title: "提示",
content: "确定要删除吗?",
success: function(res) {
if (res.confirm) {
that.shippList.splice(index, 1)
}
}
})
},
discountChange1(index,e) {
this.shippList[index].modelBlod = e.detail.value
},
discountChange(index,e) {
this.shippList[index].modelLeft = e.detail.value
},
topAddShip(){
this.printName = ''
this.shipId = ''
this.shippList = []
this.addShippList()
this.$refs.getaPopup.open()
},
addShippList(){
let data = {
name:'',
value:'',
modelLeft:'left',
modelBlod:'blod',
leftIcon:[],
rightIcon:[]
}
this.shippList.push(data)
this.$forceUpdate()
},
goAddClass(){
for(let i = 0 ; i < this.shippList.length; i++){
if(this.shippList[i].name == ''){
this.tui.toast('请输入标签名称')
return
}
}
let data = JSON.stringify(this.shippList)
if(this.shipId != ''){
this.tui.request("/app/shopprint/update", "POST", {
printName:this.printName,
id:this.shipId,
content:data
}, false, false).then((res) => {
if (res.code == 200) {
this.tui.toast('修改成功')
this.printName = ''
this.shipId = ''
this.$refs.getaPopup.close()
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
}else{
this.tui.request("/app/shopprint/add", "POST", {
printName:this.printName,
shopId:uni.getStorageSync('shopId'),
content:data
}, false, false).then((res) => {
if (res.code == 200) {
this.tui.toast('新增成功')
} else {
this.tui.toast(res.message)
}
}).catch((res) => {})
}
setTimeout(res=>{
uni.navigateBack({
delta: 1
})
},300)
}
}
}
</script>
<style>
.popup-pay-content {
align-items: center;
justify-content: center;
padding: 15px;
height: 1000rpx;
background-color: #fff;
}
.popup-pay-title {
font-size: 36rpx;
font-weight: bold;
text-align: center;
position: relative;
}
</style>