许成详 6 years ago
parent
commit
39c5e8edbf

BIN
src/common/icon/kong.png View File


+ 178
- 0
src/components/slideTabH/index.vue View File

@@ -0,0 +1,178 @@
1
+<template>
2
+  <div class="components flex-v">
3
+    <div class="tabNav flex-h" :style="{backgroundColor: backgroundColor || '#fff'}">
4
+      <a
5
+        class="flex-item"
6
+        v-for="(item, index) in data"
7
+        :key="index"
8
+        @click="cutNav(index)"
9
+        :style="{fontSize: fontSize + 'px', color: index === activeIndex ? (activeColor || 'red') : (normalColor || '#333')}"
10
+      >{{item.value}}</a>
11
+      <div class="activeLine" id="activeLine"></div>
12
+    </div>
13
+    <div class="flex-item">
14
+      <div>
15
+        <swiper :options="swiperOption" ref="mySwiper">
16
+          <swiper-slide class="swiper-slide" v-for="(item, index) in data" :key="index">
17
+            <slot :name="'slideTabH-' + item.id"></slot>
18
+          </swiper-slide>
19
+        </swiper>
20
+      </div>
21
+    </div>
22
+  </div>
23
+</template>
24
+
25
+<script>
26
+import { swiper, swiperSlide } from 'vue-awesome-swiper'
27
+import 'swiper/dist/css/swiper.css'
28
+export default {
29
+  name: 'slideTabH',
30
+  props: ['data', 'fontSize', 'activeColor', 'normalColor', 'backgroundColor', 'initIndex'],
31
+  data () {
32
+    var _self = this
33
+    return {
34
+      leftArr: [],
35
+      widthArr: [],
36
+      activeWidth: 0,
37
+      activeIndex: 0,
38
+      stepNum: 120,
39
+      swiperOption: {
40
+        watchSlidesProgress: true,
41
+        initialSlide: _self.activeIndex,
42
+        on: {
43
+          init () {
44
+            document.getElementById('activeLine').style.width = _self.widthArr[_self.activeIndex * _self.stepNum] + 'px'
45
+            document.getElementById('activeLine').style.left = _self.leftArr[_self.activeIndex * _self.stepNum] + 'px'
46
+          },
47
+          setTranslate (translate) { // 滑动偏移量监听
48
+            var num = (-translate / document.body.clientWidth * _self.stepNum).toFixed(0)
49
+            if (num >= 0 && num <= (_self.data.length - 1) * _self.stepNum) {
50
+              document.getElementById('activeLine').style.width = _self.widthArr[num] + 'px'
51
+              document.getElementById('activeLine').style.left = _self.leftArr[num] + 'px'
52
+            }
53
+          },
54
+          touchStart () {
55
+            document.getElementById('activeLine').style.transition = ''
56
+            document.getElementById('activeLine').style.WebkitTransition = ''
57
+          },
58
+          touchEnd () {
59
+            document.getElementById('activeLine').style.transition = '300ms'
60
+            document.getElementById('activeLine').style.WebkitTransition = '300ms'
61
+            if (this.realIndex !== _self.activeIndex) {
62
+              document.getElementById('activeLine').style.width = (_self.widthArr[this.realIndex * _self.stepNum]) + 'px'
63
+              document.getElementById('activeLine').style.left = (_self.leftArr[this.realIndex * _self.stepNum]) + 'px'
64
+            }
65
+          },
66
+          setTransition (speed) {
67
+            if (this.realIndex !== _self.activeIndex) {
68
+              document.getElementById('activeLine').style.width = (_self.widthArr[this.realIndex * _self.stepNum]) + 'px'
69
+              document.getElementById('activeLine').style.left = (_self.leftArr[this.realIndex * _self.stepNum]) + 'px'
70
+            }
71
+          },
72
+          transitionEnd () {
73
+            _self.activeIndex = this.activeIndex
74
+            _self.$emit('slideChange', this.activeIndex)
75
+          }
76
+        }
77
+      }
78
+    }
79
+  },
80
+  computed: {
81
+    MySwiper () {
82
+      return this.$refs.mySwiper.swiper
83
+    }
84
+  },
85
+  components: {
86
+    swiper,
87
+    swiperSlide
88
+  },
89
+  created () {
90
+    this.activeIndex = this.initIndex || 0
91
+    var aLeft = (document.body.clientWidth / this.data.length).toFixed(0)
92
+    this.data.map((item, index) => {
93
+      this.widthArr.push(item.value.length * (this.fontSize || 15))
94
+      this.leftArr.push((aLeft * index - 0) + ((aLeft / 2).toFixed(0) - 0) - this.widthArr[index] / 2)
95
+    })
96
+    this.activeWidth = this.widthArr[this.activeIndex]
97
+    this.widthArr = this.calcArr(this.widthArr, this.stepNum)
98
+    this.leftArr = this.calcArr(this.leftArr, this.stepNum)
99
+  },
100
+  mounted () {
101
+    this.$nextTick(() => {
102
+    })
103
+  },
104
+  methods: {
105
+    cutNav (index) { // 切换nav
106
+      document.getElementById('activeLine').style.transition = '300ms'
107
+      document.getElementById('activeLine').style.WebkitTransition = '300ms'
108
+      this.MySwiper.slideTo(index, 0, false)
109
+    },
110
+    calcArr (arr, num) { // 构造间隔数组:arr-原数组;num-间隔数
111
+      arr = arr || []
112
+      num = num || 20
113
+      var aArr = []
114
+      arr.map((item, index) => {
115
+        if (index < arr.length - 1) {
116
+          aArr.push([])
117
+          for (var n = 0; n < num; n++) {
118
+            aArr[index].push(item + (arr[index + 1] - item) * (n + 1) / num)
119
+          }
120
+        }
121
+      })
122
+      return [arr[0]].concat(...aArr)
123
+    }
124
+  }
125
+}
126
+</script>
127
+
128
+<!-- Add "scoped" attribute to limit CSS to this component only -->
129
+<style lang="scss" scoped>
130
+.components {
131
+  width: 100%;
132
+  height: 100%;
133
+  position: relative;
134
+  overflow: hidden;
135
+  .tabNav {
136
+    background: #fff;
137
+    position: relative;
138
+    overflow: hidden;
139
+    box-shadow: 0 0 0.1rem 0.02rem rgba(0, 0, 0, 0.05);
140
+    z-index: 100;
141
+    > a {
142
+      line-height: 0.45rem;
143
+      text-align: center;
144
+      color: #333;
145
+      position: relative;
146
+      z-index: 1;
147
+    }
148
+    .activeLine {
149
+      height: 0.02rem;
150
+      background: #f9064b;
151
+      position: absolute;
152
+      left: 0;
153
+      bottom: 0;
154
+      z-index: 2;
155
+    }
156
+  }
157
+  > .flex-item {
158
+    position: relative;
159
+    > div {
160
+      width: 100%;
161
+      position: absolute;
162
+      left: 0;
163
+      bottom: 0;
164
+      top: 0;
165
+      overflow: hidden;
166
+      > div {
167
+        width: 100%;
168
+        height: 100%;
169
+      }
170
+    }
171
+  }
172
+  .swiper-slide {
173
+    background: #f8f8f8;
174
+    position: relative;
175
+    z-index: 1;
176
+  }
177
+}
178
+</style>

