setting.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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="speakControl()">
  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="onCheckVersion()">
  25. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  26. </u-cell-item>
  27. <u-cell-item title="退出登录" @click="onLoginOut()">
  28. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  29. </u-cell-item>
  30. </u-cell-group>
  31. </view>
  32. <u-popup v-model="speakShow" mode="center" length="auto" >
  33. <view class="speack">
  34. <view class="speack-pop">
  35. <u-form>
  36. <u-form-item label="设备入场开关" label-width="350"><u-switch v-model="switchVal1" @change="change1"></u-switch></u-form-item>
  37. <u-form-item label="设备出场开关" label-width="350"><u-switch v-model="switchVal2" @change="change2"></u-switch></u-form-item>
  38. <u-form-item label="收费员入场开关" label-width="350"><u-switch v-model="switchVal3" @change="change3"></u-switch></u-form-item>
  39. <u-form-item label="收费员出场开关" label-width="350"><u-switch v-model="switchVal4" @change="change4"></u-switch></u-form-item>
  40. </u-form>
  41. </view>
  42. <view class="speack-btn">
  43. <u-button @click="submitSpeak" type="primary" size="medium">执行</u-button>
  44. </view>
  45. </view>
  46. </u-popup>
  47. <u-popup v-model="show" mode="center" length="auto" >
  48. <view>
  49. <u-form :model="lockForm" ref="uForm">
  50. <u-form-item label="车位" label-width="150"><u-input v-model="lockListForm.spaceName" type="select" @click="lockListForm.show = true"/></u-form-item>
  51. <u-form-item label="命令" label-width="150"><u-input v-model="lockForm.cmdLabel" type="select" @click="lockForm.cmdFlag = true"/></u-form-item>
  52. </u-form>
  53. </view>
  54. <u-button @click="submit" type="primary">执行</u-button>
  55. </u-popup>
  56. <u-select v-model="lockForm.cmdFlag" :list="list" @confirm="getCmdValue"></u-select>
  57. <u-select v-model="lockListForm.show" :list="lockList" @confirm="onLockSelect"></u-select>
  58. <u-toast ref="uToast" />
  59. <view class="version">
  60. <view > 版本号: {{wgtInfo.version + '-' + wgtInfo.versionCode}}</view>
  61. <view > APPID: {{wgtInfo.appid}}</view>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. //#ifdef APP-PLUS
  67. var device = uni.requireNativePlugin("DeviceInfo")
  68. //#endif
  69. import update from '@/utils/update.js';
  70. export default{
  71. data(){
  72. return{
  73. switchVal1:'',
  74. switchVal2:'',
  75. switchVal3:'',
  76. switchVal4:'',
  77. speakShow:false,
  78. show: false,
  79. wgtInfo:{},
  80. lockForm:{
  81. deviceNo:'',
  82. cmd:'',
  83. cmdLabel: '',
  84. cmdFlag: false
  85. },
  86. lockListForm:{
  87. show: false,
  88. deviceNo:'',
  89. spaceName:''
  90. },
  91. lockList:[],
  92. list:[{
  93. value: 'up',
  94. label: '升板'
  95. },
  96. {
  97. value: 'down',
  98. label: '降板'
  99. }]
  100. }
  101. },
  102. onLoad(){
  103. this.getVersion();
  104. },
  105. onShow(){
  106. },
  107. methods:{
  108. change1(status){
  109. // console.log(status)
  110. this.switchVal1=status;
  111. },
  112. change2(status){
  113. // console.log(status)
  114. this.switchVal2=status;
  115. },
  116. change3(status){
  117. // console.log(status)
  118. this.switchVal3=status;
  119. },
  120. change4(status){
  121. // console.log(status)
  122. this.switchVal4=status;
  123. },
  124. speakControl(){
  125. this.speakShow=true;
  126. uni.getStorage({
  127. key:'speakData',
  128. success: (res) => {
  129. this.switchVal1 = res.data.switchVal1;
  130. this.switchVal2 = res.data.switchVal2;
  131. this.switchVal3 = res.data.switchVal3;
  132. this.switchVal4 = res.data.switchVal4;
  133. // console.log('passWord',res.data)
  134. },
  135. fail: (err) => {
  136. // console.log('passWord err',err)
  137. }
  138. })
  139. },
  140. submitSpeak(){
  141. uni.setStorage({
  142. key:'speakData',
  143. data:{switchVal1:this.switchVal1, switchVal2:this.switchVal2, switchVal3:this.switchVal3, switchVal4:this.switchVal4 }
  144. });
  145. this.speakShow=false;
  146. },
  147. lockControl(){
  148. let that = this;
  149. let roadInfo = this.$store.state.vuex_user?.roadList?.[0]||[];
  150. that.lockList = [];
  151. this.$u.api.lockList({roadNo:roadInfo.roadNo})
  152. .then(res => {
  153. if(res.code == 200){
  154. let list = res.data?.lockList;
  155. if(list == null || list.length <=0){
  156. plus.nativeUI.toast('没有可操作的车位锁' );
  157. }else {
  158. list.forEach(item => {
  159. let pushItem = {
  160. value: item.deviceNo,
  161. label: item.spaceName
  162. }
  163. that.lockList.push(pushItem);
  164. })
  165. this.show=true;
  166. }
  167. }
  168. })
  169. .catch(err =>{
  170. })
  171. },
  172. submit(){
  173. let reqParams = {
  174. deviceNo: this.lockListForm.deviceNo,
  175. cmd: this.lockForm.cmd
  176. }
  177. this.$u.api.lockControl(reqParams)
  178. .then( res =>{
  179. if(res.code == 200){
  180. this.$refs.uToast.show({
  181. title: res.msg,
  182. type: 'success',
  183. });
  184. }
  185. }).catch(err=>{
  186. this.$refs.uToast.show({
  187. title: err.msg,
  188. type: 'error',
  189. });
  190. })
  191. },
  192. customBack(){
  193. uni.navigateBack({
  194. delta: 1
  195. })
  196. },
  197. openPage(path) {
  198. // console.log('path',path);
  199. this.$u.route({
  200. url: path
  201. });
  202. },
  203. onPrintFeed(){
  204. //#ifdef APP-PLUS
  205. device.printFeed(10);
  206. //#endif
  207. //#ifdef H5
  208. uni.showToast({
  209. title: '非APP环境',
  210. duration: 2000
  211. });
  212. //#endif
  213. },
  214. getCmdValue(val) {
  215. console.log(val)
  216. this.lockForm.cmd = val[0].value
  217. this.lockForm.cmdLabel = val[0].label
  218. },
  219. onLockSelect(val){
  220. this.lockListForm.deviceNo = val[0].value;
  221. this.lockListForm.spaceName = val[0].label;
  222. },
  223. onCheckVersion(){
  224. update(this);
  225. },
  226. onLoginOut(){
  227. uni.showModal({
  228. title: '温馨提示',
  229. content: '是否确认退出?',
  230. success: (res) => {
  231. if (res.confirm) {
  232. this.$u.api.loginOut({})
  233. .then(res=>{
  234. uni.clearStorage();
  235. this.$u.vuex('vuex_token', null);
  236. this.$u.vuex('vuex_user', null);
  237. this.$u.vuex('vuex_hasLogin', false);
  238. this.userInfo = [];
  239. this.theRoad = [];
  240. uni.setStorageSync('pushreg_switch', '1');
  241. plus.nativeUI.toast('退成成功');
  242. uni.reLaunch({
  243. url: '/pages/login/login'
  244. });
  245. }).catch(err=>{
  246. uni.showToast({
  247. title: '退出失败',
  248. duration: 2000
  249. });
  250. });
  251. } else if (res.cancel) {
  252. }
  253. }
  254. })
  255. },
  256. getVersion(){
  257. plus.runtime.getProperty(plus.runtime.appid, (info) => {
  258. this.wgtInfo = info;
  259. });
  260. }
  261. }
  262. }
  263. </script>
  264. <style lang="scss">
  265. @import './setting.scss'
  266. </style>