setUp.vue 12 KB

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