index.vue 5.1 KB

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