setUp.vue 13 KB

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