index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <view class="home" :style="'padding-top:'+nvaHeight+'px;padding-bottom:'+footHeight+'rpx'">
  3. <view class="navbox">
  4. <uni-nav-bar :title="title" leftWidth='400rpx' color="#ffffff" :background-color="backgroundColor" :border="false" statusBar='true' fixed="true">
  5. <block slot="left">
  6. <view class="topl flexc">
  7. <image src="@/static/images/home/adr.png" ></image>
  8. <view class="over">{{city}}</view>
  9. </view>
  10. </block>
  11. </uni-nav-bar>
  12. </view>
  13. <view class="hmain flex1">
  14. <!-- -->
  15. <view class="mtop flexc mb15">
  16. <view class="overh flex1" @click="handleToInfo">
  17. <view class="tit flexc ">
  18. <view class="over">{{name}}</view>
  19. <view class="roles flexcc">{{roleGroup}}</view></view>
  20. <view class="flexc num">
  21. <image src="@/static/images/mine/phone.png"></image>
  22. {{kaPho(phone)}}
  23. </view>
  24. </view>
  25. <view class="headimg" @click.stop="handleToAvatar">
  26. <image v-if="avatar" :src="avatar" mode="aspectFill"></image>
  27. <image src="@/static/images/mine/head.png" v-else></image>
  28. </view>
  29. </view>
  30. <view class="htabs flexcj">
  31. <view class="htab flexc">
  32. <view class="imgs flex0 flexc">
  33. <image src="@/static/images/home/htaba.png" class="imga"></image>
  34. </view>
  35. <view class="flex1" @click="getNoticeFn">
  36. <view class="tit mb5">防溺通知</view>
  37. <view class="txt">预警提醒 守护安全</view>
  38. </view>
  39. </view>
  40. <view class="htab flexc" @click="getRzList">
  41. <view class="imgs flex0 flexc">
  42. <image src="@/static/images/home/htabb.png" class="imgb"></image>
  43. </view>
  44. <view class="flex1">
  45. <view class="tit mb5">绑定认证</view>
  46. <view class="txt">绑定监护 溺水早知</view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="mb12" v-if="bannerList&&bannerList.length">
  51. <banner :list="bannerList" height="148"></banner>
  52. </view>
  53. <view class="minbox">
  54. <view class="mines flexc" @click="handleToSetting">
  55. <view class="imgs"><image src="@/static/images/mine/minea.png" class="imga"></image></view>
  56. <view class="tit">我的设置</view>
  57. <view class="rimg"><image src="@/static/images/mine/rimg.png"></image></view>
  58. </view>
  59. <view class="mines flexc" @click="handleUpassword">
  60. <view class="imgs"><image src="@/static/images/mine/mineb.png" class="imgb"></image></view>
  61. <view class="tit">修改密码</view>
  62. <view class="rimg"><image src="@/static/images/mine/rimg.png"></image></view>
  63. </view>
  64. <!-- #ifdef APP-PLUS -->
  65. <view class="mines flexc" @click="onlineWgt">
  66. <view class="imgs"><image src="@/static/images/mine/minec.png" class="imgc"></image></view>
  67. <view class="tit">当前版本</view>
  68. <view class="txt">V.1.0.3.</view>
  69. <view class="rimg"><image src="@/static/images/mine/rimg.png"></image></view>
  70. </view>
  71. <!-- #endif -->
  72. <view class="mines flexc" @click="handleLogout">
  73. <view class="imgs"><image src="@/static/images/mine/mined.png" class="imgc"></image></view>
  74. <view class="tit">退出登录</view>
  75. <view class="rimg"><image src="@/static/images/mine/rimg.png"></image></view>
  76. </view>
  77. </view>
  78. <!-- 完善按钮 -->
  79. <view class="rxfbtn" v-if="initFace=='Y'">
  80. <view class="rxbtn flexc">
  81. <image src="@/static/images/home/rztip.png" class="imga flex0"></image>
  82. <view class="tit flex1 over">1分钟完善信息,守护孩子的安全</view>
  83. <view class="btn flexcc flex0">去完善</view>
  84. <image src="@/static/images/home/wclose.png" class="imgb flex0" @click="getzrCloseFn"></image>
  85. </view>
  86. </view>
  87. </view>
  88. <loading></loading>
  89. <footers v-if="isfootflag" :footerindex="footerindex"></footers>
  90. </view>
  91. </template>
  92. <script>
  93. import footers from '@/components/footer/footer.vue'
  94. import {findVersion,getUserProfile} from "@/api/system/user.js"
  95. import banner from '@/components/swiper/banner.vue'
  96. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  97. import {getBannerListNoPage} from "@/api/work/index.js"
  98. import config from '@/config'
  99. const baseUrl = config.baseUrl
  100. export default {
  101. components:{footers,banner},
  102. data(){
  103. return{
  104. footerindex:'mine',
  105. isfootflag:true,
  106. activeColor:'#A7A7A7',
  107. nactiveColor:'#E6E6E6',
  108. footHeight:'150',
  109. nvaHeight:44,
  110. backgroundColor: "transparent",
  111. title:'',
  112. city:"潜山市",
  113. initFace:'Y',//y:显示
  114. roleGroup:'',
  115. baseUrl:config.baseUrl,
  116. name: this.$store.state.user.nickName,
  117. phone: this.$store.state.user.phonenumber,
  118. wgtcode: this.$store.state.user.wgtcode,
  119. platform: 'Android',
  120. bannerList:[],
  121. }
  122. },
  123. computed: {
  124. avatar() {
  125. return this.$store.state.user.avatar
  126. },
  127. windowHeight() {
  128. return uni.getSystemInfoSync().windowHeight - 50
  129. }
  130. },
  131. onShow() {
  132. this.initFace=this.$store.state.user.initFace||'Y';
  133. if(this.initFace=='Y'){
  134. this.footHeight=282
  135. }
  136. },
  137. onLoad: function() {
  138. this.nvaHeight=uni.getSystemInfoSync().statusBarHeight+44;
  139. // #ifdef APP-PLUS
  140. plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
  141. that.$store.dispatch('SetwgtFn', widgetInfo.version).then(() => {
  142. that.wgtcode=widgetInfo.version
  143. })
  144. });
  145. // #endif
  146. this.getBanner()
  147. getUserProfile().then(response => {
  148. this.roleGroup = response.roleGroup
  149. // this.postGroup = response.postGroup
  150. })
  151. },
  152. methods:{
  153. checkPermi,checkRole,
  154. kaPho(val){
  155. if(val){
  156. return val.substring(0,3)+'****'+val.substring(7)
  157. }
  158. },
  159. getzrCloseFn(){
  160. this.$store.dispatch('checkInitFace', 'N').then(() => {
  161. this.initFace='N';
  162. this.footHeight='150';
  163. })
  164. },
  165. getRzList(){
  166. this.$tab.navigateTo(`/work/pages/rz/index`)
  167. },
  168. getNoticeFn(type){
  169. this.$tab.navigateTo(`/news/pages/notice/index`)
  170. },
  171. // 修改密码
  172. handleUpassword(){
  173. this.$tab.navigateTo(`/pages/mine/pwd/index`)
  174. },
  175. handleToSetting() {
  176. this.$tab.navigateTo('/pages/mine/setting/index')
  177. },
  178. handleToInfo() {
  179. this.$tab.navigateTo('/pages/mine/info/index')
  180. },
  181. handleToAvatar() {
  182. this.$tab.navigateTo('/pages/mine/avatar/index')
  183. },
  184. handleLogout() {
  185. this.$modal.confirm('确定注销并退出系统吗?').then(() => {
  186. this.$store.dispatch('LogOut').then(() => {
  187. this.$tab.reLaunch('/pages/login')
  188. })
  189. })
  190. },
  191. getBanner(){
  192. var params={
  193. status:'0',
  194. type:'2',//个人中心
  195. }
  196. getBannerListNoPage(params).then(res=>{
  197. if(res.code==200){
  198. var arr=[];
  199. if(res.rows&&res.rows.length){
  200. res.rows.map(v => {
  201. if(v.imgUrl){
  202. var newArr=v.imgUrl.split(',')
  203. arr=arr.concat(newArr)
  204. }
  205. })
  206. }
  207. this.bannerList = arr;
  208. }else{
  209. this.$toast(res.msg)
  210. }
  211. })
  212. },
  213. onlineWgt() {
  214. let that = this;
  215. plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
  216. that.$store.dispatch('SetwgtFn', widgetInfo.version).then(() => {
  217. that.wgtcode=widgetInfo.version
  218. })
  219. that.comparisonVersionNo(widgetInfo.versionCode);
  220. });
  221. // that.comparisonVersionNo()
  222. },
  223. comparisonVersionNo(versionCode) {
  224. let that = this;
  225. // console.log("aaaaaaa===versionCode", versionCode);
  226. const parmas = {
  227. model: that.platform,
  228. }
  229. findVersion(parmas).then(res => {
  230. if (res.code == "200") {
  231. let versionNos = res.data.code;
  232. console.log(versionNos, 'versionNos')
  233. // console.log(res.data.path);
  234. let filePath = res.data.path;
  235. if (Number(versionNos) > Number(versionCode)) { //服务器返回1更新,0则不更新
  236. uni.showModal({
  237. title: '提示',
  238. content: '发现新版本,是否升级',
  239. success: function(res) {
  240. // console.log(widgetInfo.version);
  241. if (res.confirm) {
  242. console.log('用户点击确定');
  243. that.getProperty(filePath);
  244. } else if (res.cancel) {
  245. console.log('用户点击取消');
  246. }
  247. }
  248. });
  249. } else {
  250. this.$toast('该版本已是最新版')
  251. }
  252. }
  253. }).catch(error => {
  254. uni.hideLoading()
  255. console.log(error)
  256. })
  257. },
  258. getProperty(getProperty) {
  259. // console.log("bbbbbbbbb----------->", getProperty)
  260. let that = this;
  261. // 在线升级app/热更新
  262. that.showwri = true;
  263. const downloadTask = uni.downloadFile({ //下载文件
  264. url: baseUrl + getProperty,
  265. success: (downloadResult) => {
  266. // console.log(downloadResult);
  267. if (downloadResult.statusCode == 200) {
  268. // 更新升级
  269. plus.runtime.install(downloadResult.tempFilePath, {
  270. force: true
  271. }, function() {
  272. // console.log('install success...');
  273. that.showwri = false;
  274. plus.nativeUI.alert("应用资源更新完成!", function() {
  275. plus.runtime.restart();
  276. });
  277. }, function(e) {
  278. that.showwri = false;
  279. plus.nativeUI.alert("更新失败,请稍后再试");
  280. });
  281. }
  282. }
  283. });
  284. downloadTask.onProgressUpdate((res) => { //下载文件的进度
  285. that.totalBytesWritten = res.totalBytesWritten; //当前下载大小
  286. that.progress = res.progress; //当前下载比例
  287. that.totalBytesExpectedToWrite = res.totalBytesExpectedToWrite; //
  288. });
  289. },
  290. }
  291. }
  292. </script>
  293. <style lang="scss" scoped>
  294. .home{height: 100vh;background: linear-gradient(127deg, #DFEBFF, #F1F6FF, #E2EDFF);padding-bottom: 150rpx;display: flex;flex-direction: column;}
  295. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4;
  296. .topl{padding-left: 6rpx;overflow: hidden;
  297. image{width: 18rpx;height: 20rpx;margin-right: 12rpx;flex: 0 0 auto;}
  298. view{font-weight: bold;font-size: 24rpx;color: #272727;}
  299. }
  300. }
  301. .hmain{padding: 0 24rpx;overflow: auto;
  302. .rxfbtn{position: fixed;left:0rpx;right: 0rpx;bottom: 150rpx;padding: 10rpx 24rpx;}
  303. .rxbtn{width: 100%;background: #4280FB;border-radius: 20rpx;padding: 16rpx 22rpx 16rpx 16rpx;
  304. .imga{width: 58rpx;height: 60rpx;margin-right: 14rpx;}
  305. .imgb{width: 20rpx;height: 20rpx;margin-left: 20rpx;}
  306. .tit{font-weight: bold;font-size: 26rpx;color: #FFFFFF;}
  307. .btn{background: #FFFFFF;padding: 0 26rpx;height: 58rpx;
  308. box-shadow: 0px 0px 0px 0px #2B6AE7;
  309. border-radius: 30rpx;font-weight: bold;
  310. font-size: 26rpx;color: #2B73FF;}
  311. }
  312. }
  313. .mtop{padding-top: 20rpx;
  314. .tit{font-size: 36rpx;font-weight: bold;color: #272727;margin-bottom: 12rpx;
  315. .roles{background: #DDEAFF;font-weight: bold;font-size:20rpx;color: #4E8CEE;border-radius: 18rpx;padding: 0 16rpx;line-height: 30rpx; flex: 0 0 auto;
  316. border: 2rpx solid #4775EA;margin-left: 20rpx;}
  317. }
  318. .num{font-weight: 500;font-size: 24rpx;color: #808080;
  319. image{width: 16rpx;height: 20rpx;margin-right: 10rpx;}
  320. }
  321. .headimg{width: 110rpx;height: 110rpx;flex: 0 0 auto;margin-left: 12rpx;
  322. image{width: 100%;height: 100%;}
  323. }
  324. }
  325. .htabs{margin-bottom: 26rpx;
  326. .htab{width: 48%;height: 140rpx;background: #FFFFFF;border-radius: 20rpx;padding: 0 24rpx;box-sizing: border-box;
  327. .imgs{width: 74rpx;height: 70rpx;margin-right: 14rpx;
  328. .imga{width: 72rpx;height: 70rpx;}
  329. .imgb{width: 74rpx;height: 68rpx;}
  330. }
  331. .tit{font-weight: bold;font-size: 28rpx;color: #000000;}
  332. .txt{font-weight: 500;font-size: 24rpx;color: #666666;}
  333. }
  334. }
  335. .minbox{background: #FFFFFF;border-radius: 20rpx;
  336. .mines{padding: 30rpx 26rpx 30rpx 30rpx;
  337. .imgs{width: 48rpx;height: 48rpx;display: flex;align-items: center;justify-content: center;margin-right: 24rpx;flex:0 0 auto;
  338. .imga{width: 48rpx;height: 46rpx;}
  339. .imgb{width: 42rpx;height: 46rpx;}
  340. .imgc{width: 48rpx;height: 48rpx;}
  341. }
  342. .rimg{width: 12rpx;height: 22rpx;margin-left: 24rpx;flex:0 0 auto;
  343. image{width: 100%;height: 100%;}
  344. }
  345. .tit{font-weight: 500;font-size: 30rpx;color: #000000;flex: 1;}
  346. .txt{flex: 0 0 auto;font-weight: 500;font-size: 26rpx;color: #666666;}
  347. }
  348. }
  349. </style>