微信

index.vue 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div class="mainPage" v-if="showPage">
  3. <div class="flex-h">
  4. <div class="flex-item">
  5. <div>
  6. <ul>
  7. <router-link
  8. v-for="(item, index) in project"
  9. :key="index"
  10. class="flex-h"
  11. tag="li"
  12. :to="{ name:'majorProjects', query:{ id: item.CmsCaseId } }"
  13. >
  14. <a class="img">
  15. <img :src="getImg(item.CmsCaseImgs)" class="cover" alt>
  16. </a>
  17. <router-link
  18. tag="div"
  19. class="flex-item"
  20. :to="{ name:'majorProjects', query:{ id: item.CmsCaseId } }"
  21. >
  22. <div>
  23. <span>{{item.Name}}</span>
  24. <span>{{item.CaseAddress}}</span>
  25. </div>
  26. </router-link>
  27. </router-link>
  28. </ul>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import { mapState, createNamespacedHelpers } from 'vuex'
  36. const { mapActions: mapIndexActions } = createNamespacedHelpers('index')
  37. const wx = require('weixin-js-sdk')
  38. import wxsdk from '@/util/share'
  39. export default {
  40. name: '',
  41. data () {
  42. return {
  43. showPage: false
  44. }
  45. },
  46. computed: {
  47. ...mapState({
  48. project: x => x.index.project,
  49. orgid: x => x.app.orgId
  50. })
  51. },
  52. created () {
  53. let that = this
  54. wxsdk({ url: encodeURIComponent(window.location.href.split('#')[0]) }, {
  55. title: '城的空间',
  56. desc: '城的空间',
  57. link: `${window.location.origin}${window.location.pathname}#/mainPage/indexPage`,
  58. thu_image: `https://spaceofcheng.oss-cn-beijing.aliyuncs.com/indexlogo.jpg?x-oss-process=style/wxicon`
  59. }).then(() => {
  60. wx.getLocation({
  61. type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
  62. success: function (res) {
  63. that.setLocation({ latitude1: res.latitude, longitude1: res.longitude })
  64. that.showPage = true
  65. that.init()
  66. },
  67. cancel: function () {
  68. that.showPage = true
  69. that.init()
  70. },
  71. fail: function () {
  72. that.showPage = true
  73. that.init()
  74. }
  75. })
  76. })
  77. },
  78. methods: {
  79. ...mapIndexActions(['getProjectList', 'setLocation']),
  80. getImg (list) {
  81. return list.filter(item => item.ImageType === 'cover')[0].CaseImageUrl
  82. },
  83. init () {
  84. this.getProjectList({ orgid: this.orgid, locationid: 'index' }).then(() => {
  85. this.showPage = true
  86. })
  87. }
  88. }
  89. }
  90. </script>
  91. <!-- Add "scoped" attribute to limit CSS to this component only -->
  92. <style lang="scss" scoped>
  93. @import 'page.scss';
  94. </style>