Lufaneng 9 months ago
parent 7e2a9e7594
commit b5e5a0f56f

@ -19,7 +19,8 @@
"path": "pages/index/index",
"needLogin": true,
"style": {
"navigationBarTitleText": "电梯图纸生成平台"
"navigationBarTitleText": "电梯图纸生成平台",
"enablePullDownRefresh":true
}
},
{

@ -18,12 +18,12 @@
type: 'flex',
num: 2,
gap: '20rpx',
children:[{
children: [{
type: 'custom',
num: 1,
gap: '20rpx',
style: 'width: 300rpx;height:200rpx;marginLeft: 10rpx;'
},{
}, {
type: 'custom',
num: 1,
gap: '20rpx',
@ -31,17 +31,16 @@
}]
}]"></uv-skeletons>
<view class="template-grid" v-else>
<view class="template-item" :class="{ active: currentTemplate.id === item.id }"
@click="selectTemplate(item)" v-for="item in templateList" :key="item.id">
<view class="tag" v-if="item.price_cents">¥ {{item.price_cents / 100}}</view>
<view class="template-name">{{item.name}}</view>
<view class="template-desc">{{item.description}}</view>
<view class="template-item" :class="{ active: currentTemplate.id === item.id }" @click="selectTemplate(item)" v-for="item in templateList" :key="item.id">
<view class="tag" v-if="item.price_cents">¥ {{ item.price_cents / 100 }}</view>
<view class="template-name">{{ item.name }}</view>
<view class="template-desc">{{ item.description }}</view>
</view>
</view>
</view>
<!-- 设置参数 -->
<view class="section">
<view class="section" v-if="has_access">
<view class="section-title">设置参数</view>
<uv-skeletons v-if="loading" :loading="loading" :skeleton="[{
type: 'line',
@ -49,11 +48,9 @@
gap: '20rpx'
}]"></uv-skeletons>
<view class="form" v-else>
<uv-form labelAlign="left" labelWidth="auto" labelPosition="left" :model="formField" :rules="rules"
ref="form">
<uv-form-item :prop="item.key" :label="item.name + ''" v-for="item in (currentTemplate.params?.filter(item => item.enabled) || [])">
<uv-input :type="item.type === 'number' ? 'digit' : 'text'" v-model="item.value" color="#000"
border="bottom" :placeholderStyle="{ color: '#666778' }" placeholder="请输入"></uv-input>
<uv-form labelAlign="left" labelWidth="auto" labelPosition="left" :model="formField" :rules="rules" ref="form">
<uv-form-item :prop="item.name" :label="item.name + ''" v-for="item in (currentTemplate.params?.filter(item => item.enabled) || [])">
<uv-input @click="openPicker(item)" :readonly="item.type === 'select'" :type="item.type === 'number' ? 'digit' : 'text'" v-model="item.value" color="#000" border="bottom" :placeholderStyle="{ color: '#666778' }" placeholder="请输入"></uv-input>
</uv-form-item>
<!-- <uv-form-item prop="password" label="载重kg">
<uv-input
@ -115,48 +112,84 @@
</view>
</view>
<view class="section" v-else>
<div class="status">状态{{ currentTemplate.access_status }}</div>
<uv-button text="申请权限" color="#3F70FF"></uv-button>
</view>
<!-- 底部按钮 -->
<view class="bottom-actions">
<uv-button :loading="generating" @click="() => modalRef.open()" text="生成图纸" color="#3F70FF"></uv-button>
<uv-button :loading="generating" @click="modalRefOpen" text="生成图纸" color="#3F70FF"></uv-button>
<uv-button @click="viewHistory" text="查看记录"></uv-button>
</view>
<uv-modal ref="modalRef" showCancelButton content='确定生成图纸?' @confirm="confirmGenerate"></uv-modal>
<uv-picker ref="picker" :columns="columns" @confirm="confirm"></uv-picker>
</view>
</template>
<script setup>
import {
import {
ref,
onMounted
} from "vue";
import {
} from "vue";
import {
onShow,
onLoad,
onShareAppMessage,
onShareTimeline,
onReachBottom,
} from "@dcloudio/uni-app";
import {
onPullDownRefresh
} from "@dcloudio/uni-app";
import {
useAuthStore,
useUserStore
} from "@/store";
import RPC from "@/utils/request";
import {
} from "@/store";
import RPC from "@/utils/request";
import {
usePermission
} from "@/hooks/usePermission";
} from "@/hooks/usePermission";
const authStore = useAuthStore();
const userStore = useUserStore();
const loading = ref(false)
const authStore = useAuthStore();
const userStore = useUserStore();
const loading = ref(false)
const has_access = ref(false)
const applyRef = ref(null)
const modalRefOpen = () => {
if(!has_access.value) {
uni.showToast({
title: "模板无权限使用",
icon: "error",
});
return
}
modalRef.value.open()
}
const generating = ref(false);
const modalRef = ref(null)
const confirmGenerate = () => {
const currentParams = ref(null)
const openPicker = item => {
console.log(item)
if (item.type !== 'select') return
currentParams.value = item
columns.value = [item.options.split(',')]
picker.value.open()
}
const picker = ref(null)
const columns = ref([[]])
const confirm = val => {
console.log(val)
currentParams.value.value = val.value[0]
}
const generating = ref(false);
const modalRef = ref(null)
const confirmGenerate = () => {
const params = {}
currentTemplate.value.params?.filter(item => item.enabled).forEach(item => {
params[item.name] = item.value
})
RPC.post('/template_create_task', {template_id:currentTemplate.value.id,template_data:params}).then(() => {
RPC.post('/template_create_task', { template_id: currentTemplate.value.id, template_data: params }).then(() => {
uni.showToast({
title: "图纸开始生成",
@ -169,12 +202,12 @@
}, 1000)
modalRef.value.close()
})
}
const templateList = ref([])
const currentTemplate = ref({})
const getList = () => {
}
const templateList = ref([])
const currentTemplate = ref({})
const getList = () => {
loading.value = true
RPC.post('/template/list', {
RPC.post('/template/list_with_access', {
page: 1,
limit: -1
}).then(res => {
@ -183,20 +216,20 @@
}).finally(() => {
loading.value = false
})
}
getList()
}
//
const selectTemplate = (item) => {
//
const selectTemplate = (item) => {
currentTemplate.value = JSON.parse(JSON.stringify(item));
};
has_access.value = currentTemplate.value.has_access
};
const form = ref(null);
const formField = ref({
const form = ref(null);
const formField = ref({
phone: "",
password: "",
});
const rules = ref({
});
const rules = ref({
// 'phone': {
// required: true,
// message: '',
@ -207,37 +240,38 @@
// message: '',
// trigger: ['blur', 'change']
// }
});
});
//
const viewHistory = () => {
//
const viewHistory = () => {
uni.navigateTo({
url: "/pagesA/generate-record/generate-record",
});
};
};
//
onShareAppMessage((data) => {
//
onShareAppMessage((data) => {
console.log("🚀 ~ onShareAppMessage ~ data:", data);
return {
title: "电梯图纸生成平台",
path: "/pages/index/index",
};
});
});
//
onShareTimeline((data) => {
//
onShareTimeline((data) => {
console.log("🚀 ~ onShareTimeline ~ data:", data);
return {
title: "电梯图纸生成平台",
query: "a=1&b=2",
};
});
});
onLoad(() => {
onLoad(() => {
console.log("index-onLoad");
});
onShow(async () => {
});
onShow(async () => {
getList()
console.log("test page onShow");
const hasPermission = await usePermission();
console.log(hasPermission ? "已登录" : "跳转登录");
@ -246,11 +280,15 @@
authStore.signOut();
uni.$uv.route("/pages/login/login");
}
});
});
onPullDownRefresh(() => {
getList()
uni.stopPullDownRefresh();
});
</script>
<style lang="scss" scoped>
.container {
.container {
font-size: 14px;
min-height: 100vh;
background-color: #f8f8f8;
@ -260,9 +298,9 @@
padding-bottom: 102px;
/* H5环境下需要更多空间 (50px按钮 + 50px tabBar + 2px间距) */
/* #endif */
}
}
.header-section {
.header-section {
position: relative;
height: 200px;
overflow: hidden;
@ -293,9 +331,9 @@
font-size: 12px;
}
}
}
}
.section {
.section {
margin: 16px;
background: white;
border-radius: 12px;
@ -307,9 +345,9 @@
color: #333;
margin-bottom: 16px;
}
}
}
.template-grid {
.template-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
@ -323,6 +361,7 @@
text-align: center;
transition: all 0.3s;
position: relative;
.tag {
position: absolute;
top: 0px;
@ -351,9 +390,9 @@
color: #999;
}
}
}
}
.bottom-actions {
.bottom-actions {
z-index: 999;
position: fixed;
bottom: 0;
@ -373,13 +412,13 @@
bottom: 50px;
/* H5环境下给tabBar留出空间 */
/* #endif */
}
}
</style>
<style lang="scss">
.bottom-actions {
.bottom-actions {
.uv-button-wrapper {
width: 48%;
}
}
}
</style>
Loading…
Cancel
Save