Commit 8ac9f6ed authored by xhx's avatar xhx

fix:调整

parent ed9fd412
......@@ -23,5 +23,7 @@ module.exports = {
"@typescript-eslint"
],
"rules": {
"no-unused-vars": "off",
"vue/no-unused-components": "off"
}
};
\ No newline at end of file
......@@ -45,4 +45,6 @@ http://121.40.18.70:9056/
location /api {
proxy_pass http://172.16.100.93:8901/;
}
```
\ No newline at end of file
```
#### 代码调整,当前版本尚未测试
\ No newline at end of file
<template>
<div id="app">
<keep-alive include="Layout,Mine,MinePage|Layout,Initiate,UserInitiate|Layout,Initiate,Founder">
<router-view v-if="!cabilityChecked"></router-view>
<app-wait v-else-if="cabilityChecked === 2" />
<app-res v-else-if="cabilityChecked === 3" :type="type" :res="res" :text="text" />
<app-error v-else-if="cabilityChecked === 4" />
<van-loading v-else class="w-full h-full flex items-center justify-center bg-app-drak-1" type="spinner" />
</keep-alive>
<router-view />
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import { mapState } from 'vuex'
import { Loading } from 'vant'
import { getCurrentBTYAddress } from '@/utils/bridge' // 币钱包环境
// import { test } from '@/constants/test' // 本地测试
// import {routes} from '@/router/index'
// import { permissionList } from '@/constants/permission'
Vue.use(Loading)
import { test } from '@/constants/test' // 本地测试
export default Vue.extend({
components: {
'app-wait': () => import('@/components/Wait.vue'),
'app-res': () => import('@/components/Result.vue'),
'app-error': () => import('@/views/Error.vue')
},
name: 'Home',
data(){
return{
// cabilityChecked: this.$store.getters['app/loadingStatus']
}
},
computed: {
cabilityChecked() {
return this.$store.state.app.loading
},
...mapState({
isLoading: state => (state as any).app.loading
}),
type() {
return this.$store.state.app.type
},
res() {
return this.$store.state.app.res
},
text() {
return this.$store.state.app.text1
}
},
async mounted() {
// this.$store.commit('app/SET_ADDRESS', test.addr)
getCurrentBTYAddress('',(res: any) => {
console.log('res', res)
this.$store.commit('app/SET_ADDRESS', res)
// const _routes = routes[0].children as NavItem[]
// if (permissionList.indexOf(res) > -1) {
// _routes[2].meta.text = '发起活动'
// }
// console.log(_routes)
})
// window.onresize = function () {
// const ua = navigator.userAgent;
// const isAndroid = /android|Android/i.test(ua); //android终端
// if(!isAndroid) {
// console.log('resize')
// if ((document.activeElement as any).tagName == "INPUT" || (document.activeElement as any).tagName == "TEXTAREA") {
// setTimeout(function () {
// const top = (document.activeElement as any).getBoundingClientRect().top;
// console.log('top',top)
// window.scrollTo(0,top);
// }, 0);
// }
// }
// }
// const config ={
// url: 'https://mainnet.infura.io/v3/',
// id:'ab632ac39b8d4aff98d65429af748550'
// }
// let a = ETH_PROVIDER(config)
// const fee = await a.provider.eth.getBalance('0xfc55a938a349dc526a4d633a8395a82ca661820f')
// console.log(fee);
// this.appReady()
},
methods:{
appReady(){
// web3.ready,
// Vue.prototype.$ETHweb3 = ETH_PROVIDER('b186ce03905e4f759fb7243fac5fc0df')
// db.ready,
// this.cabilityChecked = true
}
},
});
</script>
<template>
<div class="w-full h-screen bg-homeBanner bg-top bg-contain bg-no-repeat bg-app-drak-1 flex flex-col items-center justify-center">
<template v-if="type === 1">
<img class="w-24 h-24 mb-6" src="@/assets/success.png" alt="">
<p class="text-lg text-white mb-7">提交成功</p>
<p class="text-sm text-white mb-8">您的{{ text || '提案' }}已经提交成功,并且已扣除0.002BTY</p>
<button class="w-11/12 h-10 bg-app-blue-2 text-white rounded-lg" @click="hide">确 定</button>
</template>
<template v-else>
<img class="w-24 h-24 mb-6" src="@/assets/fail.png" alt="">
<p class="text-lg text-white mb-7">提交失败</p>
<p class="text-sm text-white mb-8">{{ res }}</p>
<button class="w-11/12 h-10 bg-app-blue-2 text-white rounded-lg" @click="hide">确 定</button>
</template>
</div>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
props: {
type: {
default: 1,
type: Number
},
res: {
type: String
},
text: {
type: String
}
},
// computed: {
// text() {
// return this.$store.state.app.text
// }
// },
methods: {
hide() {
this.$store.commit('app/HIDE_LOADING')
}
}
})
</script>
\ No newline at end of file
<template>
<div class="options py-3">
<div class="flex justify-between">
<div class="inpu-title">选项管理</div>
<div class=" text-xs text-app-red"></div>
</div>
<div class="option-items">
<div class="option-item flex" v-for="(i,index) in value" :key="index">
<div @click="deleteClicked(i,index)">
<app-icon customize type='icon-delete-s' size='24px' color='#BF463D' ></app-icon>
</div>
<div class="pl-3 flex-grow">
<textarea
v-model="value[index]"
type="text"
placeholder="请输入"
maxlength="100"
rows="2"
cols="50"
class="w-full text-sm py-2 px-3 mt-2 rounded text-app-blue-1"
@blur="setVal"/>
</div>
</div>
</div>
<div class="flex mt-5 justify-center gap-x-1">
<div class='self-start'>
<app-icon customize type='icon-zengjia' size='20px' color='#6870f1' ></app-icon>
<div class="options py-3">
<div class="flex justify-between">
<div class="inpu-title">选项管理</div>
<div class="text-xs text-app-red"></div>
</div>
<div class="option-items">
<div class="option-item flex" v-for="(i, index) in value" :key="index">
<div @click="deleteClicked(i, index)">
<app-icon
customize
type="icon-delete-s"
size="24px"
color="#BF463D"
></app-icon>
</div>
<div class='leading-6' @click="addOption">添加选项</div>
<div class="pl-3 flex-grow">
<textarea
v-model="value[index]['name']"
type="text"
placeholder="请输入"
maxlength="100"
rows="2"
cols="50"
class="w-full text-sm py-2 px-3 mt-2 rounded text-app-blue-1"
@blur="setVal"
/>
</div>
</div>
</div>
<div class="flex mt-5 justify-center gap-x-1">
<div class="self-start">
<app-icon
customize
type="icon-zengjia"
size="20px"
color="#6870f1"
></app-icon>
</div>
<div class="leading-6" @click="addOption">添加选项</div>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import Vue from "vue";
// import {remove as _remove} from 'lodash'
export default Vue.extend({
components:{
'app-icon':()=>import('@/components/common/Icon.vue'),
components: {
"app-icon": () => import("@/components/common/Icon.vue"),
},
props: {
options: {
type: Array,
},
props: {
options: {
type: Array
}
},
data() {
return {
value: [{ name: "" }, { name: "" }] as { name: string }[],
};
},
methods: {
deleteClicked(item: any, Click_index: any) {
if (this.value.length > 2) {
this.value.splice(Click_index, 1);
} else {
this.$toast.fail("选项不能少于两个");
}
this.$emit("getVal", this.value);
},
data(){
return{
value:['',''] as string[]
}
addOption() {
if (this.value.length >= 10) return;
this.value.push({ name: "" });
this.$emit("getVal", this.value);
},
methods:{
deleteClicked(item:any,Click_index:any){
if(this.value.length>2){
this.value.splice(Click_index,1)
}else{
this.$toast.fail('选项不能少于两个')
}
this.$emit('getVal', this.value)
},
addOption(){
if (this.value.length >= 10) return
this.value.push('')
this.$emit('getVal', this.value)
},
setVal() {
const set = new Set(this.value)
if (set.size !== this.value.length) {
this.$toast('已存在重复项')
}
this.$emit('getVal', this.value)
}
setVal() {
const set = new Set(this.value);
if (set.size !== this.value.length) {
this.$toast("已存在重复项");
}
this.$emit("getVal", this.value);
},
watch: {
options(n) {
if (n.length > 0) {
this.value = []
for (let item of n) {
this.value.push(item.name)
}
}
},
created() {
const options = this.options as Array<{name: string}>
this.value = options.length < 2 ? [{ name: "" }, { name: "" }] : options
},
watch: {
options(n) {
if (n.length >= 2) {
this.value = [];
for (let item of n) {
this.value.push(item);
}
}
} else {
this.value = [{ name: "" }, { name: "" }]
}
},
},
});
</script>
......@@ -3,75 +3,117 @@
<div class="px-4 py-5 border border-app-blue-3 border-solid rounded-lg">
<p class="text-sm mb-2.5">社区名称</p>
<div>
<input class="w-full h-10 rounded-lg mb-5 px-3 text-sm text-gray-600 x-input" placeholder="请输入社区名称" maxlength="10" v-model="communityName" />
<input
class="w-full h-10 rounded-lg mb-5 px-3 text-sm text-gray-600 x-input"
placeholder="请输入社区名称"
maxlength="10"
v-model="form.name"
/>
</div>
<p class="text-sm mb-2.5">社区简介</p>
<div>
<textarea class="w-full rounded-lg px-3 pt-2 text-sm text-gray-600 x-input x-area" placeholder="这里写社区描述简介(500字以内)" maxlength="500" v-model="intro"></textarea>
<textarea
class="
w-full
rounded-lg
px-3
pt-2
text-sm text-gray-600
x-input x-area
"
placeholder="这里写社区描述简介(500字以内)"
maxlength="500"
v-model="form.desc"
></textarea>
</div>
</div>
<div class="mt-5 flex justify-between">
<button class="w-2/5 py-2 bg-app-blue-2 text-center text-sm font-medium rounded-lg" @click="cancel">取消</button>
<button class="w-2/5 py-2 bg-app-blue-2 text-center text-sm font-medium rounded-lg" @click="submit">确认报名</button>
<button
class="
w-2/5
py-2
bg-app-blue-2
text-center text-sm
font-medium
rounded-lg
"
@click="cancel"
>
取消
</button>
<button
class="
w-2/5
py-2
bg-app-blue-2
text-center text-sm
font-medium
rounded-lg
"
@click="submit"
>
确认报名
</button>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue'
import { Toast } from 'vant'
import { service } from '@/service/index'
import Vue from "vue";
import { Toast } from "vant";
import { service } from "@/service/index";
const baseForm = () => {
return {
name: "",
desc: "",
};
};
export default Vue.extend({
name: 'AttendForm',
name: "AttendForm",
props: {
attendShow: {
type: Boolean,
default: false
default: false,
},
voteId: {
type: String
}
type: String,
},
},
data() {
return {
communityName: '',
intro: ''
}
form: baseForm(),
};
},
methods: {
submit() {
if (!this.communityName || !this.intro) {
Toast('请先填写表单信息')
if (!this.form.name || !this.form.desc) {
Toast("请先填写表单信息");
} else {
this.$store.commit('app/SET_TEXT', '报名的社区')
service.attendVote({
voteId: this.voteId as string,
name: this.communityName,
desc: this.intro
}, () => {
this.communityName = ''
this.intro = ''
this.$emit('submitForm', true)
this.$store.commit('app/SET_TEXT1', '社区')
// this.$router.push('/Home')
})
// .then(res => {
// console.log(res)
// this.communityName = ''
// this.intro = ''
// this.$emit('submitForm', true)
// })
// this.$store.commit("app/SET_COMMITTEXT", "报名的社区");
service.attendVote(
{
voteId: this.voteId as string,
...this.form,
},
{
request: { text: '报名的社区' },
result: {
text: '社区'
}
},
() => {
this.form = baseForm()
this.$emit("submitForm", true);
// this.$store.commit("app/SET_RESULTTEXT", "社区");
}
);
}
},
cancel() {
this.$emit('submitForm', false)
}
}
})
this.$emit("submitForm", false);
},
},
});
</script>
<style scoped>
</style>
<template>
<div class="home-banner relative">
<div class="pt-5">
<img class="w-48 object-fill mx-auto" src="@/assets/home/banner-img.png" alt="">
<img
class="w-48 object-fill mx-auto"
src="@/assets/home/banner-img.png"
alt=""
/>
</div>
<div
v-if="!showPart"
class="header-box w-full h-auto flex flex-col items-center justify-center"
class="header-box w-full h-auto flex flex-col items-center justify-center"
:class="{ 'opacity-0': scrollHide }"
>
<app-btn v-if="status < 3" @btnClicked='attendActivity' text="立即报名" class=" bg-app-cyan text-app-blue-1 px-5"></app-btn>
<p v-if="voteType === 1" class="text-center text-xs mb-2">距离本轮投票开始还有约</p>
<p v-if="voteType === 2" class="text-center text-xs mb-2">距离本轮投票结束还剩约</p>
<p v-if="voteType === 3" class="text-center text-xs mb-2">本轮投票已结束</p>
>
<app-btn
v-if="status < 3"
@btnClicked="$emit('showAttendForm', true)"
text="立即报名"
class="bg-app-cyan text-app-blue-1 px-5"
></app-btn>
<p class="text-center text-xs mb-2">{{ states[voteType] }}</p>
<!-- <p v-if="voteType === 1" class="text-center text-xs mb-2">
距离本轮投票开始还有约
</p>
<p v-if="voteType === 2" class="text-center text-xs mb-2">
距离本轮投票结束还剩约
</p>
<p v-if="voteType === 3" class="text-center text-xs mb-2">
本轮投票已结束
</p> -->
<div class="px-10">
<Timebox :times="timeStamp" />
</div>
......@@ -23,71 +36,63 @@
</template>
<script lang="ts">
import Vue from 'vue'
import Timebox from '@/components/Timebox.vue'
import Vue from "vue";
import Timebox from "@/components/Timebox.vue";
import { VoteStateEnum } from '@/types/VoteState'
export default Vue.extend({
components: {
Timebox,
'app-btn':()=>import('@/components/common/Btn.vue')
"app-btn": () => import("@/components/common/Btn.vue"),
},
name: 'HomeBanner',
name: "HomeBanner",
data() {
return {
canAttend: true,
clientWidth: 0,
clientHeight: 0,
top: '50%',
right: '4px'
top: "50%",
right: "4px",
};
},
computed: {
states(): any {
const stateObj = {
[VoteStateEnum.START]: '距离本轮投票开始还有约',
[VoteStateEnum.PENDING]: '距离本轮投票结束还剩约',
[VoteStateEnum.END]: '本轮投票已结束'
}
return stateObj
}
},
props: {
showBtn: {
showPart: {
type: Boolean,
default: true
},
showPart:{
type: Boolean
},
scrollHide: {
type: Boolean,
default: false
default: false,
},
timeStamp: {
type: String
type: String,
},
voteType: {
type: Number,
default: 1
default: 1,
},
status: {
type: Number
}
},
methods: {
attendActivity() {
this.$emit('showAttendForm', true)
type: Number,
},
},
mounted() {
// const _now = new Date().getTime()
// const range = +_now - +this.timeStamp
// if (range )
}
})
});
</script>
<style lang="css" scoped>
input {
outline: none;
}
input {
outline: none;
}
.imgbtn {
/* z-index: 10000; */
}
.imgbtn {
/* z-index: 10000; */
}
</style>
\ No newline at end of file
......@@ -85,6 +85,7 @@ import Vue from 'vue'
import AppIcon from '@/components/common/Icon.vue'
import { Dialog, Toast, Uploader } from 'vant'
import { scanQRCode } from '@/utils/bridge'
import { mapMutations, mapState } from 'vuex'
// import { service } from '@/service/index'
Vue.use(Dialog)
Vue.use(Uploader)
......@@ -97,7 +98,6 @@ export default Vue.extend({
return {
show: false,
address: '',
type: 'add',
num: 0
}
},
......@@ -108,27 +108,29 @@ export default Vue.extend({
}
},
computed: {
members() {
return this.$store.state.app.members
}
...mapState({
members: (state: any) => state.app.form.members,
form: (state: any) => state.app.form
})
},
methods: {
showDialog() {
this.show = true
this.type = 'add'
this.init()
},
init() {
this.address = ''
},
scan() {
scanQRCode('',(res: any) => {
// console.log('res', res)
scanQRCode('', (res: any) => {
this.address = res
})
},
delItem(o: any, i: number) {
this.$store.commit('app/REMOVE_MEMBER', i)
const subMember = JSON.parse(JSON.stringify(this.members))
subMember.splice(i, 1)
this.$store.commit('app/SET_FORM', { ...this.form, members: subMember })
// this.$store.commit('app/REMOVE_MEMBER', i)
// console.log(this.$store.state)
},
downloadModel() {
......@@ -142,24 +144,13 @@ export default Vue.extend({
name: '成员地址',
addr: this.address
}
this.$store.commit('app/ADD_MEMBER', params)
// if (this.type === 'add') {
// const that = this as any
// service.addMember(params, function(v: any) {
// console.log(v)
// that.$store.commit('app/HIDE_LOADING')
// that.$store.commit('app/SET_RES')
// if (v.data.result.receipt.ty === 1) {
// // Toast('失败')
// that.$store.commit('app/SET_TYPE', 2)
// that.$store.commit('app/SET_RESULT', v.data.result.receipt.logs[0].log)
// } else {
// // Toast('成功')
// that.$store.commit('app/SET_TYPE', 1)
// that.$store.commit('app/ADD_MEMBER', params)
// }
// })
// }
const subMember = JSON.parse(JSON.stringify(this.members))
console.log(subMember, 'asdhjkasd---------')
subMember.push(params)
// this.setForm({ ...this.form, members: subMember })
this.$store.commit('app/SET_FORM', { ...this.form, members: subMember })
console.log(this.form)
// this.$store.commit('app/ADD_MEMBER', params)
}
},
})
......
import Vue from 'vue'
import XLoading from './Loading.vue'
const v = new Vue({
const $vue = new Vue({
render(createElement) {
return createElement(XLoading)
}
})
v.$mount()
$vue.$mount()
document.body.appendChild(v.$el)
document.body.appendChild($vue.$el)
const load = v.$children[0]
const load = $vue.$children[0]
function showLoading() {
(load as any).showLoading()
......
......@@ -47,6 +47,8 @@ import Card from '@/components/Card.vue'
import CardTwo from '@/components/Card_two.vue'
import { service } from '@/service/index'
import { Dialog } from 'vant'
import loading from '../loading'
import { mapState } from 'vuex'
export default Vue.extend({
components: {
Card,
......@@ -66,11 +68,16 @@ export default Vue.extend({
type: Number
}
},
computed: {
...mapState({
address: (state: any) => state.app.address
})
},
methods: {
getBlockHeight() {
service.getHeight().then(res => {
this.blockHeight = res.data.result.mainHeight
this.blockTime = +res.data.result.mainBlockTime
this.blockHeight = res.result.mainHeight
this.blockTime = +res.result.mainBlockTime
})
},
goPage(item: any, n: number, i?: any) {
......@@ -94,15 +101,14 @@ export default Vue.extend({
this.$router.push({path: '/Mine/AttendProject', query: {voteID: item.ID, optionId: '' }})
}
},
closeOption(v: string, o: string) {
closeOption(id: string, vid: string) {
Dialog.confirm({
title: '提示',
message: '确认删除当前活动报名?',
}).then(() => {
// on confirm
service.delOption({
id: o,
optId: v
id: vid,
optId: id
}).then(() => {
this.updateTab()
})
......@@ -115,10 +121,13 @@ export default Vue.extend({
title: '提示',
message: '确认关闭当前活动?',
}).then(() => {
// this.$store.commit('app/SET_COMMITTEXT', '发起的活动')
// this.$store.commit('app/SET_RESULTTEXT', '活动')
service.memberCloseVote({
voteId: id
}).then(res => {
console.log(res)
}, {
request: { text: '发起的活动' },
result: { text: '活动' }
})
})
},
......@@ -136,27 +145,29 @@ export default Vue.extend({
this.lists.forEach(item => {
if (item.type === 2) {
this.voteId = item.ID
item.voteOptions = item.voteOptions.filter((items: { creator: string }) => items.creator === this.$store.state.app.address)
item.voteOptions = item.voteOptions.filter((items: { creator: string }) => items.creator === this.address)
}
})
},
// 发起
getSetList(fn?: any) {
getSetList() {
service.voteList({
execer: 'user.p.szhtest.rankvote',
funcName: 'GetRankVoteList',
payload: {
addr: this.$store.state.app.address,
addr: this.address,
count: -1,
direction: 0,
height: 0,
index: 0
}
}).then(res => {
this.lists = res.data.result && res.data.result.list || []
this.lists = res.result && res.result.list || []
this.setDesc()
this.filterSetList()
if (fn) fn()
loading.hideLoading()
}).catch(() => {
loading.hideLoading()
})
},
// 参与
......@@ -165,16 +176,19 @@ export default Vue.extend({
execer: 'user.p.szhtest.rankvote',
funcName: 'GetUserVotedList',
payload: {
addr: this.$store.state.app.address,
addr: this.address,
index: 0,
count: -1,
height: 0,
direction: 0
}
}).then(res => {
this.lists = res.data.result && res.data.result.list || []
this.lists = res.result && res.result.list || []
this.lists = this.lists.filter(item => item.type === 1)
this.setDesc()
loading.hideLoading()
}).catch(() => {
loading.hideLoading()
})
},
getAttendOption() {
......@@ -182,18 +196,20 @@ export default Vue.extend({
execer: 'user.p.szhtest.rankvote',
funcName: 'GetUserVotedActivityList',
payload: {
// addr: test.addr,
addr: this.$store.state.app.address,
addr: this.address,
index: 0,
count: -1,
height: 0,
direction: 0
}
}).then(res => {
this.lists = res.data.result && res.data.result.optList || []
this.lists = res.result && res.result.optList || []
this.lists.forEach((item: any) => {
item.description = item.desc
})
loading.hideLoading()
}).catch(() => {
loading.hideLoading()
})
},
getSetOption() {
......@@ -201,43 +217,38 @@ export default Vue.extend({
execer: 'user.p.szhtest.rankvote',
funcName: 'GetUserSignUpList',
payload: {
addr: this.$store.state.app.address,
addr: this.address,
index: 0,
count: -1,
height: 0,
direction: 0
}
}).then(res => {
this.lists = res.data.result && res.data.result.optList || []
this.lists = res.result && res.result.optList || []
this.lists.forEach((item: any) => {
item.description = item.desc
})
loading.hideLoading()
}).catch(() => {
loading.hideLoading()
})
},
updateTab() {
console.log(this.tab)
loading.showLoading()
this.lists = []
if (this.tab === 1) {
this.needEdit = true
this.lists = []
this.getSetList()
} else if (this.tab === 2) {
this.needEdit = false
this.lists = []
this.getAttendList()
} else if (this.tab === 3) {
this.lists = []
this.getSetOption()
} else {
this.lists = []
this.getAttendOption()
}
},
},
activated() {
this.updateTab()
},
watch: {
},
created() {
this.getBlockHeight()
this.updateTab()
......
<template>
<div v-if="show" class="w-full h-screen bg-homeBanner bg-top bg-contain bg-no-repeat bg-app-drak-1 flex flex-col items-center justify-center fixed top-0 vote-result">
<template v-if="type === 1">
<img class="w-24 h-24 mb-6" src="@/assets/success.png" alt="">
<p class="text-lg text-white mb-7">提交成功</p>
<p class="text-sm text-white mb-8">您的{{ text || '提案' }}已经提交成功,并且已扣除0.002BTY</p>
<button class="w-11/12 h-10 bg-app-blue-2 text-white rounded-lg" @click="hideResult">确 定</button>
</template>
<template v-else>
<img class="w-24 h-24 mb-6" src="@/assets/fail.png" alt="">
<p class="text-lg text-white mb-7">提交失败</p>
<p class="text-sm text-white mb-8">{{ fail }}</p>
<button class="w-11/12 h-10 bg-app-blue-2 text-white rounded-lg" @click="hideResult">确 定</button>
</template>
</div>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
data() {
return {
show: false,
text: '',
type: 1,
fail: ''
}
},
methods: {
hideResult() {
// this.$store.commit('app/HIDE_LOADING')
this.show = false
},
showResult() {
this.show = true
}
}
})
</script>
<style scoped>
.vote-result {
z-index: 9999;
}
</style>
\ No newline at end of file
import Vue from 'vue';
import Main from './Result.vue';
const WaitConstructor = Vue.extend(Main);
const Result = function(options: any) {
options = options || {};
const instance = new WaitConstructor({
el: document.createElement('div'),
data: options,
});
instance.$mount()
document.body.append(instance.$el)
return instance
}
export default Result
<template>
<div class="time-box flex items-center">
<div v-if="showNum >= 1" class="flex items-center">
<div class="p-1 px-2 rounded font-semibold" :style="fontStyle" :class="bgColor">{{ day }}</div>
<p class="text text-xs mx-1 mb-0"></p>
</div>
<div v-if="showNum >= 2" class="flex items-center">
<div class="p-1 px-2 rounded font-semibold" :style="fontStyle" :class="bgColor">{{ hour }}</div>
<p class="text text-xs mx-1 mb-0"></p>
</div>
<div v-if="showNum >= 3" class="flex items-center">
<div class="p-1 px-2 rounded font-semibold" :style="fontStyle" :class="bgColor">{{ min }}</div>
<p class="text text-xs mx-1 mb-0"></p>
</div>
<div v-if="showNum >= 4" class="flex items-center">
<div class="p-1 px-2 rounded font-semibold" :style="fontStyle" :class="bgColor">{{ sec }}</div>
<p class="text text-xs mx-1 mb-0"></p>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
data() {
return {
day: '00',
hour: '00',
min: '00',
sec: '00',
time: 0,
timer: 0
}
},
props: {
times: {
type: [String, Date, Number]
},
fontStyle: {
type: Object
},
bgColor:{
type: String,
default:'bg-app-blue-3'
},
showNum: {
type: Number,
default: 4
}
},
methods: {
getTimes() {
const r = +this.time - Date.now()
if (r < 0) {
if (this.timer) clearInterval(this.timer)
return
// throw Error('已超出截至时间')
}
const day = +parseInt(r / (1000 * 60 * 60 * 24) + '')
this.day = day >= 10 ? day + '' : '0' + day
const hour = +parseInt(r / (1000 * 60 * 60) % 24 + '')
this.hour = hour >= 10 ? hour + '' : '0' + hour
const min = +parseInt(r / (1000 * 60) % 60 + '')
this.min = min >= 10 ? min + '' : '0' + min
const sec = +parseInt((r - (day * 24 * 60 * 60 * 1000) - hour * (1000 * 60 * 60) - min * (1000 * 60)) / 1000 + '')
this.sec = sec >= 10 ? sec + '' : '0' + sec
}
},
watch: {
times() {
this.time = +this.times
this.getTimes()
if (this.timer) clearInterval(this.timer)
this.timer = window.setInterval(() => {
this.time--
this.getTimes()
}, 1000)
}
},
mounted() {
this.time = +this.times
this.getTimes()
if (this.timer) clearInterval(this.timer)
this.timer = window.setInterval(() => {
this.time--
this.getTimes()
}, 1000)
}
})
</script>
<template>
<div class="w-full h-screen bg-app-drak-1 bg-homeBanner bg-top bg-contain bg-no-repeat flex flex-col items-center justify-center absolute waiter">
<div v-if="show" class="w-full h-screen bg-app-drak-1 bg-homeBanner bg-top bg-contain bg-no-repeat flex flex-col items-center justify-center fixed top-0 waiter">
<img class="w-48 h40 mb-3" src="@/assets/wait.png" alt="">
<div class="text-sm text-center text-white mb-2">{{ text || '发起的提案' }}正在上链...</div>
<div class="text-sm text-center text-white">请耐心等待</div>
......@@ -8,13 +8,23 @@
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
computed: {
text() {
return this.$store.state.app.text
data() {
return {
show: false,
text: ''
}
},
methods: {
showWait() {
this.show = true
},
hideWait() {
this.show = false
}
}
})
})
</script>
<style scoped>
......
import Vue from 'vue';
import Wait from './Wait.vue';
const WaitConstructor = Vue.extend(Wait);
const Waiting = function(options: any) {
options = options || {};
if (typeof options === 'string') {
options = {
text: options
}
}
const instance = new WaitConstructor({
el: document.createElement('div'),
data: options,
});
instance.$mount()
document.body.append(instance.$el)
return instance
}
export default Waiting
......@@ -3,7 +3,9 @@
// privateKey: '0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944'
// }
export const test = {
addr: '1K7Fko7e21F2qXdYriVLheJue5ZW5KerZL',
addr: '1MwgSgsRpuMVnRLGBgs7c7VNELA4PPHM1n',
// addr: '1Gr8DCrNL1q9Jhifm87rNcWHBoSiM6smES',
// addr: '1K7Fko7e21F2qXdYriVLheJue5ZW5KerZL',
privateKey: '0x208706573b6ef4b729b0804ac0803bd1f4266661d0e475e49de472378738574e'
}
// export const test = {
......
......@@ -3,7 +3,9 @@
<!-- <header>header</header> -->
<app-overlay></app-overlay>
<div class='content'>
<router-view></router-view>
<keep-alive>
<router-view></router-view>
</keep-alive>
</div>
<app-rules ref="rule" :hidden="hidden" />
<app-navigator class='fixed bottom-0'></app-navigator>
......
<template>
<div class="flex w-full justify-around bg-app-blue-1 z-50" >
{{ currentIndex }}
<div v-for="(i,index) in routeList" :key="index" class="py-3 flex flex-col text-center " @click="navigating(i,index)">
<div class="self-center">
<app-icon customize :type='i.meta.icon' size='18px' :color='index===activedIndex?"#FFBB00":" #FFFFFF"'></app-icon>
......@@ -53,21 +52,7 @@ export default Vue.extend({
},
methods:{
init() {
// if (permissionList.indexOf(this.$store.state.app.address) > -1) {
// this.navRoutes.forEach(item => {
// if (item.meta.text === '发起提案') {
// item.meta.text = '发起活动'
// }
// })
// } else {
// this.navRoutes.forEach(item => {
// if (item.meta.text === '发起提案') {
// item.meta.text = '发起提案'
// }
// })
// }
const indexNumber = this.navRoutes.findIndex(i=>{
// console.log(i);
return i?.path === this.$route?.path
})
if(this.navRoutes[this.activedIndex]?.path != this.$route.path){
......@@ -96,9 +81,12 @@ export default Vue.extend({
}
return value
},
<<<<<<< Updated upstream
currentIndex() {
return this.$store.state.app.index
},
=======
>>>>>>> Stashed changes
address():string {
return this.$store.state.app.address
},
......
This diff is collapsed.
import { CreateVoteDto, MemberItem, ListItem } from '@/types/Dto'
const _form = () => {
return {
name: '',
description: '',
url: '',
type: 1,
startHeight: undefined,
endHeight: undefined,
options: [] as ListItem[],
members: [] as MemberItem[],
isOpen: true,
numType: 2
}
}
const stateData = {
overlay:{
show:false,
......@@ -6,15 +23,8 @@ const stateData = {
title:'默认'
}
},
members: [] as any,
loading: 0,
requestCount: 0,
type: 1,
res: '', // 提交失败信息
text: '', // 提交提示
text1: '', // 提交提示1
address: '', // 用户地址
form: {} // 发起表单
form: _form() as CreateVoteDto // 发起表单
}
interface overlayData {
title:string
......@@ -41,72 +51,21 @@ export const appStore = {
SET_OVERLAY(state:AppType,payload:overlayData){
Object.assign(state.overlay.data,payload)
},
ADD_MEMBER(state:AppType, member: memberItem) {
state.members.push(member)
},
EDIT_MEMBER(state:AppType, o: any) {
state.members.splice(o.num, 1, o.params)
},
REMOVE_MEMBER(state:AppType, i: number) {
state.members.splice(i, 1)
},
SET_MEMBER(state:AppType, o: any) {
state.members = o
},
CLEAR_MEMBER(state:AppType) {
state.members = [] as any
},
SHOW_LOADING(state:AppType) {
state.loading = 1
},
HIDE_LOADING(state:AppType) {
state.loading = 0
},
SET_WAIT(state: AppType) {
state.loading = 2
},
SET_RES(state: AppType) {
state.loading = 3
},
SET_ERROR(state: AppType) {
state.loading = 4
},
SET_TYPE(state: AppType, i: number) {
state.type = i
},
SET_RESULT(state: AppType, s: string) {
state.res = s
},
SET_TEXT(state: AppType, s: string) {
state.text = s
},
SET_TEXT1(state: AppType, s: string) {
state.text1 = s
},
SET_ADDRESS(state: AppType, s: string) {
state.address = s
},
CLEAR_ADDRESS(state: AppType) {
state.address = ''
},
SET_FORM(state: AppType, s: any) {
state.form = s
SET_FORM(state: AppType, form: CreateVoteDto) {
state.form = form
},
CLEAR_FORM(state: AppType) {
state.form = {}
},
ADD_REQUEST(state: AppType) {
state.requestCount++
},
DEC_REQUEST(state: AppType) {
state.requestCount--
state.form = _form()
},
},
actions: {
},
getters: {
loadingStatus: (state: AppType) => state.loading
}
};
interface ListItem {
name: string
desc: string
export interface ListItem {
name: string
desc?: string
}
interface MemberItem{
addr: string
name: string
export interface MemberItem {
addr: string
name: string
}
interface payload {
voteID?: string,
optionId?: string
voteID?: string,
optionId?: string
}
interface payloadRest {
id: string,
addr: string
id: string,
addr: string
}
interface payloadList {
addr?: string,
count: number,
direction: number,
height: number,
index: number
addr?: string,
count: number,
direction: number,
height: number,
index: number
}
interface trade {
id?: string,
optId?: string,
addr?: string,
count: number,
direction: number,
height: number,
index: number
id?: string,
optId?: string,
addr?: string,
count: number,
direction: number,
height: number,
index: number
}
interface Item {
addr: string;
count: number;
direction: number;
height: number;
index: number
}
export interface CreateVoteDto{
name:string;
options:ListItem[];
startHeight:number;
endHeight:number;
description?:string;
url:string;
numType:number; //投票期间可复投次数 1 表示一次性 2表示每天一次
members:MemberItem[];
isOpen:boolean;
type:number;
addr: string;
count: number;
direction: number;
height: number;
index: number
}
export interface CreateVoteDto {
name: string;
options?: ListItem[];
startHeight: number|undefined;
endHeight: number|undefined;
description?: string;
url?: string;
numType: number; //投票期间可复投次数 1 表示一次性 2表示每天一次
members?: MemberItem[];
isOpen: boolean;
type: number;
}
export interface attendVote {
voteId: string;
name: string;
desc: string
voteId?: string;
name: string;
desc: string
}
export interface memberInfo {
id: string;
addMembers: { addr: string, name: string }
id: string;
addMembers: { addr: string, name: string }
}
export interface delMember {
id: string;
addr: string []
id: string;
addr: string[]
}
export interface memberVote {
voteId: string;
optionId: string;
amount: number
voteId: string;
optionId: string;
amount: number
}
export interface memberCloseVote {
voteId: string
voteId: string
}
export interface memberChangeVote {
voteId: string;
addr: string
voteId: string;
addr: string
}
export interface voteDetails {
execer: string;
funcName: string;
payload: payload
execer: string;
funcName: string;
payload: payload
}
export interface voteRest {
execer: string;
funcName: string;
payload: payloadRest
execer: string;
funcName: string;
payload: payloadRest
}
export interface voteList {
execer: string;
funcName: string;
payload: payloadList
execer: string;
funcName: string;
payload: payloadList
}
export interface tradeList {
execer: string;
funcName: string;
payload: trade
execer: string;
funcName: string;
payload: trade
}
export interface blockInfo {
start: number;
end: number;
isDetail: boolean
start: number;
end: number;
isDetail: boolean
}
export interface listItem {
execer: string;
funcName: string;
payload: Item
execer: string;
funcName: string;
payload: Item
}
export interface delItem {
id: string;
optId: string
id: string;
optId: string
}
export interface activityItem {
execer: string;
funcName: string;
payload: {
addr: string;
count: number;
direction: number;
height: number;
index: number
}
execer: string;
funcName: string;
payload: {
addr: string;
count: number;
direction: number;
height: number;
index: number
}
}
export interface hashList {
execer: string;
funcName: string;
payload: {
data: string
}
execer: string;
funcName: string;
payload: {
data: string
}
}
export interface voteInfos {
ID: string;
amount: string;
blockTime: string;
commitInfos: any[];
creator: string;
description: string;
startHeight: string;
endHeight: string;
execer: number;
height: string;
index: number;
isOpen: boolean;
lastOptionId: string;
members: { addr: string; name: string }[];
name: string;
numType: number;
payAddr: string;
status: number;
txsNum: string;
type: number;
url: string;
voteOptions: Array<voteOptionItem>
}
export interface voteOptionItem {
creator: string;
desc: string;
description?: string;
height: string;
id: string;
index: number;
isClose: boolean;
name: string;
rank: number;
score: number
}
\ No newline at end of file
export enum ActionEnum {
ONLY = 1,
DAYS,
}
\ No newline at end of file
export enum VoteStateEnum {
START = 1,
PENDING,
END,
CLOSED
}
export const TICKET_COUNT = 100 // 输入框与当前区块差值最小值
\ No newline at end of file
This diff is collapsed.
<template>
<div class="initiate">
<!-- <div v-if="isFounder === 0" class="w-full h-screen flex flex-col items-center justify-center">
<button class="block w-1/2 py-4 my-5 border border-app-white border-solid rounded-lg" @click="isFounder = 1">发起提案</button>
<button class="block w-1/2 py-4 my-5 border border-app-white border-solid rounded-lg" @click="isFounder = 2">发起社区活动</button>
</div> -->
<initiate-founder v-if="isFounder === false"></initiate-founder>
<initiate-user v-else></initiate-user>
<!-- <attend-form v-else-if="isFounder === 3" @submitForm="submitForm" /> -->
</div>
</template>
<script lang="ts">
import Vue from "vue";
// import { service } from '@/service/index'
import { permissionList } from '@/constants/permission'
export default Vue.extend({
name: "Initiate",
......@@ -26,30 +20,12 @@ export default Vue.extend({
const addr = this.$store.state.app.address
if (permissionList.indexOf(addr) > -1) {
this.isFounder = false
// this.$route.meta.text = '发起活动'
}
// else {
// this.$route.meta.text = '发起提案'
// }
// // 测试关闭投票
// service.memberCloseVote({
// voteId: '000000000608800001'
// }).then(res => {
// console.log(res)
// })
},
components:{
'initiate-founder':()=>import('./initiate_comp/founder_initiate.vue'),
'initiate-user':()=>import('./initiate_comp/user_initiate.vue')
},
methods: {
// submitForm(v: boolean) {
// if (!v) {
// this.isFounder = 0
// }
// }
}
});
</script>
......
......@@ -37,6 +37,7 @@ import Vue from "vue";
import { service } from '@/service/index'
import {TimelineLite, Power2, CSSPlugin, gsap} from 'gsap'
import BScroll from 'better-scroll'
import loading from '@/components/loading'
gsap.registerPlugin(CSSPlugin)
/// <reference path="tween.d.ts"/>
......@@ -56,6 +57,13 @@ export default Vue.extend({
};
},
mounted(){
loading.showLoading()
this.getBlockHeight()
this.getVoteList()
this.initAnima()
},
activated() {
loading.showLoading()
this.getBlockHeight()
this.getVoteList()
this.initAnima()
......@@ -73,17 +81,17 @@ export default Vue.extend({
funcName: 'GetRankVoteList',
payload: { addr: '', count: -1, direction: 0, height: 0, index: 0 }
}).then(res => {
let lists = res.data.result && res.data.result.list || []
let lists = res.result && res.result.list || []
lists = lists.filter((item: any) => item.type === 1)
this.lists = lists
this.copyList = lists
// this.initScroll()
loading.hideLoading()
})
},
getBlockHeight() {
service.getHeight().then(res => {
this.blockHeight = res.data.result.mainHeight
this.blockTime = +res.data.result.mainBlockTime
this.blockHeight = res.result.mainHeight
this.blockTime = +res.result.mainBlockTime
})
},
initScroll() {
......@@ -136,16 +144,6 @@ export default Vue.extend({
this.anima.pause()
},
scrollStart(e:any){
// let poisition = e.y
// this.scrollArr.push(poisition)
// let l = this.scrollArr.slice(-2)
// if(Math.abs(e.y) > 320 && l[0]>l[1]){
// // 设置高度检测,当小于回滚高度时跳出
// // if (e.target.scrollHeight - 320 < window.innerHeight) return
// this.anima.play()
// }else if(Math.abs(e.y) <= 320 && l[0]<l[1]){
// this.anima.reverse()
// }
let poisition = e.target.scrollTop
this.scrollArr.push(poisition)
let l = this.scrollArr.slice(-2)
......@@ -157,8 +155,8 @@ export default Vue.extend({
this.anima.reverse()
}
},
search(v: string) {
const str = v ? v : ''
search(value: string) {
const str = value ? value : ''
if (str) {
this.filterList(str)
} else {
......@@ -168,19 +166,19 @@ export default Vue.extend({
doFilter(){
this.showfilter = true
},
showhidden(v: boolean) {
this.showfilter = !v
showhidden(show: boolean) {
this.showfilter = !show
},
filterList(v: object|string) {
this.showfilter = false
let lists = JSON.parse(JSON.stringify(this.copyList))
this.lists = []
if (typeof v === 'string') {
const l1 = lists.filter((item: any) => item.name.indexOf(v) > -1)
const l2 = lists.filter((item: any) => item.ID === v)
const l = [...l1, ...l2]
const filterName = lists.filter((item: any) => item.name.indexOf(v) > -1)
const filterId = lists.filter((item: any) => item.ID === v)
const result = [...filterName, ...filterId]
this.$nextTick(() => {
this.lists = l
this.lists = result
})
} else {
const o = v as any
......@@ -197,12 +195,12 @@ export default Vue.extend({
})
}
},
goPage(o: any) {
const type = o.status
goPage(obj: { status: number, ID: string }) {
const type = obj.status
if (type <= 2) {
this.goVote(o.ID)
this.goVote(obj.ID)
} else {
this.goDetails(o.ID)
this.goDetails(obj.ID)
}
},
goVote(id: string) {
......@@ -212,25 +210,6 @@ export default Vue.extend({
this.$router.push({path: '/Square/SquareDetails', query: {voteID: id}})
},
},
// activated() {
// this.getBlockHeight()
// this.getVoteList()
// this.initAnima()
// },
watch: {
$route: {
immediate: true,
handler(n) {
if (n.path !== '/Square') return
this.lists = []
this.getBlockHeight()
this.getVoteList();
if (this.$refs.filter) {
(this.$refs.filter as any).clear()
}
}
}
}
});
</script>
......
......@@ -125,7 +125,7 @@ export default Vue.extend({
index: 0
}
}).then(res => {
this.all = res.data.result && res.data.result.list || []
this.all = res.result && res.result.list || []
this.getpage(this.currentPage)
this.totalPage = Math.ceil(this.all.length/this.count) <= 0 ? 1 : Math.ceil(this.all.length/this.count)
}).catch(() => {
......@@ -142,8 +142,8 @@ export default Vue.extend({
optionId: this.$route.query.optionId as string
}
}).then(res => {
this.type = res.data.result?.type
this.community = res.data.result?.voteOptions[0] || {}
this.type = res.result?.type
this.community = res.result?.voteOptions[0] || {}
})
},
timer() {
......@@ -156,15 +156,15 @@ export default Vue.extend({
this.getDetails()
this.message = JSON.parse(this.$route.query.item as any)
},
watch: {
$route(n, o) {
if (n.path.indexOf('/MyAttend') <= -1) return
if (n.query.optionId !== o.query.optionId) {
this.getList()
this.message = JSON.parse(this.$route.query.item as any)
}
}
},
// watch: {
// $route(n, o) {
// if (n.path.indexOf('/MyAttend') <= -1) return
// if (n.query.optionId !== o.query.optionId) {
// this.getList()
// this.message = JSON.parse(this.$route.query.item as any)
// }
// }
// },
})
</script>
......@@ -106,7 +106,7 @@ export default Vue.extend({
index: 0
}
}).then(res => {
this.all = res.data.result && res.data.result.list || []
this.all = res.result && res.result.list || []
this.all.forEach((item: {amount: string}) => {
this.amount += +item.amount
})
......@@ -125,7 +125,7 @@ export default Vue.extend({
optionId: this.$route.query.optionId as string,
}
}).then(res => {
this.message = res.data.result
this.message = res.result
})
},
},
......@@ -133,13 +133,13 @@ export default Vue.extend({
this.getList()
this.getDetails()
},
watch: {
$route(n, o) {
if (n.query.voteID !== o.query.voteID) {
this.getList()
this.getDetails()
}
}
},
// watch: {
// $route(n, o) {
// if (n.query.voteID !== o.query.voteID) {
// this.getList()
// this.getDetails()
// }
// }
// },
})
</script>
......@@ -112,8 +112,8 @@ export default Vue.extend({
optionId: this.$route.query.optionId as string,
}
}).then(res => {
this.message = res.data.result.voteOptions[0]
this.addr = res.data.result.creator
this.message = res.result.voteOptions[0]
this.addr = res.result.creator
})
},
getpage(i: number) {
......@@ -133,7 +133,7 @@ export default Vue.extend({
index: 0
}
}).then(res => {
this.all = res.data.result && res.data.result.list || []
this.all = res.result && res.result.list || []
this.getpage(this.currentPage)
this.totalPage = Math.ceil(this.all.length/this.count) <= 0 ? 1 : Math.ceil(this.all.length/this.count)
}).catch(() => {
......@@ -146,14 +146,14 @@ export default Vue.extend({
this.getList()
this.getDetails()
},
watch: {
$route(n, o) {
if (n.path.indexOf('/ProjectDetails') <= -1) return
if (n.query.optionId !== o.query.optionId) {
this.getList()
this.getDetails()
}
}
},
// watch: {
// $route(n, o) {
// if (n.path.indexOf('/ProjectDetails') <= -1) return
// if (n.query.optionId !== o.query.optionId) {
// this.getList()
// this.getDetails()
// }
// }
// },
})
</script>
......@@ -133,7 +133,7 @@ export default Vue.extend({
data: this.$route.query.addr as string
}
}).then(res => {
this.all = [res.data.result] || []
this.all = [res.result] || []
this.zHeight = this.all[0].height
this.getpage(this.currentPage)
this.totalPage = Math.ceil(this.all.length/this.count) <= 0 ? 1 : Math.ceil(this.all.length/this.count)
......
......@@ -131,7 +131,7 @@ export default Vue.extend({
index: 0
}
}).then(res => {
this.all = res.data.result && res.data.result.list || []
this.all = res.result && res.result.list || []
this.getpage(this.currentPage)
this.totalPage = Math.ceil(this.all.length/this.count) <= 0 ? 1 : Math.ceil(this.all.length/this.count)
})
......@@ -145,7 +145,7 @@ export default Vue.extend({
optionId: this.$route.query.optionId as string
}
}).then(res => {
this.message = res.data.result
this.message = res.result
})
}
}
......
......@@ -3,7 +3,7 @@
<child-view>
<div class="sub-page">
<div>
<time-line ref="timeline" :status="status" :count="count" :isEnd="isEnd" />
<time-line ref="timeline" :status="voteDetails.status" :count="count" :isEnd="isEnd" />
</div>
<div class="mt-3 mx-4 py-5 bg-app-dark-2 border border-app-blue-3 border-solid rounded-lg">
<div class="border-b border-app-blue-3 border-solid pb-5 px-4">
......@@ -11,7 +11,7 @@
</div>
<div class="pt-7 px-4">
<div class="mb-5">
<TicketBar :ticketNum="ticketNum" />
<TicketBar :ticketNum="this.community.score" />
</div>
<input class="x-input text-sm" placeholder="请输入投票数量" v-model="useNum" @input="checkInput" />
<div class="flex items-center justify-between mt-3">
......@@ -23,7 +23,7 @@
<div class="px-4 mt-5">
<button
class="w-full h-10 leading-10 text-center text-sm rounded-lg"
:class="[status === 2 ? 'bg-app-blue-2' : 'bg-app-blue-5 text-app-white', rest === 0 ? 'bg-app-blue-5' : 'bg-app-blue-3', community.isClose ? 'bg-app-blue-5' : 'bg-app-blue-3']"
:class="[voteDetails.status === 2 ? 'bg-app-blue-2' : 'bg-app-blue-5 text-app-white', rest === 0 ? 'bg-app-blue-5' : 'bg-app-blue-3', community.isClose ? 'bg-app-blue-5' : 'bg-app-blue-3']"
@click="vote">{{ voteText }}</button>
<p v-if="fail" class="pt-2.5 text-sm text-yellow-600 text-center">投票失败,请重新投票</p>
</div>
......@@ -39,8 +39,11 @@ import TicketBar from '@/components/home/TicketBar.vue'
import Vue from 'vue'
import ChildView from '@/layouts/childView.vue'
import { service } from '@/service/index'
// import { test } from '@/constants/test'
import { test } from '@/constants/test'
import { Toast } from 'vant'
import { mapState } from 'vuex'
import { voteInfos, voteOptionItem } from '@/types/Dto';
import loading from '@/components/loading'
export default Vue.extend({
components: {
TimeLine,
......@@ -51,104 +54,87 @@ export default Vue.extend({
name: 'CommunityVote',
data() {
return {
voteDetails: {} as voteInfos,
height: 0,
ticketNum: 0,
rest: 0,
useNum: '',
community: {} as any,
community: {} as voteOptionItem,
voteText: '投票',
isToday: true,
numType: 1,
status: 0, // 以此为依据 设置投票按钮状态
// status: 0, // 以此为依据 设置投票按钮状态
fail: false,
count: 0,
endHeight: 0, // 下次投票的参数
end: 0, // 最终结束时间
isEnd: 0
// endHeight: 0, // 下次投票的参数
isEnd: 0, // 是否为最后一次投票,文本判断
}
},
computed: {
...mapState({
address: (state: any):string => state.app.address
})
},
methods: {
getContent() {
loading.showLoading()
service.voteDetails({
execer: "user.p.szhtest.rankvote",
funcName: "GetRankVoteInfo",
payload: {optionId: this.$route.query.optionId as string, voteID: this.$route.query.voteID as string}
payload: { optionId: this.$route.query.optionId as string, voteID: this.$route.query.voteID as string }
}).then(res => {
this.numType = res.data.result.numType
this.status = res.data.result.status
this.isEnd = res.data.result.status
this.community = res.data.result.voteOptions[0]
this.voteDetails = res.result
this.isEnd = res.result.status
this.community = res.result.voteOptions[0]
// 参数统一
this.community.description = this.community.desc
this.ticketNum = +this.community.score
this.end = +res.data.result.endHeight
if (this.status === 1) {
this.height = +res.data.result.startHeight
// this.getHeight(this.height + '')
if (this.voteDetails.status === 1) {
this.height = +res.result.startHeight
} else {
this.height = +res.data.result.endHeight
this.height = +res.result.endHeight
}
this.getRest()
// this.getLast()
this.setBtn()
})
},
// getLast() {
// chainService.getLastBlocks().then(res => {
// if (this.status === 1) {
// this.count = Math.abs(res.data.result.height - this.height)
// } else {
// this.count = Math.abs(this.height - res.data.result.height)
// }
// })
// },
getRest() {
service.voteRest({
execer: 'user.p.szhtest.rankvote',
funcName: 'GetRankVoteAccountInfo',
payload: {
id: this.$route.query.voteID as string,
// addr: test.addr
addr: this.$store.state.app.address
addr: this.address
}
}).then(res => {
const lists = res.data.result && res.data.result.dayAccount || []
let o = []
o = lists.filter((item: any) => item.isToday)
const lists = res.result?.dayAccount || []
const o = lists.filter((item: any) => item.isToday)
this.isToday = o[0]?.isToday
// if (this.community.isClose) {
// this.rest = 0
// } else {
// this.rest = +o[0]?.balance || 0
// }
this.rest = +o[0]?.balance || 0
this.endHeight = +o[0]?.endHeight || 0
const endHeight = +o[0]?.endHeight || 0
// 结束时间或下次投票
if (Math.abs(this.endHeight - +this.end) < 5) {
if (Math.abs(endHeight - +this.voteDetails.endHeight) < 5) {
this.isEnd = 3
} else {
this.isEnd = this.status
this.isEnd = this.voteDetails.status
}
console.log(this.end)
console.log(this.endHeight)
this.getHeight()
this.getHeight(endHeight)
})
},
getHeight() {
getHeight(endHeight: number) {
service.getHeight().then(res => {
const height = +res.data.result.mainHeight
if (this.status === 1) {
const height = +res.result.mainHeight
if (this.voteDetails.status === 1) {
this.count = Math.abs(this.height - height)
} else {
this.count = Math.abs(this.endHeight - height)
this.count = Math.abs(endHeight - height)
}
loading.hideLoading()
})
},
setBtn() {
if (this.status === 3) {
if (this.voteDetails.status === 3) {
this.voteText = this.community.isClose === true ? '投票已关闭' : '投票已结束'
} else if (this.status === 2) {
} else if (this.voteDetails.status === 2) {
this.voteText = this.community.isClose === true ? '投票已关闭' : '投票'
} else if (this.status === 1) {
} else if (this.voteDetails.status === 1) {
this.voteText = this.community.isClose === true ? '投票已关闭' : '投票'
} else {
this.voteText = '投票已关闭'
......@@ -176,18 +162,21 @@ export default Vue.extend({
return
}
if (this.isToday) {
this.$store.commit('app/SET_TEXT', '提交的投票')
// this.$store.commit('app/SET_COMMITTEXT', '提交的投票')
service.memberVote({
optionId: this.$route.query.optionId as string,
voteId: this.$route.query.voteID as string,
amount: +this.useNum
}, {
request: { text: '提交的投票' },
result: { text: '投票' }
}, () => {
// Toast('投票成功')
this.$store.commit('app/SET_TEXT1', '投票')
this.$router.push({path: '/Home', query: {t: Date.now() + ''}})
// this.$store.commit('app/SET_RESULTTEXT', '投票')
this.$router.push({path: '/Home'})
})
} else {
if (this.numType === 1) {
if (this.voteDetails.numType === 1) {
Toast('已完成投票')
} else {
Toast('今日已投票')
......@@ -198,18 +187,7 @@ export default Vue.extend({
},
created() {
this.getContent()
// this.getRest()
},
// watch: {
// $route(n) {
// if (n.path.indexOf('/CommunityVote') <= -1) return
// // if (n.query.optionId !== o.query.optionId) {
// this.getContent()
// this.getRest()
// this.useNum = ''
// // }
// }
// }
})
</script>
......
......@@ -59,20 +59,20 @@ export default Vue.extend({
funcName: "GetRankVoteInfo",
payload: {optionId: this.$route.query.optionId as string, voteID: this.$route.query.voteID as string}
}).then(res => {
this.result = res.data.result
this.result = res.result
this.status = this.result.status
if (this.result.type === 1) {
this.community = res.data.result
this.community = res.result
this.ticketNum = +this.community.amount
} else {
this.community = res.data.result.voteOptions[0]
this.community = res.result.voteOptions[0]
this.community.description = this.community.desc
this.ticketNum = this.community.score
}
if (this.status === 1) {
this.height = +res.data.result.startHeight
this.height = +res.result.startHeight
} else {
this.height = +res.data.result.endHeight
this.height = +res.result.endHeight
}
this.getRest()
})
......@@ -87,7 +87,7 @@ export default Vue.extend({
addr: this.$store.state.app.address
}
}).then(res => {
const lists = res.data.result && res.data.result.dayAccount || []
const lists = res.result && res.result.dayAccount || []
let o = []
o = lists.filter((item: any) => item.isToday)
this.endHeight = +o[0].endHeight
......@@ -96,7 +96,7 @@ export default Vue.extend({
},
getHeight() {
service.getHeight().then(res => {
const height = +res.data.result.mainHeight
const height = +res.result.mainHeight
if (this.status === 1) {
this.count = Math.abs(this.height - height)
} else {
......@@ -108,12 +108,5 @@ export default Vue.extend({
created() {
this.getDetails()
},
watch: {
$route(n, o) {
if (n.query.optionId !== o.query.optionId) {
this.getDetails()
}
}
}
})
</script>
<template>
<ChildView>
<div class="sub-page">
<!-- <div class="tab flex items-center justify-center text-sm mt-3">
<div class="w-20 h-10 leading-10 text-center bg-app-blue-2 rounded-t-md mr-4" @click="tab = 1">手动录入</div>
<div class="w-20 h-10 leading-10 text-center bg-app-blue-2 rounded-t-md" @click="tab = 2">批量导入</div>
</div> -->
<div class="member-content mx-4 bg-app-dark-2 border border-app-blue-3 border-solid rounded-lg">
<add :tab="tab"></add>
</div>
......
This diff is collapsed.
......@@ -31,6 +31,7 @@ import TicketBar from '@/components/home/TicketBar.vue'
import TicketRecord from '@/components/mine/TicketRecord.vue'
import ChildView from '@/layouts/childView.vue'
import { service } from '@/service/index'
import loading from '@/components/loading'
export default Vue.extend({
components: {
......@@ -51,6 +52,7 @@ export default Vue.extend({
this.$router.push({ path: '/Home/CommunityVote', query: { ...this.$route.query }})
},
getDetails() {
loading.showLoading()
service.voteDetails({
execer: 'user.p.szhtest.rankvote',
funcName: 'GetRankVoteInfo',
......@@ -59,7 +61,8 @@ export default Vue.extend({
optionId: this.$route.query.optionId as string
}
}).then(res => {
this.community = res.data.result.voteOptions[0]
loading.hideLoading()
this.community = res.result.voteOptions[0]
this.community.description = this.community.desc
this.ticketNum = +(this.community as any).score
})
......@@ -78,7 +81,7 @@ export default Vue.extend({
index: 0
}
}).then(res => {
this.list = res.data.result && res.data.result.list || []
this.list = res.result && res.result.list || []
})
}
},
......@@ -86,14 +89,5 @@ export default Vue.extend({
this.getList()
this.getDetails()
},
watch: {
$route(n, o) {
if (n.path.indexOf('/AttendCommunity') <= -1) return
if (n.query.voteID !== o.query.voteID) {
this.getDetails()
this.getList()
}
}
}
})
</script>
\ No newline at end of file
......@@ -30,6 +30,7 @@ import TicketBar from '@/components/home/TicketBar.vue'
import TicketRecord from '@/components/mine/TicketRecord.vue'
import ChildView from '@/layouts/childView.vue'
import { service } from '@/service/index'
import loading from '@/components/loading'
export default Vue.extend({
components: {
......@@ -54,6 +55,7 @@ export default Vue.extend({
}
},
getDetails() {
loading.showLoading()
service.voteDetails({
execer: "user.p.szhtest.rankvote",
funcName: "GetRankVoteInfo",
......@@ -62,14 +64,15 @@ export default Vue.extend({
voteID: this.$route.query.voteID as string
}
}).then(res => {
this.community = res.data.result
this.ticketNum = +res.data.result.amount
const lists = res.data.result.voteOptions
this.community = res.result
this.ticketNum = +res.result.amount
const lists = res.result.voteOptions
this.list.forEach(item => {
const id = (item as any).optionId
const o = lists.filter((i: { id: string }) => i.id === id)[0]
this.$set(item, 'name', o?.name || '')
})
loading.hideLoading()
this.$forceUpdate()
})
},
......@@ -87,7 +90,7 @@ export default Vue.extend({
index: 0
}
}).then(res => {
this.list = res.data.result && res.data.result.list || []
this.list = res.result && res.result.list || []
this.getDetails()
})
}
......@@ -96,13 +99,5 @@ export default Vue.extend({
this.getList()
this.getDetails()
},
// watch: {
// $route(n, o) {
// if (n.path.indexOf('/AttendProject') <= -1) return
// if (n.query.voteID !== o.query.voteID && n.path !== o.path) {
// this.getList()
// }
// }
// }
})
</script>
\ No newline at end of file
......@@ -74,12 +74,9 @@ export default Vue.extend({
closeVote() {
service.memberCloseVote({
voteId: this.$route.query.voteID as string
}, () => {
}, {}, () => {
this.$router.push('/Mine')
})
// .then(res => {
// console.log(res)
// })
}
},
watch: {
......
......@@ -43,6 +43,7 @@ import TicketBar from '@/components/home/TicketBar.vue'
import Vue from 'vue'
import ChildView from '@/layouts/childView.vue'
import { service } from '@/service/index'
import loading from '@/components/loading'
export default Vue.extend({
components: {
CommunityCard,
......@@ -79,12 +80,13 @@ export default Vue.extend({
optionId: this.$route.query.optionId as string
}
}).then(res => {
this.community = res.data.result.voteOptions[0]
this.community = res.result.voteOptions[0]
this.community.description = this.community.desc
this.ticketNum = +(this.community as any).score
})
},
getList() {
loading.showLoading()
service.tradeList({
execer: 'user.p.szhtest.rankvote',
funcName: 'GetCommitInfoList',
......@@ -98,7 +100,8 @@ export default Vue.extend({
index: 0
}
}).then(res => {
this.list = res.data.result && res.data.result.list || []
loading.hideLoading()
this.list = res.result && res.result.list || []
})
}
},
......@@ -106,13 +109,5 @@ export default Vue.extend({
this.getDetails()
this.getList()
},
watch: {
// $route(n, o) {
// if (n.query.voteID !== o.query.voteID) {
// this.getDetails()
// this.getList()
// }
// }
}
})
</script>
......@@ -11,6 +11,7 @@ import childView from '@/layouts/childView.vue'
import Vue from 'vue'
import UserInitiate from '../initiate_comp/user_initiate.vue'
import { service } from '@/service/index'
import { mapState } from 'vuex'
export default Vue.extend({
components: { childView, UserInitiate },
data() {
......@@ -18,6 +19,11 @@ export default Vue.extend({
form: {}
}
},
computed: {
...mapState({
storeForm: (state: any) => state.app.form
})
},
methods: {
getDetails() {
service.voteDetails({
......@@ -27,19 +33,27 @@ export default Vue.extend({
voteID: this.$route.query.voteID as string
}
}).then(res => {
this.form = res.data.result
const result = {
name: res.result.name,
description: res.result.description,
url: res.result.url,
type: res.result.type,
startHeight: res.result.startHeight,
endHeight: res.result.endHeight,
options: res.result.voteOptions,
members: res.result.members,
isOpen: res.result.isOpen,
numType: res.result.numType
}
this.$store.commit('app/SET_FORM', result)
this.form = result
})
}
},
created() {
this.getDetails()
},
watch: {
$route(n, o) {
if (n.query.voteID !== o.query.voteID) {
this.getDetails()
}
if (!this.storeForm.name) {
this.getDetails()
}
}
},
})
</script>
\ No newline at end of file
......@@ -11,17 +11,6 @@
:key="index"
class="mb-3 py-3 flex flex-col border border-app-blue-3 border-solid rounded-lg"
>
<!-- <div ref="content" class="text-sm px-3">
<span class="inline-block" v-if="!item.type1">{{ item.content }}</span>
<div v-else class="flex items-end" @click="item.type1 = false">
<span class="inline-block type-1">
{{ item.content }}
</span>
<div class="mb-1">
<app-icon customize type='icon-arrow-right-copy-copy'></app-icon>
</div>
</div>
</div> -->
<div ref="content" class="text-sm px-3">
<span class="inline-block" v-if="item.type1 === 0">{{ item.name }}</span>
<div v-else class="flex items-end" @click="triggle(index, item.type1)">
......@@ -48,7 +37,6 @@
</div>
</div>
</div>
<!-- <button class="w-full bg-app-blue-2 h-10 leading-10 text-center text-sm rounded-lg opacity-30">已结束</button> -->
</div>
</div>
</div>
......@@ -62,6 +50,7 @@ import AppIcon from '@/components/common/Icon.vue'
import { Progress } from 'vant'
import Vue from 'vue'
import { service } from '@/service/index'
import loading from '@/components/loading'
Vue.use(Progress)
export default Vue.extend({
components: {
......@@ -71,13 +60,8 @@ export default Vue.extend({
},
data() {
return {
lists: [
],
type1: true,
voteNum: '',
rest: 0,
lists: [],
hide: false,
sumVote: 0,
community: {} as any
}
},
......@@ -103,6 +87,7 @@ export default Vue.extend({
}
},
getDetails() {
loading.showLoading()
service.voteDetails({
execer: 'user.p.szhtest.rankvote',
funcName: 'GetRankVoteInfo',
......@@ -111,18 +96,17 @@ export default Vue.extend({
optionId: ''
}
}).then(res => {
this.community = res.data.result
this.lists = res.data.result.voteOptions
this.sumVote = +res.data.result.amount
this.community = res.result
this.lists = res.result.voteOptions
const amount = +res.result.amount
this.lists.forEach((item: any) => {
if (this.sumVote === 0) {
if (amount === 0) {
item.val = 0
} else {
item.val = +Math.round((item.score / this.sumVote)*100)
item.val = +Math.round((item.score / amount)*100)
}
})
this.$nextTick(() => {
// const content = this.$refs.content as any[]
for (let i = 0; i < this.lists.length; i++) {
if ((this.lists[i] as any).name.length > 50) {
this.$set(this.lists[i], 'type1', 1)
......@@ -130,6 +114,7 @@ export default Vue.extend({
this.$set(this.lists[i], 'type1', 0)
}
}
loading.hideLoading()
})
})
}
......@@ -137,14 +122,6 @@ export default Vue.extend({
mounted() {
this.getDetails()
},
watch: {
$route(n, o) {
if (n.path.indexOf('/MyProject') <= -1) return
if (n.query.optionId !== o.query.optionId) {
this.getDetails()
}
}
}
})
</script>
......
......@@ -43,13 +43,9 @@ export default Vue.extend({
service.memberChangeVote({
voteId: this.$route.query.voteID as string,
addr: this.addr
}, () => {
}, {}, () => {
this.$router.push('/Mine')
})
// .then(res => {
// console.log(res)
// this.$router.push('/Mine')
// })
},
scan() {
scanQRCode('',(res: any) => {
......
<template>
<div class="bg-homeBanner bg-top bg-contain bg-no-repeat">
<h5 class="my-5 text-lg text-center text-white font-medium">我的</h5>
<!-- <div class="tab flex justify-center items-center">
<div class="px-8 text-sm" :class="{ 'active': tab === 1 }" @click="getList(1)">我发起的</div>
<div class="px-8 text-sm" :class="{ 'active': tab === 2 }" @click="getList(2)">我参与的</div>
</div>
<keep-alive>
<attend :tab="tab" />
</keep-alive> -->
<van-tabs class="bg-transparent" :swipe-threshold="3">
<van-tab title="我发起的提案">
<attend :tab="1" />
......
......@@ -7,7 +7,7 @@
</div>
<div class="p-4 border-0 border-b border-app-blue-3 border-solid" :class="{'mb-36': hide}">
<div
v-for="(item, index) in lists"
v-for="(item, index) in community.voteOptions"
:key="index"
class="mb-3 py-3 flex flex-col border border-app-blue-3 border-solid rounded-lg"
>
......@@ -50,6 +50,7 @@ import childView from '@/layouts/childView.vue'
import AppIcon from '@/components/common/Icon.vue'
import { Progress } from 'vant'
import { service } from '@/service/index'
import loading from '@/components/loading'
import Vue from 'vue'
Vue.use(Progress)
export default Vue.extend({
......@@ -60,17 +61,15 @@ export default Vue.extend({
},
data() {
return {
lists: [],
type1: true,
voteNum: '',
rest: 1111,
hide: false,
community: {},
sumVote: 0
community: {} as any,
}
},
methods: {
getDetails() {
loading.showLoading()
service.voteDetails({
execer: 'user.p.szhtest.rankvote',
funcName: 'GetRankVoteInfo',
......@@ -78,23 +77,25 @@ export default Vue.extend({
voteID: this.$route.query.voteID as string
}
}).then(res => {
this.community = res.data.result
this.lists = res.data.result.voteOptions
this.sumVote = +res.data.result.amount
this.lists.forEach((item: any) => {
const val = this.sumVote ? +parseInt((item.score / this.sumVote)*100 + '') : 0
loading.hideLoading()
this.community = res.result
const lists = res.result.voteOptions
const amount = +res.result.amount
this.community.voteOptions.forEach((item: any) => {
const val = amount ? +parseInt((item.score / amount)*100 + '') : 0
this.$set(item, 'val', val)
})
this.$nextTick(() => {
// const content = this.$refs.content as any[]
for (let i = 0; i < this.lists.length; i++) {
if ((this.lists[i] as any).name.length > 50) {
this.$set(this.lists[i], 'type1', 1)
for (let i = 0; i < lists.length; i++) {
if ((lists[i] as any).name.length > 50) {
this.$set(lists[i], 'type1', 1)
} else {
this.$set(this.lists[i], 'type1', 0)
this.$set(lists[i], 'type1', 0)
}
}
})
}).catch(() => {
loading.hideLoading()
})
},
goProject(id: number) {
......@@ -102,22 +103,15 @@ export default Vue.extend({
},
triggle(i: number, v: number) {
if (v === 1) {
this.$set(this.lists[i], 'type1', 2)
this.$set(this.community.voteOptions[i], 'type1', 2)
} else {
this.$set(this.lists[i], 'type1', 1)
this.$set(this.community.voteOptions[i], 'type1', 1)
}
}
},
mounted() {
this.getDetails()
},
watch: {
$route(n, o) {
if (n.query.voteID !== o.query.voteID) {
this.getDetails()
}
}
}
})
</script>
......
This diff is collapsed.
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