my.vue 9.7 KB

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