setting.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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="lockListForm.spaceName" type="select" @click="lockListForm.show = true"/></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-select v-model="lockListForm.show" :list="lockList" @confirm="onLockSelect"></u-select>
  37. <u-toast ref="uToast" />
  38. </view>
  39. </template>
  40. <script>
  41. //#ifdef APP-PLUS
  42. var device = uni.requireNativePlugin("DeviceInfo")
  43. //#endif
  44. export default{
  45. data(){
  46. return{
  47. show: false,
  48. lockForm:{
  49. deviceNo:'',
  50. cmd:'',
  51. cmdLabel: '',
  52. cmdFlag: false
  53. },
  54. lockListForm:{
  55. show: false,
  56. deviceNo:'',
  57. spaceName:''
  58. },
  59. lockList:[],
  60. list:[{
  61. value: 'up',
  62. label: '升板'
  63. },
  64. {
  65. value: 'down',
  66. label: '降板'
  67. }]
  68. }
  69. },
  70. onLoad(){
  71. },
  72. onShow(){
  73. },
  74. methods:{
  75. lockControl(){
  76. let that = this;
  77. let roadInfo = this.$store.state.vuex_user?.roadList?.[0]||[];
  78. that.lockList = [];
  79. this.$u.api.lockList({roadNo:roadInfo.roadNo})
  80. .then(res => {
  81. if(res.code == 200){
  82. let list = res.data?.lockList;
  83. if(list == null || list.length <=0){
  84. plus.nativeUI.toast('没有可操作的车位锁' );
  85. }else {
  86. list.forEach(item => {
  87. let pushItem = {
  88. value: item.deviceNo,
  89. label: item.spaceName
  90. }
  91. that.lockList.push(pushItem);
  92. })
  93. this.show=true;
  94. }
  95. }
  96. })
  97. .catch(err =>{
  98. })
  99. },
  100. submit(){
  101. let reqParams = {
  102. deviceNo: this.lockListForm.deviceNo,
  103. cmd: this.lockForm.cmd
  104. }
  105. this.$u.api.lockControl(reqParams)
  106. .then( res =>{
  107. if(res.code == 200){
  108. this.$refs.uToast.show({
  109. title: res.msg,
  110. type: 'success',
  111. });
  112. }
  113. }).catch(err=>{
  114. this.$refs.uToast.show({
  115. title: err.msg,
  116. type: 'error',
  117. });
  118. })
  119. },
  120. customBack(){
  121. uni.navigateBack({
  122. delta: 1
  123. })
  124. },
  125. openPage(path) {
  126. // console.log('path',path);
  127. this.$u.route({
  128. url: path
  129. });
  130. },
  131. onPrintFeed(){
  132. //#ifdef APP-PLUS
  133. device.printFeed(10);
  134. //#endif
  135. //#ifdef H5
  136. uni.showToast({
  137. title: '非APP环境',
  138. duration: 2000
  139. });
  140. //#endif
  141. },
  142. getCmdValue(val) {
  143. console.log(val)
  144. this.lockForm.cmd = val[0].value
  145. this.lockForm.cmdLabel = val[0].label
  146. },
  147. onLockSelect(val){
  148. this.lockListForm.deviceNo = val[0].value;
  149. this.lockListForm.spaceName = val[0].label;
  150. },
  151. onLoginOut(){
  152. uni.showModal({
  153. title: '温馨提示',
  154. content: '是否确认退出?',
  155. success: (res) => {
  156. if (res.confirm) {
  157. this.$u.api.loginOut({})
  158. .then(res=>{
  159. uni.clearStorage();
  160. this.$u.vuex('vuex_token', null);
  161. this.$u.vuex('vuex_user', null);
  162. this.$u.vuex('vuex_hasLogin', false);
  163. this.userInfo = [];
  164. this.theRoad = [];
  165. uni.setStorageSync('pushreg_switch', '1');
  166. plus.nativeUI.toast('切换路段成功');
  167. uni.reLaunch({
  168. url: '/pages/login/login'
  169. });
  170. }).catch(err=>{
  171. uni.showToast({
  172. title: '退出失败',
  173. duration: 2000
  174. });
  175. });
  176. } else if (res.cancel) {
  177. }
  178. }
  179. })
  180. }
  181. }
  182. }
  183. </script>
  184. <style lang="scss">
  185. @import './setting.scss'
  186. </style>