Baozhangchao 3 years ago
parent
commit
fac40a3500
5 changed files with 119 additions and 57 deletions
  1. 1
    3
      public/index.html
  2. 62
    24
      src/components/StrongPhoto.vue
  3. 2
    2
      src/components/UserCenter.vue
  4. 54
    0
      src/util/initial.js
  5. 0
    28
      src/util/request.js

+ 1
- 3
public/index.html View File

@@ -61,9 +61,7 @@
61 61
       <div class="loading-image">
62 62
         <img src="./images/Loading.png" width="100%" alt="">
63 63
       </div>
64
-      <!-- <div class="loading-tips">
65
-        <img src="./images/Loading.png" width="100%" alt="">
66
-      </div> -->
64
+
67 65
     </div>
68 66
   </div>
69 67
   <div id="app"></div>

+ 62
- 24
src/components/StrongPhoto.vue View File

@@ -29,12 +29,12 @@
29 29
     </div>
30 30
 
31 31
     <div class="PhotoList-box">
32
-      <div class="PhotoList-box-text">
33
-        <div></div>
34
-        <span>1122222</span>
35
-      </div>
36
-      <div class="PhotoList-box-images">
37
-        <span v-for="(image, index) in imageList" :key="index">
32
+      <div class="PhotoList-box-images" v-for="(item, index) in newArrImageList" :key="index">
33
+        <div class="PhotoList-box-text">
34
+          <div></div>
35
+          <span>{{item.createDate}}</span>
36
+        </div>
37
+        <span v-for="(image, index) in item.res" :key="index">
38 38
           <van-image width="31vw" :src="image.url" style="padding:0 3px 0 2px" />
39 39
         </span>
40 40
       </div>
@@ -44,6 +44,7 @@
44 44
 
45 45
 <script>
46 46
 import { getPhotoSotr, getPhotos } from '../util/api'
47
+import { parseTime, SignInTime } from '../util/formattingData'
47 48
 
48 49
 import { getBanner } from '../util/api'
49 50
 
@@ -57,12 +58,15 @@ export default {
57 58
       buttList: [],
58 59
       photoBannerImages: [],
59 60
 
60
-      imageList: []
61
+      imageList: [],
62
+      newArrImageList: []
61 63
     }
62 64
   },
