12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <template>
- <view>
- <uni-list >
- <uni-list-item v-for="(item,index) in projectList" :title="item.unitCode" :key="index" :rightText="item.unitName" @click="onClick(index,item)" clickable style="cursor: pointer;"/>
- </uni-list>
- </view>
- </template>
- <script>
- import {selectProject} from "@/common/api/commonApi.js";
- export default {
- data() {
- return {
- projectList:[]
- }
- },
- onLoad:function(){
- this.$util.persistLogin(this);
- },
- created:function(){
- this.getProjectList();
- },
- methods: {
- getProjectList:function(){
- var that=this;
- selectProject().then((res)=>{
- console.info('getProjectList',res);
-
- res.forEach(function(item,index,array){
- that.$set(that.projectList,index,item);
- });
- //console.info(that.projectList);
- });
- },
- onClick:function(index,item) {
- //console.info(index);
- //console.info(item);
- let unitCode=item.unitCode; //获取项目编码
- this.$store.commit('setProjectCode',unitCode); //赋值
- uni.setStorage({
- key:'storage_state',
- data:this.$store.state,
- success:function(){
- console.info("setProjectCode选择项目后状态缓存成功");
- },
- fail: () => {
- console.error("setProjectCode选择项目后状态缓存失败");
- }
- });
- //导向到首页
- uni.navigateTo({
- url: "/pages/index/index"
- });
- // uni.showToast({
- // title: '点击反馈'
- // });
- }
- }
- }
- </script>
- <style>
- </style>
|