setUp.vue 12 KB

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