mine.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <view class="myContent">
  3. <view class="header">
  4. <view class="myPhoto">
  5. <img src="https://img0.baidu.com/it/u=1250551608,2180019998&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500"
  6. alt="">
  7. </view>
  8. <text class="myInformation">{{userName}}</text>
  9. </view>
  10. <view class="middle-num">
  11. <u-cell-group>
  12. <!-- icon-style="color:red" -->
  13. <u-cell :border="false" icon="setting-fill" :value="value" title="项目选择" @click="projectChoose"
  14. :isLink="true"></u-cell>
  15. <!-- <u-cell icon="order" title="新增项目" @click="toAddProject" :isLink="true"></u-cell>
  16. <u-cell icon="list-dot" @click="toList" title="项目列表" :isLink="true"></u-cell> -->
  17. </u-cell-group>
  18. </view>
  19. <view class="exit">
  20. <u-cell-group>
  21. <u-cell @click="toUpload" icon="camera-fill" :isLink="true" title="上传人脸"></u-cell>
  22. <u-cell icon-style="color:#1296db" :border="false" @click="exit" icon="minus-people-fill" :isLink="true"
  23. title="退出登录"></u-cell>
  24. </u-cell-group>
  25. </view>
  26. <u-picker :show="show" :columns="columns" keyName='description' @confirm="confirm"
  27. @cancel="show=false"></u-picker>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. userName: uni.getStorageSync('userName'),
  35. pic: uni.getStorageSync('face'),
  36. msg: {
  37. userId: uni.getStorageSync('userId'),
  38. pageNo: 1,
  39. pageSize: 100
  40. },
  41. value: '',
  42. columns: [
  43. []
  44. ],
  45. show: false,
  46. arr: []
  47. }
  48. },
  49. methods: {
  50. projectChoose() {
  51. this.getProjectList()
  52. this.show = true
  53. console.log('弹出');
  54. },
  55. confirm(e) {
  56. // console.log('confirm', e.value[0])
  57. // console.log(this.arr,'全部项目');
  58. let getWay = this.arr.filter((item) => {
  59. return item.name == e.value[0]
  60. })
  61. console.log(getWay, '过滤');
  62. // console.log(getWay);
  63. uni.setStorageSync('testProjectId', getWay[0].id)
  64. uni.setStorageSync('gatewayDeviceId', getWay[0].gatewayDeviceId)
  65. // uni.setStorageSync('testProjectId', e.value[0].id)
  66. this.value = getWay[0].description
  67. this.show = false
  68. },
  69. selectClick(index) {
  70. console.log(index)
  71. },
  72. choose() {
  73. this.show3 = true
  74. console.log('我弹出来了');
  75. },
  76. toUpload() {
  77. uni.navigateTo({
  78. url: "/pages/upload-face/upload-face"
  79. })
  80. },
  81. toList() {
  82. uni.navigateTo({
  83. url: "/pages/project-list/project-list"
  84. })
  85. },
  86. exit() {
  87. uni.showModal({
  88. title: '温馨提示',
  89. content: '确定要退出吗?',
  90. success: res => {
  91. if (res.confirm) {
  92. uni.removeStorageSync('Token')
  93. uni.removeStorageSync('userId')
  94. uni.removeStorageSync('testProjectId')
  95. uni.redirectTo({
  96. url: "/pages/login/login"
  97. })
  98. }
  99. }
  100. })
  101. },
  102. toAddProject() {
  103. uni.navigateTo({
  104. url: "/pages/add-project/add-project"
  105. })
  106. },
  107. async getProjectList() {
  108. // uni.showLoading({
  109. // title: "正在请求中"
  110. // })
  111. const {
  112. data: res
  113. } = await uni.$http.post('/api/v1/test/testProject/queryByCondition', this.msg)
  114. // console.log(res,'项目');
  115. uni.hideLoading()
  116. if (res.code == 200) {
  117. if (res.data.records.length == 0) {
  118. this.$u.toast(`未检测到测试项目`)
  119. } else {
  120. let filter = []
  121. res.data.records.forEach((item) => {
  122. filter.push(item.description)
  123. })
  124. this.columns[0] = filter
  125. this.arr = res.data.records
  126. }
  127. let filter = []
  128. res.data.records.forEach((item) => {
  129. filter.push(item.description)
  130. })
  131. this.columns[0] = filter
  132. this.arr = res.data.records
  133. } else {
  134. this.$u.toast(`请求失败`)
  135. }
  136. }
  137. },
  138. onLoad(options) {
  139. this.getProjectList()
  140. // const {
  141. // page
  142. // } = options
  143. // if (page == upload) {
  144. // uni.navigateTo({
  145. // url: '/pages/mine/mine',
  146. // success: () => {
  147. // uni.navigateBack()
  148. // }
  149. // })
  150. // }
  151. }
  152. }
  153. </script>
  154. <style lang="scss">
  155. page {
  156. background: #eaeaea;
  157. }
  158. .myContent {
  159. width: 100%;
  160. height: 100%;
  161. margin: 0 auto;
  162. }
  163. .header {
  164. flex-direction: row;
  165. display: flex;
  166. height: 200rpx;
  167. }
  168. .headbgImage {
  169. height: 25%;
  170. width: 100%;
  171. position: absolute;
  172. z-index: 1;
  173. }
  174. .myPhoto {
  175. height: 140rpx;
  176. width: 140rpx;
  177. position: absolute;
  178. z-index: 2;
  179. margin-left: 3%;
  180. margin-top: 3%;
  181. border-radius: 50%;
  182. img {
  183. border-radius: 50%;
  184. width: 100%;
  185. height: 100%;
  186. }
  187. }
  188. .myInformation {
  189. position: absolute;
  190. z-index: 2;
  191. margin-left: 25%;
  192. margin-top: 9%;
  193. }
  194. .exit {
  195. margin-top: 50px;
  196. background: white;
  197. width: 100%;
  198. // margin-left: 20rpx;
  199. height: 176rpx;
  200. // border-radius: 10px;
  201. }
  202. .middle-num {
  203. position: absolute;
  204. z-index: 2;
  205. display: flex;
  206. flex-wrap: nowrap;
  207. background: white;
  208. width: 100%;
  209. // margin-left: 20rpx;
  210. height: 93rpx;
  211. // border-radius: 10px;
  212. margin-top: -16rpx;
  213. }
  214. .popup {
  215. height: 700rpx;
  216. width: 100vw;
  217. // width: calc(100vw - 40rpx);
  218. // margin: 0 20rpx;
  219. .title {
  220. padding: 20rpx;
  221. text-align: center;
  222. }
  223. }
  224. </style>