Commit 8ac9f6ed authored by xhx's avatar xhx

fix:调整

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