menu.vue 7.3 KB

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