index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. uni.clearStorage()
  114. try {
  115. postJ(this.apiUrl + '/user/logout')
  116. .then(res => {
  117. uni.removeStorageSync('token')
  118. uni.removeStorageSync('userInfo')
  119. uni.removeStorageSync('treeList')
  120. uni.reLaunch({
  121. url: '/pages/login/login'
  122. })
  123. })
  124. .catch(err => {
  125. uni.showToast({
  126. title: '退出失败',
  127. icon: 'none'
  128. })
  129. })
  130. } catch (error) {
  131. console.log(error,'error----')
  132. uni.reLaunch({
  133. url: '/pages/login/login'
  134. })
  135. }
  136. } else if (res.cancel) {
  137. console.log('用户点击取消')
  138. }
  139. }
  140. })
  141. },
  142. handlUpdate () {
  143. get(this.apiUrl + '/versioning/getLatestData').then(res => {
  144. if (res.success) {
  145. const currentVersion = this.currentVersion
  146. const Nversion = res.data.version
  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>