65
+  watch: {},
63 66
   mounted() {
64 67
     this.onBanner()
65 68
     this.onLoadSort()
69
+    this.dataResort()
66 70
 
67 71
     // if (this.buttList.length >= 2) {
68 72
     //   this.iconShow = true
@@ -71,6 +75,39 @@ export default {
71 75
     // }
72 76
   },
73 77
   methods: {
78
+    parseTime,
79
+    dataResort(arr) {
80
+      var newArr = []
81
+      this.imageList.forEach(function (oldData, i) {
82
+        var index = -1
83
+        var createTime = parseTime(oldData.createDate, '{y}-{m}-{d}')
84
+        var newTime = parseTime(createTime, '{y}-{m}-{d}')
85
+
86
+        var alreadyExists = newArr.some(function (newData, j) {
87
+          var noData = parseTime(newData.createDate, '{y}-{m}-{d}')
88
+          if (newTime === noData) {
89
+            index = j
90
+            return true
91
+          }
92
+        })
93
+        if (!alreadyExists) {
94
+          var res = []
95
+          res.push(oldData)
96
+          newArr.push({
97
+            createDate: createTime,
98
+            res: res
99
+          })
100
+        } else {
101
+          newArr[index].res.push(oldData)
102
+        }
103
+      })
104
+      console.log(
105
+        '🚀 ~ file: StrongPhoto.vue ~ line 105 ~ dataResort ~ newArr',
106
+        newArr
107
+      )
108
+
109
+      this.newArrImageList = newArr
110
+    },
74 111
     onLoadSort() {
75 112
       getPhotoSotr().then((e) => {
76 113
         this.buttList = e.records
@@ -85,6 +122,7 @@ export default {
85 122
       this.activeNum = i
86 123
       getPhotos(id).then((e) => {
87 124
         this.imageList = e.records
125
+        this.dataResort()
88 126
       })
89 127
       // this.clickStyle = !this.clickStyle
90 128
     },
@@ -146,27 +184,27 @@ export default {
146 184
     height: auto;
147 185
     background-color: #fff;
148 186
 
149
-    .PhotoList-box-text {
150
-      display: flex;
151
-      align-items: center;
152
-      margin: 1.2em 0 0.8em 0;
153
-      > div {
154
-        width: 6px;
155
-        height: 6px;
156
-        border-radius: 50%;
157
-        background-color: #13c0b4;
158
-        margin: 0 13px 0 9px;
159
-      }
160
-      > span {
161
-        font-size: 12px;
162
-        letter-spacing: 1px;
163
-        color: rgb(128, 128, 128);
164
-      }
165
-    }
166 187
     .PhotoList-box-images {
167 188
       width: 97%;
168 189
       margin: 0 auto;
169 190
       padding-bottom: 10vh;
191
+      .PhotoList-box-text {
192
+        display: flex;
193
+        align-items: center;
194
+        margin: 1.2em 0 0.8em 0;
195
+        > div {
196
+          width: 6px;
197
+          height: 6px;
198
+          border-radius: 50%;
199
+          background-color: #13c0b4;
200
+          margin: 0 13px 0 9px;
201
+        }
202
+        > span {
203
+          font-size: 12px;
204
+          letter-spacing: 1px;
205
+          color: rgb(128, 128, 128);
206
+        }
207
+      }
170 208
     }
171 209
   }
172 210
 }

+ 2
- 2
src/components/UserCenter.vue View File

@@ -27,11 +27,11 @@
27 27
         <div>我的收藏</div>
28 28
         <van-icon name="arrow" />
29 29
       </div>
30
-      <div class="button-box-div">
30
+      <!-- <div class="button-box-div">
31 31
         <img src="../assets/userImag/wenjuan.png" alt />
32 32
         <div>我的问卷</div>
33 33
         <van-icon name="arrow" />
34
-      </div>
34
+      </div>-->
35 35
     </div>
36 36
   </div>
37 37
 </template>

+ 54
- 0
src/util/initial.js View File

@@ -6,6 +6,60 @@ import store from '../store'
6 6
 
7 7
 import { UserLogin } from './api'
8 8
 
9
+const jsApiList = [
10
+  'updateAppMessageShareData',
11
+  'updateTimelineShareData',
12
+  'onMenuShareTimeline',
13
+  'onMenuShareAppMessage',
14
+  'onMenuShareQQ',
15
+  'onMenuShareWeibo',
16
+  'onMenuShareQZone'
17
+]
18
+
19
+function initSDK (url) {
20
+  request(`https://api.h5.njyunzhi.com/mp/jssdk?url=${encodeURIComponent(url)}`).then((res) => {
21
+    window.wx.config({
22
+      debug: process.env.NODE_ENV === 'development', // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
23
+      appId: res.appId, // 必填,公众号的唯一标识
24
+      timestamp: res.timestamp, // 必填,生成签名的时间戳
25
+      nonceStr: res.nonceStr, // 必填,生成签名的随机串
26
+      signature: res.signature, // 必填,签名
27
+      jsApiList // 必填,需要使用的JS接口列表
28
+    })
29
+  })
30
+}
31
+// Vue.use(Vuex)
32
+
33
+/**
34
+ * 分享
35
+ * @param {*} opt
36
+ */
37
+export function share (opt) {
38
+  const { origin, pathname, search } = window.location
39
+  // const defaultLink = origin + pathname
40
+  const defaultImg = `${origin}${pathname}images/share.png`
41
+
42
+  const link = origin + pathname + search // opt.link || defaultLink
43
+  const imgUrl = opt.imgUrl || defaultImg
44
+
45
+  initSDK(link)
46
+  window.wx.ready(function () {
47
+    jsApiList.map((apiName) => {
48
+      const fn = window.wx[apiName]
49
+      if (typeof fn === 'function') {
50
+        fn({
51
+          title: opt.title || '开启干洗护理新时代', // 分享标题
52
+          link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
53
+          imgUrl, // 分享图标
54
+          desc: opt.desc || '即刻尊享'
55
+        })
56
+      }
57
+    })
58
+  })
59
+}
60
+
61
+
62
+
9 63
 
10 64
 // Vue.use(Vuex)
11 65
 

+ 0
- 28
src/util/request.js View File

@@ -2,28 +2,16 @@
2 2
 
3 3
 
4 4
 import axios from 'axios'
5
-
6 5
 import store from '../store'
7 6
 
8
-import {
9
-
10
-  Toast,
11
-
12
-} from 'vant';
13
-
14
-
15 7
 export default function (url, options) {
16 8
   const { params, header, ...leftOptions } = options || {}
17 9
 
18 10
   return new Promise((resolve, reject) => {
19 11
     const { code, token } = store.state.user
20
-
21
-
22 12
     let header = {
23 13
       'X-Authorization-JWT': token,
24 14
     }
25
-
26
-
27 15
     axios.request({
28 16
       ...leftOptions,
29 17
       url: url,
@@ -31,28 +19,12 @@ export default function (url, options) {
31 19
       headers: header,
32 20
     }).then(res => {
33 21
       const { code, data, message } = res.data
34
-
35 22
       if (code === 1000) {
36 23
         resolve(data)
37
-      } else {
38
-        // Message.error(message)
39
-        // alert(message)
40
-
41
-        if (code === 1001) {
42
-          // Message.error('请重新登陆')
43
-
44
-          // routerfrom.push('../Login.vue')
45
-
46
-          // this.$router.replace('../Login.vue') //replace  不记录页面 ,无法返回
47
-        }
48 24
       }
49
-
50
-
51
-
52 25
     }).catch(err => {
53 26
       const message = err.message || err.errMsg || err
54 27
       console.error("🚀 错误~ err", err)
55
-      // Message.error('请求错误', err)
56 28
 
57 29
 
58 30
       if (err.message.includes('timeout')) {