setting.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view>
  3. <u-navbar
  4. title="设置"
  5. title-color="#fff"
  6. :custom-back="customBack"
  7. :border-bottom="false"
  8. back-icon-color="#CCE8FF"
  9. :background="{background: 'linear-gradient(145deg, #41AFF9 0%, #2D8CFB 100%)' }"></u-navbar>
  10. <view class="cell-group" style="margin-top: 30rpx;">
  11. <u-cell-group>
  12. <u-cell-item title="修改密码" @click="openPage('pages/modifypwd/modifypwd')">
  13. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  14. </u-cell-item>
  15. <u-cell-item title="打印走纸" @click="onPrintFeed()">
  16. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  17. </u-cell-item>
  18. <u-cell-item title="地锁控制" @click="lockControl()">
  19. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  20. </u-cell-item>
  21. <u-cell-item title="退出登录" @click="onLoginOut()">
  22. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  23. </u-cell-item>
  24. </u-cell-group>
  25. </view>
  26. <u-popup v-model="show" mode="center" length="auto" >
  27. <view>
  28. <u-form :model="lockForm" ref="uForm">
  29. <u-form-item label="设备编码" label-width="150"><u-input v-model="lockForm.deviceNo" /></u-form-item>
  30. <u-form-item label="是否开锁" label-width="150"><u-input v-model="lockForm.cmdLabel" type="select" @click="lockForm.cmdFlag = true"/></u-form-item>
  31. </u-form>
  32. </view>
  33. <u-button @click="submit" type="primary">提交</u-button>
  34. </u-popup>
  35. <u-select v-model="lockForm.cmdFlag" :list="list" @confirm="getCmdValue"></u-select>
  36. <u-toast ref="uToast" />
  37. </view>
  38. </template>
  39. <script>
  40. //#ifdef APP-PLUS
  41. var device = uni.requireNativePlugin("DeviceInfo")
  42. //#endif
  43. export default{
  44. data(){
  45. return{
  46. show: false,
  47. lockForm:{
  48. deviceNo:'',
  49. cmd:'',
  50. cmdLabel: '',
  51. cmdFlag: false
  52. },
  53. list:[{
  54. value: 'up',
  55. label: '升板'
  56. },
  57. {
  58. value: 'down',
  59. label: '降板'
  60. }]
  61. }
  62. },
  63. onLoad(){
  64. },
  65. onShow(){
  66. },
  67. methods:{
  68. lockControl(){
  69. this.show=true;
  70. },
  71. submit(){
  72. this.$u.api.lockControl({deviceNo:this.lockForm.deviceNo, cmd:this.lockForm.cmd})
  73. .then( res =>{
  74. if(res.code == 200){
  75. this.$refs.uToast.show({
  76. title: res.msg,
  77. type: 'success',
  78. });
  79. }
  80. }).catch(err=>{
  81. this.$refs.uToast.show({
  82. title: err.msg,
  83. type: 'error',
  84. });
  85. })
  86. },
  87. customBack(){
  88. this.$u.route({
  89. // type:'switchTab',
  90. url: 'pages/index/index'
  91. });
  92. },
  93. openPage(path) {
  94. // console.log('path',path);
  95. this.$u.route({
  96. url: path
  97. });
  98. },
  99. onPrintFeed(){
  100. //#ifdef APP-PLUS
  101. device.printFeed(10);
  102. //#endif
  103. //#ifdef H5
  104. uni.showToast({
  105. title: '非APP环境',
  106. duration: 2000
  107. });
  108. //#endif
  109. },
  110. getCmdValue(val) {
  111. console.log(val)
  112. this.lockForm.cmd = val[0].value
  113. this.lockForm.cmdLabel = val[0].label
  114. },
  115. onLoginOut(){
  116. uni.showModal({
  117. title: '温馨提示',
  118. content: '是否确认退出?',
  119. success: (res) => {
  120. if (res.confirm) {
  121. this.$u.api.loginOut({})
  122. .then(res=>{
  123. uni.clearStorage();
  124. this.$u.vuex('vuex_token', null);
  125. this.$u.vuex('vuex_user', null);
  126. this.$u.vuex('vuex_hasLogin', false);
  127. this.userInfo = [];
  128. this.theRoad = [];
  129. this.$refs.uToast.show({
  130. title: '退出成功,即将跳转登录页!',
  131. type: 'success',
  132. url:'pages/login/login'
  133. });
  134. // uni.showToast({
  135. // title: '退出成功',
  136. // duration: 2000
  137. // });
  138. // uni.redirectTo({
  139. // url:'../login/login'
  140. // });
  141. }).catch(err=>{
  142. uni.showToast({
  143. title: '退出失败',
  144. duration: 2000
  145. });
  146. });
  147. } else if (res.cancel) {
  148. }
  149. }
  150. })
  151. }
  152. }
  153. }
  154. </script>
  155. <style lang="scss">
  156. @import './setting.scss'
  157. </style>