setUp.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <view class="container">
  3. <view class="cu-list menu text-left solid-top indexlow">
  4. <view class='cu-item' style='margin-bottom:10px;' @click="switchPicture">
  5. <view>
  6. <text>头像</text>
  7. </view>
  8. <view style='align-items: center;' class="flex">
  9. <view class="pictures">
  10. <image :src="headUrl" class="picture"></image>
  11. </view>
  12. <image src="../../static/img/myimg/gengduo1@3x.png" class="arrow"></image>
  13. </view>
  14. </view>
  15. <view class='cu-item' style='margin-bottom:10px;' @click="nickname(username)">
  16. <view>
  17. <text>昵称</text>
  18. </view>
  19. <view style='align-items: center;' class="flex">
  20. <view class="username">
  21. {{username}}
  22. </view>
  23. <image src="../../static/img/myimg/gengduo1@3x.png" class="arrow"></image>
  24. </view>
  25. </view>
  26. <view class='cu-item' style='margin-bottom:10px;' @click='fankui'>
  27. <view>
  28. <text>意见反馈</text>
  29. </view>
  30. <image src="../../static/img/myimg/gengduo1@3x.png" class="arrow"></image>
  31. </view>
  32. <view class='cu-item' style='margin-bottom:10px;' @click='clearStorage'>
  33. <view>
  34. <text>清除缓存</text>
  35. </view>
  36. <image src="../../static/img/myimg/gengduo1@3x.png" class="arrow"></image>
  37. </view>
  38. <view class='cu-item' style='margin-bottom:10px;' @click='UpdataPassword'>
  39. <view>
  40. <text>修改密码</text>
  41. </view>
  42. <image src="../../static/img/myimg/gengduo1@3x.png" class="arrow"></image>
  43. </view>
  44. <view class='cu-item' style='margin-bottom:10px;' @click='updataEdition'>
  45. <view>
  46. <text>检查新版本</text>
  47. </view>
  48. <image src="../../static/img/myimg/gengduo1@3x.png" class="arrow"></image>
  49. </view>
  50. </view>
  51. <view class='exitloginwrap'>
  52. <button @click='logout()' class='exitlogin'>退出登录</button>
  53. </view>
  54. <u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
  55. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='温馨提示'
  56. showCancelButton='false' :content="content" @confirm="goOpenService" @cancel="cancelClick"></u-modal>
  57. </view>
  58. </template>
  59. <script>
  60. import appUpdate from 'common/appUpdate.js'
  61. import {
  62. mapState
  63. } from 'vuex';
  64. export default {
  65. data() {
  66. return {
  67. isShowAlert: false,
  68. content: '您确定要退出吗?',
  69. headUrl: "../../static/img/myimg/YongHu@3x.png",
  70. username: "",
  71. gridList: [{
  72. num: 0,
  73. name: '退出登录',
  74. // icon:'cuIcon-exit',
  75. src: '../../static/img/sign/return@3x.png',
  76. tips: 0,
  77. url: '',
  78. show: true
  79. }, ],
  80. }
  81. },
  82. computed: {
  83. // ...mapState(['hasLogin', 'userInfo'])
  84. },
  85. onShow() {
  86. this.getList()
  87. },
  88. onLoad() {},
  89. methods: {
  90. updataEdition() {
  91. // #ifdef APP-PLUS
  92. let type = uni.getSystemInfoSync().platform
  93. if (type == "android") {
  94. uni.request({
  95. url: 'http://api1.eliangeyun.com/appVersion/selectInfo',
  96. data: {
  97. appid: plus.runtime.appid,
  98. version: plus.runtime.version,
  99. imei: "1"
  100. },
  101. method: 'GET',
  102. success: (res) => {
  103. if (res.statusCode === 200) {
  104. console.log("uni.request update success", res)
  105. plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
  106. let client_version = wgtinfo.version
  107. var flag_update = client_version.split(".").splice(0, 2).join(
  108. ".") != res.data.data.version.split(".").splice(0, 2)
  109. .join(".")
  110. var flag_hot = (Number(client_version.split(".")[2]) < Number(res
  111. .data.data.version.split(".")[2])) & !flag_update
  112. console.log("client_version", client_version)
  113. console.log("flag_update", flag_update)
  114. console.log("flag_hot", flag_hot)
  115. if (flag_update) {
  116. console.log("更新弹窗")
  117. // 提醒用户更新
  118. uni.showModal({
  119. title: '更新提示',
  120. content: res.data.data.note,
  121. success: (showResult) => {
  122. if (showResult.confirm) {
  123. plus.nativeUI.toast("正在准备环境,请稍后!");
  124. console.log(res.data.data.url, )
  125. var dtask = plus.downloader
  126. .createDownload(res.data.data
  127. .url, {
  128. method: 'GET',
  129. filename: '_doc/update/'
  130. }, function(d, status) {
  131. if (status == 200) {
  132. var path = d
  133. .filename; //下载apk
  134. plus.runtime.install(
  135. path); // 自动安装apk文件
  136. } else {
  137. plus.nativeUI.alert(
  138. '版本更新失败:' +
  139. status);
  140. }
  141. });
  142. dtask.start();
  143. }
  144. }
  145. })
  146. } else if (flag_hot) {
  147. console.log("热更新")
  148. uni.showLoading({
  149. title:'正在热更新'
  150. })
  151. uni.downloadFile({
  152. url: res.data.data.wgtUrl,
  153. success: (downloadResult) => {
  154. console.log(downloadResult.tempFilePath)
  155. if (downloadResult.statusCode === 200) {
  156. plus.nativeUI.toast(
  157. `正在热更新!${res.data.data.versionCode}`
  158. );
  159. plus.runtime.install(downloadResult
  160. .tempFilePath, {
  161. force: false
  162. },
  163. function() {
  164. uni.hideLoading()
  165. plus.nativeUI.toast(
  166. "热更新成功");
  167. uni.clearStorageSync();
  168. plus.nativeUI.toast(
  169. "缓存清除成功");
  170. that.$api.doRequest('post',
  171. '/auth/api/logout')
  172. .then(res => {
  173. if (res.data
  174. .data) {
  175. that.$store
  176. .commit(
  177. 'logout'
  178. )
  179. that.$api
  180. .logout()
  181. plus.nativeUI
  182. .toast(
  183. "登出成功"
  184. );
  185. plus.runtime
  186. .restart();
  187. plus.nativeUI
  188. .toast(
  189. "重启成功"
  190. );
  191. }
  192. })
  193. plus.runtime.restart();
  194. },
  195. function(e) {
  196. uni.hideLoading()
  197. console.log(e)
  198. plus.nativeUI.toast(
  199. `热更新失败:${e.message}`
  200. );
  201. });
  202. }
  203. }
  204. });
  205. } else {
  206. this.content = '您当前版本为最新版本'
  207. this.isShowAlert = true
  208. }
  209. });
  210. }
  211. }
  212. })
  213. }
  214. // #endif
  215. },
  216. UpdataPassword() {
  217. uni.navigateTo({
  218. url: `/pages/public/reset?phone=${this.userInfo.phone}`
  219. })
  220. },
  221. clearStorage() {
  222. let that = this
  223. uni.clearStorage({
  224. success: function(res) {
  225. console.log('success');
  226. that.goOpenService()
  227. }
  228. })
  229. },
  230. cancelClick() {
  231. this.isShowAlert = false
  232. },
  233. goOpenService() {
  234. if (this.content == '您当前版本为最新版本') {
  235. this.isShowAlert = false
  236. return
  237. }
  238. uni.hideTabBarRedDot({
  239. index: 3
  240. })
  241. uni.clearStorageSync();
  242. var that = this
  243. this.$api.doRequest('post', '/auth/api/logout').then(res => {
  244. if (res.data.data) {
  245. }
  246. })
  247. this.$store.commit('logout')
  248. this.$api.logout()
  249. uni.navigateTo({
  250. url: `/pages/public/login`
  251. })
  252. },
  253. getList() {
  254. this.userInfo = uni.getStorageSync('userInfo')
  255. this.headUrl = this.userInfo.avatarUrl
  256. if (this.headUrl == null || this.headUrl == "") {
  257. this.headUrl = "../../static/img/myimg/YongHu@3x.png"
  258. }
  259. this.username = this.userInfo.userName
  260. },
  261. switchPicture() {
  262. uni.navigateTo({
  263. url: `/pages/user/set_picture`
  264. })
  265. },
  266. nickname(username) {
  267. uni.navigateTo({
  268. url: `/pages/user/set_nickname?nickname=${username}`
  269. })
  270. },
  271. exitlogin() {
  272. },
  273. fankui() {
  274. uni.navigateTo({
  275. url: `/pages/user/fankui`
  276. })
  277. },
  278. logout() {
  279. // const that = this
  280. this.isShowAlert = true
  281. // uni.showModal({
  282. // title: '询问',
  283. // content: '您确定要退出吗?',
  284. // cancelText: '取消',
  285. // confirmText: '确定',
  286. // success: (e) => {
  287. // if (e.confirm) {
  288. // uni.hideTabBarRedDot({
  289. // index: 3
  290. // })
  291. // uni.clearStorageSync();
  292. // that.$store.commit('logout')
  293. // that.$api.logout()
  294. // uni.navigateTo({
  295. // url: `/pages/public/login`
  296. // })
  297. // }
  298. // }
  299. // })
  300. },
  301. }
  302. }
  303. </script>
  304. <style lang="scss" scoped>
  305. page {
  306. background-color: #F5F6FA;
  307. }
  308. .container {
  309. padding: 10px 0 0px;
  310. }
  311. .headPortrait {
  312. width: 100%;
  313. height: 52px;
  314. margin-top: 15px;
  315. background-color: #FFFFFF;
  316. border-radius: 6px;
  317. // justify-content: flex-end;
  318. }
  319. .title {
  320. font-size: 16px;
  321. line-height: 50px;
  322. font-weight: 600;
  323. margin-left: 10px;
  324. }
  325. .pictures {
  326. justify-content: flex-end;
  327. width: 35px;
  328. height: 35px;
  329. background-color: #E0FAF6;
  330. border-radius: 18px;
  331. }
  332. .picture {
  333. width: 35px;
  334. height: 35px;
  335. }
  336. .arrow {
  337. margin-left: 15px;
  338. width: 8px;
  339. height: 12px;
  340. // justify-content: flex-end
  341. }
  342. .username {
  343. line-height: 50px;
  344. color: #6D6D72;
  345. }
  346. .sign {
  347. width: 18px;
  348. height: 18px;
  349. top: 4px;
  350. margin-right: 6px;
  351. }
  352. .cu-list>.cu-item:after {
  353. border: none;
  354. }
  355. .exitloginwrap {
  356. position: fixed;
  357. bottom: 0;
  358. left: 0;
  359. width: 100%;
  360. padding-bottom: 20px;
  361. }
  362. .exitlogin {
  363. width: 90%;
  364. background: #fff;
  365. border-radius: 30px;
  366. color: #FB1E1E;
  367. font-size: 17px;
  368. }
  369. .exitlogin:after {
  370. border: none;
  371. }
  372. </style>