menu.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <view class="mine-area">
  3. <image style="width: 100%;" mode="aspectFill" :src="require('@/static/images/微信图片_20230411112151.png')"></image>
  4. <view class="big-circle"></view>
  5. <view class="avatar-area z10" >
  6. <u-avatar :src="src" size="80" shape="circle"></u-avatar>
  7. </view>
  8. <view class="menu-area z10">
  9. <view class="basic-msg">
  10. <text class="basic-name">{{name}}</text>
  11. <!-- <text class="basic-amount">借用中设备:{{amount}}</text> -->
  12. </view>
  13. <u-list
  14. :enableFlex="true"
  15. >
  16. <u-list-item>
  17. <view class="menu-list" @click="toPersonInfo">
  18. <i class="iconfont icon-ditu"></i>
  19. <text>我的信息</text>
  20. </view>
  21. </u-list-item>
  22. <u-list-item>
  23. <view class="menu-list" @click="toBorrowRecord">
  24. <i class="iconfont icon-qianbao"></i>
  25. <text style="margin-right: 10rpx;">借用记录</text>
  26. <u-badge max="99" :value="amount"></u-badge>
  27. </view>
  28. </u-list-item>
  29. <u-list-item>
  30. <view class="menu-list" @click="toRepeat">
  31. <i class="iconfont icon-a-shezhi2"></i>
  32. <text>故障上报</text>
  33. </view>
  34. </u-list-item>
  35. <u-list-item v-if="role==='admin'?true:false">
  36. <view class="menu-list" @click="toHandleFault">
  37. <i class="iconfont icon-baogaoguanli"></i>
  38. <text>故障处理</text>
  39. </view>
  40. </u-list-item>
  41. <u-list-item v-if="role==='admin'?true:false">
  42. <view class="menu-list" @click="showPopup">
  43. <i class="iconfont icon-bangzhu"></i>
  44. <text>重置密码</text>
  45. </view>
  46. </u-list-item>
  47. <!--
  48. <u-list-item>
  49. <view class="menu-list">
  50. <i class="iconfont "></i>
  51. <text>关于我们</text>
  52. </view>
  53. </u-list-item> -->
  54. <u-list-item>
  55. <view class="menu-list" @click="toLogout">
  56. <i class="iconfont icon-tuichu"></i>
  57. <text>退出登录</text>
  58. </view>
  59. </u-list-item>
  60. </u-list>
  61. </view>
  62. <u-popup :show="show" @close="close" :round="10" closeable>
  63. <view class="popup-area">
  64. <view class="form-area" style="padding:0 20rpx;">
  65. <text class="form-label">工号</text>
  66. <u--input placeholder="请输入工号" clearable v-model="userName"></u--input>
  67. </view>
  68. <view class="form-area" style="padding:0 20rpx;margin-top: 20rpx;">
  69. <text class="form-label">新密码</text>
  70. <u--input placeholder="请输入新密码" clearable v-model="password"></u--input>
  71. </view>
  72. <view class="pwd-btn">
  73. <!-- <u-button size="small" @click="show = false">取消</u-button> -->
  74. <u-button type="primary" @click="resetPassword">重置密码</u-button>
  75. </view>
  76. </view>
  77. </u-popup>
  78. <u-toast ref="uToast" />
  79. </view>
  80. </template>
  81. <script>
  82. import cache from '@/utils/storage.js'
  83. import { sumBorrow } from '@/api/asset.js'
  84. import { logout,resetPwd } from '@/api/user.js'
  85. export default {
  86. data() {
  87. return {
  88. src: 'https://tupian.qqw21.com/article/UploadPic/2021-1/20211722215735941.jpg',
  89. name: "",
  90. amount:null,
  91. role:"",
  92. show: false,
  93. userName:"",
  94. password:""
  95. };
  96. },
  97. methods:{
  98. close(){
  99. this.show = false
  100. },
  101. showPopup(){
  102. this.show = true
  103. this.userName = ""
  104. this.password = ""
  105. },
  106. resetPassword(){
  107. if(this.userName.trim()===""){
  108. uni.showToast({
  109. icon:'error',
  110. title:'请输入工号'
  111. })
  112. return
  113. }
  114. if(this.password.trim()===""){
  115. uni.showToast({
  116. icon:'error',
  117. title:'请输入工号'
  118. })
  119. return
  120. }
  121. resetPwd(this.userName,this.password).then(res=>{
  122. if(res.data.code===200 && res.data.msg==="操作成功"){
  123. uni.showToast({
  124. icon:'success',
  125. title:'重置成功',
  126. duration:1000,
  127. success: () => {
  128. this.show = false
  129. }
  130. })
  131. }
  132. // console.log(res)
  133. })
  134. },
  135. toPersonInfo(){
  136. uni.navigateTo({
  137. url:'/pages/menus/mine/mine'
  138. })
  139. },
  140. toBorrowRecord(){
  141. uni.switchTab({
  142. url:'/pages/menus/borrow-record/borrow-record'
  143. })
  144. },
  145. init(){
  146. sumBorrow(0).then(res=>{
  147. this.amount = res
  148. })
  149. },
  150. toRepeat(){
  151. uni.scanCode({
  152. scanType:['barCode'],
  153. success (res) {
  154. uni.navigateTo({
  155. url:'/pages/fault/fault-report/fault-report?id='+res.result
  156. })
  157. }
  158. })
  159. },
  160. toHandleFault(){
  161. uni.navigateTo({
  162. url:'/pages/fault/fault-list/fault-list'
  163. })
  164. },
  165. toLogout(){
  166. //#ifdef MP-WEIXIN
  167. wx.showModal({
  168. title: '系统提示',
  169. content: '是否确认退出登录?',
  170. success (res) {
  171. uni.showLoading({
  172. title:'正在退出登录中',
  173. icon:'none',
  174. mask:true
  175. })
  176. if (res.confirm) {
  177. try{
  178. logout().then(res=>{
  179. if(res.data.code===200&&res.data.msg==="退出成功"){
  180. uni.hideLoading()
  181. uni.switchTab({
  182. url:'/pages/home/home'
  183. })
  184. }
  185. })
  186. }catch(err){
  187. uni.hideLoading()
  188. }
  189. } else if (res.cancel) {
  190. uni.hideLoading()
  191. console.log('用户点击取消')
  192. }
  193. }
  194. })
  195. //#endif
  196. //#ifndef MP-WEIXIN
  197. uni.showModal({
  198. title: '系统提示',
  199. content: '是否确认退出登录?',
  200. success (res) {
  201. uni.showLoading({
  202. title:'正在退出登录中',
  203. icon:'none',
  204. mask:true
  205. })
  206. if (res.confirm) {
  207. try{
  208. logout().then(res=>{
  209. if(res.data.code===200&&res.data.msg==="退出成功"){
  210. uni.hideLoading()
  211. uni.switchTab({
  212. url:'/pages/home/home'
  213. })
  214. }
  215. })
  216. }catch(err){
  217. uni.hideLoading()
  218. }
  219. } else if (res.cancel) {
  220. uni.hideLoading()
  221. console.log('用户点击取消')
  222. }
  223. }
  224. })
  225. //#endif
  226. }
  227. },
  228. onLoad() {
  229. this.init()
  230. },
  231. onShow(){
  232. this.name = cache.session.getJSON('nickName')
  233. this.role = cache.session.getJSON('role')
  234. }
  235. }
  236. </script>
  237. <style lang="scss">
  238. .mine-area{
  239. // background-color: #225f15;
  240. // background-image: url('@/static/images/tsg02 (1).jpg');
  241. height: 100vh;
  242. position: relative;
  243. overflow: hidden;
  244. }
  245. .big-circle{
  246. width: 937px;
  247. height: 937px;
  248. background-color: rgba(255, 255, 255, 1);
  249. border-radius: 50%;
  250. position: absolute;
  251. top: 25%;
  252. left: 50%;
  253. transform: translate(-50%, 0);
  254. z-index: 5;
  255. }
  256. .avatar-area{
  257. position: absolute;
  258. top: 25%;
  259. left: 20%;
  260. transform: translateY(-50%);
  261. }
  262. .z10{
  263. z-index: 10;
  264. }
  265. .menu-area{
  266. height: 65%;
  267. width: 100%;
  268. position: absolute;
  269. bottom: 0;
  270. padding: 0 64rpx;
  271. box-sizing: border-box;
  272. }
  273. .menu-list{
  274. display: flex;
  275. align-items: center;
  276. font-size: 30rpx;
  277. padding: 20rpx 0 ;
  278. color: #323538;
  279. .iconfont{
  280. font-size: 65rpx;
  281. padding-right: 20rpx;
  282. }
  283. }
  284. .basic-msg{
  285. display: flex;
  286. margin-bottom: 40rpx;
  287. flex-direction: column;
  288. .basic-name{
  289. font-size: 32rpx;
  290. line-height: 150%;
  291. }
  292. .basic-amount{
  293. color: rgba(128, 128, 128, 1);
  294. font-size: 26rpx;
  295. line-height: 150%;
  296. }
  297. }
  298. .popup-area{
  299. height: 500rpx;
  300. box-sizing: border-box;
  301. padding: 0 30rpx;
  302. .form-area{
  303. display: flex;
  304. align-items: center;
  305. margin-top: 100rpx;
  306. .form-label{
  307. // padding: 0 20rpx 0 0;
  308. display: inline-block;
  309. width: 140rpx;
  310. text-align: left;
  311. }
  312. }
  313. .pwd-btn{
  314. display: flex;
  315. padding-top: 50rpx;
  316. /deep/.u-button{
  317. margin: 30rpx;
  318. }
  319. }
  320. }
  321. </style>