健康同学微信公众号h5项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

303 lines
9.2KB

  1. <!-- -->
  2. <template>
  3. <div class="myself">
  4. <!-- <NavBar></NavBar> -->
  5. <div class="container">
  6. <div class="banner">
  7. <div class="top">
  8. <div class="avatar">
  9. <img src="../../assets/myself/4_62.png" alt="" />
  10. </div>
  11. <div class="nick-name">
  12. <span>{{ userInfos.username }}</span>
  13. </div>
  14. </div>
  15. <div class="bottom">
  16. <span>已绑定{{ userInfos.deviceNumber }}台设备</span>
  17. </div>
  18. </div>
  19. <div class="submenu device-manage">
  20. <SubmenuList :title="device.title" :list="device.list" rounded>
  21. <template #addDevice>
  22. <div class="add-device"><span>+</span></div>
  23. </template>
  24. </SubmenuList>
  25. </div>
  26. <div class="submenu family">
  27. <SubmenuList :title="family.title" :list="family.list"> </SubmenuList>
  28. </div>
  29. <div class="submenu safe-helper">
  30. <div class="title">
  31. <p>安全助手</p>
  32. </div>
  33. <div class="safe-helper-container">
  34. <div class="top">
  35. <p>{{ currentDevice.address }}</p>
  36. <span>纬度: {{ currentDevice.lat }} 经度: {{ currentDevice.lng }}</span>
  37. </div>
  38. <div class="bottom">
  39. <p @click="goMap">进入地图 <span>></span></p>
  40. </div>
  41. </div>
  42. </div>
  43. <div class="submenu study-helper">
  44. <SubmenuList :title="studyHelper.title" :list="studyHelper.list"> </SubmenuList>
  45. </div>
  46. <div class="submenu life-helper">
  47. <SubmenuList :title="lifeHelper.title" :list="lifeHelper.list"> </SubmenuList>
  48. </div>
  49. <div class="submenu param-setting">
  50. <SubmenuList :title="paramSetting.title" :list="paramSetting.list"> </SubmenuList>
  51. </div>
  52. <div class="submenu others-setting">
  53. <SubmenuList :title="othersSetting.title" :list="othersSetting.list"> </SubmenuList>
  54. </div>
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. /* import NavBar from '@/components/NavBar.vue'; */
  60. import SubmenuList from '@/components/SubmenuList.vue';
  61. import APIUser from '@/api/user';
  62. import APIDevice from '@/api/device';
  63. import ToastService from '@/services/toast-service';
  64. import { isNotNull } from '@/services/utils-service';
  65. export default {
  66. components: { /* NavBar, */ SubmenuList },
  67. data() {
  68. return {
  69. userInfos: {},
  70. listData: [],
  71. family: {
  72. title: '亲情沟通',
  73. list: [
  74. {
  75. imgPath: require('../../assets/myself/4_76.png'),
  76. text: '亲情号码',
  77. bgColor: this.$green,
  78. showType: 'newPage',
  79. routerName: 'familyNumber'
  80. },
  81. {
  82. imgPath: require('../../assets/myself/4_79.png'),
  83. text: '留言',
  84. bgColor: this.$green,
  85. showType: 'newPage',
  86. routerName: 'sendMessage'
  87. },
  88. {
  89. imgPath: require('../../assets/myself/4_81.png'),
  90. text: '通话记录',
  91. bgColor: this.$green,
  92. showType: 'newPage',
  93. routerName: 'callList'
  94. }
  95. ]
  96. },
  97. device: {
  98. title: '孩子管理',
  99. list: [
  100. { imgPath: require('../../assets/myself/4_62.png'), text: '孩子1', bgColor: 'green' },
  101. { imgPath: require('../../assets/myself/4_62.png'), text: '孩子2', bgColor: 'green' },
  102. { imgPath: require('../../assets/myself/4_62.png'), text: '孩子3', bgColor: 'green' }
  103. ]
  104. },
  105. studyHelper: {
  106. title: '学习助手',
  107. list: [
  108. {
  109. imgPath: require('../../assets/myself/4_88.png'),
  110. text: '课堂禁用',
  111. bgColor: this.$green,
  112. showType: 'newPage',
  113. routerName: 'prohibit'
  114. },
  115. { imgPath: require('../../assets/myself/4_91.png'), text: '课程表', bgColor: 'green' }
  116. ]
  117. },
  118. lifeHelper: {
  119. title: '生活助手',
  120. list: [
  121. {
  122. imgPath: require('../../assets/myself/4_104.png'),
  123. text: '闹钟',
  124. bgColor: this.$green,
  125. showType: 'newPage',
  126. routerName: 'clock'
  127. },
  128. {
  129. imgPath: require('../../assets/myself/4_107.png'),
  130. text: '支付密码修改',
  131. bgColor: this.$green,
  132. showType: 'newPage',
  133. routerName: 'changePayPassword'
  134. },
  135. {
  136. imgPath: require('../../assets/myself/4_109.png'),
  137. text: '短信代收',
  138. bgColor: this.$green,
  139. showType: 'newPage',
  140. routerName: 'messageList'
  141. },
  142. {
  143. imgPath: require('../../assets/myself/4_96.png'),
  144. text: '亲友关注',
  145. bgColor: this.$green,
  146. showType: 'newPage',
  147. routerName: 'management'
  148. }
  149. ]
  150. },
  151. paramSetting: {
  152. title: '参数设置',
  153. list: [
  154. {
  155. imgPath: require('../../assets/myself/4_98.png'),
  156. text: '参数设置',
  157. bgColor: this.$green,
  158. showType: 'newPage',
  159. routerName: 'watchSetting'
  160. },
  161. {
  162. imgPath: require('../../assets/myself/4_111.png'),
  163. text: '远程控制',
  164. bgColor: this.$green,
  165. showType: 'newDialog',
  166. routerName: 'remote'
  167. },
  168. {
  169. imgPath: require('../../assets/myself/4_101.png'),
  170. text: '休眠设置',
  171. bgColor: this.$green,
  172. showType: 'newPage',
  173. routerName: 'sleep'
  174. }
  175. ]
  176. },
  177. othersSetting: {
  178. title: '其他设置',
  179. list: [
  180. {
  181. imgPath: require('../../assets/myself/4_42.png'),
  182. text: '账户安全',
  183. bgColor: this.$green,
  184. showType: '',
  185. routerName: ''
  186. },
  187. {
  188. imgPath: require('../../assets/myself/4_45.png'),
  189. text: '常见问题',
  190. bgColor: this.$green,
  191. showType: 'newPage',
  192. routerName: 'help'
  193. },
  194. {
  195. imgPath: require('../../assets/myself/4_47.png'),
  196. text: '版本信息',
  197. bgColor: this.$green,
  198. showType: 'newDialog',
  199. routerName: 'version'
  200. },
  201. { imgPath: require('../../assets/myself/4_53.png'), text: '关于我们', bgColor: 'green' },
  202. {
  203. imgPath: require('../../assets/myself/4_72.png'),
  204. text: '退出登录',
  205. bgColor: 'green',
  206. showType: 'newDialog',
  207. routerName: 'logout'
  208. }
  209. ]
  210. },
  211. userImg: require('../../assets/myself/4_62.png'), //用户头像
  212. currentDevice: {
  213. address: '',
  214. lat: '',
  215. lng: ''
  216. }
  217. };
  218. },
  219. created() {},
  220. mounted() {
  221. this.getUserInfos();
  222. this.getDeviceList();
  223. },
  224. methods: {
  225. getUserInfos() {
  226. APIUser.getUserInfos({
  227. userId: this.$store.getters.userId
  228. })
  229. .then(res => {
  230. console.log('res', res);
  231. if (res.data.stateCode === 1) {
  232. if (res.data) {
  233. this.userInfos = { ...res.data };
  234. }
  235. }
  236. })
  237. .catch(err => {
  238. console.log(err);
  239. })
  240. .finally(() => {
  241. ToastService.clear();
  242. });
  243. },
  244. getDeviceList() {
  245. ToastService.loading({ message: '正在加载', forbidClick: false });
  246. /* let that = this; */
  247. APIDevice.deviceList({
  248. userId: this.$store.getters.userId,
  249. mapType: 'gaode',
  250. timeOffset: -new Date().getTimezoneOffset() / 60
  251. })
  252. .then(res => {
  253. let item = res.data;
  254. this.longName = item.longName;
  255. /* this.device.list =
  256. item.devicesList == null
  257. ? []
  258. : item.devicesList.map(device => {
  259. return {
  260. imgPath: device.imagePath,
  261. text: device.nickName ? device.nickName : device.serialNo.slice(-3),
  262. bgColor: 'green'
  263. };
  264. }); */
  265. if (isNotNull(item.devicesList)) {
  266. this.currentDevice = { ...item.devicesList[0] };
  267. this.$store.commit('roleUser', item.devicesList[0].roleUser);
  268. this.$store.commit('deviceType', item.devicesList[0].deviceType);
  269. this.$store.commit('deviceId', item.devicesList[0].deviceId);
  270. this.$store.commit('serialNo', item.devicesList[0].serialNo);
  271. /* item.devicesList.forEach(val => {
  272. if (val.deviceId == that.$store.getters.deviceId) {
  273. this.$store.commit('roleUser', val.roleUser);
  274. this.$store.commit('deviceType', val.deviceType);
  275. }
  276. }); */
  277. } else {
  278. this.$store.commit('deviceId', '');
  279. this.$store.commit('serialNo', '');
  280. }
  281. })
  282. .catch(err => {
  283. console.log(err);
  284. })
  285. .finally(() => {
  286. ToastService.clear();
  287. });
  288. },
  289. goMap() {
  290. this.$router.push({
  291. name: 'location'
  292. });
  293. }
  294. }
  295. };
  296. </script>
  297. <style scoped lang="scss">
  298. @import './index.scss'; /* @import url(); 引入css类 */
  299. </style>