project.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="">
  3. <scroll-view scroll-y="true" class="DrawerPage margin-bottom-xxxl">
  4. <cu-custom bgColor="bg-blue" :isBack="true">
  5. <block slot="backText">项目管理</block>
  6. <block slot="content"></block>
  7. <block slot="right">
  8. <view class=" flex justify-center">
  9. <!-- <button class="margin-top-ssm cu-btn round bg-blue text-blue"><text class="cuIcon-add"></text></button> -->
  10. </view>
  11. </block>
  12. </cu-custom>
  13. <view class="cu-list menu margin-bottom-xl shadow-lg margin-top-sm">
  14. <!-- 菜单-->
  15. <view class="cu-item " style="height: 100%;" v-for="(item,index) in list" :key="index" :class="index==0 ? 'margin-bottom-sm':'' ">
  16. <view class="content padding-tb-sm" v-if="index==0">
  17. <view>
  18. <text class="text-black text-bold text-xl">{{item.project_name}}</text>
  19. </view>
  20. <view>
  21. <text class="text-black text-lg span-wrap">{{item.contractName}}</text>
  22. </view>
  23. <view class="flex justify-start">
  24. <text class="text-gray text-sm">{{item.startTime | timeStamp}} 加入</text>
  25. <button @click="current(item)" class="cu-btn round line-orange" style="margin-left: auto;" >
  26. <image class="login-img" src="/static/user/star.png"></image> <text class="text-orange">当前项目</text>
  27. </button>
  28. </view>
  29. </view>
  30. <view class="content padding-tb-sm content_b" v-else>
  31. <view>
  32. <text class="text-black text-bold text-xl">{{item.project_name}}</text>
  33. </view>
  34. <view>
  35. <text class="text-black text-lg span-wrap">{{item.contractName}}</text>
  36. </view>
  37. <view class="flex justify-start">
  38. <text class="text-gray text-sm">{{item.startTime | timeStamp}} 加入</text>
  39. <button class="cu-btn round line-blue" @click="current(item)" style="margin-left: auto;">
  40. <text class="text-blue">设为当前</text>
  41. </button>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="flex justify-center text-gray margin-bottom-big">没有更多内容了~</view>
  47. </scroll-view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data () {
  53. return {
  54. list:[],
  55. type:"",
  56. }
  57. },
  58. onLoad(e) {
  59. if(e.type){
  60. this.type=e.type;
  61. }
  62. this.findProject();
  63. },
  64. filters:{
  65. timeStamp: function(value) {
  66. if (!value) return '';
  67. var now = new Date(value);
  68. var year = now.getFullYear();
  69. var month = now.getMonth() + 1;
  70. if (month < 10) {
  71. month = '0' + month
  72. }
  73. var date = now.getDate();
  74. if (date < 10) {
  75. date = '0' + date
  76. }
  77. return year + "-" + month + "-" + date
  78. },
  79. },
  80. methods: {
  81. findProject(){
  82. var that =this;
  83. var userInfo = uni.getStorageSync("userInfo")
  84. that.userInfo = userInfo;
  85. that.http.request('/app/findProject', { userId:userInfo.id}).then((result)=>{
  86. let lastData=[];
  87. let datas = result.datas;
  88. var project = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id);
  89. if(project){
  90. uni.setStorageSync("storeName",project.store_name);
  91. var id = project.contractId;
  92. datas.forEach((item,index,arry)=>{
  93. if(item.contractId!=id){
  94. lastData.push(item);//存放没有选择的
  95. }else{
  96. that.list.push(item)//存放已选择的
  97. }
  98. })
  99. }
  100. lastData.forEach((item,index,arry)=>{
  101. that.list.push(item);
  102. })
  103. });
  104. },
  105. current(data){
  106. if(this.type==1){//首页跳转过来的
  107. //如果选择,则设置权限
  108. uni.setStorageSync("storeName",data.store_name);
  109. uni.setStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id,data);
  110. uni.navigateBack({
  111. delta: 1
  112. });
  113. }else{
  114. //如果选择,则设置权限
  115. uni.setStorageSync("storeName",data.store_name);
  116. uni.setStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id,data);
  117. this.$prompt.none("设置成功");
  118. setTimeout(function(){
  119. uni.redirectTo({
  120. url:'/pages/user/project/project'
  121. })
  122. },200)
  123. }
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss">
  129. .box {
  130. margin-top:-20rpx;
  131. }
  132. .box view.cu-bar {
  133. margin-top: 20upx;
  134. }
  135. .page {
  136. height: 100Vh;
  137. width: 100vw;
  138. }
  139. .page.show {
  140. overflow: hidden;
  141. }
  142. .cu-list.menu-avatar>.cu-item .content {
  143. position: absolute;
  144. left: 10px;
  145. width: calc(100% - 48px - 30px - 60px - 10px);
  146. line-height: 1.6em;
  147. }
  148. .text-black{
  149. color:#101010;
  150. }
  151. .cu-list.menu>.cu-item:after {
  152. border-bottom: 1px dashed #fff !important;
  153. }
  154. .content_b{border-bottom: 1px solid #E3e1e1;}
  155. .cu-item:last-child .content_b{border-bottom: none;}
  156. .span-wrap{
  157. word-break: break-all;white-space: normal;
  158. }
  159. </style>