setting.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <!-- -->
  2. <template>
  3. <div class="setting_box" :style="'height:' + fullHeight + 'px'">
  4. <!-- 头部 -->
  5. <div class="setting_head">
  6. <div class="setting_head_returnA" @click="FanHui()">
  7. <img
  8. src="../../assets/image/new/30.png"
  9. alt
  10. class="setting_head_returnA_img"
  11. />
  12. </div>
  13. <!-- 标题 -->
  14. <div class="head_title">
  15. <span class="head_title_text">设置</span>
  16. </div>
  17. </div>
  18. <!-- list列表 -->
  19. <ul class="setting_box_ul">
  20. <!-- 版本更新 -->
  21. <li class="setting_box_li" @click="update()">
  22. <div class="setting_box_li_account">
  23. <div class="li_account_box">
  24. <span class="li_account_text">版本更新</span>
  25. </div>
  26. </div>
  27. </li>
  28. <!-- 版本更新记录 -->
  29. <li class="setting_box_li" @click="versionsUpdateHistory()">
  30. <div class="setting_box_li_nickname">
  31. <div class="li_nickname_box">
  32. <span class="li_nickname_text">版本更新记录</span>
  33. </div>
  34. <div class="nickname_user_box"></div>
  35. </div>
  36. </li>
  37. <!-- 个人信息编辑 -->
  38. <li class="setting_box_li" @click="userMessage()">
  39. <div class="setting_box_li_password">
  40. <div class="li_password_box">
  41. <span class="li_password_text">个人信息编辑</span>
  42. </div>
  43. </div>
  44. </li>
  45. <!-- 登录退出 -->
  46. <li class="setting_box_li" @click="log_out()">
  47. <div class="setting_box_li_password" style="border: 0">
  48. <div class="li_password_box">
  49. <span class="li_password_text">退出登录</span>
  50. </div>
  51. </div>
  52. </li>
  53. </ul>
  54. </div>
  55. </template>
  56. <script>
  57. export default {
  58. //import引入的组件需要注入到对象中才能使用
  59. components: {},
  60. data() {
  61. //这里存放数据
  62. return {
  63. fullHeight: document.documentElement.clientHeight,
  64. isClick: true, //版本更新开关
  65. };
  66. },
  67. //监听属性 类似于data概念
  68. computed: {},
  69. //监控data中的数据变化
  70. watch: {
  71. fullHeight(val) {
  72. //监控浏览器高度变化
  73. if (!this.timer) {
  74. this.fullHeight = val;
  75. this.timer = true;
  76. let that = this;
  77. setTimeout(function () {
  78. //防止过度调用监测事件,导致卡顿
  79. that.timer = false;
  80. }, 400);
  81. }
  82. },
  83. input: function () {
  84. this.input = this.input.replace(/[^A-Za-z0-9\u4e00-\u9fa5]/g, "");
  85. },
  86. },
  87. //方法集合
  88. methods: {
  89. //动态获取浏览器高度
  90. get_boderHeight() {
  91. const that = this;
  92. window.onresize = () => {
  93. return (() => {
  94. window.fullHeight = document.documentElement.clientHeight;
  95. that.fullHeight = window.fullHeight;
  96. })();
  97. };
  98. },
  99. //点击返回到home页面
  100. FanHui() {
  101. let _this = this;
  102. _this.$router.replace("/person");
  103. },
  104. // 点击进入个人信息编辑界面
  105. userMessage() {
  106. var that = this;
  107. that.$router.push("/mine");
  108. },
  109. // 点击进入版本更新记录界面
  110. versionsUpdateHistory() {
  111. var that = this;
  112. that.$router.push("/versions_updateHistory");
  113. },
  114. // 点击版本更新请求接口
  115. update() {
  116. var that = this;
  117. var isClick = that.isClick;
  118. if (isClick === true) {
  119. that.isClick = false;
  120. that
  121. .$axios({
  122. method: "get",
  123. url: "http://192.168.1.8:8002/edition",
  124. })
  125. .then((res) => {
  126. console.log(res.data);
  127. let num = "115"; //当前版本
  128. var data = res.data.edition_num;
  129. var a = data.replace(/\./g, "");
  130. if (num === a) {
  131. this.$message({
  132. showClose: true,
  133. message: "当前已经是最新版本",
  134. duration: 1500,
  135. });
  136. } else if (num < a) {
  137. this.$notify({
  138. title: "成功",
  139. message: "检测到有新版本,需要更新",
  140. type: "success",
  141. duration: 1500,
  142. });
  143. const timerA = setInterval(() => {
  144. var wait = plus.nativeUI.showWaiting("下载更新中,请勿关闭");
  145. //创建一个下载任务
  146. var dtask = plus.downloader.createDownload(
  147. "http://192.168.1.8:8002/down_app/deity.apk",
  148. {
  149. method: "GET",
  150. },
  151. function (d, status) {
  152. if (status == 200) {
  153. console.log("Download success: " + d.filename);
  154. plus.runtime.install(d.filename); // 安装下载的apk文件
  155. } else {
  156. that.$message({
  157. type: "info",
  158. message: "更新失败",
  159. });
  160. // plus.runtime.install('../H5B2852C7_0925104810.apk'); // 安装下载的apk文件
  161. }
  162. wait.close();
  163. }
  164. );
  165. //开始下载
  166. dtask.start();
  167. clearInterval(timerA);
  168. }, 1500);
  169. }
  170. })
  171. .catch((err) => {
  172. console.log(err);
  173. });
  174. setTimeout(function () {
  175. that.isClick = true;
  176. }, 2000);
  177. }
  178. },
  179. // 点击退出登录
  180. //退出登录
  181. log_out() {
  182. this.$confirm("即将退出登录, 是否继续?", "提示", {
  183. confirmButtonText: "确定",
  184. cancelButtonText: "取消",
  185. type: "warning",
  186. })
  187. .then(() => {
  188. this.$axios({
  189. method: "get",
  190. url: "http://192.168.1.8:8002/out_land",
  191. })
  192. .then((res) => {
  193. if (res.data === 0) {
  194. this.$message({
  195. type: "success",
  196. message: "退出成功!",
  197. });
  198. sessionStorage.removeItem("login");
  199. localStorage.removeItem("homeIndex");
  200. this.$router.replace("/");
  201. } else if (res.data === 1) {
  202. this.$message({
  203. type: "info",
  204. message: "退出失败,请重试",
  205. duration: 1500,
  206. });
  207. }
  208. })
  209. .catch((err) => {
  210. this.$message({
  211. type: "info",
  212. message: "退出失败,请重试",
  213. duration: 1500,
  214. });
  215. });
  216. })
  217. .catch(() => {
  218. this.$message({
  219. type: "info",
  220. message: "取消退出",
  221. duration: 1500,
  222. });
  223. });
  224. },
  225. },
  226. //生命周期 - 创建完成(可以访问当前this实例)
  227. created() {
  228. localStorage.removeItem("insect"); //删除本地的虫害值
  229. localStorage.removeItem("plant"); //删除本地的病害值
  230. },
  231. //生命周期 - 挂载完成(可以访问DOM元素)
  232. mounted() {
  233. let _this = this;
  234. _this.get_boderHeight();
  235. },
  236. };
  237. </script>
  238. <style>
  239. .el-message-box {
  240. width: 320px;
  241. }
  242. </style>
  243. <style lang='scss' scoped>
  244. @import "../../assets/scss/bus.scss";
  245. .setting_box {
  246. background: #f6f6f6;
  247. }
  248. span {
  249. margin-left: 0;
  250. }
  251. // 头部
  252. .setting_box .setting_head {
  253. display: flex;
  254. justify-content: space-between;
  255. margin-bottom: 0.4rem;
  256. background: -webkit-linear-gradient(right, #0dc6b6, #0cd3aa, #1dd69c);
  257. height: 1.2rem;
  258. }
  259. // 返回图标
  260. .setting_box .setting_head_returnA {
  261. padding: 0.3rem 0 0 0.5rem;
  262. }
  263. .setting_head_returnA_img {
  264. width: 0.5rem;
  265. height: 0.5rem;
  266. }
  267. // 标题
  268. .setting_box .head_title {
  269. margin: 0.14rem 3.8rem 0 0;
  270. }
  271. .setting_box .head_title_text {
  272. font-size: 18px;
  273. font-weight: 500;
  274. margin: 0 0 0 -2rem;
  275. line-height: 0.95rem;
  276. color: #fff;
  277. }
  278. // list列表
  279. .setting_box_ul {
  280. margin: -0.4rem 0 0 0;
  281. background: #fff;
  282. }
  283. .setting_box_li {
  284. margin: 0 0 0.2rem 0;
  285. }
  286. // 头像
  287. .setting_box_li_portrait {
  288. border-bottom: 2px solid #f6f6f6;
  289. height: 1rem;
  290. width: 90%;
  291. margin: 0 auto;
  292. display: flex;
  293. justify-content: space-between;
  294. }
  295. .li_portrait_box {
  296. margin: 0.35rem 0 0 0.45rem;
  297. }
  298. .li_portrait_text {
  299. color: #000;
  300. font-size: 13px;
  301. font-weight: 500;
  302. }
  303. .portrait_img_box {
  304. margin: 0.1rem 0.15rem 0 0;
  305. }
  306. .portrait_img {
  307. width: 0.8rem;
  308. height: 0.8rem;
  309. border-radius: 50px;
  310. }
  311. // 账号
  312. .setting_box_li_account {
  313. border-bottom: 2px solid #f6f6f6;
  314. height: 1rem;
  315. width: 90%;
  316. margin: 0 auto;
  317. display: flex;
  318. justify-content: space-between;
  319. }
  320. .li_account_box {
  321. margin: 0.35rem 0 0 0.45rem;
  322. }
  323. .li_account_text {
  324. // color: #000;
  325. color: #5c5c5c;
  326. font-size: 13px;
  327. font-weight: 500;
  328. }
  329. .account_accountNumber_box {
  330. margin: 0.5rem 0 0 0;
  331. }
  332. .accountNumber_text {
  333. color: #999999;
  334. }
  335. // 账号
  336. .setting_box_li_nickname {
  337. border-bottom: 5px solid #f6f6f6;
  338. height: 1rem;
  339. width: 100%;
  340. margin: 0 auto;
  341. display: flex;
  342. justify-content: space-between;
  343. }
  344. .li_nickname_box {
  345. margin: 0.35rem 0 0 0.95rem;
  346. }
  347. .li_nickname_text {
  348. color: #5c5c5c;
  349. font-size: 13px;
  350. font-weight: 500;
  351. }
  352. .nickname_user_box {
  353. margin: 0.5rem 0.55rem 0 0;
  354. }
  355. .nickname_text {
  356. color: #999999;
  357. }
  358. //修改密码
  359. .setting_box_li_password {
  360. height: 1rem;
  361. width: 90%;
  362. margin: 0 auto;
  363. display: flex;
  364. justify-content: space-between;
  365. border-bottom: 2px solid #f6f6f6;
  366. }
  367. .li_password_box {
  368. // margin: .35rem 0 0 .95rem;
  369. margin: 0.35rem 0 0 0.45rem;
  370. }
  371. .li_password_text {
  372. color: #5c5c5c;
  373. font-size: 13px;
  374. font-weight: 500;
  375. }
  376. // 修改头像弹框
  377. .picture_box {
  378. position: relative;
  379. top: -6.409rem;
  380. left: 0;
  381. background: rgba(0, 0, 0, 0.8);
  382. }
  383. .setting_box .modification {
  384. width: 4rem;
  385. }
  386. .picture_box_div {
  387. border: 1px solid rgb(255, 255, 255);
  388. position: absolute;
  389. left: 23%;
  390. top: 20%;
  391. border-radius: 5px;
  392. background: #eeeded;
  393. }
  394. .picture_box_ul {
  395. width: 5.5rem;
  396. }
  397. .picture_box_li {
  398. border-bottom: 1px solid #fff;
  399. }
  400. .picture_box_li_text {
  401. font-size: 23px;
  402. padding: 0.2rem 0 0.2rem 0;
  403. color: rgb(146, 146, 146);
  404. }
  405. .picture_box_li_del {
  406. border-bottom: 1px solid #fff;
  407. }
  408. .picture_box_del_img {
  409. width: 0.5rem;
  410. height: 0.5rem;
  411. margin: 0 0 0 4.8rem;
  412. }
  413. //修改昵称
  414. .el-button--primary span {
  415. margin: 0;
  416. }
  417. .modify_the_picture {
  418. display: inline-block;
  419. }
  420. .avatar-uploader {
  421. position: absolute;
  422. left: 0;
  423. bottom: 0.5rem;
  424. }
  425. .el-icon-plus:before {
  426. font-size: 40px;
  427. color: #fff;
  428. }
  429. </style>