index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" @clickLeft="back" title="系统设置">
  4. </uni-nav-bar>
  5. <u-cell-group>
  6. <picker @change="handlePicker" :range="['是', '否']">
  7. <u-cell title="记住密码" :isLink="true" arrow-direction="right">
  8. <text slot="value" class="u-slot-value">{{
  9. isMemo ? '是' : '否'
  10. }}</text>
  11. </u-cell>
  12. </picker>
  13. <u-cell title="服务器地址" :isLink="true" arrow-direction="right" @click="handleServerSettings">
  14. <text slot="value" class="u-slot-value" :key="apiAdress">{{
  15. apiAdress
  16. }}</text>
  17. </u-cell>
  18. <!-- <u-cell :title="'当前版本 ' + currentVersion" :isLink="true" arrow-direction="right">
  19. <text slot="value" class="u-slot-value" @click="handlUpdate">{{
  20. Nversion == currentVersion ? '' : `发现新版本(${this.Nversion})`
  21. }}</text>
  22. </u-cell> -->
  23. </u-cell-group>
  24. <view class="flex-buttom">
  25. <view class="btn" @click="loginOut"> 退出登录 </view>
  26. <view class="copyright">
  27. <view>版权所有© 2019-2021中赢合力</view>
  28. <view>湘ICP备20015098号</view>
  29. </view>
  30. </view>
  31. <updatePop ref="updatePop" :versionNum="versionNum" :downloadUrl="downloadUrl" :sizes="VersionInfo.fileSize">
  32. </updatePop>
  33. <ServerSetting ref="serverSettingRef" @setServerStatus="setServerStatus" />
  34. </view>
  35. </template>
  36. <script>
  37. import {
  38. postJ,
  39. get
  40. } from '@/utils/api.js'
  41. import updatePop from './components/updatePop.vue'
  42. import {
  43. setMemo,
  44. isMemo,
  45. removeMemo
  46. } from '@/utils/passwordMemo.js'
  47. import ServerSetting from '@/components/ServerSetting/index'
  48. export default {
  49. components: {
  50. updatePop,
  51. ServerSetting
  52. },
  53. data() {
  54. return {
  55. show: false,
  56. versionNum: '',
  57. downloadUrl: '',
  58. currentVersion: '',
  59. isMemo: isMemo(),
  60. apiAdress: '',
  61. Nversion: '',
  62. VersionInfo: ''
  63. }
  64. },
  65. onLoad() {
  66. const apiInfo = uni.getStorageSync('apiInfo')
  67. this.apiAdress =
  68. apiInfo.hostname &&
  69. `${apiInfo.protocal || ''}${apiInfo.hostname || ''}:${apiInfo.port || ''}`
  70. console.log(plus);
  71. this.currentVersion = plus?.runtime.version
  72. // this.getbb()
  73. },
  74. created() {
  75. },
  76. methods: {
  77. handlePicker(e) {
  78. this.isMemo = e.detail.value === 0
  79. if (e.detail.value === 0) {
  80. setMemo()
  81. } else {
  82. removeMemo()
  83. }
  84. },
  85. setServerStatus(val) {
  86. if (val) {
  87. const apiInfo = uni.getStorageSync('apiInfo')
  88. this.apiAdress = `${apiInfo.protocal || ''}${apiInfo.hostname || ''}:${
  89. apiInfo.port || ''
  90. }`
  91. }
  92. },
  93. handleServerSettings() {
  94. this.$refs.serverSettingRef.open()
  95. },
  96. loginOut() {
  97. uni.showModal({
  98. title: '提示',
  99. content: '确认退出登录',
  100. success: res => {
  101. console.log(res, res.confirm, '-----确认退出登录');
  102. if (res.confirm) {
  103. console.log('-----确认退出登录9999999');
  104. uni.clearStorage()
  105. try {
  106. postJ(this.apiUrl + '/main/user/logout')
  107. .then(res => {
  108. uni.showToast({
  109. title: '退出成功',
  110. icon: 'success',
  111. duration: 500
  112. })
  113. setTimeout(() => {
  114. uni.removeStorageSync('token')
  115. uni.removeStorageSync('userInfo')
  116. uni.removeStorageSync('treeList')
  117. uni.reLaunch({
  118. url: '/pages/login/login'
  119. })
  120. }, 500)
  121. })
  122. .catch(err => {
  123. console.log(err);
  124. uni.showToast({
  125. title: '退出失败',
  126. icon: 'none'
  127. })
  128. })
  129. } catch (error) {
  130. console.log(error, 'error----')
  131. uni.reLaunch({
  132. url: '/pages/login/login'
  133. })
  134. }
  135. } else if (res.cancel) {
  136. console.log('用户点击取消')
  137. }
  138. }
  139. })
  140. },
  141. handlUpdate() {
  142. get(this.apiUrl + '/versioning/getLatestData').then(res => {
  143. console.log(res);
  144. if (res.success) {
  145. const currentVersion = this.currentVersion
  146. const Nversion = res.data.version
  147. console.log(currentVersion,Nversion);
  148. this.VersionInfo = res.data
  149. if (currentVersion !== Nversion) {
  150. this.$refs.updatePop.open()
  151. this.versionNum = Nversion
  152. this.downloadUrl = this.apiUrl + res.data.path
  153. } else {
  154. uni.showToast({
  155. title: '暂无新版本',
  156. icon: 'none'
  157. })
  158. }
  159. }
  160. })
  161. },
  162. getbb() {
  163. get(this.apiUrl + '/versioning/getLatestData').then(res => {
  164. if (res.success) {
  165. this.Nversion = res.data.version
  166. }
  167. })
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="scss" scoped>
  173. .u-slot-value {
  174. color: #157a2c;
  175. }
  176. .flex-buttom {
  177. position: fixed;
  178. bottom: 0;
  179. left: 0;
  180. width: 100%;
  181. padding: 20rpx;
  182. box-sizing: border-box;
  183. .btn {
  184. color: #157a2c;
  185. font-size: 28rpx;
  186. display: flex;
  187. justify-content: center;
  188. align-items: center;
  189. border: 1px solid #157a2c;
  190. border-radius: 10rpx;
  191. height: 80rpx;
  192. }
  193. }
  194. .copyright {
  195. color: #555;
  196. font-size: 28rpx;
  197. text-align: center;
  198. padding: 20rpx 0;
  199. }
  200. </style>