my.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <view>
  3. <template v-if="!userInfo || !userInfo.realName">
  4. <view class="top d-flex a-center px3 main-color-bg" @tap="login">
  5. <view class="img">
  6. <image src="/static/images/user_pic.png" mode=""></image>
  7. </view>
  8. <view class="ml-3 f-size-36 text-color-white">登录 / 注册</view>
  9. </view>
  10. </template>
  11. <template v-else>
  12. <view class="top d-flex a-center px3 main-color-bg">
  13. <view class="img">
  14. <image :src="myAvatar" @error="myDefaultAvatar" mode=""></image>
  15. </view>
  16. <view class="ml-3 f-size-36 text-color-white">{{
  17. userInfo.realName
  18. }}</view>
  19. </view>
  20. </template>
  21. <view class="divider"></view>
  22. <view class="px3 bg-color-white">
  23. <view class="f-size-32 f-weight-bold py2 border-bottom">我的任务</view>
  24. <!-- <my-card
  25. icon="icon-runhuaguanli"
  26. title="点检任务"
  27. :tipNum="gatherTask.checkTask"
  28. @handleLubrication="handleCheck"
  29. ></my-card>
  30. <my-card
  31. icon="icon-xunjianguanli"
  32. title="巡检填报"
  33. @handleLubrication="handleInspection"
  34. ></my-card>-->
  35. <!-- <my-card icon="icon-tubiaozhizuomoban-135" title="今日保养任务" :tipNum="gatherTask.lubricationTask" @handleLubrication="handleMaintain(1)"></my-card> -->
  36. <!-- <my-card icon="icon-tubiaozhizuomoban-135" title="本周保养任务" :tipNum="gatherTask.lubricationTaskWeek" @handleLubrication="handleMaintain(2)"></my-card> -->
  37. <my-card icon="icon-tubiaozhizuomoban-135" title="本月保养任务" :tipNum="gatherTask.lubricationTaskMonth" @handleLubrication="handleMaintain(3)"></my-card>
  38. <!-- <my-card
  39. icon="icon-jiayou"
  40. title="加油任务"
  41. :tipNum="gatherTask.oilTask"
  42. @handleLubrication="handleOiling"
  43. iColor="#F1650C"
  44. ></my-card>-->
  45. <my-card v-show="$BaseTool.UserUtil.getUserInfo() != null && ($BaseTool.UserUtil.isRepairRole() || $BaseTool.UserUtil.isManagerRole())" icon="icon-weixiu" title="维修任务" :tipNum="gatherTask.repairTask" @handleLubrication="handleService"></my-card>
  46. <my-card v-show="$BaseTool.UserUtil.getUserInfo() != null && $BaseTool.UserUtil.isManagerRole()" icon="icon-tubiaozhizuomoban-135" title="审核任务" :tipNum="gatherTask.repairCheckTask" @handleLubrication="handleRepairCheck"></my-card>
  47. <!-- <my-card
  48. icon="icon-tubiaozhizuomoban-135"
  49. title="盘点任务"
  50. :tipNum="gatherTask.storeCheckTask"
  51. @handleLubrication="handleStoreCheck"
  52. ></my-card>-->
  53. </view>
  54. <view class="divider"></view>
  55. <view class="px3 bg-color-white">
  56. <my-card icon="icon-shezhi" title="设置" @handleLubrication="getSetting"></my-card>
  57. </view>
  58. <u-tabbar :list="tabbar" :mid-button="true" active-color="#0082ff"></u-tabbar>
  59. </view>
  60. </template>
  61. <script>
  62. export default {
  63. data() {
  64. return {
  65. userInfo: {
  66. realName: null,
  67. avatar: null
  68. },
  69. gatherTask: {
  70. checkTask: 0,
  71. maintainTask: 0,
  72. lubricationTask: 0,
  73. lubricationTaskWeek: 0,
  74. lubricationTaskMonth: 0,
  75. oilTask: 0,
  76. repairTask: 0,
  77. repairCheckTask: 0
  78. },
  79. myAvatar: '',
  80. tabbar: [
  81. {
  82. iconPath: '/static/tabars/home.png',
  83. pagePath: '/pages/home/home',
  84. selectedIconPath: '/static/tabars/home_s.png',
  85. text: '首页'
  86. },
  87. {
  88. iconPath: '/static/tabars/order.png',
  89. pagePath: '/pages/operate/operate',
  90. selectedIconPath: '/static/tabars/order_s.png',
  91. text: '功能'
  92. },
  93. {
  94. iconPath: '/static/tabars/publish.png',
  95. pagePath: '/pages/middle/middle',
  96. selectedIconPath: '/static/tabars/publish.png',
  97. text: '报修',
  98. midButton: true
  99. },
  100. {
  101. iconPath: '/static/tabars/tiding.png',
  102. pagePath: '/pages/tidings/tidings',
  103. selectedIconPath: '/static/tabars/tiding_s.png',
  104. text: '消息'
  105. },
  106. {
  107. iconPath: '/static/tabars/mine.png',
  108. pagePath: '/pages/my/my',
  109. selectedIconPath: '/static/tabars/mine_s.png',
  110. text: '我的'
  111. }
  112. ]
  113. }
  114. },
  115. onLoad() {},
  116. onShow() {
  117. this.userInfo = this.$BaseTool.UserUtil.getUserInfo()
  118. if (!this.userInfo || !this.userInfo.username) {
  119. uni.showModal({
  120. content: '登录后方可查看内容',
  121. showCancel: true,
  122. cancelText: '账号登录',
  123. confirmText: '快捷登录',
  124. success: res => {
  125. if (res.confirm) {
  126. this.$Http.loginQuickly().then(res => {
  127. const url = res.data
  128. if (url !== '' && url !== null && url != undefined) {
  129. // 请求用户授权
  130. window.location.href = url
  131. }
  132. })
  133. } else if (res.cancel) {
  134. uni.reLaunch({ url: '/pages/login/login' })
  135. }
  136. }
  137. })
  138. return
  139. }
  140. this.myAvatar = this.$BaseTool.UserUtil.getFileUrl(this.userInfo.avatar)
  141. this.$Http.getGatherTask().then(res => {
  142. this.gatherTask = res.data
  143. })
  144. },
  145. methods: {
  146. myDefaultAvatar() {
  147. this.myAvatar = '/static/images/user_pic.png'
  148. },
  149. getSetting() {
  150. uni.navigateTo({
  151. url: '../setting/setting'
  152. })
  153. },
  154. // 维修任务
  155. handleService() {
  156. uni.navigateTo({
  157. url: '../service/service?filter=0'
  158. })
  159. },
  160. // 维修验收任务
  161. handleRepairCheck() {
  162. uni.navigateTo({
  163. url: '../repair-check/repair-check'
  164. })
  165. },
  166. // 盘点任务
  167. handleStoreCheck() {
  168. uni.navigateTo({
  169. url: '../store-check/list'
  170. })
  171. },
  172. // 加油任务
  173. handleOiling() {
  174. uni.navigateTo({
  175. url: '../oiling/oiling'
  176. })
  177. },
  178. // 点检任务
  179. handleCheck() {
  180. uni.navigateTo({
  181. url: '../check/check'
  182. })
  183. },
  184. // 保养任务
  185. handleMaintain(searchType) {
  186. uni.navigateTo({
  187. url: '../maintain/mainPosition?timeFlag=' + searchType
  188. })
  189. },
  190. // 巡检任务
  191. handleInspection() {
  192. uni.navigateTo({
  193. url: '../inspection/inspection'
  194. })
  195. },
  196. // 润滑任务
  197. handleLubrication(e) {
  198. uni.navigateTo({
  199. url: '../lubrication/lubrication'
  200. })
  201. },
  202. // 扫码
  203. handleCode() {
  204. // #ifdef H5
  205. uni.showToast({
  206. title: '暂不支持该功能',
  207. icon: 'none'
  208. })
  209. // #endif
  210. // #ifndef H5
  211. uni.scanCode({
  212. success(e) {
  213. console.log(e.result)
  214. if (e.result) {
  215. uni.navigateTo({
  216. url: '/pages/equipment-detail/equipment-detail?detailId=' + e.result
  217. })
  218. }
  219. }
  220. })
  221. // #endif
  222. },
  223. // 扫码出库
  224. handleCodeOut() {
  225. // #ifdef H5
  226. uni.showToast({
  227. title: '暂不支持该功能',
  228. icon: 'none'
  229. })
  230. // #endif
  231. // #ifndef H5
  232. uni.scanCode({
  233. success(e) {
  234. console.log(e.result)
  235. if (e.result) {
  236. uni.navigateTo({
  237. url: '/pages/out-store/out-store?detailId=' + e.result
  238. })
  239. }
  240. }
  241. })
  242. // #endif
  243. },
  244. // 登录
  245. login() {
  246. uni.navigateTo({
  247. url: '../login/login'
  248. })
  249. }
  250. }
  251. }
  252. </script>
  253. <style lang="less">
  254. page {
  255. background-color: #f4f4f4;
  256. }
  257. .often {
  258. image {
  259. width: unit(50, rpx);
  260. height: unit(50, rpx);
  261. }
  262. .iconfont {
  263. font-size: unit(50, rpx);
  264. }
  265. }
  266. .top {
  267. height: unit(200, rpx);
  268. .img {
  269. width: unit(128, rpx);
  270. height: unit(128, rpx);
  271. border-radius: 50%;
  272. image {
  273. width: unit(128, rpx);
  274. height: unit(128, rpx);
  275. border-radius: 50%;
  276. background-color: #999;
  277. // border: 5rpx solid #fff;
  278. }
  279. }
  280. }
  281. </style>