setting.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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="onCheckVersion()">
  22. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  23. </u-cell-item>
  24. <u-cell-item title="退出登录" @click="onLoginOut()">
  25. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  26. </u-cell-item>
  27. </u-cell-group>
  28. </view>
  29. <u-popup v-model="show" mode="center" length="auto" >
  30. <view>
  31. <u-form :model="lockForm" ref="uForm">
  32. <u-form-item label="车位" label-width="150"><u-input v-model="lockListForm.spaceName" type="select" @click="lockListForm.show = true"/></u-form-item>
  33. <u-form-item label="命令" label-width="150"><u-input v-model="lockForm.cmdLabel" type="select" @click="lockForm.cmdFlag = true"/></u-form-item>
  34. </u-form>
  35. </view>
  36. <u-button @click="submit" type="primary">执行</u-button>
  37. </u-popup>
  38. <u-select v-model="lockForm.cmdFlag" :list="list" @confirm="getCmdValue"></u-select>
  39. <u-select v-model="lockListForm.show" :list="lockList" @confirm="onLockSelect"></u-select>
  40. <u-toast ref="uToast" />
  41. <view class="version">
  42. <view > 版本号: {{wgtInfo.version + '-' + wgtInfo.versionCode}}</view>
  43. <view > APPID: {{wgtInfo.appid}}</view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. //#ifdef APP-PLUS
  49. var device = uni.requireNativePlugin("DeviceInfo")
  50. //#endif
  51. import update from '@/utils/update.js';
  52. export default{
  53. data(){
  54. return{
  55. show: false,
  56. wgtInfo:{},
  57. lockForm:{
  58. deviceNo:'',
  59. cmd:'',
  60. cmdLabel: '',
  61. cmdFlag: false
  62. },
  63. lockListForm:{
  64. show: false,
  65. deviceNo:'',
  66. spaceName:''
  67. },
  68. lockList:[],
  69. list:[{
  70. value: 'up',
  71. label: '升板'
  72. },
  73. {
  74. value: 'down',
  75. label: '降板'
  76. }]
  77. }
  78. },
  79. onLoad(){
  80. this.getVersion();
  81. },
  82. onShow(){
  83. },
  84. methods:{
  85. lockControl(){
  86. let that = this;
  87. let roadInfo = this.$store.state.vuex_user?.roadList?.[0]||[];
  88. that.lockList = [];
  89. this.$u.api.lockList({roadNo:roadInfo.roadNo})
  90. .then(res => {
  91. if(res.code == 200){
  92. let list = res.data?.lockList;
  93. if(list == null || list.length <=0){
  94. plus.nativeUI.toast('没有可操作的车位锁' );
  95. }else {
  96. list.forEach(item => {
  97. let pushItem = {
  98. value: item.deviceNo,
  99. label: item.spaceName
  100. }
  101. that.lockList.push(pushItem);
  102. })
  103. this.show=true;
  104. }
  105. }
  106. })
  107. .catch(err =>{
  108. })
  109. },
  110. submit(){
  111. let reqParams = {
  112. deviceNo: this.lockListForm.deviceNo,
  113. cmd: this.lockForm.cmd
  114. }
  115. this.$u.api.lockControl(reqParams)
  116. .then( res =>{
  117. if(res.code == 200){
  118. this.$refs.uToast.show({
  119. title: res.msg,
  120. type: 'success',
  121. });
  122. }
  123. }).catch(err=>{
  124. this.$refs.uToast.show({
  125. title: err.msg,
  126. type: 'error',
  127. });
  128. })
  129. },
  130. customBack(){
  131. uni.navigateBack({
  132. delta: 1
  133. })
  134. },
  135. openPage(path) {
  136. // console.log('path',path);
  137. this.$u.route({
  138. url: path
  139. });
  140. },
  141. onPrintFeed(){
  142. //#ifdef APP-PLUS
  143. device.printFeed(10);
  144. //#endif
  145. //#ifdef H5
  146. uni.showToast({
  147. title: '非APP环境',
  148. duration: 2000
  149. });
  150. //#endif
  151. },
  152. getCmdValue(val) {
  153. console.log(val)
  154. this.lockForm.cmd = val[0].value
  155. this.lockForm.cmdLabel = val[0].label
  156. },
  157. onLockSelect(val){
  158. this.lockListForm.deviceNo = val[0].value;
  159. this.lockListForm.spaceName = val[0].label;
  160. },
  161. onCheckVersion(){
  162. update(this);
  163. },
  164. onLoginOut(){
  165. uni.showModal({
  166. title: '温馨提示',
  167. content: '是否确认退出?',
  168. success: (res) => {
  169. if (res.confirm) {
  170. this.$u.api.loginOut({})
  171. .then(res=>{
  172. uni.clearStorage();
  173. this.$u.vuex('vuex_token', null);
  174. this.$u.vuex('vuex_user', null);
  175. this.$u.vuex('vuex_hasLogin', false);
  176. this.userInfo = [];
  177. this.theRoad = [];
  178. uni.setStorageSync('pushreg_switch', '1');
  179. plus.nativeUI.toast('退成成功');
  180. uni.reLaunch({
  181. url: '/pages/login/login'
  182. });
  183. }).catch(err=>{
  184. uni.showToast({
  185. title: '退出失败',
  186. duration: 2000
  187. });
  188. });
  189. } else if (res.cancel) {
  190. }
  191. }
  192. })
  193. },
  194. getVersion(){
  195. plus.runtime.getProperty(plus.runtime.appid, (info) => {
  196. this.wgtInfo = info;
  197. });
  198. }
  199. }
  200. }
  201. </script>
  202. <style lang="scss">
  203. @import './setting.scss'
  204. </style>