setUp.vue 10 KB

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