menu.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <view class="mine-area">
  3. <image style="width: 100%;" mode="aspectFill" :src="imgSrc('/profile/logo/menuBackgroundImage.png')"></image>
  4. <view class="big-circle"></view>
  5. <view class="avatar-area z10" >
  6. <u-avatar :src="avatar.length > 0 ? imgSrc(avatar) : 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. import { getImage } from '@/api/visitor.js'
  86. export default {
  87. data() {
  88. return {
  89. src: 'https://tupian.qqw21.com/article/UploadPic/2021-1/20211722215735941.jpg',
  90. avatar: '',
  91. name: "",
  92. amount:null,
  93. role:"",
  94. show: false,
  95. userName:"",
  96. password:""
  97. };
  98. },
  99. methods:{
  100. close(){
  101. this.show = false
  102. },
  103. showPopup(){
  104. this.show = true
  105. this.userName = ""
  106. this.password = ""
  107. },
  108. imgSrc(src) {
  109. return getImage(src)
  110. },
  111. resetPassword(){
  112. if(this.userName.trim()===""){
  113. uni.showToast({
  114. icon:'error',
  115. title:'请输入工号'
  116. })
  117. return
  118. }
  119. if(this.password.trim()===""){
  120. uni.showToast({
  121. icon:'error',
  122. title:'请输入工号'
  123. })
  124. return
  125. }
  126. resetPwd(this.userName,this.password).then(res=>{
  127. if(res.data.code===200 && res.data.msg==="操作成功"){
  128. uni.showToast({
  129. icon:'success',
  130. title:'重置成功',
  131. duration:1000,
  132. success: () => {
  133. this.show = false
  134. }
  135. })
  136. }
  137. // console.log(res)
  138. })
  139. },
  140. toPersonInfo(){
  141. uni.navigateTo({
  142. url:'/pages/menus/mine/mine'
  143. })
  144. },
  145. toBorrowRecord(){
  146. uni.switchTab({
  147. url:'/pages/menus/borrow-record/borrow-record'
  148. })
  149. },
  150. init(){
  151. sumBorrow(0).then(res=>{
  152. this.amount = res
  153. })
  154. },
  155. toRepeat(){
  156. uni.scanCode({
  157. scanType:['barCode'],
  158. success (res) {
  159. uni.navigateTo({
  160. url:'/pages/fault/fault-report/fault-report?id='+res.result
  161. })
  162. }
  163. })
  164. },
  165. toHandleFault(){
  166. uni.navigateTo({
  167. url:'/pages/fault/fault-list/fault-list'
  168. })
  169. },
  170. toLogout(){
  171. //#ifdef MP-WEIXIN
  172. wx.showModal({
  173. title: '系统提示',
  174. content: '是否确认退出登录?',
  175. success (res) {
  176. uni.showLoading({
  177. title:'正在退出登录中',
  178. icon:'none',
  179. mask:true
  180. })
  181. if (res.confirm) {
  182. try{
  183. logout().then(res=>{
  184. if(res.data.code===200&&res.data.msg==="退出成功"){
  185. uni.hideLoading()
  186. uni.switchTab({
  187. url:'/pages/home/home'
  188. })
  189. }
  190. })
  191. }catch(err){
  192. uni.hideLoading()
  193. }
  194. } else if (res.cancel) {
  195. uni.hideLoading()
  196. console.log('用户点击取消')
  197. }
  198. }
  199. })
  200. //#endif
  201. //#ifndef MP-WEIXIN
  202. uni.showModal({
  203. title: '系统提示',
  204. content: '是否确认退出登录?',
  205. success (res) {
  206. uni.showLoading({
  207. title:'正在退出登录中',
  208. icon:'none',
  209. mask:true
  210. })
  211. if (res.confirm) {
  212. try{
  213. logout().then(res=>{
  214. if(res.data.code===200&&res.data.msg==="退出成功"){
  215. uni.hideLoading()
  216. uni.switchTab({
  217. url:'/pages/home/home'
  218. })
  219. }
  220. })
  221. }catch(err){
  222. uni.hideLoading()
  223. }
  224. } else if (res.cancel) {
  225. uni.hideLoading()
  226. console.log('用户点击取消')
  227. }
  228. }
  229. })
  230. //#endif
  231. }
  232. },
  233. onLoad() {
  234. this.init()
  235. },
  236. onShow(){
  237. this.init()
  238. this.name = cache.session.getJSON('nickName')
  239. this.role = cache.session.getJSON('role')
  240. this.avatar = cache.session.getJSON('avatar')
  241. }
  242. }
  243. </script>
  244. <style lang="scss">
  245. .mine-area{
  246. // background-color: #225f15;
  247. // background-image: url('@/static/images/tsg02 (1).jpg');
  248. height: 100vh;
  249. position: relative;
  250. overflow: hidden;
  251. }
  252. .big-circle{
  253. width: 937px;
  254. height: 937px;
  255. background-color: rgba(255, 255, 255, 1);
  256. border-radius: 50%;
  257. position: absolute;
  258. top: 25%;
  259. left: 50%;
  260. transform: translate(-50%, 0);
  261. z-index: 5;
  262. }
  263. .avatar-area{
  264. position: absolute;
  265. top: 25%;
  266. left: 20%;
  267. transform: translateY(-50%);
  268. }
  269. .z10{
  270. z-index: 10;
  271. }
  272. .menu-area{
  273. height: 65%;
  274. width: 100%;
  275. position: absolute;
  276. bottom: 0;
  277. padding: 0 64rpx;
  278. box-sizing: border-box;
  279. }
  280. .menu-list{
  281. display: flex;
  282. align-items: center;
  283. font-size: 30rpx;
  284. padding: 20rpx 0 ;
  285. color: #323538;
  286. .iconfont{
  287. font-size: 65rpx;
  288. padding-right: 20rpx;
  289. }
  290. }
  291. .basic-msg{
  292. display: flex;
  293. margin-bottom: 40rpx;
  294. flex-direction: column;
  295. .basic-name{
  296. font-size: 32rpx;
  297. line-height: 150%;
  298. }
  299. .basic-amount{
  300. color: rgba(128, 128, 128, 1);
  301. font-size: 26rpx;
  302. line-height: 150%;
  303. }
  304. }
  305. .popup-area{
  306. height: 500rpx;
  307. box-sizing: border-box;
  308. padding: 0 30rpx;
  309. .form-area{
  310. display: flex;
  311. align-items: center;
  312. margin-top: 100rpx;
  313. .form-label{
  314. // padding: 0 20rpx 0 0;
  315. display: inline-block;
  316. width: 140rpx;
  317. text-align: left;
  318. }
  319. }
  320. .pwd-btn{
  321. display: flex;
  322. padding-top: 50rpx;
  323. /deep/.u-button{
  324. margin: 30rpx;
  325. }
  326. }
  327. }
  328. </style>