SelectProject.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view>
  3. <uni-list >
  4. <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;"/>
  5. </uni-list>
  6. </view>
  7. </template>
  8. <script>
  9. import {selectProject} from "@/common/api/commonApi.js";
  10. export default {
  11. data() {
  12. return {
  13. projectList:[]
  14. }
  15. },
  16. onLoad:function(){
  17. this.$util.persistLogin(this);
  18. },
  19. created:function(){
  20. this.getProjectList();
  21. },
  22. methods: {
  23. getProjectList:function(){
  24. var that=this;
  25. selectProject().then((res)=>{
  26. console.info('getProjectList',res);
  27. if(!res.isSuccess){
  28. uni.showToast({
  29. title:res.errMsg,
  30. duration:3000,
  31. icon:"none"
  32. });
  33. }
  34. res.data.forEach(function(item,index,array){
  35. that.$set(that.projectList,index,item);
  36. });
  37. //console.info(that.projectList);
  38. });
  39. },
  40. onClick:function(index,item) {
  41. //console.info(index);
  42. //console.info(item);
  43. let unitCode=item.unitCode; //获取项目编码
  44. this.$store.commit('setProjectCode',unitCode); //赋值
  45. uni.setStorage({
  46. key:'storage_state',
  47. data:this.$store.state,
  48. success:function(){
  49. console.info("setProjectCode选择项目后状态缓存成功");
  50. },
  51. fail: () => {
  52. console.error("setProjectCode选择项目后状态缓存失败");
  53. }
  54. });
  55. //导向到首页
  56. uni.navigateTo({
  57. url: "/pages/index/index"
  58. });
  59. // uni.showToast({
  60. // title: '点击反馈'
  61. // });
  62. }
  63. }
  64. }
  65. </script>
  66. <style>
  67. </style>