完善投票编辑模式及收藏/历史列表兜底展示
This commit is contained in:
+24
-15
@@ -58,7 +58,7 @@
|
||||
@submit="handleSubmit"
|
||||
:start-year="2000"
|
||||
:end-year="2099"
|
||||
:time-init="1688860800000"
|
||||
:time-init="defaultTime"
|
||||
:time-hide="[true, true, true, true, true, true]"
|
||||
:time-label="['年', '月', '日', '时', '分', '秒']"
|
||||
/>
|
||||
@@ -68,7 +68,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ref, reactive, onLoad } from 'vue'
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
@@ -79,24 +79,34 @@
|
||||
const select = ref(0)
|
||||
const voteTitle = ref("")
|
||||
const pageType = ref("add")
|
||||
const defaultTime = ref(Date.now())
|
||||
const voteLst = ref([
|
||||
{ value: "" },
|
||||
{ value: "" },
|
||||
{ value: "" },
|
||||
])
|
||||
|
||||
onMounted(() => {
|
||||
// 模拟 onLoad
|
||||
})
|
||||
|
||||
function generateRandomCode() {
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
||||
let code = ''
|
||||
for (let i = 0; i < 24; i++) {
|
||||
code += chars.charAt(Math.floor(Math.random() * chars.length))
|
||||
onLoad((options) => {
|
||||
if (options.type === "edit") {
|
||||
pageType.value = "edit"
|
||||
let index = uni.getStorageSync("selectIndex")
|
||||
let cms = uni.getStorageSync("cms")
|
||||
if (cms && cms.cmsLst && cms.cmsLst[index] && cms.cmsLst[index].vote) {
|
||||
const vote = cms.cmsLst[index].vote
|
||||
voteTitle.value = vote.voteTitle || ""
|
||||
vote_id.value = vote.vote_id || ""
|
||||
voteLst.value = vote.voteLst && vote.voteLst.length
|
||||
? vote.voteLst.map(i => ({ value: i.value || "" }))
|
||||
: [{ value: "" }]
|
||||
let typeIndex = array.value.indexOf(vote.type)
|
||||
select.value = typeIndex >= 0 ? typeIndex : 0
|
||||
birthday.value = vote.datetime || ""
|
||||
if (vote.datetime) {
|
||||
defaultTime.value = new Date(vote.datetime.replace(/-/g, '/')).getTime() || Date.now()
|
||||
}
|
||||
}
|
||||
}
|
||||
return code
|
||||
}
|
||||
})
|
||||
|
||||
function openDatetimePicker() {
|
||||
myPicker.value.show()
|
||||
@@ -152,7 +162,6 @@
|
||||
} else {
|
||||
vote.selectValue = []
|
||||
}
|
||||
vote.selectValu = false
|
||||
if (pageType.value === "add") {
|
||||
cms.cmsLst.splice(index, 0, {
|
||||
type: "vote",
|
||||
@@ -192,8 +201,8 @@
|
||||
select,
|
||||
voteTitle,
|
||||
pageType,
|
||||
defaultTime,
|
||||
voteLst,
|
||||
generateRandomCode,
|
||||
openDatetimePicker,
|
||||
handleSubmit,
|
||||
bindPickerChange,
|
||||
|
||||
Reference in New Issue
Block a user