+ 1
- 1
src/pages/bodyCheck/app.js View File

@@ -1,7 +1,7 @@
1 1
 import Vue from 'vue'
2 2
 import App from './App.vue'
3 3
 import Vant from 'vant'
4
-import 'vant/lib/index.css'
4
+import 'vant/lib/vant-css/index.css'
5 5
 import router from './router'
6 6
 import store from '../../store/index'
7 7
 import Vuex from 'vuex'

+ 1
- 1
src/pages/sales/app.js View File

@@ -1,7 +1,7 @@
1 1
 import Vue from 'vue'
2 2
 import App from './App.vue'
3 3
 import Vant from 'vant'
4
-import 'vant/lib/index.css'
4
+import 'vant/lib/vant-css/index.css'
5 5
 import router from './router'
6 6
 import store from '../../store/index'
7 7
 import Vuex from 'vuex'

+ 1
- 1
src/pages/user/app.js View File

@@ -1,7 +1,7 @@
1 1
 import Vue from 'vue'
2 2
 import App from './App.vue'
3 3
 import Vant from 'vant'
4
-import 'vant/lib/index.css'
4
+import 'vant/lib/vant-css/index.css'
5 5
 import router from './router'
6 6
 import store from '../../store/index'
7 7
 import Vuex from 'vuex'

+ 164
- 17
src/pages/user/library/booksSearch/index.vue View File

@@ -1,16 +1,62 @@
1 1
 <template>
