system.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <div class="system-boxA">
  3. <!-- 页面头部 -->
  4. <el-header>
  5. <el-page-header title @back="goBack" content="系统设置"></el-page-header>
  6. </el-header>
  7. <!-- 页面主内容 -->
  8. <el-main :style="'height:' + fullHeight + 'px'">
  9. <ul class="system-ul">
  10. <!-- 地点设置 -->
  11. <!-- <li class="system-li" @click="site()">
  12. <img src="../../assets/imageOne/dingwei.png" alt class="system-img" />
  13. <div class="system-box">
  14. <div class="system-div1 didian">地点和月份设置</div>
  15. <div
  16. class="system-div2 dizhi"
  17. v-show="isShow"
  18. >{{this.dizhi + this.yuefen + '月份'}}</div>
  19. </div>
  20. <img src="../../assets/imageOne/15.png" alt class="system-img1" />
  21. </li>-->
  22. <!-- 病害统计模板 -->
  23. <li class="system-li" @click="crop()">
  24. <img src="../../assets/imageOne/plant.png" alt class="system-img leaf" />
  25. <div class="system-box">
  26. <div class="system-div1 kindA">病害统计模板</div>
  27. </div>
  28. <img src="../../assets/imageOne/15.png" alt class="system-img1" />
  29. </li>
  30. <!-- 虫害统计模板 -->
  31. <li class="system-li" @click="kunchong()">
  32. <img src="../../assets/imageOne/insect.png" alt class="system-img forbid" />
  33. <div class="system-box">
  34. <div class="system-div1 kindA">虫害统计模板</div>
  35. </div>
  36. <img src="../../assets/imageOne/15.png" alt class="system-img1" />
  37. </li>
  38. <!-- 用户反馈 -->
  39. <li class="system-li" @click="fedk()">
  40. <img src="../../assets/imageOne/fankui.png" alt class="system-img forbidA" />
  41. <div class="system-box">
  42. <div class="system-div1 kind">用户反馈</div>
  43. </div>
  44. <img src="../../assets/imageOne/15.png" alt class="system-img1" />
  45. </li>
  46. <!-- 版本更新 -->
  47. <!-- <li class="system-li" @click="update()">
  48. <img src="../../assets/imageOne/gengxin.png" alt class="system-img forbidB" />
  49. <div class="system-box">
  50. <div class="system-div1 kind">版本更新</div>
  51. </div>
  52. <img src="../../assets/imageOne/15.png" alt class="system-img1" />
  53. </li> -->
  54. <!-- 版本更新历史记录 -->
  55. <li class="system-li" @click="updateHistory()">
  56. <img src="../../assets/imageOne/gengjilu.png" alt class="system-img forbidB" />
  57. <div class="system-box">
  58. <div class="system-div1 kind">版本更新历史记录</div>
  59. </div>
  60. <img src="../../assets/imageOne/15.png" alt class="system-img1" />
  61. </li>
  62. <!-- 删除app默认设置 -->
  63. <!-- <li class="system-li" @click="dialogVisibleshan = true">
  64. <img src="../../assets/imageOne/delMoren.png" alt class="system-img forbidB" />
  65. <div class="system-box">
  66. <div class="system-div1 kind">删除默认设置</div>
  67. </div>
  68. <img src="../../assets/imageOne/15.png" alt class="system-img1" />
  69. </li>-->
  70. </ul>
  71. <!-- 删除框 -->
  72. <el-dialog title="提示" :visible.sync="dialogVisibleshan" :before-close="handleCloseshanchu">
  73. <span>此操作将删除默认设置(地址、虫害、病害)</span>
  74. <span slot="footer" class="dialog-footer">
  75. <el-button @click="dialogVisibleshan = false">取 消</el-button>
  76. <el-button type="primary" @click="dialogVisibleshan = false,delDefault()">确 定</el-button>
  77. </span>
  78. </el-dialog>
  79. <!-- 删除框 -->
  80. <!-- 进度条 -->
  81. <div class="schedule_box" v-if="scheduleShow" :style="'height:' + fullHeight + 'px'">
  82. <div class="schedule_box_div">
  83. <div class="schedule_box_title">正在下载...</div>
  84. <el-progress :percentage="percentage" :color="customColors"></el-progress>
  85. </div>
  86. </div>
  87. </el-main>
  88. </div>
  89. </template>
  90. <script>
  91. export default {
  92. name: "system",
  93. data() {
  94. return {
  95. value1: localStorage.identification,
  96. dizhi: localStorage.regionNameset, //地区
  97. yuefen: localStorage.monthset, //月份
  98. xianName: localStorage.xianAname,
  99. fullHeight: document.documentElement.clientHeight,
  100. isShow: false, // 判断是否显示
  101. timer: null, //定时器
  102. dialogVisibleshan: false, //删除
  103. dialogVisible: false, //更新弹框
  104. scheduleShow: false, //进度条
  105. redataName: localStorage.getItem("redataName"), //获取到后端发来的app的名字
  106. //测试进度条
  107. percentage: 20,
  108. customColor: "#409eff",
  109. customColors: [
  110. { color: "#f56c6c", percentage: 20 },
  111. { color: "#e6a23c", percentage: 40 },
  112. { color: "#5cb87a", percentage: 60 },
  113. { color: "#1989fa", percentage: 80 },
  114. { color: "#6f7ad3", percentage: 100 }
  115. ],
  116. isClick: true //更新弹框
  117. };
  118. },
  119. watch: {
  120. fullHeight(val) {
  121. //监控浏览器高度变化
  122. if (!this.timer) {
  123. this.fullHeight = val;
  124. this.timer = true;
  125. let that = this;
  126. setTimeout(function() {
  127. //防止过度调用监测事件,导致卡顿
  128. that.timer = false;
  129. }, 400);
  130. }
  131. },
  132. //判断进度条是否为100%
  133. percentage(time) {
  134. if (time === 100) {
  135. this.scheduleShow = false;
  136. this.$message({
  137. message: "已经下载成功,可以安装",
  138. type: "success",
  139. duration: 1000
  140. });
  141. localStorage.removeItem("redataName"); //删除存在本地的apk名字
  142. }
  143. }
  144. },
  145. mounted() {
  146. this.get_boderHeight();
  147. },
  148. created() {
  149. let _this = this;
  150. if (localStorage.getItem("default") !== "MoRen") {
  151. _this.isShow = false;
  152. } else {
  153. _this.isShow = true;
  154. }
  155. },
  156. computed: {
  157. //操作默认采集人设置的值
  158. num() {
  159. return this.$store.state.changableNum;
  160. }
  161. },
  162. methods: {
  163. //动态获取浏览器高度
  164. get_boderHeight() {
  165. const that = this;
  166. window.onresize = () => {
  167. return (() => {
  168. window.fullHeight = document.documentElement.clientHeight;
  169. that.fullHeight = window.fullHeight;
  170. })();
  171. };
  172. },
  173. //点击返回到主页
  174. goBack() {
  175. let _this = this;
  176. localStorage.removeItem("newdataID");
  177. localStorage.removeItem("chonghaiID");
  178. localStorage.removeItem("zuowuID");
  179. localStorage.removeItem("kunchongid");
  180. // _this.$router.push("/home");
  181. _this.$router.replace("/home");
  182. },
  183. // 点击进入地点设置页面
  184. // site() {
  185. // let _this = this;
  186. // _this.$router.push("/Site");
  187. // },
  188. //点击进入作物种类设置页面
  189. crop() {
  190. let _this = this;
  191. localStorage.removeItem("insectsetID");
  192. _this.$router.push("/plantset");
  193. // _this.$router.push("/crop");
  194. },
  195. //点击进入昆虫种类设置
  196. kunchong() {
  197. let _this = this;
  198. localStorage.removeItem("plantsetID");
  199. _this.$router.push("/insectset");
  200. // _this.$router.push("/insectType");
  201. },
  202. //点击删除默认设置
  203. delDefault() {
  204. let _this = this;
  205. localStorage.removeItem("xianAname");
  206. localStorage.removeItem("shiAname");
  207. localStorage.removeItem("shengAname");
  208. localStorage.removeItem("textarea");
  209. localStorage.removeItem("shengAcode");
  210. localStorage.removeItem("shiAcode");
  211. localStorage.removeItem("userName");
  212. localStorage.removeItem("default");
  213. localStorage.removeItem("crop");
  214. localStorage.removeItem("insectType");
  215. localStorage.removeItem("insectTypeIndex");
  216. localStorage.removeItem("cropIndex");
  217. this.$message({
  218. type: "success",
  219. message: "删除成功!"
  220. });
  221. const timer = setInterval(() => {
  222. // location.reload();
  223. }, 1000);
  224. },
  225. //删除框
  226. handleCloseshanchu(done) {
  227. let _this = this;
  228. _this.dialogVisibleshan = false;
  229. },
  230. //点击进入用户反馈页面
  231. fedk() {
  232. let _this = this;
  233. //判断账号是普通用户还是管理用户
  234. if (sessionStorage.getItem("common") !== null) {
  235. _this.$router.push("feedback");
  236. } else if (sessionStorage.getItem("Administrator") !== null) {
  237. _this.$router.push("/feedback_list");
  238. }
  239. },
  240. //点击请求后端进行更新
  241. update() {
  242. let _this = this;
  243. var isClick = _this.isClick;
  244. if (isClick === true) {
  245. _this.isClick = false;
  246. _this
  247. .$axios({
  248. method: "get",
  249. url: "bigservers/app_upgrade"
  250. })
  251. .then(res => {
  252. if (res.data.app_num > "1.1.7") {
  253. this.$notify({
  254. title: "成功",
  255. message: "检测到有新版本,需要更新",
  256. type: "success",
  257. duration: 1500
  258. });
  259. // const timerA = setInterval(() => {
  260. // window.location.href =
  261. // "bigservers/app_file/" + res.data.app_name;
  262. // clearInterval(timerA);
  263. // }, 1500);
  264. const timerA = setInterval(() => {
  265. var wait = plus.nativeUI.showWaiting("下载更新中,请勿关闭");
  266. //创建一个下载任务
  267. var dtask = plus.downloader.createDownload(
  268. "bigservers/app_file/" + res.data.app_name,
  269. {
  270. method: "GET"
  271. },
  272. function(d, status) {
  273. if (status == 200) {
  274. console.log("Download success: " + d.filename);
  275. plus.runtime.install(d.filename); // 安装下载的apk文件
  276. } else {
  277. alert("更新失败");
  278. // plus.runtime.install('../H5B2852C7_0925104810.apk'); // 安装下载的apk文件
  279. }
  280. wait.close();
  281. }
  282. );
  283. //开始下载
  284. dtask.start();
  285. clearInterval(timerA);
  286. }, 1500);
  287. } else if (res.data.app_num == "1.1.7") {
  288. this.$notify({
  289. title: "警告",
  290. message: "已是最新版本",
  291. type: "warning",
  292. duration: 1500
  293. });
  294. }
  295. })
  296. .catch(err => {
  297. console.log(err);
  298. });
  299. setTimeout(function() {
  300. _this.isClick = true;
  301. }, 1500);
  302. }
  303. },
  304. //点击跳转到历史记录页面
  305. updateHistory() {
  306. this.$router.push("/updateHistory");
  307. }
  308. }
  309. };
  310. </script>
  311. <style lang="scss">
  312. @import "../../assets/style/bus.scss";
  313. @import "../../assets/style/scss/system.scss";
  314. </style>