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