2
-  <div class="mainPage">
3
-    1
2
+  <div class="mainPage flex-v">
3
+    <div class="header flex-h">
4
+      <div class="flex-item flex-h">
5
+        <i class="iconfont icon-sousuo"></i>
6
+        <div class="flex-item">
7
+          <div>
8
+            <input type="text" v-model="searchKey" placeholder="请输入图书名">
9
+          </div>
10
+        </div>
11
+      </div>
12
+      <a @click="search">搜索</a>
13
+    </div>
14
+    <div class="searchRemark" v-if="showSearchRemark">
15
+      <span>
16
+        关于“
17
+        <em>{{indexSearchKey}}</em>”的搜索结果:
18
+      </span>
19
+    </div>
20
+    <div class="flex-item">
21
+      <div>
22
+        <div class="noData" v-if="noData">
23
+          <img src="../../../../common/icon/kong.png" alt>
24
+          <span>暂无内容</span>
25
+        </div>
26
+        <ul>
27
+          <li v-for="(item, index) in searchBooksList" :key="index">
28
+            <libraryListItem :data="item" @appointmentBook="appointmentBook"></libraryListItem>
29
+          </li>
30
+        </ul>
31
+      </div>
32
+    </div>
33
+    <van-dialog v-model="showAppointmentDialog" :show-confirm-button="false">
34
+      <div class="dialogContent">
35
+        <span class="title">确认在线预约当前图书?</span>
36
+        <div>
37
+          <span style="color: #666;">在线预约需在2018年12月20日前前往案场借阅图书, 否则 将取消预约资格</span>
38
+        </div>
39
+        <div class="btn">
40
+          <a @click="sureAppointmentBook">确定</a>
41
+          <a @click="showAppointmentDialog = false">取消</a>
42
+        </div>
43
+      </div>
44
+    </van-dialog>
4 45
   </div>
5 46
 </template>
6 47
 
7 48
 <script>
49
+import libraryListItem from '../../../../components/libraryListItem/index'
8 50
 import { mapState, createNamespacedHelpers } from 'vuex'
9 51
 const { mapActions: mapAppActions } = createNamespacedHelpers('app')
10 52
 const { mapState: mapLibraryState, mapActions: mapLibraryAction, mapMutations: mapLibraryMutations } = createNamespacedHelpers('library')
11 53
 export default {
12 54
   data () {
13 55
     return {
56
+      searchKey: '',
57
+      showSearchRemark: false,
58
+      noData: false,
59
+      showAppointmentDialog: false
14 60
     }
15 61
   },
16 62
   created () {
@@ -20,9 +66,17 @@ export default {
20 66
       CaseList: x => x.app.CaseList,
21 67
     }),
22 68
     ...mapLibraryState({
69
+      indexSearchKey: x => x.indexSearchKey,
70
+      searchBooksList: x => x.searchBooksList
71
+    })
72
+  },
73
+  mounted () {
74
+    this.$nextTick(() => {
75
+      this.searchKey = this.indexSearchKey || ''
23 76
     })
24 77
   },
25 78
   components: {
79
+    libraryListItem
26 80
   },
27 81
   methods: {
28 82
     ...mapAppActions([
@@ -30,29 +84,122 @@ export default {
30 84
     ]),
31 85
     ...mapLibraryAction(['']),
32 86
     ...mapLibraryMutations(['setIndexSearchKey']),
87
+    search () { // 搜索
88
+      if (this.searchKey !== '') {
89
+        this.setIndexSearchKey(this.searchKey)
90
+        this.showSearchRemark = true
91
+      } else {
92
+        this.$toast('搜索关键词不能为空')
93
+      }
94
+    },
95
+    appointmentBook () { // 预约图书
96
+      this.showAppointmentDialog = true
97
+    },
98
+    sureAppointmentBook () { // 确定预约图书
99
+      this.showAppointmentDialog = false
100
+    },
33 101
   }
34 102
 }
35 103
 </script>
36 104
 
37 105
 <style lang="scss" scoped>
