setUp.vue 12 KB

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