mine.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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(1);
  57. console.log('confirm', e)
  58. console.log(this.arr,'全部项目');
  59. if(this.arr.length==0){
  60. this.show = false
  61. return this.$u.toast(`未检测到测试项目`)
  62. }
  63. let getWay = this.arr.filter((item) => {
  64. return item.name == e.value[0]
  65. })
  66. console.log(getWay, '过滤');
  67. // console.log(getWay);
  68. uni.setStorageSync('testProjectId', getWay[0].id)
  69. uni.setStorageSync('gatewayDeviceId', getWay[0].gatewayDeviceId)
  70. // uni.setStorageSync('testProjectId', e.value[0].id)
  71. this.value = getWay[0].name
  72. this.show = false
  73. },
  74. selectClick(index) {
  75. console.log(index)
  76. },
  77. choose() {
  78. this.show3 = true
  79. console.log('我弹出来了');
  80. },
  81. toUpload() {
  82. uni.navigateTo({
  83. url: "/pages/upload-face/upload-face"
  84. })
  85. },
  86. toList() {
  87. uni.navigateTo({
  88. url: "/pages/project-list/project-list"
  89. })
  90. },
  91. exit() {
  92. uni.showModal({
  93. title: '温馨提示',
  94. content: '确定要退出吗?',
  95. success: res => {
  96. if (res.confirm) {
  97. uni.removeStorageSync('Token')
  98. uni.removeStorageSync('userId')
  99. uni.removeStorageSync('testProjectId')
  100. uni.redirectTo({
  101. url: "/pages/login/login"
  102. })
  103. }
  104. }
  105. })
  106. },
  107. toAddProject() {
  108. uni.navigateTo({
  109. url: "/pages/add-project/add-project"
  110. })
  111. },
  112. async getProjectList() {
  113. // uni.showLoading({
  114. // title: "正在请求中"
  115. // })
  116. const {
  117. data: res
  118. } = await uni.$http.post('/api/v1/test/testProject/queryByCondition', this.msg)
  119. // console.log(res,'项目');
  120. uni.hideLoading()
  121. if (res.code == 200) {
  122. if (res.data.records.length == 0) {
  123. this.$u.toast(`未检测到测试项目`)
  124. } else {
  125. let filter = []
  126. res.data.records.forEach((item) => {
  127. filter.push(item.name)
  128. })
  129. this.columns[0] = filter
  130. this.arr = res.data.records
  131. }
  132. // let filter = []
  133. // res.data.records.forEach((item) => {
  134. // filter.push(item.description)
  135. // })
  136. // this.columns[0] = filter
  137. // this.arr = res.data.records
  138. } else {
  139. this.$u.toast(`请求失败`)
  140. }
  141. }
  142. },
  143. onLoad(options) {
  144. this.getProjectList()
  145. // const {
  146. // page
  147. // } = options
  148. // if (page == upload) {
  149. // uni.navigateTo({
  150. // url: '/pages/mine/mine',
  151. // success: () => {
  152. // uni.navigateBack()
  153. // }
  154. // })
  155. // }
  156. }
  157. }
  158. </script>
  159. <style lang="scss">
  160. page {
  161. background: #eaeaea;
  162. }
  163. .myContent {
  164. width: 100%;
  165. height: 100%;
  166. margin: 0 auto;
  167. }
  168. .header {
  169. flex-direction: row;
  170. display: flex;
  171. height: 200rpx;
  172. }
  173. .headbgImage {
  174. height: 25%;
  175. width: 100%;
  176. position: absolute;
  177. z-index: 1;
  178. }
  179. .myPhoto {
  180. height: 140rpx;
  181. width: 140rpx;
  182. position: absolute;
  183. z-index: 2;
  184. margin-left: 3%;
  185. margin-top: 3%;
  186. border-radius: 50%;
  187. img {
  188. border-radius: 50%;
  189. width: 100%;
  190. height: 100%;
  191. }
  192. }
  193. .myInformation {
  194. position: absolute;
  195. z-index: 2;
  196. margin-left: 25%;
  197. margin-top: 9%;
  198. }
  199. .exit {
  200. margin-top: 50px;
  201. background: white;
  202. width: 100%;
  203. // margin-left: 20rpx;
  204. height: 176rpx;
  205. // border-radius: 10px;
  206. }
  207. .middle-num {
  208. position: absolute;
  209. z-index: 2;
  210. display: flex;
  211. flex-wrap: nowrap;
  212. background: white;
  213. width: 100%;
  214. // margin-left: 20rpx;
  215. height: 93rpx;
  216. // border-radius: 10px;
  217. margin-top: -16rpx;
  218. }
  219. .popup {
  220. height: 700rpx;
  221. width: 100vw;
  222. // width: calc(100vw - 40rpx);
  223. // margin: 0 20rpx;
  224. .title {
  225. padding: 20rpx;
  226. text-align: center;
  227. }
  228. }
  229. </style>