38 106
 .mainPage {
39
-  > div {
40
-    width: 100%;
41
-    position: absolute;
42
-    left: 0;
43
-    top: 0;
44
-    bottom: 0;
45
-    overflow-y: scroll;
46
-    -webkit-overflow-scrolling: touch;
47
-    transform: translateZ(0);
48
-    -webkit-transform: translateZ(0);
49
-    >ul{
50
-      padding: 0 .16rem;
51
-      margin-bottom: .1rem;
107
+  .header {
108
+    padding: 0.1rem 0.2rem;
109
+    > div {
110
+      background: #f2f2f2;
52 111
       position: relative;
53 112
       overflow: hidden;
54
-      li{
55
-        margin: .1rem auto 0;
113
+      i {
114
+        font-size: 0.15rem;
115
+        color: #ccc;
116
+        margin-left: 0.08rem;
117
+        line-height: 0.3rem;
118
+      }
119
+      > div {
120
+        margin-left: 0.1rem;
121
+        > div {
122
+          width: 100%;
123
+          position: relative;
124
+          overflow: hidden;
125
+          input {
126
+            width: 100%;
127
+            display: block;
128
+            line-height: 0.2rem;
129
+            padding: 0.05rem 0;
130
+            background: none;
131
+            font-size: 0.13rem;
132
+          }
133
+        }
134
+      }
135
+    }
136
+    > a {
137
+      line-height: 0.3rem;
138
+      margin-left: 0.1rem;
139
+      font-size: 0.14rem;
140
+    }
141
+  }
142
+  .searchRemark {
143
+    padding: 0 0.2rem;
144
+    span {
145
+      width: 100%;
146
+      white-space: nowrap;
147
+      overflow: hidden;
148
+      display: block;
149
+      line-height: 0.22rem;
150
+      font-size: 0.14rem;
151
+      color: #616161;
152
+      em {
153
+        line-height: 0.22rem;
154
+        font-size: 0.14rem;
155
+        color: #fc5634;
156
+      }
157
+    }
158
+  }
159
+  > .flex-item {
160
+    position: relative;
161
+    overflow: hidden;
162
+    > div {
163
+      width: 100%;
164
+      position: absolute;
165
+      left: 0;
166
+      top: 0;
167
+      bottom: 0;
168
+      overflow-y: scroll;
169
+      -webkit-overflow-scrolling: touch;
170
+      transform: translateZ(0);
171
+      -webkit-transform: translateZ(0);
172
+      .noData {
173
+        width: 100%;
174
+        margin: 0.5rem auto 0;
175
+        position: relative;
176
+        overflow: hidden;
177
+        img {
178
+          width: 0.7rem;
179
+          display: block;
180
+          margin: 0 auto;
181
+        }
182
+        span {
183
+          width: 100%;
184
+          display: block;
185
+          text-align: center;
186
+          line-height: 0.3rem;
187
+          color: #b4b4b4;
188
+          font-size: 0.14rem;
189
+          margin: 0.05rem auto 0;
190
+        }
191
+      }
192
+      > ul {
193
+        padding: 0 0.2rem;
194
+        margin: 0 auto 0.1rem;
195
+        position: relative;
196
+        overflow: hidden;
197
+        > li {
198
+          width: 100%;
199
+          position: relative;
200
+          overflow: hidden;
201
+          margin: .1rem auto 0;
202
+        }
56 203
       }
57 204
     }
58 205
   }

+ 87
- 0
src/pages/user/library/borrowedRecord/index.vue View File

@@ -0,0 +1,87 @@
1
+<template>
2
+  <div class="mainPage">
3
+    <slideTabH
4
+      :data="tabList"
5
+      fontSize="16"
6
+      activeColor="red"
7
+      normalColor="#666"
8
+      @slideChange="slideChange"
9
+    >
10
+      <div slot="slideTabH-1">1</div>
11
+      <div slot="slideTabH-2">2</div>
12
+    </slideTabH>
13
+  </div>
14
+</template>
15
+
16
+<script>
17
+import slideTabH from '../../../../components/slideTabH/index'
18
+import libraryListItem from '../../../../components/libraryListItem/index'
19
+import { mapState, createNamespacedHelpers } from 'vuex'
20
+const { mapActions: mapAppActions } = createNamespacedHelpers('app')
21
+const { mapState: mapLibraryState, mapActions: mapLibraryAction } = createNamespacedHelpers('library')
22
+export default {
23
+  data () {
24
+    return {
25
+      tabList: [{ value: '借阅记录', id: '1' }, { value: '线上预约记录', id: '2' }],
26
+      showAppointmentDialog: false
27
+    }
28
+  },
29
+  created () {
30
+  },
31
+  computed: {
32
+    ...mapState({
33
+      CaseList: x => x.app.CaseList,
34
+    }),
35
+    ...mapLibraryState({
36
+      navList: x => x.navList,
37
+      bookTypeList: x => x.bookTypeList
38
+    })
39
+  },
40
+  components: {
41
+    libraryListItem,
42
+    slideTabH
43
+  },
44
+  methods: {
45
+    ...mapAppActions([
46
+      'getCaseList',
47
+    ]),
48
+    ...mapLibraryAction(['getBookListByType']),
49
+    navClick (item) {
50
+    },
51
+    appointmentBook () { // 预约图书
52
+      this.showAppointmentDialog = true
53
+    },
54
+    sureAppointmentBook () { // 确定预约图书
55
+      this.showAppointmentDialog = false
56
+    },
57
+    slideChange (e) {
58
+      console.log(e)
59
+    }
60
+  }
61
+}
62
+</script>
63
+
64
+<style lang="scss" scoped>
65
+.mainPage {
66
+  > div {
67
+    width: 100%;
68
+    position: absolute;
69
+    left: 0;
70
+    top: 0;
71
+    bottom: 0;
72
+    overflow-y: scroll;
73
+    -webkit-overflow-scrolling: touch;
74
+    transform: translateZ(0);
75
+    -webkit-transform: translateZ(0);
76
+    > ul {
77
+      padding: 0 0.16rem;
78
+      margin-bottom: 0.1rem;
79
+      position: relative;
80
+      overflow: hidden;
81
+      li {
82
+        margin: 0.1rem auto 0;
83
+      }
84
+    }
85
+  }
86
+}
87
+</style>

+ 6
- 0
src/pages/user/router.js View File

@@ -17,6 +17,7 @@ import userCenter from './mainPage/userCenter/index' // 个人中心
17 17
 import libraryNavList from './library/navList/index' // 图书馆nav
18 18
 import booksSearch from './library/booksSearch/index' // 搜索图书
19 19
 import booksList from './library/booksList/index' // 图书列表
20
+import borrowedRecord from './library/borrowedRecord/index' // 借阅记录
20 21
 import bindMobile from './bindMobile/bindMobile' // 绑定手机号
21 22
 import lessonOrder from './lessonOrder/index' // 我的订单
22 23
 import vip from './vip/index' // vip卡说明
@@ -83,6 +84,11 @@ const router = new Router({
83 84
     name: 'booksList',
84 85
     component: booksList,
85 86
     children: []
87
+  }, { // 借阅记录
88
+    path: '/borrowedRecord',
89
+    name: 'borrowedRecord',
90
+    component: borrowedRecord,
91
+    children: []
86 92
   }, { // 城咖啡-点单
87 93
     path: '/placeOrder',
88 94
     name: 'placeOrder',

+ 73
- 0
src/store/library/index.js View File

@@ -151,6 +151,79 @@ export default {
151 151
       author: '作者',
152 152
       publishingHouses: '出版社',
153 153
       stock: '10'
154
+    }],
155
+    searchBooksList: [{ // 搜索书籍列表
156
+      img: '',
157
+      name: '书名',
158
+      id: '',
159
+      status: '状态',
160
+      author: '作者',
161
+      publishingHouses: '出版社',
162
+      stock: '10'
163
+    }, {
164
+      img: '',
165
+      name: '书名',
166
+      id: '',
167
+      status: '状态',
168
+      author: '作者',
169
+      publishingHouses: '出版社',
170
+      stock: '10'
171
+    }, {
172
+      img: '',
173
+      name: '书名',
174
+      id: '',
175
+      status: '状态',
176
+      author: '作者',
177
+      publishingHouses: '出版社',
178
+      stock: '10'
179
+    }, {
180
+      img: '',
181
+      name: '书名',
182
+      id: '',
183
+      status: '状态',
184
+      author: '作者',
185
+      publishingHouses: '出版社',
186
+      stock: '10'
187
+    }, {
188
+      img: '',
189
+      name: '书名',
190
+      id: '',
191
+      status: '状态',
192
+      author: '作者',
193
+      publishingHouses: '出版社',
194
+      stock: '10'
195
+    }, {
196
+      img: '',
197
+      name: '书名',
198
+      id: '',
199
+      status: '状态',
200
+      author: '作者',
201
+      publishingHouses: '出版社',
202
+      stock: '10'
203
+    }, {
204
+      img: '',
205
+      name: '书名',
206
+      id: '',
207
+      status: '状态',
208
+      author: '作者',
209
+      publishingHouses: '出版社',
210
+      stock: '10'
211
+    }, {
212
+      img: '',
213
+      name: '书名',
214
+      id: '',
215
+      status: '状态',
216
+      author: '作者',
217
+      publishingHouses: '出版社',
218
+      stock: '10'
219
+    }, {
220
+      img: '',
221
+      name: '书名',
222
+      id: '',
223
+      status: '状态',
224
+      author: '作者',
225
+      publishingHouses: '出版社',
226
+      stock: '10'
154 227
     }]
155 228
   },
156 229
   mutations: {