index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. created() {
  66. const apiInfo = uni.getStorageSync('apiInfo')
  67. this.apiAdress =
  68. apiInfo.hostname &&
  69. `${apiInfo.protocal || ''}${apiInfo.hostname || ''}:${apiInfo.port || ''}`
  70. this.currentVersion = plus?.runtime.version
  71. this.getbb()
  72. },
  73. methods: {
  74. handlePicker(e) {
  75. this.isMemo = e.detail.value === 0
  76. if (e.detail.value === 0) {
  77. setMemo()
  78. } else {
  79. removeMemo()
  80. }
  81. },
  82. setServerStatus(val) {
  83. if (val) {
  84. const apiInfo = uni.getStorageSync('apiInfo')
  85. this.apiAdress = `${apiInfo.protocal || ''}${apiInfo.hostname || ''}:${
  86. apiInfo.port || ''
  87. }`
  88. }
  89. },
  90. handleServerSettings() {
  91. this.$refs.serverSettingRef.open()
  92. },
  93. loginOut() {
  94. uni.showModal({
  95. title: '提示',
  96. content: '确认退出登录',
  97. success: res => {
  98. console.log(res, res.confirm, '-----确认退出登录');
  99. if (res.confirm) {
  100. console.log('-----确认退出登录9999999');
  101. uni.clearStorage()
  102. try {
  103. postJ(this.apiUrl + '/main/user/logout')
  104. .then(res => {
  105. uni.showToast({
  106. title: '退出成功',
  107. icon: 'success',
  108. duration: 500
  109. })
  110. setTimeout(() => {
  111. uni.removeStorageSync('token')
  112. uni.removeStorageSync('userInfo')
  113. uni.removeStorageSync('treeList')
  114. uni.reLaunch({
  115. url: '/pages/login/login'
  116. })
  117. }, 500)
  118. })
  119. .catch(err => {
  120. uni.showToast({
  121. title: '退出失败',
  122. icon: 'none'
  123. })
  124. })
  125. } catch (error) {
  126. console.log(error, 'error----')
  127. uni.reLaunch({
  128. url: '/pages/login/login'
  129. })
  130. }
  131. } else if (res.cancel) {
  132. console.log('用户点击取消')
  133. }
  134. }
  135. })
  136. },
  137. handlUpdate() {
  138. get(this.apiUrl + '/versioning/getLatestData').then(res => {
  139. if (res.success) {
  140. const currentVersion = this.currentVersion
  141. const Nversion = res.data.version
  142. this.VersionInfo = res.data
  143. if (currentVersion !== Nversion) {
  144. this.$refs.updatePop.open()
  145. this.versionNum = Nversion
  146. this.downloadUrl = this.apiUrl + res.data.path
  147. } else {
  148. uni.showToast({
  149. title: '暂无新版本',
  150. icon: 'none'
  151. })
  152. }
  153. }
  154. })
  155. },
  156. getbb() {
  157. get(this.apiUrl + '/versioning/getLatestData').then(res => {
  158. if (res.success) {
  159. this.Nversion = res.data.version
  160. }
  161. })
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. .u-slot-value {
  168. color: #157a2c;
  169. }
  170. .flex-buttom {
  171. position: fixed;
  172. bottom: 0;
  173. left: 0;
  174. width: 100%;
  175. padding: 20rpx;
  176. box-sizing: border-box;
  177. .btn {
  178. color: #157a2c;
  179. font-size: 28rpx;
  180. display: flex;
  181. justify-content: center;
  182. align-items: center;
  183. border: 1px solid #157a2c;
  184. border-radius: 10rpx;
  185. height: 80rpx;
  186. }
  187. }
  188. .copyright {
  189. color: #555;
  190. font-size: 28rpx;
  191. text-align: center;
  192. padding: 20rpx 0;
  193. }
  194. </style>