Commit cc2a9e59 by hank

列表编辑,以及增加子项

parent 63069502
NODE_ENV='development' NODE_ENV='development'
VUE_APP_BASE_API='http://server.bdideal.com' VUE_APP_BASE_API='http://172.16.4.219:8090'
\ No newline at end of file \ No newline at end of file
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
</div> </div>
</template> </template>
<script> <script>
// import { getCookie } from '@/api/cookie'
export default { export default {
data() { data() {
return { return {
...@@ -32,7 +33,6 @@ export default { ...@@ -32,7 +33,6 @@ export default {
} }
}, },
created () { created () {
// var self = this
if (window.history && window.history.pushState) { if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL) history.pushState(null, null, document.URL)
window.addEventListener( window.addEventListener(
......
import { get } from './index'
export function getCookie() {
return get('/test/get/cookie')
}
...@@ -18,7 +18,7 @@ export default { ...@@ -18,7 +18,7 @@ export default {
}, },
zIndex: { zIndex: {
type: Number, type: Number,
default: 1 default: 2
}, },
className: { className: {
type: String, type: String,
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
<div class="device-detail-container"> <div class="device-detail-container">
<NavBar title="添加新设备" left-arrow></NavBar> <NavBar title="添加新设备" left-arrow></NavBar>
<div class="pin-add-container"> <div class="pin-add-container">
<div class="tips">请输入PIN码(区分大小写:)</div> <div class="tips">请输入PIN码(区分大小写:)</div>
<input v-model.trim="pinCode" class type="text" placeholder="请输入PIN码(区分大小写:)" /> <input v-model.trim="pinCode" class type="text" placeholder="请输入PIN码(区分大小写:)" />
<div class="why">什么是pin码</div> <div class="why">什么是pin码</div>
<br /> <br />
<van-button class="enter-btn" type="info" @click="addDeviceToPin" size="large">确定</van-button> <van-button class="enter-btn" type="info" @click="addDeviceToPin" size="large">确定</van-button>
</div> </div>
<!-- <van-tabs v-model="active" sticky animated ellipsis color="#1989fa"> <!-- <van-tabs v-model="active" sticky animated ellipsis color="#1989fa">
<van-tab title="扫码添加"></van-tab> <van-tab title="扫码添加"></van-tab>
<van-tab title="PIN码添加"> <van-tab title="PIN码添加">
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<br /> <br />
<van-button class="enter-btn" type="info" @click="addDeviceToPin" size="large">确定</van-button> <van-button class="enter-btn" type="info" @click="addDeviceToPin" size="large">确定</van-button>
</div> </div>
</van-tab> --> </van-tab>-->
<!-- </van-tabs> --> <!-- </van-tabs> -->
</div> </div>
</template> </template>
...@@ -45,24 +45,31 @@ export default { ...@@ -45,24 +45,31 @@ export default {
callback() {}, callback() {},
addDeviceToPin() { addDeviceToPin() {
if (!this.pinCode) { if (!this.pinCode) {
this.$toast('请输入要添加设备的PIN码') this.$toast("请输入要添加设备的PIN码");
return return;
} }
this.$dialog.confirm({ this.$dialog
title: "添加设备", .confirm({
message: `是否将设备 ${this.pinCode} 添加至我的设备` title: "添加设备",
}) message: `是否将设备 ${this.pinCode} 添加至我的设备`
})
.then(() => { .then(() => {
// on confirm // on confirm
addDeviceFromPin(this.pinCode).then(() => { addDeviceFromPin(this.pinCode).then(() => {
this.$toast('添加成功') this.$toast("添加成功");
this.$router.back() this.$toast.loading({
duration: 2000,
mask: true,
message: "加载中..."
});
setTimeout(() => {
this.$router.back();
}, 2000);
}); });
}) })
.catch(() => { .catch(() => {
// on cancel // on cancel
}); });
} }
} }
}; };
......
...@@ -65,9 +65,14 @@ ...@@ -65,9 +65,14 @@
</template> </template>
<script> <script>
import { getDeviceList, deleteDevice, addDeviceFromToken } from "@/api/device.js"; import {
getDeviceList,
deleteDevice,
addDeviceFromToken
} from "@/api/device.js";
import JSBridge from "@/utils/jssdk"; import JSBridge from "@/utils/jssdk";
import { setTimeout } from "timers";
export default { export default {
name: "Films", name: "Films",
data() { data() {
...@@ -166,7 +171,14 @@ export default { ...@@ -166,7 +171,14 @@ export default {
// on confirm // on confirm
addDeviceFromToken(str).then(() => { addDeviceFromToken(str).then(() => {
this.$toast("添加成功"); this.$toast("添加成功");
this.onRefresh() this.$toast.loading({
duration: 2000,
mask: true,
message: "加载中..."
});
setTimeout(() => {
this.onRefresh();
}, 2000);
}); });
}) })
.catch(() => { .catch(() => {
......
<template> <template>
<Sticky> <Sticky style="z-index: 10;">
<van-nav-bar <van-nav-bar
:title="title" :title="title"
:left-arrow="typeof leftArrow !== 'undefined' ? true : false" :left-arrow="typeof leftArrow !== 'undefined' ? true : false"
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<div class="name">Vmatrix</div> <div class="name">Vmatrix</div>
<div class="login-content"> <div class="login-content">
<van-cell-group> <van-cell-group>
<van-field complate v-model.trim="loginForm.phone" left-icon="phone-o" placeholder="请输入手机号" /> <van-field type="number" complate v-model.trim="loginForm.phone" left-icon="phone-o" placeholder="请输入手机号" />
<van-field v-model.trim="loginForm.code" left-icon="smile-comment-o" placeholder="请输入验证码"> <van-field type="number" v-model.trim="loginForm.code" left-icon="smile-comment-o" placeholder="请输入验证码">
<span slot="button" class="code" @click="sendCode"> <span slot="button" class="code" @click="sendCode">
<span v-if="time === 0">获取验证码</span> <span v-if="time === 0">获取验证码</span>
<span v-else>{{time}}s</span> <span v-else>{{time}}s</span>
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
this.isload = false; this.isload = false;
window.localStorage.setItem("login", JSON.stringify(this.loginForm)); window.localStorage.setItem("login", JSON.stringify(this.loginForm));
this.$router.replace({ this.$router.replace({
path: "/" path: "/tempaltes"
}); });
}) })
.catch(() => { .catch(() => {
......
...@@ -32,27 +32,36 @@ ...@@ -32,27 +32,36 @@
:key="index2" :key="index2"
> >
<div class="btn-con"> <div class="btn-con">
<span> <span>序号{{index2}}</span>
序号{{index2}} <span class="del-btn" @click="deleteItem(index2, schemaData[item.dataKey])">删除</span>
</span>
<span class="del-btn" @click="deleteItem(index2, schemaData[item.dataKey])">
删除
</span>
</div> </div>
<div class="list-item-list" v-for="(item3, index3) in item2" :key="index3"> <div class="list-item-list" v-for="(item3, index3) in item2" :key="index3">
<input
v-if="index3 != 'index'" <div v-if="(index3 != 'schemaIndex' && index3 != 'index')">
<input
v-if="item.modelSchema[isSchemaIndex(item2)][index3].type === 'text'"
:placeholder="item.modelSchema[isSchemaIndex(item2)][index3].description"
class="edit-input" class="edit-input"
type="text" type="text"
v-model="item2[index3]" v-model="item2[index3]"
@keyup="valueChange2()" @keyup="valueChange2()"
/> />
</div>
</div> </div>
</div> </div>
<div class="create-btn-container">
<van-button class="create-btn" type="info" @click="addItem(item)">添加</van-button>
</div>
</div> </div>
<button v-if="item.type === 'image'">上传</button> <van-uploader
<button v-if="item.type === 'video'">上传</button> result-type="dataUrl"
v-if="item.type == 'image'"
@click.native="uploadItem(item.dataKey)"
:after-read="uploadAfter"
>
<van-button icon="photo" type="info">上传图片</van-button>
</van-uploader>
</div> </div>
</van-collapse-item> </van-collapse-item>
</van-collapse> </van-collapse>
...@@ -60,6 +69,8 @@ ...@@ -60,6 +69,8 @@
</template> </template>
<script> <script>
import { upload } from "@/api/api";
export default { export default {
name: "editMenu", name: "editMenu",
props: { props: {
...@@ -75,7 +86,8 @@ export default { ...@@ -75,7 +86,8 @@ export default {
created() {}, created() {},
data() { data() {
return { return {
activeName: "" activeName: "",
dataKey: ""
}; };
}, },
methods: { methods: {
...@@ -83,8 +95,46 @@ export default { ...@@ -83,8 +95,46 @@ export default {
console.log(this.schemaData); console.log(this.schemaData);
this.$emit("setList", this.schemaData); this.$emit("setList", this.schemaData);
}, },
uploadItem(key) {
alert(key);
this.dataKey = key;
},
isSchemaIndex(item) {
return item["schemaIndex"] ? item["schemaIndex"] : 0;
},
toObj(obj) {
console.log(obj)
return JSON.parse(JSON.stringify(obj));
},
addItem(item) {
if (item.modelSchema && item.modelSchema.length === 1) {
var keys = Object.keys(item.modelSchema[0]);
var obj = {};
keys.map(function(item) {
obj[item] = "";
});
this.schemaData[item.dataKey].push(obj);
} else {
alert('选择类型添加,敬请期待!')
}
console.log(item);
},
uploadAfter(file) {
// console.log(file, upload);
upload(file.file)
.then(res => {
console.log(res.data);
console.log(this.dataKey);
this.schemaData[this.dataKey].value = res.data.data;
this.valueChange2();
})
.catch(e => {
console.log(e);
this.$toast("上传失败");
});
},
deleteItem(index, arr) { deleteItem(index, arr) {
arr.splice(index, 1) arr.splice(index, 1);
this.$emit("setList", this.schemaData); this.$emit("setList", this.schemaData);
} }
} }
...@@ -135,7 +185,7 @@ input { ...@@ -135,7 +185,7 @@ input {
border: none; border: none;
} }
.edit-input { .edit-input {
width: 90%; width: 97%;
border: 1px solid #d0d0d0; border: 1px solid #d0d0d0;
color: #333333; color: #333333;
} }
......
...@@ -289,8 +289,7 @@ export default { ...@@ -289,8 +289,7 @@ export default {
vm.isEdited = true; vm.isEdited = true;
} }
if (typeof e.data === "object" && e.data["type"] == "getList") { if (typeof e.data === "object" && e.data["type"] == "getList") {
console.log(e.data.pages); vm.templateData.listData = e.data.pages;
// vm.templateData.listData = e.data.pages;
// console.log("12121321321"); // console.log("12121321321");
} }
// var color = e.data; // var color = e.data;
...@@ -315,10 +314,7 @@ export default { ...@@ -315,10 +314,7 @@ export default {
this.show = false; this.show = false;
this.pageViews = false; this.pageViews = false;
} else { } else {
var a = confirm("确认退出页面"); next();
if (a) {
next();
}
} }
}, },
mounted() {}, mounted() {},
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
@load="getData" @load="getData"
class="iframe" class="iframe"
v-show="loaded" v-show="loaded"
scrolling="no"
:src="templateData.frameUrl+'?isPreview=1'" :src="templateData.frameUrl+'?isPreview=1'"
frameborder="0" frameborder="0"
></iframe> ></iframe>
......
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 sign in to comment