index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view class="mine-container" :style="{height: `${windowHeight}px`}">
  3. <!--顶部个人信息栏-->
  4. <view class="header-section">
  5. <view class="flex padding justify-between">
  6. <view class="flex align-center">
  7. <view v-if="!avatar" class="cu-avatar xl round bg-white">
  8. <view class="iconfont icon-people text-gray icon"></view>
  9. </view>
  10. <image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix">
  11. </image>
  12. <view v-if="!name" @click="handleToLogin" class="login-tip">
  13. 点击登录
  14. </view>
  15. <view v-if="name" @click="handleToInfo" class="user-info">
  16. <view class="u_title">
  17. 用户名:{{ name }}
  18. </view>
  19. </view>
  20. </view>
  21. <view @click="handleToInfo" class="flex align-center">
  22. <text>个人信息</text>
  23. <view class="iconfont icon-right"></view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="content-section">
  28. <view class="mine-actions grid col-4 text-center">
  29. <view class="action-item" @click="handleJiaoLiuQun">
  30. <view class="iconfont icon-friendfill text-pink icon"></view>
  31. <text class="text">交流群</text>
  32. </view>
  33. <view class="action-item" @click="handleBuilding">
  34. <view class="iconfont icon-service text-blue icon"></view>
  35. <text class="text">在线客服</text>
  36. </view>
  37. <view class="action-item" @click="handleBuilding">
  38. <view class="iconfont icon-community text-mauve icon"></view>
  39. <text class="text">反馈社区</text>
  40. </view>
  41. <view class="action-item" @click="handleBuilding">
  42. <view class="iconfont icon-dianzan text-green icon"></view>
  43. <text class="text">点赞我们</text>
  44. </view>
  45. </view>
  46. <view class="menu-list">
  47. <view class="list-cell list-cell-arrow" @click="handleToEditInfo">
  48. <view class="menu-item-box">
  49. <view class="iconfont icon-user menu-icon"></view>
  50. <view>编辑资料</view>
  51. </view>
  52. </view>
  53. <view class="list-cell list-cell-arrow" @click="handleHelp">
  54. <view class="menu-item-box">
  55. <view class="iconfont icon-help menu-icon"></view>
  56. <view>常见问题</view>
  57. </view>
  58. </view>
  59. <view class="list-cell list-cell-arrow" @click="handleAbout">
  60. <view class="menu-item-box">
  61. <view class="iconfont icon-aixin menu-icon"></view>
  62. <view>关于我们</view>
  63. </view>
  64. </view>
  65. <view class="list-cell list-cell-arrow" @click="handleToSetting">
  66. <view class="menu-item-box">
  67. <view class="iconfont icon-setting menu-icon"></view>
  68. <view>应用设置</view>
  69. </view>
  70. </view>
  71. <!-- #ifdef APP-PLUS -->
  72. <!-- #endif -->
  73. <view class="list-cell list-cell-arrow" @click="onlineWgt">
  74. <view class="menu-item-box">
  75. <view class="iconfont icon-setting menu-icon"></view>
  76. <view>版本号{{wgtcode}}</view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <footers v-if="isfootflag" :footerindex="footerindex" :isHomeIndex="false"></footers>
  82. </view>
  83. </template>
  84. <script>
  85. import storage from '@/utils/storage'
  86. import footers from '@/components/footer/footer.vue'
  87. import {findVersion} from "@/api/system/user.js"
  88. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  89. import config from '@/config'
  90. const baseUrl = config.baseUrl
  91. export default {
  92. data() {
  93. return {
  94. name: this.$store.state.user.name,
  95. version: getApp().globalData.config.appInfo.version,
  96. footerindex: 'mine',
  97. isfootflag: true,
  98. wgtcode: this.$store.state.user.wgtcode,
  99. platform: 'Android',
  100. }
  101. },
  102. components: {
  103. footers
  104. },
  105. computed: {
  106. avatar() {
  107. return this.$store.state.user.avatar
  108. },
  109. windowHeight() {
  110. return uni.getSystemInfoSync().windowHeight - 50
  111. }
  112. },
  113. onLoad() {
  114. var that=this;
  115. this.nvaHeight=uni.getSystemInfoSync().statusBarHeight+44;
  116. // #ifdef APP-PLUS
  117. plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
  118. that.$store.dispatch('SetwgtFn', widgetInfo.version).then(() => {
  119. that.wgtcode=widgetInfo.version
  120. })
  121. });
  122. // #endif
  123. },
  124. methods: {
  125. checkPermi,checkRole,
  126. handleToInfo() {
  127. this.$tab.navigateTo('/pages/mine/info/index')
  128. },
  129. handleToEditInfo() {
  130. this.$tab.navigateTo('/pages/mine/info/edit')
  131. },
  132. handleToSetting() {
  133. this.$tab.navigateTo('/pages/mine/setting/index')
  134. },
  135. handleToLogin() {
  136. this.$tab.reLaunch('/pages/login')
  137. },
  138. handleToAvatar() {
  139. this.$tab.navigateTo('/pages/mine/avatar/index')
  140. },
  141. handleLogout() {
  142. this.$modal.confirm('确定注销并退出系统吗?').then(() => {
  143. this.$store.dispatch('LogOut').then(() => {
  144. this.$tab.reLaunch('/pages/index/index')
  145. })
  146. })
  147. },
  148. handleHelp() {
  149. this.$tab.navigateTo('/pages/mine/help/index')
  150. },
  151. handleAbout() {
  152. this.$tab.navigateTo('/pages/mine/about/index')
  153. },
  154. handleJiaoLiuQun() {
  155. this.$modal.showToast('QQ群:①133713780(满)、②146013835(满)、③189091635')
  156. },
  157. handleBuilding() {
  158. this.$modal.showToast('模块建设中~')
  159. },
  160. onlineWgt() {
  161. let that = this;
  162. plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
  163. that.$store.dispatch('SetwgtFn', widgetInfo.version).then(() => {
  164. that.wgtcode=widgetInfo.version
  165. })
  166. that.comparisonVersionNo(widgetInfo.versionCode);
  167. });
  168. // that.comparisonVersionNo()
  169. },
  170. comparisonVersionNo(versionCode) {
  171. let that = this;
  172. // console.log("aaaaaaa===versionCode", versionCode);
  173. const parmas = {
  174. model: that.platform
  175. }
  176. findVersion(parmas).then(res => {
  177. if (res.code == "200") {
  178. let versionNos = res.data.code;
  179. console.log(versionNos, 'versionNos')
  180. // console.log(res.data.path);
  181. let filePath = res.data.path;
  182. if (Number(versionNos) > Number(versionCode)) { //服务器返回1更新,0则不更新
  183. uni.showModal({
  184. title: '提示',
  185. content: '发现新版本,是否升级',
  186. success: function(res) {
  187. // console.log(widgetInfo.version);
  188. if (res.confirm) {
  189. console.log('用户点击确定');
  190. that.getProperty(filePath);
  191. } else if (res.cancel) {
  192. console.log('用户点击取消');
  193. }
  194. }
  195. });
  196. } else {
  197. this.$toast('该版本已是最新版')
  198. }
  199. }
  200. }).catch(error => {
  201. uni.hideLoading()
  202. console.log(error)
  203. })
  204. },
  205. getProperty(getProperty) {
  206. // console.log("bbbbbbbbb----------->", getProperty)
  207. let that = this;
  208. // 在线升级app/热更新
  209. that.showwri = true;
  210. const downloadTask = uni.downloadFile({ //下载文件
  211. url: baseUrl + getProperty,
  212. success: (downloadResult) => {
  213. // console.log(downloadResult);
  214. if (downloadResult.statusCode == 200) {
  215. // 更新升级
  216. plus.runtime.install(downloadResult.tempFilePath, {
  217. force: true
  218. }, function() {
  219. // console.log('install success...');
  220. that.showwri = false;
  221. plus.nativeUI.alert("应用资源更新完成!", function() {
  222. plus.runtime.restart();
  223. });
  224. }, function(e) {
  225. that.showwri = false;
  226. plus.nativeUI.alert("更新失败,请稍后再试");
  227. });
  228. }
  229. }
  230. });
  231. downloadTask.onProgressUpdate((res) => { //下载文件的进度
  232. that.totalBytesWritten = res.totalBytesWritten; //当前下载大小
  233. that.progress = res.progress; //当前下载比例
  234. that.totalBytesExpectedToWrite = res.totalBytesExpectedToWrite; //
  235. });
  236. },
  237. }
  238. }
  239. </script>
  240. <style lang="scss">
  241. page {
  242. background-color: #f5f6f7;
  243. }
  244. .mine-container {
  245. width: 100%;
  246. height: 100%;
  247. .header-section {
  248. padding: 15px 15px 45px 15px;
  249. background-color: #3c96f3;
  250. color: white;
  251. .login-tip {
  252. font-size: 18px;
  253. margin-left: 10px;
  254. }
  255. .cu-avatar {
  256. border: 2px solid #eaeaea;
  257. .icon {
  258. font-size: 40px;
  259. }
  260. }
  261. .user-info {
  262. margin-left: 15px;
  263. .u_title {
  264. font-size: 18px;
  265. line-height: 30px;
  266. }
  267. }
  268. }
  269. .content-section {
  270. position: relative;
  271. top: -50px;
  272. .mine-actions {
  273. margin: 15px 15px;
  274. padding: 20px 0px;
  275. border-radius: 8px;
  276. background-color: white;
  277. .action-item {
  278. .icon {
  279. font-size: 28px;
  280. }
  281. .text {
  282. display: block;
  283. font-size: 13px;
  284. margin: 8px 0px;
  285. }
  286. }
  287. }
  288. }
  289. }
  290. </style>